<?php 
include 'connection.php';
session_start();
if (!isset($_SESSION['is_logged_in'])) {
    header("Location:login.php");
    die();
    }
	
$queryls2 = "select * from tax_invoice where tax_id ='".$_REQUEST['tax_id']."' ";
$resultls2 = mysqli_query($conn,$queryls2);	
while($row=mysqli_fetch_array($resultls2))
{
$invoice_no=$row['invoice_no'];
$invoice_date=$row['invoice_date'];	
$delivery_note = $row['delivery_note'];
$mode_of_payment = $row['mode_of_payment'];
$suppelier_ref = $row['suppelier_ref'];
$other_ref = $row['other_ref'];
$terms_of_delivery = $row['terms_of_delivery'];
$mode_transport = $row['mode_transport'];
$name_of_goods = $row['name_of_goods'];

}
	
	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
-->
</style></head>

<body>
              <div class="panel-body">
			  
<?php 			  
		$queryaaprgroup = "SELECT * FROM  delivery_challan_more_product_02 where tax_id='".$_REQUEST['tax_id']."'    group by category_id   ";
$result1group = mysqli_query($conn,$queryaaprgroup);
$num_rows2 = mysqli_num_rows($result1hsn);
while($row=mysqli_fetch_array($result1group))
{

$category_id = $row['category_id'];
$category_name = $row['category_name'];

$sumoftotal='';
$sumqty='';
?>
<table width="100%" border="1" style="border-collapse:collapse">
                  <thead>
				  <tr><th colspan="10"> <?php echo $category_name;?></th></tr>
                    <tr>
                    
									 <th>Sr No</th>
									 <th>#</th>
									<th>BMST Challan Date</th>
									<th>BMST Challan No.</th>
									<th>DINESH Challan No.</th>
									<th>COMPONANT</th>
									<th>P.O.No.</th>
									<th>QTY</th>
									<th>RATE OF P.O.</th>
									<th>TOTAL AMOUNT </th>
					</tr>
                  </thead>
                  <tbody>        
				 
				  <? $k=1;
			$queryaapr = "SELECT * FROM  delivery_challan_more_product_02 where  tax_id='".$_REQUEST['tax_id']."' and  receipt_no!='' and category_id='$category_id' ";
				
				
				
				$result1hsn = mysqli_query($conn,$queryaapr);
$num_rows2 = mysqli_num_rows($result1hsn);
while($row=mysqli_fetch_array($result1hsn))
{
$material_name = $row['material_name'];
$inward_challan_no = $row['inward_challan_no'];
$cust_more_row_id = $row['cust_more_row_id'];
$row_id = $row['row_id'];

$receipt_no=$row['receipt_no'];
$delivery_challan_no = $row['delivery_challan_no'];
$componant = $row['componant'];
$cust_po = $row['cust_po'];
$qty = $row['qty'];
$rate_of_po = $row['rate_of_po'];
$total = $row['total'];
$delivered_date=$row['delivered_date'];
$delivery_challan_more_product_id=$row['delivery_challan_more_product_id'];
$sumoftotal+=$total;
$sumqty+=$qty;

?>  <tr>
                    	
                        <td><?php echo $k;?>
						</td>                                <td></td>

						<td><?php $qry9705 = "select * from cust_inward_more_row_02 where row_id='$row_id' and cust_more_row_id='$cust_more_row_id'";
$re9702 = mysqli_query($conn,$qry9705);
while($row=mysqli_fetch_array($re9702))
{
$challan_date = $row['challan_date'];

}
 echo $delivered_date; ?></td>
					    <td><?php echo $receipt_no; ?></td>
						<td><?php echo $delivery_challan_no; ?></td>
						<td><?php echo $componant; ?></td>
						<td><?php echo $cust_po; ?></td>
						<td><?php echo $qty; ?></td>
						<td><?php echo $rate_of_po; ?></td>
						<td><?php echo $total; ?></td>
						</tr>

                     <?php $k++; }?>
					 <tr>
<td colspan="7"><div align="right">Total</div></td>
<td><?php echo $sumqty?></td>
<td>&nbsp;</td>
<td><?php echo $sumoftotal?></td>
</tr>
</table>
<?php 
}


?>

</body>
</html>
