<?php include("config.php");
$wresult=mysql_query("select * from restaurant_chalan_product WHERE id='$_GET[delid]'");
$wrow=mysql_fetch_array($wresult);

 

if($wrow[qty]>"1"){
$qty=$wrow[qty]-1;
$total_prize=$wrow[unit_price]*$qty;

mysql_query("update restaurant_chalan_product set qty='$qty',total_prize='$total_prize' WHERE id='$_GET[delid]' limit 1");
}else{
mysql_query("delete from restaurant_chalan_product WHERE id='$_GET[delid]' limit 1");
}

  

$result=mysql_query("select * from restaurant_chalan_product WHERE cid='$_GET[cid]'");
$row=mysql_fetch_array($result);

?>
<table width="100%" border="0" cellpadding="2" cellspacing="1" bgcolor="#CCCCCC">
  <tr>
    <td width="15%" bgcolor="#DFDFDF"><strong>Product </strong></td>
    <td width="39%" bgcolor="#DFDFDF"><strong>Item</strong></td>
    <td width="12%" bgcolor="#DFDFDF"><strong>Quantity</strong></td>
    <td width="12%" bgcolor="#DFDFDF"><strong>Unit Price</strong></td>
    <td width="12%" bgcolor="#DFDFDF"><strong>Total</strong></td>
    <td width="10%" align="center" bgcolor="#DFDFDF">Delete</td>
  </tr>
  <?php do{
	  
$tresult=mysql_query("select * from restaurant_product_details  WHERE id='$row[product_type]'");
$trow=mysql_fetch_array($tresult);
	  
	  ?>
  <tr>
    <td width="15%" bgcolor="#FFFFFF"><?php echo $trow[pname];?></td>
    <td width="39%" bgcolor="#FFFFFF"><?php echo $trow[product_item];?></td>
    <td width="12%" bgcolor="#FFFFFF"><?php echo $row[qty];?></td>
    <td width="12%" bgcolor="#FFFFFF"><?php echo $row[unit_price];?></td>
    <td width="12%" bgcolor="#FFFFFF"><?php echo $row[total_prize];?>
        <?php $totalp=$totalp+$row[total_prize];?></td>
    <td align="center" bgcolor="#FFFFFF" class="link"><a href="JavaScript:void(0);" onclick="chalan_product_del('<?php echo $row[id];?>');"><strong>Delete</strong></a></td>
  </tr>
  <?php }while($row=mysql_fetch_array($result));?>
  <tr>
    <td colspan="2" bgcolor="#FFFFFF">Total </td>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    <td bgcolor="#FFFFFF"><?php echo $totalp;?></td>
    <td align="center" bgcolor="#FFFFFF" class="link">&nbsp;</td>
  </tr>
</table>
<input name="aj_total" type="hidden" id="aj_total" value="<?php echo $totalp;?>" />
<input name="stotal_taka" type="hidden" id="stotal_taka" value="<?php echo $totalp;?>" />
