<?php 
    require_once ("../var/res.php");
    if(ISSET($_POST['res'])){
    try {
        
	   $i = 0;
       $Gtot=0;
       $res=$_POST['res'];
	   $stmt = $db->prepare("SELECT * FROM tbl_boqcon b
	   INNER JOIN tbl_items i ON i.item_id=b.matid 
	   WHERE itmid ='".$res."' AND sttscon=4 ORDER BY boqcon_id ASC");
	    
	   $stmt->execute(array());
	   $item_count = $stmt->rowCount();

	   if($item_count > 0)
	   {
       	while ($rows = $stmt->fetch(PDO::FETCH_ASSOC)) {
		$boqcon_id = $rows['boqcon_id'];
        $iPrice = $rows['iPrice'];
		$qtyboq = $rows['qtyboq'];
        $totMont = $iPrice*$qtyboq;
        $i++;
        $Gtot= $Gtot+$totMont;
	?>
    <tr>
        <td>
            <div class="custom-control custom-checkbox">
                <input type="checkbox" name="delids[]" value="<?php echo $rows['boqcon_id'];?>" class="custom-control-input active" id="ckit_<?php echo $rows['boqcon_id'];?>">
                <label class="custom-control-label" for="ckit_<?php echo $rows['boqcon_id'];?>"></label>
            </div>
        </td>
        <td><?php echo $rows['item_name'];?></td>
        <td class="text-right"><?php echo $qtyboq;?></td>
        <td class="text-right"><?php echo number_format($iPrice);?></td>
	    <td class="text-right" style="font-weight: bold;"><?php echo number_format(round($totMont, 2));?></td>
	</tr>
    
	<?php 	
       	}//END. While
       	
	   }//End Count.	
       }
		catch (PDOException $ex) {
		echo $ex->getMessage();
		}		
    }
	?>
    <tr>
        <th style="font-weight: bold;" colspan="4">G.tot</th>
        <th style="font-weight: bold;" class="text-right"><?php echo number_format(round($Gtot, 2));?></th>
    </tr>