<?php include("config.php");

$tresult=mysql_query("select * from restaurant_product_details  WHERE id='$_GET[product_type]'");
$trow=mysql_fetch_array($tresult);

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


if($row!=""){

$qty=$row[qty]+1;
}else{
$qty=1;
}

$total_prize=$trow[sale_rate]*$qty;



if($row!=""){
mysql_query("update restaurant_chalan_product set qty='$qty',total_prize='$total_prize' WHERE cid='$_GET[cid]' and product_type='$_GET[product_type]' limit 1");
}else{
mysql_query("insert into restaurant_chalan_product(cid,pid,psr,pmodel,product_type,qty,description, unit_price,bill,temp_bill,qubeeid,total_prize)VALUES('$_GET[cid]', '0','', '0','$_GET[product_type]', '1', '','$trow[sale_rate]','0','0','0', '$total_prize')");
}
 

$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;?>" />