<?php
include "include/config.php"; 	
include "include/date.php"; 
ob_start();
session_start();
include "include/config.php"; 
include "include/date.php"; 
$fid=$_SESSION['fid'];
$employeeid=$_SESSION['employeeid'];
$third_party=$_SESSION['third_party'];
// $gst=$_SESSION['gst'];
$gst=="No";
if($employeeid=='1188')
	  {
	      echo'<script>
	     window.location.replace("login.php");
	      </script>';
}
// if($fid=='16')
// 	  {
// 	      echo'<script>
// 	      alert("Please Contact Owner");
// 	     window.location.replace("login.php");
// 	      </script>';
	  
// }
if(isset($_POST['home_delivery'])){
$cart="";
	$displayquery = "SELECT shop_status,deposit FROM franchises WHERE fid='$fid'"; 
	$result = mysqli_query($con,$displayquery);
    if(mysqli_num_rows($result) > 0){
		while ($row = mysqli_fetch_array($result)) {
			$shop_status=$row['shop_status'];
			$deposite=$row['deposit'];
	}
    }
$cart='    <div class="row"style="margin-top:2rem">
    <div class="col-md-4 text-center">';    
    if($shop_status=="Open")
    {
        $cart.='
        <i class="fa fa-toggle-on fa-2x" onclick="opened()" style="color:green; " aria-hidden="true"></i>
        ';
    }
     else
    {
        $cart.=' <i class="fa fa-toggle-off fa-2x" onclick="closed()" style="color:red" aria-hidden="true"></i>
        
        ';
    }
    $cart.='
    </div>
    <div class="col-md-4 text-center" >
							';
	 $j=0;

    $rs ="select * from customer_bill_mobile_app_details where fid='$fid' && order_status ='added'";
	$result = $con-> query($rs);
	if($result-> num_rows > 0) {
	while ($row = $result-> fetch_assoc()){
		$j++;
		} 	 
	}
if($j!=0)
{
	$cart.='
	<i class="fa fa-bell fa-2x" aria-hidden="true" style="color:red" data-toggle="modal" onclick="frenchises()" data-target="#home_delivery_display"></i>
	<span class="button__badge"><b>'.$j.'</b></span>';
}
else
{
	$cart.='<i class="fa fa-bell fa-2x" aria-hidden="true" style="color:green" data-toggle="modal" onclick="frenchises()" data-target="#home_delivery_display"></i>
	';
}
	$cart.='</div>
	<div class="col-md-4 text-center" ><i class="fa fa-inr" aria-hidden="true"></i>
 '.$deposite.'</div>
	</div><hr style="margin-top: 6px;margin-bottom: 6px;">';
	echo $cart;
}

if(isset($_POST['closed']))
{

$insertquery = "UPDATE franchises SET shop_status='Open' where fid='$fid'"; 
$result = mysqli_query($con,$insertquery);
mysqli_close($con);
}

if(isset($_POST['opened']))
{

$insertquery = "UPDATE franchises SET shop_status='Closed' where fid='$fid'"; 
$result = mysqli_query($con,$insertquery);
mysqli_close($con);
}

if(isset($_POST['frenchises'])){
    //$order_type=$_POST['order_type'];
    
    	$frenchises='';
	 $cid1;
$query="SELECT avg(cid) as cid, max(parcel) as parcel FROM customer_bill_mobile_app_details WHERE order_status ='added' && fid='$fid' GROUP By cid";
$result1 = mysqli_query($con,$query);
if(mysqli_num_rows($result1) > 0){
	while ($row1 = mysqli_fetch_array($result1)){	
	    $cid=round($row1['cid'],0);
	    $order_type=$row1['parcel'];
	    $i=1;
	    
    $customer_query="SELECT * FROM customer_details WHERE cid='$cid'";
    $customer_result=mysqli_query($con,$customer_query);
    if(mysqli_num_rows($customer_result)>0){
        $customer_row=mysqli_fetch_assoc($customer_result);
        $customer_name=$customer_row['firstname'];
        $customer_name=$customer_name." ".$customer_row['lastname'];
        $customer_mobile=$customer_row['mobile'];
    }	
	    
$frenchises.='
        <center><h3 style="color:red">'.$order_type.'</h3></center>
        <center><h4>'.$customer_name.' - '.$customer_mobile.'</h4></center>
    	<table class="table" style="margin-bottom: unset;">
  <thead>
    <tr>
	  <th scope="col" width="5%" class="text-center">Sr No</th>
      <th scope="col" width="30%" class="text-center">Product Name</th>
	   <th scope="col" width="10%" class="text-center">Size</th>
      <th scope="col" width="10%" class="text-center">Quantity</th>
      <th scope="col" width="15%" class="text-center">Price</th>
    </tr>
  </thead>
  <tbody>';

$cquery="SELECT * FROM customer_bill_mobile_app_details WHERE cid='$cid'";
$amount=0;
$cresult = mysqli_query($con,$cquery);
if(mysqli_num_rows($cresult) > 0){
	while ($crow = mysqli_fetch_array($cresult)){
	    
	    $productid=$crow['productid'];
		$productname=$crow['productname'];
		$size=$crow['size'];
		$quantity=$crow['quantity'];
		$price=$crow['price'];
		$amount=$amount+$price;
		if($crow['extra']!=""){
		    $extra=$crow['extra'];
		}
	if($productid=='0')
	{
	    $delivery_charges=$price;
	    $extra=$crow['extra'];
	}
	else
	{
    $frenchises.='  <th scope="row" class="text-center">'.$i++.'</th>
      <td class="text-center">'.$productname.'</td>
      <td class="text-center">'.$size.'</td>
      <td class="text-center">'.$quantity.'</td>
	  <td class="text-center">'.$price.'</td>';
	   $frenchises.='</tr>';
	}

	}
}

$fid1="'".$fid."'";
$cid1="'".$cid."'";
 $frenchises.='
 </tr></tbody>
</table>
<hr style="border-top:2px solid #eee; margin-top:0px; margin-bottom:0px">
<p class="text-right" style="margin-right: 45px;">Delivery Charges '.$delivery_charges.'</p>
<h3 class="text-right" style="margin-right: 45px;">Total - '.$amount.'</h3>
<div class="text-center">
<p>Customer Suggestion : <b>'.$extra.'</b></p><br>
<input  style= "width: fit-content;" type="submit" class="btn btn-success" data-dismiss="modal" onclick="approve('.$cid1.','.$fid1.')" name="approve" value="Approve">
	  <input style= "width: fit-content;" type="submit" class="btn btn-danger" onclick="location.href=#" data-toggle="modal" data-target="#reject_modal" name="reject" value="Reject">
<hr style="height:2px;background-color:red">	  
</div>

';
	
   $frenchises.='';		
 $frenchises.='<div class="modal fade" id="reject_modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document" style="margin: 0px auto;">
       <font color="black"><div class="modal-content">
        <div class="modal-header">
          <button class="close" type="button" data-dismiss="modal" aria-label="Close" style="margin-top:-1rem">
            <span aria-hidden="true"><font color="black">×</font></span>
          </button>
        </div>
        <div class="modal-body"><font >Are you sure you want to reject this order?</font><br>
        <label>Select Reason</label>
        <select class="form-control" id="reject_reason">
        <option value="Outoff Stock">Outoff Stock</option>
        <option value="Electricity Problem">Electricity Problem</option>
        <option value="Employee Not Available">Employee Not Available</option>
        </select>
        </div>
        <div class="modal-footer">
          <button class="btn btn-primary" type="button" data-dismiss="modal">Cancel</button>
          <a class="btn btn-danger" type="button" data-dismiss="modal" onclick="reject('.$cid1.','.$fid1.')">Reject</a>
        </div>
      </div></font>
    </div>
  </div>
  ';


}
}
$frenchises.=' ';
echo $frenchises;
	// mysqli_close($con);
 }
 
 // reject Started//
 if(isset($_POST['reject']) && isset($_POST['cid'])  && isset($_POST['fid'])){
     $billno=$_POST['billno'];
	 $fid=$_POST['fid'];
	 $cid=$_POST['cid'];
$insertquery = "UPDATE customer_bill_mobile_app_details SET fid= NULL , order_status= NULL WHERE cid='$cid' && order_status='added'"; 
$result2 = mysqli_query($con,$insertquery);

mysqli_close($con);
 }

// reject Ended//

// approve Started//
 if(isset($_POST['approve'])){
 	  $fid=$_POST['fid'];
	  $cid=$_POST['cid'];
	  $latitude="";
	  $longitude="";
	  $address="";
	  $delivery_charges=0;
	  $latitude=$_POST['latitude'];
	  $longitude=$_POST['longitude'];
	  $address=$_POST['address'];
	  $order_type=$_POST['order_type'];

     $order_status="Paid";
     
     $time1=date('H:i:s');
     $billno;

$main_billno=0;
$mod=1;
$totalquantity=0;
$totalprice=0;
$month= date("m",strtotime($today));
$year= date("y",strtotime($today));
$smain_billno=1;
$sql8 = "SELECT MAX(main_billno) AS mmain_billno FROM customer_bill WHERE fid='$fid' AND MONTH(bill_date)='$month'";
$result8 = mysqli_query($con, $sql8);
if (mysqli_num_rows($result8) > 0) {
    $row8 = mysqli_fetch_assoc($result8);
	$main_billno1=$row8["mmain_billno"];
	$main_billno=$row8["mmain_billno"]+'1';
	$smain_billno="$month$year/$main_billno";
}
$query="SELECT billno FROM customer_bill WHERE fid='$fid' && bill_date='$today' ORDER BY srno DESC LIMIT 1";
$result1 = mysqli_query($con,$query);
if(mysqli_num_rows($result1) > 0){
$row1 = mysqli_fetch_array($result1);
$billno=$row1['billno'];
if($billno==0)
{ 
$billno=50;
}
$newbillno=$billno+1;
$i=1;
}
else
{
	$newbillno=51;
}				
	$displayquery = " SELECT * FROM customer_bill_mobile_app_details WHERE cid='$cid'"; 
	$result = mysqli_query($con,$displayquery);
	$i=1;
	if(mysqli_num_rows($result) > 0){
		while ($row = mysqli_fetch_array($result)) {
		    $srno =$row['srno'];
			$productid =$row['productid'];
			$productname =$row['productname'];
			$category_id=$row['category_id'];
			$productquantity =$row['quantity'];
			$productprice =$row['price'];
			$totalprice=$totalprice+$productprice;
			$totalquantity=$totalquantity+$productquantity;
			$size =$row['size'];
	        $extra =$row['extra'];
	        if($extra=="")
	        {
	            $extra=NULL;
	        }
	$insertquery = "INSERT INTO `customer_bill_details`(`cid`,`billsrno`, `smain_billno`, `productid`, `productname`, `quantity`, `price`, `fid`, `bill_date`, `size`, `parcel`, `extra`, `category_id`, `employeeid`)
	VALUES('$cid','$i','$smain_billno','$productid','$productname','$productquantity','$productprice','$fid','$today','$size','$order_type','$extra','$category_id','$employeeid')"; 
	$result1 = mysqli_query($con,$insertquery);

	if($productid=='0')
	{
	    $delivery_charges=$productprice;
	    $half_delivery_charges=$delivery_charges/2;
	    $totalprice=$totalprice-$delivery_charges;
	}
	$i++;
		}
		$delete_query="DELETE FROM customer_bill_mobile_app_details WHERE cid='$cid'";
	mysqli_query($con,$delete_query);	
	}
	
	
$customer_query="SELECT * FROM customer_details WHERE cid='$cid'";
    $customer_result=mysqli_query($con,$customer_query);
    if(mysqli_num_rows($customer_result)>0){
        $customer_row=mysqli_fetch_assoc($customer_result);
        $number_orders=$customer_row['number_orders'];
        $number_orders=(int)$number_orders;
         $mobile=$customer_row['mobile'];
    }
    
if($number_orders<5)
{
    $before_discount=$totalprice;
    $discount=round($totalprice*10/100,0);
    $totalprice=$totalprice-$discount;
    $insertquery = "INSERT INTO customer_bill (cid,billno,bill_date,total_product,amount,fid,order_status,time,main_billno,smain_billno,orderby,payment_mode,latitude,longitude,address,discount_percentage,discount,before_discount,employeeid) VALUES 
('$cid','$newbillno','$today','$totalquantity','$totalprice','$fid','$order_status','$time1','$main_billno','$smain_billno','$order_type','Cash','$latitude','$longitude','$address','10','$discount','$before_discount','$employeeid')"; 
}  
else{
    $insertquery = "INSERT INTO customer_bill (cid,billno,bill_date,total_product,amount,fid,order_status,time,main_billno,smain_billno,orderby,payment_mode,latitude,longitude,address,employeeid) VALUES 
('$cid','$newbillno','$today','$totalquantity','$totalprice','$fid','$order_status','$time1','$main_billno','$smain_billno','$order_type','Cash','$latitude','$longitude','$address','$employeeid')"; 
}

$result = mysqli_query($con,$insertquery);
if($order_type=="Home Delivery"){
$update_query="UPDATE customer_details SET history_latitude='$latitude',history_longitude='$longitude',history_address='$address' WHERE cid='$cid'";
mysqli_query($con,$update_query);

$update_query="UPDATE franchises SET deposit=deposit-$half_delivery_charges WHERE fid='$fid'";
mysqli_query($con,$update_query);

}
if($order_type=="Take Away"){
   $update_query="UPDATE franchises SET deposit=deposit-10 WHERE fid='$fid'";
mysqli_query($con,$update_query); 
}
$update_query="UPDATE customer_details SET number_orders=number_orders+1 WHERE cid='$cid'";
mysqli_query($con,$update_query); 

//cutting of stock
$displayquery1 = " SELECT * FROM customer_bill_details WHERE fid='$fid' && smain_billno ='$smain_billno'"; 
	$result3 = mysqli_query($con,$displayquery1);
	if(mysqli_num_rows($result3) > 0){
		while ($row = mysqli_fetch_array($result3)) {
			$productid =$row['productid'];
			$category_id=$row['category_id'];
			$productquantity =$row['quantity'];
			$size =$row['size'];
		//Pizza Category Started//
if($category_id==1){
    $pizza_size="pizza".$size;
    $pizza_size($productid,$productquantity,$fid,$today,$con);
    
}
if($category_id==2){
    
    burger($productid,$productquantity,$fid,$today,$con);
    
}
if($category_id==3){
    
    fries($productid,$productquantity,$fid,$today,$con);
    
}
if($category_id==4){
    
    nuggets($productid,$productquantity,$fid,$today,$con);
    
}
if($category_id==5){
    if($productid=='60' || $productid=='61' || $productid=='62' || $productid=='63'){
    coffee($productid,$productquantity,$fid,$today,$con);
    }
}
if($category_id==7){
    
    combo($productid,$productquantity,$fid,$today,$con);
    
}

		}
	}


mysqli_close($con);
 }

// approve Ended//
 

 if(isset($_POST['completedorder_take_away'])){
     $billno=$_POST['billno'];
     $query="SELECT * FROM customer_bill WHERE billno='$billno' AND fid='$fid' AND bill_date='$today'";
     $result=mysqli_query($con,$query);
     if(mysqli_num_rows($result)>0){
         $row=mysqli_fetch_assoc($result);
         $cid=$row['cid'];
         $bill_amount_tw=$row['amount'];
     }
     $billno="'".$_POST['billno']."'";
       $customer_query="SELECT * FROM customer_details WHERE cid='$cid' ";
    $customer_result=mysqli_query($con,$customer_query);
    if(mysqli_num_rows($customer_result)>0){
        $customer_row=mysqli_fetch_assoc($customer_result);
        $customer_name=$customer_row['firstname'];
        $customer_name=$customer_name." ".$customer_row['lastname'];
        $customer_mobile=$customer_row['mobile'];
    }
     
  echo'
  <h3>'.$customer_name.' ( '.$customer_mobile.' )</h3><br>
  <h2>Bill Amount-<b>'.$bill_amount_tw.'</b></h2><br>
  <hr>
  <label>Payment Mode</label><br>
    	<input id="cash_payment_mode_take_away" type="radio" name="payment_mode_take_away" value="Cash" checked> Cash&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    	<input id="card_payment_mode_take_away" type="radio" name="payment_mode_take_away" value="Card"> Card&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    	<input  id="bank_payment_mode_take_away" type="radio" name="payment_mode_take_away" value="Bank Transfer"> Bank Transfer
  </div>
  ';  
echo'<br><br>
<center><button class="btn btn-success" onclick="take_away_payment('.$billno.')" data-dismiss="modal">Submit</button></center>';

}
 
 if(isset($_POST['completedorder_home_delivery'])){
     $billno="'".$_POST['billno']."'";
     $sql="SELECT * FROM employee where branch='$fid' && status='active'";
$result2 = mysqli_query($con,$sql);
if(mysqli_num_rows($result2) > 0){
    echo'
    <center><h3>Select Delivery Employee Id</h3></center><br>
    <select class="form-control" id="home_delivery_employeeid">';
while($row2 = mysqli_fetch_array($result2)){
$employeeid=$row2['employeeid'];
$fname=$row2['fname'];
$lname=$row2['lname'];
echo'<option value="'.$employeeid.'">'.$employeeid.' - '.$fname.' '.$lname.'</option>';
}
echo'</select>';
echo'<br>
<center><button class="btn btn-success" onclick="dispatch('.$billno.')" data-dismiss="modal">Submit</button></center>';
}
}

 if(isset($_POST['dispatch'])){
     $billno=$_POST['billno'];
     $employee_id=$_POST['employee_id'];
     
     $query="UPDATE customer_bill SET employeeid='$employee_id' WHERE billno='$billno' AND bill_date='$today'";
     mysqli_query($con,$query);
}

 if(isset($_POST['take_away_payment'])){
     $billno=$_POST['billno'];
     $payment_mode=$_POST['payment_mode'];
     $query="UPDATE customer_bill SET payment_mode='$payment_mode', order_status='Delivered' WHERE billno='$billno' AND bill_date='$today'";
     mysqli_query($con,$query);
}
 
if(isset($_POST['printbackend_discount']))
{
$productid = $_POST['productid'];
$productname = $_POST['productname']; 
$price=$_POST['price'];
$size=$_POST['size'];
$category_id=$_POST['category'];
$discount_percentage=$_POST['discount_percentage'];
$discount_before_price=$_POST['discount_before_price'];
$discounted_price=$discount_before_price-$price;
$insertquery = "INSERT INTO customer_bill_details (productid,productname,quantity,price,fid,size,category_id,discount,employeeid,bill_date) VALUES ('$productid','$productname','1','$price','$fid','$size','$category_id','$discounted_price','$employeeid','$today')"; 
mysqli_query($con,$insertquery);
}

	//Add Product to Cart Started//
if(isset($_POST['cartadd']))
{
$productid = $_POST['productid'];
$productname = $_POST['productname']; 
$price=$_POST['price'];
$size=$_POST['size'];
$category_id=$_POST['category'];

$sql="SELECT * FROM customer_bill_details where fid='$fid'  && smain_billno IS NULL && productid='$productid' && employeeid='$employeeid' && pending='No'";
echo $sql;
$result2 = mysqli_query($con,$sql);
if(mysqli_num_rows($result2) > 0){
$row2 = mysqli_fetch_array($result2);
$quantity=$row2['quantity'];
$quantity++;
$newprice=$row2['price'];
$newprice=$newprice+$price;

$insertquery = "UPDATE customer_bill_details SET quantity='$quantity',price='$newprice',bill_date='$today' WHERE fid='$fid' && smain_billno IS NULL && productid='$productid' && employeeid='$employeeid'"; 
	//check Combo 
	echo "cat-$category_id  fid-$fid";
if ($category_id==7)
	{
		if($fid==14)
		{
			$comboinsertquery = "UPDATE combo_bill SET quantity='$quantity',bill_date='$today' WHERE fid='$fid' && comboid='$productid' && smain_billno IS NULL"; 
			$comboresult = mysqli_query($con,$comboinsertquery);
			echo "$con->error";
		}
		else
		{
			$comboinsertquery = "UPDATE combo_bill SET quantity='$quantity',bill_date='$today' WHERE fid='$fid' && comboid='$productid' && smain_billno IS NULL"; 
			$comboresult = mysqli_query($con,$comboinsertquery);
			echo "$con->error";
		}
	}
}
else
{
	
$insertquery = "INSERT INTO customer_bill_details (productid,productname,quantity,price,fid,size,category_id,employeeid,bill_date) VALUES ('$productid','$productname','1','$price','$fid','$size','$category_id','$employeeid','$today')"; 
	//check Combo 
	if ($category_id==7)
	{
		if($fid==14)
		{
			$selectcombo = "SELECT * FROM combo_submenu_aurangabad WHERE productid ='$productid'"; 
			$result = mysqli_query($con,$selectcombo);
			if(mysqli_num_rows($result) > 0){
			while($row = mysqli_fetch_array($result)){
				$sub_productid=$row['sub_productid'];
				$productname=$row['productname'];
				$comboinsertquery = "INSERT INTO combo_bill (comboid,productid,productname,quantity,fid,bill_date,size,category_id,employeeid) VALUES ('$productid','$sub_productid','$productname','1','$fid','$today','$size','$category_id','$employeeid')"; 
				$comboresult = mysqli_query($con,$comboinsertquery);
				echo "$con->error";
				}
			}
		}
		else
		{
			$selectcombo = "SELECT * FROM combo_submenu WHERE productid ='$productid'"; 
			$result = mysqli_query($con,$selectcombo);
			if(mysqli_num_rows($result) > 0){
			while($row = mysqli_fetch_array($result)){
				$sub_productid=$row['sub_productid'];
				$productname=$row['productname'];
				$comboinsertquery = "INSERT INTO combo_bill (comboid,productid,productname,quantity,fid,bill_date,size,category_id,employeeid) VALUES ('$productid','$sub_productid','$productname','1','$fid','$today','$size','$category_id','$employeeid')"; 
				echo $comboinsertquery;
				$comboresult = mysqli_query($con,$comboinsertquery);
				echo "$con->error";
				}
			}
		}
	}
}
$result = mysqli_query($con,$insertquery);
mysqli_close($con);
}
 // Add To Cart Ended //

// Add Single Product Started//

if(isset($_POST['plusone']))
{
$productid = $_POST['productid'];
$productname = $_POST['productname']; 
$price=$_POST['price'];
$category_id=$_POST['category'];
$quantity=$_POST['quantity'];
$singleprice=$price/$quantity;
$quantity++;
$price=$singleprice*$quantity;
$insertquery = "UPDATE customer_bill_details SET quantity='$quantity',price='$price' WHERE fid='$fid'  && smain_billno IS NULL && productid='$productid' && employeeid='$employeeid' && pending='No'"; 
$result = mysqli_query($con,$insertquery);
if ($category_id==7)
	{
		if($fid==14)
		{
			$comboinsertquery = "UPDATE combo_bill SET quantity='$quantity' WHERE fid='$fid' && smain_billno IS NULL && comboid='$productid' && employeeid='$employeeid' && pending='No' "; 
			$comboresult = mysqli_query($con,$comboinsertquery);
		}
		else
		{
			$comboinsertquery = "UPDATE combo_bill SET quantity='$quantity' WHERE fid='$fid' && smain_billno IS NULL && comboid='$productid' && employeeid='$employeeid' && pending='No'"; 
			$comboresult = mysqli_query($con,$comboinsertquery);
		}
	}

mysqli_close($con);
}
// Add Single Product Ended//

// Delete Single Product Start//
 if(isset($_POST['minusone']))
{
$productid = $_POST['productid'];
$productname = $_POST['productname']; 
$price=$_POST['price'];
$quantity=$_POST['quantity'];
$category_id=$_POST['category'];
if($quantity>1)
{
$singleprice=$price/$quantity;
$quantity--;
$price=$singleprice*$quantity;

$deletequery1 = "UPDATE customer_bill_details SET quantity='$quantity',price='$price' WHERE fid='$fid'  && smain_billno IS NULL && productid='$productid' && employeeid='$employeeid' && pending='No'"; 
$result1 = mysqli_query($con,$deletequery1);

if ($category_id==7)
	{
		if($fid==14)
		{
			$comboinsertquery = "UPDATE combo_bill SET quantity='$quantity' WHERE fid='$fid' && smain_billno IS NULL && comboid='$productid' && employeeid='$employeeid' && pending='No'"; 
			$comboresult = mysqli_query($con,$comboinsertquery);
		}
		else
		{
			$comboinsertquery = "UPDATE combo_bill SET quantity='$quantity' WHERE fid='$fid' && smain_billno IS NULL && comboid='$productid' && employeeid='$employeeid' && pending='No'"; 
			$comboresult = mysqli_query($con,$comboinsertquery);
		}
	}
}
else
{
$deletequery = "DELETE FROM customer_bill_details WHERE fid='$fid'  && smain_billno IS NULL && productid='$productid' && employeeid='$employeeid' && pending='No'"; 
$result = mysqli_query($con,$deletequery);
if ($category_id==7)
	{
		if($fid==14)
		{
			$comboinsertquery = "DELETE FROM combo_bill WHERE fid='$fid' && smain_billno IS NULL && comboid='$productid' && employeeid='$employeeid' && pending='No'"; 
			$comboresult = mysqli_query($con,$comboinsertquery);
		}
		else
		{
			$comboinsertquery = "DELETE FROM combo_bill WHERE fid='$fid' && smain_billno IS NULL && comboid='$productid' && employeeid='$employeeid' && pending='No'"; 
			$comboresult = mysqli_query($con,$comboinsertquery);
		}
	}
}
mysqli_close($con);
}
 
// Delete Single Product Ended//

if (isset($_POST['software_offer'])) {
$amount = $_POST['amount'];

// Fetch the category IDs to exclude in a single query
$displayquery = "SELECT GROUP_CONCAT(DISTINCT category_id) as excluded_categories 
                 FROM customer_bill_details 
                 WHERE fid=? AND smain_billno IS NULL AND employeeid=? AND pending='No'";
$stmt = $con->prepare($displayquery);
$stmt->bind_param("ss", $fid, $employeeid);
$stmt->execute();
$result = $stmt->get_result();
$excluded_categories = $result->fetch_assoc()['excluded_categories'];

// Prepare the common part of the query
$base_query = ($fid == '38') ? "SELECT * FROM submenu_goa" : "SELECT * FROM submenu";
$conditions = " WHERE price <=? 
                AND category_id NOT IN ('6', '7', '8')
                AND productid NOT IN ('78', '94', '72', '73', '74', '75', '79', '76')
                AND combo_status='Y'";
if ($excluded_categories) {
    $conditions .= " AND category_id NOT IN ($excluded_categories)";
}
$order_limit = " ORDER BY RAND() LIMIT 1";

// Determine discount and maximum price based on amount
if ($amount >= 100 && $amount < 150) {
    $discount_percentage = rand(13, 16);
    $max_price = 60;
} elseif ($amount >= 150 && $amount < 200) {
    $discount_percentage = rand(16, 20);
    $max_price = 99;
} elseif ($amount >= 200 && $amount < 250) {
    $discount_percentage = rand(21, 23);
    $max_price = 130;
} elseif ($amount >= 250 && $amount < 300) {
    $discount_percentage = rand(23, 25);
    $max_price = 155;
} elseif ($amount >= 300 && $amount < 400) {
    $discount_percentage = rand(23, 25);
    $max_price = 190;
} elseif ($amount >= 400 && $amount < 500) {
    $discount_percentage = rand(23, 25);
    $max_price = 250;
} else {
    $discount_percentage = rand(23, 25);
    $max_price = PHP_INT_MAX; // No price limit for amounts 500 and above
}

// Final query execution
$final_query = $base_query . $conditions . $order_limit;
$stmt = $con->prepare($final_query);
$stmt->bind_param("i", $max_price);
$stmt->execute();
$result = $stmt->get_result();
$row = $result->fetch_assoc();

if ($row) {
    $productid = $row['productid'];
    $productname = $row['productname'];
    $category_id = $row['category_id'];
    $price = $row['price'];
    $size = $row['size'];
    $price1 = $price - round($price * $discount_percentage / 100, 0);
    $show_discount = ($price - $price1) > $discount_percentage ? "<i class='fa fa-inr'></i> $price1" : "$discount_percentage %";

    echo "
        <div class='row'>
            <div class='col-md-12 text-center'>
                <b>Discount of</b>
                <h1 class='text-danger text-center' style='font-size: 50px;'><b>$show_discount</b></h1>
                <h2 class='text-success text-center'><span style='font-size: 20px;'>on &nbsp;</span><b>$productname $size</b></h2>
            </div>
        </div>
        <input type='hidden' value='$productid' id='discount_id'>
        <input type='hidden' value='$productname' id='discount_productname'>
        <input type='hidden' value='$price1' id='discount_price'>
        <input type='hidden' value='$price' id='discount_before_price'>
        <input type='hidden' value='$discount_percentage' id='discount_percentage'>
        <input type='hidden' value='$category_id' id='discount_category_id'>
        <input type='hidden' value='$size' id='discount_size'>";
} else {
    echo "<p>No eligible offers available for the current bill.</p>";
}

}

// Show Cart Bill Started//
 if(isset($_POST['showbill'])){
	$displayquery = " SELECT * FROM customer_bill_details WHERE fid='$fid'  && smain_billno IS NULL && employeeid='$employeeid' && pending='No'"; 
	$result = mysqli_query($con,$displayquery);
$billprice=0;
$totalquantity=0;
	if(mysqli_num_rows($result) > 0){
	    $cart.='<table id="cart" class="table table-hover table-condensed" style="margin-top:2.5rem">
    				<thead>
						<tr>
							<th style="width:45%" class="text-center">Product</th>
							<th style="width:4%" class="text-center">S</th>
							<th style="width:5%" class="text-center">QTY</th>
							<th style="width:10%" class="text-center">Price</th>
							<th style="width:4%"></th>
							<th style="width:4%"></th>
							<th style="width:6%">P</th>
							<th style="width:22%">Ex.</th>
						</tr>
					</thead>
					<tbody>';
		while ($row = mysqli_fetch_array($result)) {
			//$maxbillno=$row['maxbillno'];
			$productid =$row['productid'];
			$productname=$row['productname'];
			$parcel=$row['parcel'];
			$extra=$row['extra'];
			$size=$row['size'];
			$quantity=$row['quantity'];
			$price=$row['price'];
			$billprice=$billprice+$price;
			$productid1="'".$row['productid']."'";
			$productname1="'".$row['productname']."'";
			$price1="'".$row['price']."'";
			$quantity1="'".$row['quantity']."'";
			$plusone="plusone";
			$plusone="'".$plusone."'";
			$minusone="minusone";
			$minusone="'".$minusone."'";
			$billprice1="'".$billprice."'";
		    $category="'".$row['category_id']."'";
					$cart.='<tr>
							<td data-th="Product">
							<h5 class="text-center">'.$productname.'</h5>									
							</td>
							<td data-th="Size" class="text-center">'.$size[0].'</td>';

				 			$cart.='<td data-th="QTY" class="text-center"> <input id="keyup'.$productid.'" onkeyup="addkeyup('.$productid1.')" type="text" value="'.$quantity.'" /></td>

							<td data-th="Price" class="text-center">'.$price.'</td>
							
							<td class="actions" data-th="">
								<button class="btn btn-danger btn-sm" onclick="minusone('.$productid1.','.$productname1.','.$price1.','.$quantity1.','.$plusone.','.$category.')"><i class="fa fa-minus"></i></button>								
							</td>
							<td class="actions" data-th="">	
								<button class="btn btn-info btn-sm" onclick="plusone('.$productid1.','.$productname1.','.$price1.','.$quantity1.','.$minusone.','.$category.')"><i class="fa fa-plus"></i></button>
								</td>';
						$cart.='<td class="actions" data-th="">	
								<input type="checkbox" ';
								if($parcel=="true")
								{
					 $cart.='checked ';
								}
						$cart.='id="parcel'.$productid.'"value="" style="height:unset" onclick="addkeyup_parcel('.$productid1.')" />
								</td>
								<td class="actions">	
						<input type="text" name="'.$productid.'" id="extra'.$productid.'" value="'.$extra.'" style="height:unset" onchange="addkeyup_extra(this.name)"" />
								</td>
						</tr>';
						$cart.= '';	
						
						
	}
	$before_gst=$billprice;
	$cart.='</tbody>
				<tfoot>';
				if($gst=='Yes'){
				    $gst_price=round($billprice*5/100,0);
				    $billprice+=$gst_price;
				
$cart.='<tr>
		<td colspan="3" class="text-center"><strong>GST(5%)<strong></td>
		<td class="text-center" id="total_bill_price"><strong>'.$gst_price.'</strong></td>
	<td colspan="4"></td>
	</tr>';
				}			
	$cart.='<tr>
			<td colspan="3" class="text-center"><strong>Total<strong></td>
			<td class="text-center" id="total_bill_price"><strong>'.$billprice.'</strong></td>
			<td colspan="4"></td>
			</tr>
			</tfoot></table>';
				$cart.='<input type="number" id="mobile_number" name="mobile_number" autocomplete="off" placeholder="Mobile Number" class="form-control"/>';
				$cart.='</tfoot></table>
					<div class="row">
					<div class="col-md-5 text-right">
						<label>Order By</label>
						</div>
					<div class="col-md-5">	
					<select  name="orderby" id="servicetype" onchange="disable(this)" class="form-control">
							<option name="orderby" value="For Eat">For Eat</option>
							<option name="orderby" value="Parcel">Parcel</option>';
									    		 if($third_party=="Yes")
{
							$cart.='<option name="orderby" value="Swiggy">Swiggy</option>
							<option name="orderby" value="Zomato">Zomato</option>';
}
						$cart.='</select>
					</div>
					</div>
						<div class="row">
					<div class="col-md-12"  id="disable">
					<label>Payment Mode</label><br>
							<input id="cash_disable" type="radio" name="payment_mode" value="Cash" checked> Cash&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<input id="card_disable" type="radio" name="payment_mode" value="Card"> Card&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<input  id="bank_disable" type="radio" name="payment_mode" value="Bank Transfer"> Bank Transfer
					</div>
					</div>
					<br>
					<div class="row">
						<div class="col-md-4">
					<label>Bill Amount</label>
					<input type="text" name="amount" id="num1" class="form-control" value="'.$billprice.'" readonly="readonly">
					</div>
					<div class="col-md-4">
					<label>Paid</label>
					<input type="text" name="paidamount" id="num2" class="jQKeyboard form-control" onkeyup="sub(this)"value="">
					</div>
				
					<div class="col-md-4">
					<label style="color:red">Return</label>&nbsp;<br>
					<label id="Answer" name="returnamount" style="font-size:35px ;color:red" ></label>
					</div>
					</div>
					<br>
					<div class="row">
						<div class="col-md-12">
					<label>Passcode</label>
					<input type="number" name="passcode" id="passcode" class="form-control" value="" >
					</div>
					
					</div>
					<br>
					<div class="row">
					<div class="col-md-6">
					<input type="submit" class="btn btn-success btn-block" id="printbackendbutton" value="Confirm & Print" onclick="software_offer()"></input><br>
					</div>';
					$displayquery = " SELECT * FROM customer_bill_details WHERE fid='$fid'  && smain_billno IS NULL && employeeid='$employeeid' && pending='Yes'"; 
	                $result = mysqli_query($con,$displayquery);
                	if(mysqli_num_rows($result) > 0)
					{
					$cart.='<div class="col-md-6">
					<input type="button" class="btn btn-danger btn-block" value="Already pending"></input><br>
					</div>
					</div>';
					}
					else
					{
					   $cart.='<div class="col-md-6">
					<input type="button" class="btn btn-info btn-block" id="pending_button" onclick="sendpending()" value="Send To Pending"></input><br>
					</div>
					</div>'; 
					}
						}	
				$cart.='<div class="row">
					<div class="col-md-6">
						<input type="submit" data-toggle="modal" data-target="#reprint" class="btn btn-primary btn-block" value="Re-Print" onclick="reprintdisplay()">
					</div>	
					<div class="col-md-6">	
					    <input type="submit" data-toggle="modal" data-target="#reorder" class="btn btn-warning btn-block" value="Re-Order" onclick="reorderdisplay()">
						</div>
					</div>
					';
								if($billprice==0)
						{
				$cart.='<div class="col-md-12">
					<input type="hidden" class="btn btn-success btn-block" id="printbackendbutton" value="Confirm & Print"></input><br>
					</div>';
					
					$displayquery = " SELECT * FROM customer_bill_details WHERE fid='$fid'  && smain_billno IS NULL && employeeid='$employeeid' && pending='Yes'"; 
	                $result = mysqli_query($con,$displayquery);
                	if(mysqli_num_rows($result) > 0)
					{
					$cart.='<div class="col-md-12">
					<input type="button" class="btn btn-success btn-block" onclick="showpending()" value="See pending"></input><br>
					</div>
					';
					}
						}
		echo'<input type="hidden" value="'.$before_gst.'" id="without_gst_amount">';				
	 echo $cart;
			mysqli_close($con);
 }
 // Show Cart Bill Ended//
 
//  On Keyup Product Started//

if(isset($_POST['addkeyup']))
{
$productid = $_POST['productid'];
$quantity= $_POST['quantity'];
if($fid=='38'){
$query = " SELECT * FROM submenu_goa WHERE productid ='$productid'"; 
}
else
{
$query="SELECT * FROM submenu_old WHERE productid='$productid'";
}
$result1 = mysqli_query($con,$query);
if(mysqli_num_rows($result1) > 0){
$row1 = mysqli_fetch_array($result1);
$price=$row1['price'];
$price=$quantity * $price;
$insertquery = "UPDATE customer_bill_details SET quantity='$quantity',price='$price' WHERE fid='$fid'  && smain_billno IS NULL && productid='$productid' && employeeid='$employeeid' && pending='No'"; 
$result = mysqli_query($con,$insertquery);
if($fid=='38'){
$displayquery = " SELECT * FROM submenu_goa WHERE productid ='$productid'"; 
}
else{
$displayquery = " SELECT * FROM submenu_old WHERE productid ='$productid'"; 
}
$result = mysqli_query($con,$displayquery);
	if(mysqli_num_rows($result) > 0){
	$row = mysqli_fetch_array($result);
$category_id = $row['category_id']; 
	}

if ($category_id==7)
	{
		if($fid==14)
		{
			$comboinsertquery = "UPDATE combo_bill SET quantity='$quantity' WHERE fid='$fid' && smain_billno IS NULL && comboid='$productid' && employeeid='$employeeid' && pending='No'"; 
			$comboresult = mysqli_query($con,$comboinsertquery);
		}
		else
		{
			$comboinsertquery = "UPDATE combo_bill SET quantity='$quantity' WHERE fid='$fid' && smain_billno IS NULL && comboid='$productid' && employeeid='$employeeid' && pending='No'"; 
			$comboresult = mysqli_query($con,$comboinsertquery);
		}
	}
}
mysqli_close($con);
}
// On Keyup Product Ended// 

//  On Keyup Parcel Product Started//

if(isset($_POST['addkeyup_parcel']))
{
$parcel1=$_POST['parcel1'];
$productid = $_POST['productid'];

// Prepare the query to avoid multiple parsing and improve security
$stmt = $con->prepare("UPDATE customer_bill_details 
                       SET parcel = ? 
                       WHERE fid = ? 
                         AND smain_billno IS NULL 
                         AND employeeid = ? 
                         AND pending = 'No' 
                         AND productid = ? 
                       ORDER BY srno DESC 
                       LIMIT 1");

// Bind parameters to the prepared statement
$stmt->bind_param('siss', $parcel1, $fid, $employeeid, $productid);

// Execute the query
$stmt->execute();

// Close the statement and connection
$stmt->close();
$con->close();
}
// On Keyup Parcel Product Ended//

//  On Keyup Extra Product Started//

if(isset($_POST['addkeyup_extra']))
{
$productid = $_POST['productid'];
$extra1 = $_POST['extra1'];

// Prepare the query to improve performance and security
$stmt = $con->prepare("UPDATE customer_bill_details 
                       SET extra = ? 
                       WHERE fid = ? 
                         AND smain_billno IS NULL 
                         AND employeeid = ? 
                         AND pending = 'No' 
                         AND productid = ? 
                       ORDER BY srno DESC 
                       LIMIT 1");

// Bind the parameters to the prepared statement
$stmt->bind_param('siss', $extra1, $fid, $employeeid, $productid);

// Execute the query
$stmt->execute();

// Close the statement and connection
$stmt->close();
$con->close();

}
// On Keyup Extra Product Ended//

//Reprint Display Started//
if(isset($_POST['reprintdisplay'])){
// Assuming $con is the MySQLi connection object

// Prepare the main query
$stmt = $con->prepare("SELECT billno, smain_billno, amount, order_status 
                       FROM customer_bill 
                       WHERE fid = ? AND bill_date = ? 
                       ORDER BY srno DESC");
$stmt->bind_param('is', $fid, $today);


// Execute the query
$stmt->execute();
$result = $stmt->get_result();

$reprintdisplay = '';

if ($result->num_rows > 0) {
    // Prepare the inner query once, to reuse in the loop
    $stmt_details = $con->prepare("SELECT quantity, productname 
                                   FROM customer_bill_details 
                                   WHERE fid = ? AND smain_billno = ? 
                                   ORDER BY srno ASC");

    while ($row = $result->fetch_assoc()) {
        $billno = $row['billno'];
        $smain_billno = $row['smain_billno'];
        $amount = $row['amount'];
        $order_status = $row['order_status'];
$smain_billno1="'".$row['smain_billno']."'";
			$amount1="'".$row['amount']."'";
        $reprintdisplay .= '<p style="color:' . ($order_status != 'Delivered' ? 'red' : 'black') . ';">';
        $reprintdisplay .= '<button class="btn btn-space btn-primary btn-md" onclick="reprint('.$smain_billno1.','.$amount1.')">Print</button> ';
        $reprintdisplay .= '<b>' . $billno . '</b> ';

        // Bind and execute the details query
        $stmt_details->bind_param('is', $fid, $smain_billno);
        $stmt_details->execute();
        $result_details = $stmt_details->get_result();

        $i = 0;
        while ($row1 = $result_details->fetch_assoc()) {
            if ($i++ > 0) {
                $reprintdisplay .= ', ';
            }
            $quantity = $row1['quantity'];
            $productname = $row1['productname'] . "($quantity)";
            $reprintdisplay .= $productname;
        }

        $reprintdisplay .= '</p><br>';
    }

    $stmt_details->close();
}

$stmt->close();
$con->close();

echo $reprintdisplay;

}
// Reprint Display Ended  //

//Reprint Started//
 if(isset($_POST['reprint'])){
$_SESSION['printbillno']=$_POST['billno'];
	$_SESSION['printamount']=$_POST['amount'];
// 	mysqli_close($con);
}

//RePrint Ended//
 
//ReOrder Display Started//
if(isset($_POST['reorderdisplay']))
{
$reorderdisplay = '';

// Prepare and execute the first query
$stmt = $con->prepare("SELECT * FROM customer_bill WHERE fid=? AND bill_date=? AND order_status='Completed' ORDER BY srno DESC");
if (!$stmt) {
    die("Prepare failed: " . $con->error);
}
$stmt->bind_param("ss", $fid, $today);
if (!$stmt->execute()) {
    die("Execute failed: " . $stmt->error);
}
$result = $stmt->get_result();

if ($result->num_rows > 0) {
    while ($row = $result->fetch_assoc()) {
        $billno = $row['billno'];
        $amount = $row['amount'];
        $order_status = $row['order_status'];
        $smain_billno = $row['smain_billno'];

        if ($order_status != "Delivered") {
            $reorderdisplay .= ' <p style="color:red;"> <button class="btn btn-space btn-primary btn-md" onclick="reorder(\'' . $smain_billno . '\')">Re-Order</button> ';
            $reorderdisplay .= '<b>' . $billno . '</b> ';
        } else {
            $reorderdisplay .= ' <p> <button class="btn btn-space btn-primary btn-md" onclick="reprint('.$billno1.','.$amount1.')">Print</button> ';
            $reorderdisplay .= '<b>' . $billno . '</b> ';
        }

        // Prepare and execute the detail query
        $stmt1 = $con->prepare("SELECT * FROM customer_bill_details WHERE fid=? AND smain_billno=? ORDER BY srno ASC");
        if (!$stmt1) {
            // Log or display an error message, and skip to the next iteration
            $reorderdisplay .= '<p>Error preparing details query.</p>';
            continue; // Skip this iteration
        }
        $stmt1->bind_param("ss", $fid, $smain_billno);
        if (!$stmt1->execute()) {
            // Log or display an error message, and skip to the next iteration
            $reorderdisplay .= '<p>Error executing details query.</p>';
            continue; // Skip this iteration
        }
        $result1 = $stmt1->get_result();

        $details = [];
        while ($row1 = $result1->fetch_assoc()) {
            $quantity = $row1['quantity'];
            $productname = $row1['productname'] . " (" . $quantity . ")";
            $details[] = $productname;
        }

        if (!empty($details)) {
            $reorderdisplay .= implode(',', $details);
        }

        $reorderdisplay .= '</p><br> ';
        
        // Ensure $stmt1 is closed after each iteration
        $stmt1->close();
    }
}

// Clean up
$stmt->close();
$con->close();

echo $reorderdisplay;

}

// ReOrder Display Ended  // 
 
 //ReOrder Started//
 if(isset($_POST['reorder']) && ($_POST['billno'])){
$reorder_smain_billno=$_POST['billno'];
$updatedetailquery = mysqli_query($con,"UPDATE customer_bill SET order_status='Process' WHERE fid='$fid' && smain_billno='$reorder_smain_billno'"); 
//$updatedetailquery = mysqli_query($con,"UPDATE customer_bill_details SET order_status='Process' WHERE fid='$fid' && smain_billno='$reorder_smain_billno'"); 
mysqli_close($con);
}
//ReOrder Ended//

 // Confirm & Print Bill Started//
 
if(isset($_POST['printbackend'])){ 
    $orderby = $_POST['orderby'];
	 $amount=$_POST['amount'];
	 $payment_mode=$_POST['payment_mode'];
     $time1=date('H:i:s');
     $order_status="Paid";
     $mobileno=$_POST['mobile_number'];
     $passcode=$_POST['passcode'];
     $billno;
     if($orderby=="Swiggy")
     {
         $payment_mode="Swiggy";
     }
    if($orderby=="Zomato")
     {
         $payment_mode="Zomato";
     }
$main_billno=1;
$mod=1;
$totalquantity=0;
$totalprice=0;
$month= date("m",strtotime($today));
$year= date("y",strtotime($today));
$smain_billno=1;
$sql8 = "SELECT MAX(main_billno) AS mmain_billno FROM customer_bill WHERE fid='$fid' AND MONTH(bill_date)='$month'";
$result8 = mysqli_query($con, $sql8);
if (mysqli_num_rows($result8) > 0) {
    $row8 = mysqli_fetch_assoc($result8);
	$main_billno1=$row8["mmain_billno"];
	$main_billno=$row8["mmain_billno"]+'1';
	$smain_billno="$month$year/$main_billno";
}
$query="SELECT billno FROM customer_bill WHERE fid='$fid' && bill_date='$today' ORDER BY srno DESC LIMIT 1";
$result1 = mysqli_query($con,$query);
if(mysqli_num_rows($result1) > 0){
$row1 = mysqli_fetch_array($result1);
$billno=$row1['billno'];
if($billno==0)
{ 
$billno=50;
}
$newbillno=$billno+1;
$i=1;
}
else
{
	$newbillno=51;
}				
	$displayquery = " SELECT * FROM customer_bill_details WHERE fid='$fid' && smain_billno IS NULL && employeeid='$employeeid' && pending='No'"; 
	$result = mysqli_query($con,$displayquery);
	$i=1;
	if(mysqli_num_rows($result) > 0){
		while ($row = mysqli_fetch_array($result)) {
			$productid =$row['productid'];
			$category_id=$row['category_id'];
			$productquantity =$row['quantity'];
			$productprice =$row['price'];
			$totalprice=$totalprice+$productprice;
			$totalquantity=$totalquantity+$productquantity;
			$size =$row['size'];
	$insertquery = "UPDATE customer_bill_details SET billsrno='$i',smain_billno='$smain_billno' WHERE fid='$fid' && smain_billno IS NULL && employeeid='$employeeid' && pending='No' && productid='$productid'"; 
	$result1 = mysqli_query($con,$insertquery);
	$i++;
		}
	}
	
	$comboinsertquery = "UPDATE combo_bill SET smain_billno='$smain_billno' WHERE fid='$fid' && smain_billno IS NULL && employeeid='$employeeid' && pending='No'"; 
	$comboresult = mysqli_query($con,$comboinsertquery);
if($gst=='Yes'){
	    $gst_price=round($totalprice*5/100,0);
	    $insertquery = "INSERT INTO customer_bill (billno,bill_date,total_product,amount,fid,order_status,time,main_billno,smain_billno,employeeid,orderby,payment_mode,mobileno,smssent) VALUES 
('$newbillno','$today','$totalquantity','$totalprice','$fid','$order_status','$time1','$main_billno','$smain_billno','$employeeid','$orderby','$payment_mode','$mobileno','$gst_price')"; 
$result = mysqli_query($con,$insertquery);
	}else{
	$insertquery = "INSERT INTO customer_bill (billno,bill_date,total_product,amount,fid,order_status,time,main_billno,smain_billno,employeeid,orderby,payment_mode,mobileno) VALUES 
('$newbillno','$today','$totalquantity','$totalprice','$fid','$order_status','$time1','$main_billno','$smain_billno','$employeeid','$orderby','$payment_mode','$mobileno')"; 
$result = mysqli_query($con,$insertquery);
	}

if($passcode>1){
         $con->query("UPDATE customer_bill SET cid='$passcode' WHERE smain_billno='$smain_billno' && fid='$fid' && bill_date='$today'");
         $con->query("UPDATE customer_bill_details SET cid='$passcode' WHERE smain_billno='$smain_billno' && fid='$fid' && bill_date='$today'");
     }
		$_SESSION['printbillno']=$smain_billno;

if($orderby=='Parcel')
		{
		$sqlupdate = "UPDATE customer_bill_details SET parcel='true' WHERE smain_billno='$smain_billno' && fid='$fid' && bill_date='$today' "; 
	$con->query($sqlupdate);
		}

//cutting of stock
$displayquery1 = " SELECT * FROM customer_bill_details WHERE fid='$fid' && smain_billno ='$smain_billno'"; 
	$result3 = mysqli_query($con,$displayquery1);
	if(mysqli_num_rows($result3) > 0){
		while ($row = mysqli_fetch_array($result3)) {
			$productid =$row['productid'];
			$category_id=$row['category_id'];
			$productquantity =$row['quantity'];
			$size =$row['size'];
		//Pizza Category Started//
if($category_id==1){
    $pizza_size="pizza".$size;
    $pizza_size($productid,$productquantity,$fid,$today,$con);
    
}
if($category_id==2){
    
    burger($productid,$productquantity,$fid,$today,$con);
    
}
if($category_id==3){
    
    fries($productid,$productquantity,$fid,$today,$con);
    
}
if($category_id==4){
    
    nuggets($productid,$productquantity,$fid,$today,$con);
    
}
if($category_id==5){
    if($productid=='60' || $productid=='61' || $productid=='62' || $productid=='63'){
    coffee($productid,$productquantity,$fid,$today,$con);
    }
    if($productid=='129'){
    tea($productid,$productquantity,$fid,$today,$con);
    }
}
if($category_id==7){
    combo($productid,$productquantity,$fid,$today,$con);
}
if($category_id==6){
    shakes($productid,$productquantity,$fid,$today,$con);
}


		}
	}

 if($fid=='1'){
	if($mobileno<=7000000000 || $mobileno>=9999999999)
		{
		}
		else
		{
// 		$query = "SELECT * FROM franchises Where fid='$fid'"; 
// 	$result = mysqli_query($con,$query);
// 	if(mysqli_num_rows($result) > 0){

// 		while ($row = mysqli_fetch_array($result)) {
// 			$branchname =$row['smsaddress'];
// 			$sqlupdate = "UPDATE customer_bill SET smssent='1',mobileno='$mobileno' WHERE fid='$fid' && smain_billno ='$smain_billno' "; 
// 	$con->query($sqlupdate);
// 		}
// 	}

$displayquery5 = " SELECT srno FROM customer_bill WHERE fid='$fid' && smain_billno ='$smain_billno'"; 
	$result5 = mysqli_query($con,$displayquery5);
	if(mysqli_num_rows($result5) > 0){
		while ($row = mysqli_fetch_array($result5)) {
			$cbillsrno =$row['srno'];
		}
	}
		
		// create a new cURL resource
$bill_srno12=$cbillsrno."u"."$today";
$msg="Thank%20you%20for%20choosing%20%2AHeaven%20Pizza%20And%20Cafe%20-%20Urban%20Bite%2A%20for%20your%20dining%20experience%20today.%0a%0aYour%20satisfaction%20is%20our%20priority!%0a%0a%2AYour%20Order%20Details:%2A%0aOrder%20No.:%20$newbillno%0aOrder%20Amount:%20$amount%0a%0aTo%20view%20your%20bill%20online,%20click%20here:%20https://heaven.vinayakit.in/c.php?a=$bill_srno12%0a%0aWe%20would%20love%20to%20hear%20your%20valuable%20feedback.%20Please%20take%20a%20moment%20to%20share%20your%20thoughts%20and%20help%20us%20serve%20you%20better:%20https://heaven.deshnaya.com/%0a%0aOnce%20again,%20thank%20you%20for%20visiting%20us.%20We%20look%20forward%20to%20serving%20you%20again%20soon!%0a%0aBest%20regards,%0aHeaven%20Pizza%20And%20Cafe%20-%20Urban%20Bite%0aGadhinglaj%0a%0a%2ANote:%2A%20If%20you%20have%20any%20trouble%20accessing%20the%20above%20links,%20please%20reply%20with%20%2AHello%2A%20msg%20for%20activating%20above%20links";
// $mobileno="8007002203";
$url="http://37.59.76.45/api/mt/SendSMS?User=urbanbite&Password=urbanbite&Apiauthkey=651A7013C4996&mobile=91$mobileno&messageText=$msg";
$error_msg="";
$ch = curl_init();
 curl_setopt($ch, CURLOPT_URL, $url);
 curl_exec($ch);
if (curl_errno($ch)) {
    $error_msg = curl_error($ch);
}
curl_close($ch);


		
		
//  $ch = curl_init();
//  $branchname = str_replace(' ', '%20', $branchname);
//  $msg="Thanx%20For%20Visiting%20Heaven%20Pizza%20And%20Cafe,$branchname.%20Your%20Order%20No.%20is%20$billno1%20of%20Rs.$amount%20For%20Bill%20Details%20Click%20on%20heaven.vinayakit.in/c.php?a=$cbillsrno";
//  $url="http://sms.vinayakit.in/api/sendsms?username=VINAYAK1&password=1234&senderid=HEVANP&message=$msg&numbers=$mobileno&dndrefund=1";
//  curl_setopt($ch, CURLOPT_URL, $url);
//  curl_exec($ch);
//  curl_close($ch);
 
	}
}
	mysqli_close($con);
}
 // Confirm Bill Ended//

//CompletedDisplay Order Started//
 if (isset($_POST['completedorderdisplay'])) {
    $completed = '';
    $completed .= '<table class="table table-hover table-condensed">
                    <tr>
                    <td colspan="3"><label class="text-center btn btn-block" style="background-color: #fd0000; border-color: #fd0000; color: white;">Completed Order</label></td>
                    </tr><tr>';

    // Prepare the SQL statement to improve performance
    $displayquery1 = "SELECT billno, orderby, employeeid FROM customer_bill WHERE order_status='Completed' AND fid=? AND bill_date=?";
    $stmt = mysqli_prepare($con, $displayquery1);
    mysqli_stmt_bind_param($stmt, "ss", $fid, $today);
    mysqli_stmt_execute($stmt);
    $result = mysqli_stmt_get_result($stmt);
    
    $i = 0;
    if (mysqli_num_rows($result) > 0) {
        while ($r = mysqli_fetch_assoc($result)) {
            $billno = $r['billno'];
            $orderby = $r['orderby'];
            $hdemployee_id = $r['employeeid'];
            $billno1 = htmlspecialchars($billno, ENT_QUOTES); // Escape output to prevent XSS

            if ($i <= 2) {
                if ($orderby == "Home Delivery") {
                    $completed .= sprintf('<td data-toggle="modal" data-target="#completedorder_mobile" onclick="completedorder_home_delivery(\'%s\')"><label class="text-center btn btn-danger btn-block">%s (HD - %s)</label></td>', $billno1, $billno, $hdemployee_id);
                } elseif ($orderby == "Take Away") {
                    $completed .= sprintf('<td data-toggle="modal" data-target="#completedorder_mobile" onclick="completedorder_take_away(\'%s\')"><label class="text-center btn btn-success btn-block">%s (TA)</label></td>', $billno1, $billno);
                } else {
                    $completed .= sprintf('<td onclick="completedorder(\'%s\')"><label class="text-center btn btn-info btn-block">%s</label></td>', $billno1, $billno);
                }
                $i++;
            }
            if ($i == 3) {
                $completed .= '</tr><tr>';
                $i = 0;
            }
        }
    }
    $completed .= '</tr></table>';
    echo $completed;
    mysqli_stmt_close($stmt); // Close the prepared statement
    mysqli_close($con);
}

// CompletedDisplay Order Completed// 

// Completed Order Started//
  if(isset($_POST['completedorder']) && $_POST['billno']){
	 $billno = $_POST['billno'];
	$displayquery = "SELECT * FROM customer_bill WHERE order_status='Completed' && billno='$billno' && fid='$fid' && bill_date='$today'";
	$result = mysqli_query($con,$displayquery);
	if(mysqli_num_rows($result) > 0){
	$sql1 = "update customer_bill set order_status='Delivered' WHERE billno='$billno' && fid='$fid' && bill_date='$today'";
	$con->query($sql1);
	}
mysqli_close($con);	
}
// Completed Order Ended//

//KitchenDisplay Order Started//
 if(isset($_POST['kitchenorderdisplay']))
 {
 $completed='';
 $completed.='<table class="table table-hover table-condensed">
						<tr>
						<td colspan="3" ><label class="text-center btn warning btn-block" style="background-color: #f0ad4e; border-color:fd0000;color:white">Kitchen Order</label></td></tr><tr>';
					$displayquery1 = "SELECT * FROM customer_bill WHERE fid='$fid' && (order_status='Paid' OR order_status='Process') && bill_date='$today'";
 $res = mysqli_query($con,$displayquery1);
 $i=0;
	if(mysqli_num_rows($res) > 0){
		while ($r = mysqli_fetch_array($res)) {
		$billno=$r['billno'];
		$billno1="'".$billno."'";
		if($i<=2)
		{
		$completed.= '<td  onclick="kitchenorder('.$billno1.')"><label class="text-center btn btn-info btn-block">'.$billno.'</label></td>';
		$i++;
		}
		if($i==3)
		{
			$completed.= '</tr><tr>';
			$i=0;
		}
	}
	}
					$completed.= '</tr></table>';
					echo $completed;
					mysqli_close($con);
 }
// KitchenDisplay Order Ended// 

// Kitchen Order Started//
  if(isset($_POST['kitchenorder']) && $_POST['billno']){
	 $billno = $_POST['billno'];
	$displayquery = "SELECT * FROM customer_bill WHERE billno='$billno' && fid='$fid' && bill_date='$today'";
	$result = mysqli_query($con,$displayquery);
	if(mysqli_num_rows($result) > 0){
	$sql1 = "update customer_bill set order_status='Completed' WHERE billno='$billno' && fid='$fid' && bill_date='$today'";
	$con->query($sql1);
	}
mysqli_close($con);	
}
// Kitchen Order Ended//

//show pending started
if(isset($_POST['showpending'])){
    
    mysqli_query($con,"UPDATE customer_bill_details SET pending='No' WHERE fid='$fid'  && smain_billno IS NULL && employeeid='$employeeid' && pending='Yes'");
    mysqli_close($con);
}
//show pending Ended

//Send pending started
if(isset($_POST['sendpending'])){
    
    mysqli_query($con,"UPDATE customer_bill_details SET pending='Yes' WHERE fid='$fid'  && smain_billno IS NULL && employeeid='$employeeid' && pending='No'");
    mysqli_close($con);
}
//Send pending Ended

 // Pizza List Start//
	if(isset($_POST['pizza_list'])){
	    	  if($fid=='14')
	  {
	      echo'<script>
	      alert("Please Contact Owner");
	     window.location.href="login.php";
	      </script>';
	  }
	    $i=0;
	    $category1="'"."1"."'";
if($fid=='38'){
	    $displayquery = " SELECT productname,max(productid) AS productid FROM submenu_goa WHERE category_id = 1 AND productid!='94' AND combo_status='Y'  GROUP BY productname ORDER BY productid ASC";
	    }
	    else
	    {
	$displayquery = " SELECT productname,max(productid) AS productid FROM submenu_old WHERE category_id = 1 AND productid!='94' AND combo_status='Y'  GROUP BY productname ORDER BY productid ASC";
	    }
	$result = mysqli_query($con,$displayquery);
$pizzalist='<div class="row"> <div class="col-md-12">';
	if(mysqli_num_rows($result) > 0){
		while ($row = mysqli_fetch_array($result)) {
			$productid=$row['productid'];
			$productname=$row['productname'];
	//small piza
if($fid=='38'){
	  $smallquery = " SELECT * FROM submenu_goa WHERE productname = '$productname' AND size='Small' "; 
	}
	else
	{
	$smallquery = " SELECT * FROM submenu_old WHERE productname = '$productname' AND size='Small' "; 
	}
	$smallresult = mysqli_query($con,$smallquery);
	if(mysqli_num_rows($smallresult) > 0){
		$smallrow = mysqli_fetch_array($smallresult);
			$smallproductid=$smallrow['productid'];
			$smallpizza=$smallrow['price'];
			$smallsize=$smallrow['size'];
			$smallsize1="'".$smallsize."'";
			$smallproductid1="'".$smallproductid."'";
			$smallpizza1="'".$smallpizza."'";
			
	}
	//medium pizza
	if($fid==38)
	{
	$mediumquery = " SELECT * FROM submenu_goa WHERE productname = '$productname' AND size='Medium' "; 
	}
	else
	{
	$mediumquery = " SELECT * FROM submenu_old WHERE productname = '$productname' AND size='Medium' "; 
	}
	$mediumresult = mysqli_query($con,$mediumquery);
	if(mysqli_num_rows($mediumresult) > 0){
		$mediumrow = mysqli_fetch_array($mediumresult);
			$mediumproductid=$mediumrow['productid'];
			$mediumpizza=$mediumrow['price'];
			$mediumsize=$mediumrow['size'];
			$mediumsize1="'".$mediumsize."'";
			$mediumproductid1="'".$mediumproductid."'";
			$mediumpizza1="'".$mediumpizza."'";
	}
	//large pizza
	if($fid==38)
	{
	$largequery = " SELECT * FROM submenu_goa WHERE productname = '$productname' AND size='Large' "; 
	}
	else
	{
	$largequery = " SELECT * FROM submenu_old WHERE productname = '$productname' AND size='Large' "; 
	}
	$largeresult = mysqli_query($con,$largequery);
	if(mysqli_num_rows($largeresult) > 0){
		$largerow = mysqli_fetch_array($largeresult);
			$largeproductid=$largerow['productid'];
			$largepizza=$largerow['price'];
			$largesize=$largerow['size'];
			$largesize1="'".$largesize."'";
			$largeproductid1="'".$largeproductid."'";
			$largepizza1="'".$largepizza."'";
	}
			$productname1="'".$productname."'";
		
			
			
			$pizzalist.='<div class="col-md-6" style="margin-top:0rem" >
							<div class="panel panel-info">							
								<div class="panel-heading">
									<center><h4 ><b>'.$productname.'</b></h4></center>
								</div>
								<div class="panel-body" style="padding:8px"><center>
									<button class="btn btn-space btn-primary btn-md" onclick="cartadd('.$smallproductid1.','.$productname1.','.$smallpizza1.','.$smallsize1.','. $category1.')">S - <i class="fa fa-inr"></i> '.$smallpizza.'</button>								
									<button class="btn btn-space btn-info btn-md" onclick="cartadd('.$mediumproductid1.','.$productname1.','.$mediumpizza1.','.$mediumsize1.','. $category1.')">M - <i class="fa fa-inr"></i> '.$mediumpizza.'</button>
									<button class="btn btn-space btn-warning btn-md" onclick="cartadd('.$largeproductid1.','.$productname1.','.$largepizza1.','.$largesize1.','. $category1.')">L - <i class="fa fa-inr"></i> '.$largepizza.'</button>								</center>

								</div>
								</div>
							</div>';
		}
	}
	
$category1="'"."1"."'";
if($fid=='38'){
    $displayquery = " SELECT * FROM submenu_goa WHERE productid = '94'"; 
}else{
	$displayquery = " SELECT * FROM submenu_old WHERE productid = '94'"; 
}
	$result = mysqli_query($con,$displayquery);
	if(mysqli_num_rows($result) > 0){
		while ($row = mysqli_fetch_array($result)) {
			$productid=$row['productid'];
			$productname=$row['productname'];
			$price=$row['price'];
			$size1="'".$row['size']."'";
			$productid1="'".$row['productid']."'";
			$productname1="'".$row['productname']."'";
			$price1="'".$row['price']."'";
			$pizzalist.='<div class="col-md-6" onclick="cartadd('.$productid1.','.$productname1.','.$price1.','.$size1.','.$category1.')">
							<div class="panel panel-info">							
								<div class="panel-heading">
									<center><h4 ><b>'.$productname.'</b></h4></center>
								</div>
								<div class="panel-body">
									<center><i class="fa fa-inr"></i> '.$price.'</center>
								</div>
								</div>
							</div>';
						
			
		}
	}
	
	$pizzalist.='</div></div>';
	echo $pizzalist;
	mysqli_close($con);
	}
// Pizza List End//
 
 // Burger List Start//
	if(isset($_POST['burger_list'])){
	$category1="'"."2"."'";    
if($fid=='38'){
		$displayquery = " SELECT * FROM submenu_goa WHERE category_id = 2 AND combo_status='Y' ORDER BY srno ASC"; 
	}
	else
	{
	$displayquery = " SELECT * FROM submenu_old WHERE category_id = 2 AND combo_status='Y' ORDER BY srno ASC"; 
    }
	$result = mysqli_query($con,$displayquery);
$burgerlist='<div class="row"> <div class="col-md-12">';
	if(mysqli_num_rows($result) > 0){
		while ($row = mysqli_fetch_array($result)) {
			$productid=$row['productid'];
			$productname=$row['productname'];
			$price=$row['price'];
			$size1="'".$row['size']."'";
			$productid1="'".$row['productid']."'";
			$productname1="'".$row['productname']."'";
			$price1="'".$row['price']."'";
			$burgerlist.='<div class="col-md-6" style="margin-top:0.5rem" onclick="cartadd('.$productid1.','.$productname1.','.$price1.','.$size1.','.$category1.')">
							<div class="panel panel-info">							
								<div class="panel-heading">
									<center><h4 ><b>'.$productname.'</b></h4></center>
								</div>
								<div class="panel-body">
									<center><i class="fa fa-inr"></i> '.$price.'</center>
								</div>
								</div>
							</div>';
						
			
		}
	}
	$burgerlist.='</div></div>';
	echo $burgerlist;
	mysqli_close($con);
	}
// Burger List End//

// Fries List Start//
	if(isset($_POST['fries_list'])){
	    	  if($fid=='14')
	  {
	      echo'<script>
	      alert("Please Contact Owner");
	     window.location.href="login.php";
	      </script>';
	  }
	    $i=0;
	    $category1="'"."3"."'";
	    if($fid=='38'){
	    $displayquery = " SELECT productname,max(productid) AS productid FROM submenu_goa WHERE category_id = 3 AND productid!='94' AND combo_status='Y'  GROUP BY productname ORDER BY productid ASC";
	    }
	    else
	    {
	$displayquery = " SELECT productname,max(productid) AS productid FROM submenu_old WHERE category_id = 3 AND productid!='94' AND combo_status='Y'  GROUP BY productname ORDER BY productid ASC";
	    }
	$result = mysqli_query($con,$displayquery);
$frieslist='<div class="row"> <div class="col-md-12">';
	if(mysqli_num_rows($result) > 0){
		while ($row = mysqli_fetch_array($result)) {
			$productid=$row['productid'];
			$productname=$row['productname'];
	//small Fries
if($fid=='38'){
	$smallquery = " SELECT * FROM submenu_goa WHERE productname = '$productname' AND size='Small'  AND combo_status='Y' "; 
	}
	else
	{
	$smallquery = " SELECT * FROM submenu_old WHERE productname = '$productname' AND size='Small'  AND combo_status='Y'"; 
	}
	$smallresult = mysqli_query($con,$smallquery);
	if(mysqli_num_rows($smallresult) > 0){
		$smallrow = mysqli_fetch_array($smallresult);
			$smallproductid=$smallrow['productid'];
			$smallpizza=$smallrow['price'];
			$smallsize=$smallrow['size'];
			$smallsize1="'".$smallsize."'";
			$smallproductid1="'".$smallproductid."'";
			$smallpizza1="'".$smallpizza."'";
			
	}
	//medium Fries
if($fid=='38'){
	$mediumquery = " SELECT * FROM submenu_goa WHERE productname = '$productname' AND size='Medium'  AND combo_status='Y'"; 
	}
	else
	{
	$mediumquery = " SELECT * FROM submenu_old WHERE productname = '$productname' AND size='Medium'  AND combo_status='Y'"; 
	}
	$mediumresult = mysqli_query($con,$mediumquery);
	if(mysqli_num_rows($mediumresult) > 0){
		$mediumrow = mysqli_fetch_array($mediumresult);
			$mediumproductid=$mediumrow['productid'];
			$mediumpizza=$mediumrow['price'];
			$mediumsize=$mediumrow['size'];
			$mediumsize1="'".$mediumsize."'";
			$mediumproductid1="'".$mediumproductid."'";
			$mediumpizza1="'".$mediumpizza."'";
	}
			$productname1="'".$productname."'";
			$frieslist.='<div class="col-md-6" style="margin-top:0rem" >
							<div class="panel panel-info">							
								<div class="panel-heading">
									<center><h4 ><b>'.$productname.'</b></h4></center>
								</div>
								<div class="panel-body" style="padding:8px"><center>
									<button class="btn btn-space btn-primary btn-md" onclick="cartadd('.$smallproductid1.','.$productname1.','.$smallpizza1.','.$smallsize1.','. $category1.')">S - <i class="fa fa-inr"></i> '.$smallpizza.'</button>								
									<button class="btn btn-space btn-info btn-md" onclick="cartadd('.$mediumproductid1.','.$productname1.','.$mediumpizza1.','.$mediumsize1.','. $category1.')">M - <i class="fa fa-inr"></i> '.$mediumpizza.'</button>
								</div>
								</div>
							</div>';
		}
	}
	
	$frieslist.='</div></div>';
	echo $frieslist;
	mysqli_close($con);
	}
// Fries List End//

// Nuggets List Start//
	if(isset($_POST['nuggets_list'])){
	$category1="'"."4"."'";    
if($fid=='38'){
	$displayquery = " SELECT * FROM submenu_goa WHERE category_id = 4 AND combo_status='Y'"; 
	}
	else
	{
	$displayquery = " SELECT * FROM submenu_old WHERE category_id = 4 AND combo_status='Y'"; 
	}
	$result = mysqli_query($con,$displayquery);
$nuggetslist='<div class="row"> <div class="col-md-12">';
	if(mysqli_num_rows($result) > 0){
		while ($row = mysqli_fetch_array($result)) {
			$productid=$row['productid'];
			$productname=$row['productname'];
			$price=$row['price'];
			$size1="'".$row['size']."'";
			$productid1="'".$row['productid']."'";
			$productname1="'".$row['productname']."'";
			$price1="'".$row['price']."'";
			$nuggetslist.='<div class="col-md-6" style="margin-top:0.5rem" onclick="cartadd('.$productid1.','.$productname1.','.$price1.','.$size1.','.$category1.')">
							<div class="panel panel-info">							
								<div class="panel-heading">
									<center><h4 ><b>'.$productname.'</b></h4></center>
								</div>
								<div class="panel-body">
									<center><i class="fa fa-inr"></i> '.$price.'</center>
								</div>
								</div>
							</div>';
							
			
		}
	}
	$nuggetslist.='</div></div>';
	echo $nuggetslist;
	mysqli_close($con);
	}
// Nuggets List End//

// Shakes List Start//
	if(isset($_POST['shakes_list'])){
	$category1="'"."6"."'";    
if($fid=='38'){
	$displayquery = " SELECT * FROM submenu_goa WHERE category_id = 6 AND combo_status='Y'"; 
	}
	else
	{
	$displayquery = " SELECT * FROM submenu_old WHERE category_id = 6 AND combo_status='Y'"; 
	}
	$result = mysqli_query($con,$displayquery);
$shakeslist='<div class="row"> <div class="col-md-12">';
	if(mysqli_num_rows($result) > 0){
		while ($row = mysqli_fetch_array($result)) {
			$productid=$row['productid'];
			$productname=$row['productname'];
			$price=$row['price'];
			$size1="'".$row['size']."'";
			$productid1="'".$row['productid']."'";
			$productname1="'".$row['productname']."'";
			$price1="'".$row['price']."'";
			if($gst=='Yes' && $productid=='79'){
			   $price1="'19'";
			}
			/*if($gst=='Yes' && $productid=='78'){
			   $price1="'9.52'";
			}*/
			if($gst=='Yes' && $productid=='141'){
			   $price1="'119'";
			}
			$shakeslist.='<div class="col-md-6" style="margin-top:0.5rem" onclick="cartadd('.$productid1.','.$productname1.','.$price1.','.$size1.','.$category1.')">
							<div class="panel panel-info">							
								<div class="panel-heading">
									<center><h4 ><b>'.$productname.'</b></h4></center>
								</div>
								<div class="panel-body">
									<center><i class="fa fa-inr"></i> '.$price.'</center>
								</div>
								</div>
							</div>';
							
			
		}
	}
	$shakeslist.='</div></div>';
	echo $shakeslist;
	mysqli_close($con);
	}
// Shakes List End//

// coffee List Start//
	if(isset($_POST['coffee_list'])){
	$category1="'"."5"."'";
if($fid=='38'){
	$displayquery = " SELECT * FROM submenu_goa WHERE category_id = 5 AND combo_status='Y'"; 
	}
	else
	{
	$displayquery = " SELECT * FROM submenu_old WHERE category_id = 5 AND combo_status='Y'";
	}
	$result = mysqli_query($con,$displayquery);
    $coffeelist='<div class="row"> <div class="col-md-12">';
	if(mysqli_num_rows($result) > 0){
		while ($row = mysqli_fetch_array($result)) {
			$productid=$row['productid'];
			$productname=$row['productname'];
			$price=$row['price'];
			$size1="'".$row['size']."'";
			$productid1="'".$row['productid']."'";
			$productname1="'".$row['productname']."'";
			$price1="'".$row['price']."'";
			$coffeelist.='<div class="col-md-6" style="margin-top:0.5rem" onclick="cartadd('.$productid1.','.$productname1.','.$price1.','.$size1.','.$category1.')">
							<div class="panel panel-info">							
								<div class="panel-heading">
									<center><h4 ><b>'.$productname.'</b></h4></center>
								</div>
								<div class="panel-body">
									<center><i class="fa fa-inr"></i> '.$price.'</center>
								</div>
								</div>
							</div>';
						
			
		}
	}
	$coffeelist.='</div></div>';
	echo $coffeelist;
	mysqli_close($con);
	}
// COffee List End//


		// Cold Drink List Start//
if(isset($_POST['cold_drink'])){
    $category1="'"."8"."'";
if($fid=='38'){
	$displayquery = " SELECT * FROM submenu_goa WHERE category_id = 8 AND combo_status='Y'"; 
	}
	else
	{
	$displayquery = " SELECT * FROM submenu_old WHERE category_id = 8 AND combo_status='Y'"; 
	}
	$result = mysqli_query($con,$displayquery);
    $cold_drink='<div class="row"> <div class="col-md-12">';
	if(mysqli_num_rows($result) > 0){
		while ($row = mysqli_fetch_array($result)) {
			$productid=$row['productid'];
			$productname=$row['productname'];
			$price=$row['price'];
			$size1="'".$row['size']."'";
			$productid1="'".$row['productid']."'";
			$productname1="'".$row['productname']."'";
			$price1="'".$row['price']."'";
			$cold_drink.='<div class="col-md-6" style="margin-top:0.5rem" onclick="cartadd('.$productid1.','.$productname1.','.$price1.','.$size1.','.$category1.')">
							<div class="panel panel-info">							
								<div class="panel-heading">
									<center><h4 ><b>'.$productname.'</b></h4></center>
								</div>
								<div class="panel-body">
									<center><i class="fa fa-inr"></i> '.$price.'</center>
								</div>
								</div>
							</div>';
						
			
		}
	}
	$cold_drink.='</div></div>';
	echo $cold_drink;
	mysqli_close($con);
	}
		// Cold Drink List Ended//

		// Combo List Start//

	if(isset($_POST['combo_list'])){
	$category1="'"."7"."'";    
if($fid=='38'){
	$displayquery = " SELECT * FROM submenu_goa WHERE category_id = 7 AND combo_status='Y'"; 
	}
	else
	{
	$displayquery = " SELECT * FROM submenu_old WHERE category_id = 7 AND combo_status='Y'";
	}
	$result = mysqli_query($con,$displayquery);
    $combolist='<div class="row"> <div class="col-md-12">';
	if(mysqli_num_rows($result) > 0){
		while ($row = mysqli_fetch_array($result)) {
			$productid=$row['productid'];
			$productname=$row['productname'];
			$price=$row['price'];
			$size1="'".$row['size']."'";
			$productid1="'".$row['productid']."'";
			$productname1="'".$row['productname']."'";
			$price1="'".$row['price']."'";
			$combolist.='<div class="col-md-6" style="margin-top:0.5rem" onclick="cartadd('.$productid1.','.$productname1.','.$price1.','.$size1.','.$category1.')">
							<div class="panel panel-info">							
								<div class="panel-heading">
									<center><h4 ><b>'.$productname.'</b></h4></center>
								</div>
								<div class="panel-body">
									<center><i class="fa fa-inr"></i> '.$price.'</center>
								</div>
								</div>
							</div>';
						
			
		}
	}
	$combolist.='</div></div>';
	echo $combolist;
	mysqli_close($con);
	}
// Combo List End//


if(isset($_POST['mojito'])){
    $category1="'"."9"."'";
if($fid=='38'){
	$displayquery = " SELECT * FROM submenu_goa WHERE category_id = 9 AND combo_status='Y'"; 
	}
	else
	{
	$displayquery = " SELECT * FROM submenu_old WHERE category_id = 9 AND combo_status='Y'"; 
	}
	$result = mysqli_query($con,$displayquery);
    $mojito='<div class="row"> <div class="col-md-12">';
	if(mysqli_num_rows($result) > 0){
		while ($row = mysqli_fetch_array($result)) {
			$productid=$row['productid'];
			$productname=$row['productname'];
			$price=$row['price'];
			$size1="'".$row['size']."'";
			$productid1="'".$row['productid']."'";
			$productname1="'".$row['productname']."'";
			$price1="'".$row['price']."'";
			$mojito.='<div class="col-md-6" style="margin-top:0.5rem" onclick="cartadd('.$productid1.','.$productname1.','.$price1.','.$size1.','.$category1.')">
							<div class="panel panel-info">							
								<div class="panel-heading">
									<center><h4 ><b>'.$productname.'</b></h4></center>
								</div>
								<div class="panel-body">
									<center><i class="fa fa-inr"></i> '.$price.'</center>
								</div>
								</div>
							</div>';
						
			
		}
	}
	$mojito.='</div></div>';
	echo $mojito;
	mysqli_close($con);
	}

if(isset($_POST['water'])){
    $category1="'"."11"."'";
if($fid=='38'){
	$displayquery = " SELECT * FROM submenu_goa WHERE category_id = 11 AND combo_status='Y'"; 
	}
	else
	{
	$displayquery = " SELECT * FROM submenu_old WHERE category_id = 11 AND combo_status='Y'"; 
	}
	$result = mysqli_query($con,$displayquery);
    $mojito='<div class="row"> <div class="col-md-12">';
	if(mysqli_num_rows($result) > 0){
		while ($row = mysqli_fetch_array($result)) {
			$productid=$row['productid'];
			$productname=$row['productname'];
			$price=$row['price'];
			$size1="'".$row['size']."'";
			$productid1="'".$row['productid']."'";
			$productname1="'".$row['productname']."'";
			$price1="'".$row['price']."'";
			$mojito.='<div class="col-md-6" style="margin-top:0.5rem" onclick="cartadd('.$productid1.','.$productname1.','.$price1.','.$size1.','.$category1.')">
							<div class="panel panel-info">							
								<div class="panel-heading">
									<center><h4 ><b>'.$productname.'</b></h4></center>
								</div>
								<div class="panel-body">
									<center><i class="fa fa-inr"></i> '.$price.'</center>
								</div>
								</div>
							</div>';
						
			
		}
	}
	$mojito.='</div></div>';
	echo $mojito;
	mysqli_close($con);
	}



if(isset($_POST['ice_tea_list'])){
    $category1="'"."10"."'";
if($fid=='38'){
	$displayquery = " SELECT * FROM submenu_goa WHERE category_id = 10 AND combo_status='Y'"; 
	}
	else
	{
	$displayquery = " SELECT * FROM submenu_old WHERE category_id = 10 AND combo_status='Y'"; 
	}
	$result = mysqli_query($con,$displayquery);
    $ice_tea='<div class="row"> <div class="col-md-12">';
	if(mysqli_num_rows($result) > 0){
		while ($row = mysqli_fetch_array($result)) {
			$productid=$row['productid'];
			$productname=$row['productname'];
			$price=$row['price'];
			$size1="'".$row['size']."'";
			$productid1="'".$row['productid']."'";
			$productname1="'".$row['productname']."'";
			$price1="'".$row['price']."'";
			$ice_tea.='<div class="col-md-6" style="margin-top:0.5rem" onclick="cartadd('.$productid1.','.$productname1.','.$price1.','.$size1.','.$category1.')">
							<div class="panel panel-info">							
								<div class="panel-heading">
									<center><h4 ><b>'.$productname.'</b></h4></center>
								</div>
								<div class="panel-body">
									<center><i class="fa fa-inr"></i> '.$price.'</center>
								</div>
								</div>
							</div>';
						
			
		}
	}
	$ice_tea.='</div></div>';
	echo $ice_tea;
	mysqli_close($con);
	}


//Functions Started//
function pizzaSmall($productid,$productquantity,$fid,$today,$con){
    $billno1=$_SESSION['printbillno'];
    $f="f".$fid;
    if($productid=='31' ||  $productid =='34'){
        
                $update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='2'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='80'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','2','$productquantity','$today','$billno1')"); 
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material ( fid,productid,quantity,date,billno) VALUES ('$fid','80','$productquantity','$today','$billno1')");
    }
    else if($productid=='1000' ||  $productid =='1000'){
                $update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='2'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','2','$productquantity','$today','$billno1')"); 
    }
    else{
                $update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='1'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='80'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','1','$productquantity','$today','$billno1')"); 
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','80','$productquantity','$today','$billno1')"); 
    }
}
function pizzaMedium($productid,$productquantity,$fid,$today,$con){
    $billno1=$_SESSION['printbillno'];
    $f="f".$fid;    
    if($productid=='32' ||  $productid =='35'){
      
                $update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='4'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='81'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','4','$productquantity','$today','$billno1')"); 
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','81','$productquantity','$today','$billno1')"); 
    }
    else{
                $update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='3'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='81'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','3','$productquantity','$today','$billno1')"); 
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','81','$productquantity','$today','$billno1')"); 
    }
}
function pizzaLarge($productid,$productquantity,$fid,$today,$con){
    $billno1=$_SESSION['printbillno'];
    $f="f".$fid;    
    if($productid=='33' ||  $productid =='36'){
                $update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='6'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='82'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','6','$productquantity','$today','$billno1')"); 
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','82','$productquantity','$today','$billno1')");
    }
    else{
                $update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='5'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='82'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','5','$productquantity','$today','$billno1')"); 
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','82','$productquantity','$today','$billno1')");
    }
}
function burger($productid,$productquantity,$fid,$today,$con){
    $billno1=$_SESSION['printbillno'];
    $f="f".$fid;
    	if($productid=='37')
		{
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='55'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='83'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','55','$productquantity','$today','$billno1'), ('$fid','83','$productquantity','$today','$billno1')");
		}
		else if( $productid=='38')
		{
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='55'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='83'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='8'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','8','$productquantity','$today','$billno1'),('$fid','55','$productquantity','$today','$billno1'),('$fid','83','$productquantity','$today','$billno1')"); 
		}
		else if($productid=='39')
		{
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='53'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='83'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','53','$productquantity','$today','$billno1'),('$fid','83','$productquantity','$today','$billno1')"); 
		}
		else if($productid=='40')
		{
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='53'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='83'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='8'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','8','$productquantity','$today','$billno1'),('$fid','53','$productquantity','$today','$billno1'),('$fid','83','$productquantity','$today','$billno1')"); 				
		}
		else if($productid=='41')
		{
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='54'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='83'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','54','$productquantity','$today','$billno1'),('$fid','83','$productquantity','$today','$billno1')");
		}
	    else if($productid=='42')
		{
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='54'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='83'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='8'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','8','$productquantity','$today','$billno1'),('$fid','54','$productquantity','$today','$billno1'),('$fid','83','$productquantity','$today','$billno1')");
		}
		else if($productid=='43')
		{
			$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='56'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='83'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','56','$productquantity','$today','$billno1'),('$fid','83','$productquantity','$today','$billno1')"); 
		}
		else if($productid=='44')
		{
			$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='56'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='83'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='8'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','8','$productquantity','$today','$billno1'),('$fid','56','$productquantity','$today','$billno1'),('$fid','83','$productquantity','$today','$billno1')"); 				
		}		
		else if($productid=='45')
		{
			$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='57'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='83'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','57','$productquantity','$today','$billno1'),('$fid','83','$productquantity','$today','$billno1')");
		}
		else if($productid=='46')
		{
			$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='57'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='83'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='8'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','8','$productquantity','$today','$billno1'),('$fid','57','$productquantity','$today','$billno1'),('$fid','83','$productquantity','$today','$billno1')");
		}
		else if($productid=='110')
		{
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='54'");
				//$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='83'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','54','$productquantity','$today','$billno1')");
		}
	    else if($productid=='111')
		{
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='54'");
				//$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='83'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='8'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','8','$productquantity','$today','$billno1'),('$fid','54','$productquantity','$today','$billno1')");
		}
}

function shakes($productid,$productquantity,$fid,$today,$con){
    $billno1=$_SESSION['printbillno'];
    $f="f".$fid;
if($productid=='70')
			{ 
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='66'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','66','$productquantity','$today','$billno1')"); 
			}
			else if($productid=='67')
		{
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='64'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','64','$productquantity','$today','$billno1')"); 
		} 
		else if($productid=='78')
		{
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='123'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','123','$productquantity','$today','$billno1')"); 
		} 
		else if($productid=='79')
		{
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='122'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','122','$productquantity','$today','$billno1')"); 
		} 
		else if($productid=='141')
		{
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='20'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','20','$productquantity','$today','$billno1')"); 
		} 
		else if($productid=='68' || $productid=='69' || $productid=='71' || $productid=='105' || $productid=='106')
		{
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='73'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','73','$productquantity','$today','$billno1')"); 
		} 
}

function fries($productid,$productquantity,$fid,$today,$con){
    $billno1=$_SESSION['printbillno'];
    $f="f".$fid;
    if($productid=='47' || $productid=='48' || $productid=='49' || $productid=='50')
			{ 
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='58'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','58','$productquantity','$today','$billno1')"); 
			}
			else if($productid=='51' || $productid=='52')
			{ 
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='59'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','59','$productquantity','$today','$billno1')"); 
			}
			else if($productid=='99' || $productid=='100' || $productid=='101' || $productid=='102')
			{ 
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='105'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','105','$productquantity','$today','$billno1')"); 
			}
			else if($productid=='103' || $productid=='104')
			{ 
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='22'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','22','$productquantity','$today','$billno1')"); 
			}
}
function nuggets($productid,$productquantity,$fid,$today,$con){
    $billno1=$_SESSION['printbillno'];
    $f="f".$fid;
        if($productid=='53')
			{ 
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='62'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','62','$productquantity','$today','$billno1')"); 
			}
			else if($productid=='54')
			{ 
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='63'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','63','$productquantity','$today','$billno1')"); 
			}
			else if($productid=='55')
			{ 
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='61'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','61','$productquantity','$today','$billno1')"); 
			}
			else if($productid=='56')
			{ 
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='60'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','60','$productquantity','$today','$billno1')"); 
			}
}
function tea($productid,$productquantity,$fid,$today,$con){
    $billno1=$_SESSION['printbillno'];
    $f="f".$fid;
        if($productid=='129')
			{ 
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='112'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','112','$productquantity','$today','$billno1')"); 
			}
}
function coffee($productid,$productquantity,$fid,$today,$con){
    $f="f".$fid;
    $billno1=$_SESSION['printbillno'];
    for($coffee_i=1;$coffee_i<=$productquantity;$coffee_i++){
        $coffee_query="SELECT $f FROM f_stock WHERE productid='19'";
        $coffee_result=$con->query($coffee_query);
        $coffee_row=$coffee_result->fetch_assoc();
        $old_coffee_qty=$coffee_row[$f];
        $old_coffee_qty_int=(int)$old_coffee_qty;
        $coffee_decimal=$old_coffee_qty-$old_coffee_qty_int;
        $coffee_decimal = abs($coffee_decimal);
        if($coffee_decimal>0.47 && $coffee_decimal<0.49){
            $productquantity_cut=0.48;
            if($old_coffee_qty>0){
                $old_coffee_qty=round($old_coffee_qty-$productquantity_cut,2);
            }else{
                $old_coffee_qty=round($old_coffee_qty+$productquantity_cut,2);
            }
            
        }else{
            $productquantity_cut=0.44;
            if($old_coffee_qty>0){
                $old_coffee_qty=round($old_coffee_qty-$productquantity_cut,2);
            }else{
                $old_coffee_qty=round($old_coffee_qty+$productquantity_cut,2);
            }
            
        }
        $update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f='$old_coffee_qty' WHERE productid='19'");
    }
    $insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','19','$productquantity','$today','$billno1')");
}
function combo($productid,$productquantity,$fid,$today,$con){
    $billno1=$_SESSION['printbillno'];
    $f="f".$fid;
    if($fid==14)
    {
        	if($productid=='85')
			{ 
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='56'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='83'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','56','$productquantity','$today','$billno1'),('$fid','83','$productquantity','$today','$billno1')");
			}
			else if($productid=='86')
			{ 
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='1'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='80'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='58'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','1','$productquantity','$today','$billno1'),('$fid','80','$productquantity','$today','$billno1'),('$fid','58','$productquantity','$today','$billno1')"); 
			}
			else if($productid=='87')
			{ 
				$productquantity1=$productquantity*2;
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity1 WHERE productid='3'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity1 WHERE productid='81'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='58'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','3','$productquantity1','$today','$billno1'),('$fid','81','$productquantity1','$today','$billno1'),('$fid','58','$productquantity','$today','$billno1')"); 
			}
    }
    else
    {
        	if($productid=='80')
			{ 
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='1'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='80'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='58'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','1','$productquantity','$today','$billno1'),('$fid','80','$productquantity','$today','$billno1'),('$fid','58','$productquantity','$today','$billno1')"); 
			}
			else if($productid=='81')
			{ 
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='56'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='83'");
				//$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='58'");
				//('$fid','58','$productquantity','$today','$billno1'),
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='8'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','56','$productquantity','$today','$billno1'),('$fid','83','$productquantity','$today','$billno1'),('$fid','8','$productquantity','$today','$billno1')"); 
			}
			else if($productid=='85')
			{ 
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='56'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='83'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='56'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='83'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','56','$productquantity','$today','$billno1'),('$fid','83','$productquantity','$today','$billno1'),('$fid','56','$productquantity','$today','$billno1'),('$fid','83','$productquantity','$today','$billno1')"); 
			}
			else if($productid=='86')
			{ 
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='56'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='83'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='56'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='83'");
				
                $insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','56','$productquantity','$today','$billno1'),('$fid','83','$productquantity','$today','$billno1'),('$fid','56','$productquantity','$today','$billno1'),('$fid','83','$productquantity','$today','$billno1')");				
			}
			else if($productid=='87')
			{ 
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='3'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='81'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','3','$productquantity','$today','$billno1')"); 
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','81','$productquantity','$today','$billno1')"); 
			    $update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='3'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='81'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','3','$productquantity','$today','$billno1')"); 
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','81','$productquantity','$today','$billno1')"); 
			    
			}
			else if($productid=='89')
			{ 
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='5'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='82'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','5','$productquantity','$today','$billno1')"); 
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','82','$productquantity','$today','$billno1')");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='5'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='82'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','5','$productquantity','$today','$billno1')"); 
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','82','$productquantity','$today','$billno1')");
			}
			else if($productid=='90')
			{ 
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='5'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='82'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','5','$productquantity','$today','$billno1')"); 
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','82','$productquantity','$today','$billno1')");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='5'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='82'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','5','$productquantity','$today','$billno1')"); 
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','82','$productquantity','$today','$billno1')");
			}
			else if($productid=='91')
			{ 
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='54'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='83'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='8'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','8','$productquantity','$today','$billno1'),('$fid','54','$productquantity','$today','$billno1'),('$fid','83','$productquantity','$today','$billno1')");
                coffee($productid,$productquantity,$fid,$today,$con);
			}
			else if($productid=='92')
			{ 
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='3'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='81'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','3','$productquantity','$today','$billno1')"); 
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','81','$productquantity','$today','$billno1')"); 
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='58'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','58','$productquantity','$today','$billno1')"); 
			    coffee($productid,$productquantity,$fid,$today,$con);
			}
			else if($productid=='93')
			{ 
                $update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='5'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='82'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','5','$productquantity','$today','$billno1')"); 
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','82','$productquantity','$today','$billno1')");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='59'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','59','$productquantity','$today','$billno1')"); 
                coffee($productid,$productquantity,$fid,$today,$con);
			}
			else if($productid=='95')
			{ 
			    $update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='57'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='83'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='8'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','8','$productquantity','$today','$billno1'),('$fid','57','$productquantity','$today','$billno1'),('$fid','83','$productquantity','$today','$billno1')");
                $update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='58'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','58','$productquantity','$today','$billno1')"); 
			    coffee($productid,$productquantity,$fid,$today,$con);
			}
			else if($productid=='96')
			{ 
			    $update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='6'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='82'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','6','$productquantity','$today','$billno1')"); 
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','82','$productquantity','$today','$billno1')");
			    coffee($productid,$productquantity,$fid,$today,$con);
			}
			else if($productid=='97')
			{ 
			    burger('39',$productquantity,$fid,$today,$con);
			    burger('39',$productquantity,$fid,$today,$con);
			}
			else if($productid=='98')
			{ 
			    $update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='3'");
				$update_f_stock=mysqli_query($con,"UPDATE f_stock SET $f=$f-$productquantity WHERE productid='81'");
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','3','$productquantity','$today','$billno1')"); 
				$insert_f_quantity = mysqli_query($con,"INSERT INTO daily_row_material (fid,productid,quantity,date,billno) VALUES ('$fid','81','$productquantity','$today','$billno1')"); 
			    coffee($productid,$productquantity,$fid,$today,$con);
			}
			else if($productid=='107')
			{ 
			    burger('40',$productquantity,$fid,$today,$con);
			}
			else if($productid=='108')
			{ 
			    pizzaSmall('22',$productquantity,$fid,$today,$con);
			    fries('47',$productquantity,$fid,$today,$con);
			}
			else if($productid=='109')
			{ 
			    pizzaLarge('36',$productquantity,$fid,$today,$con);
			    nuggets('53',$productquantity,$fid,$today,$con);
			}
			else if($productid=='112')
			{ 
			    pizzaSmall('31',$productquantity,$fid,$today,$con);
			}
			else if($productid=='113')
			{ 
			    pizzaMedium('32',$productquantity,$fid,$today,$con);
			}
			else if($productid=='114')
			{ 
			    pizzaLarge('33',$productquantity,$fid,$today,$con);
			}
			else if($productid=='115')
			{ 
			    burger('45',$productquantity,$fid,$today,$con);
			}
			else if($productid=='116')
			{ 
			    burger('46',$productquantity,$fid,$today,$con);
			}else if($productid=='117')
			{ 
			    pizzaSmall('31',$productquantity,$fid,$today,$con);
			    pizzaSmall('31',$productquantity,$fid,$today,$con);
			}
			else if($productid=='118')
			{ 
			    pizzaMedium('32',$productquantity,$fid,$today,$con);
			    pizzaMedium('32',$productquantity,$fid,$today,$con);
			}
			else if($productid=='119')
			{ 
			    pizzaLarge('33',$productquantity,$fid,$today,$con);
			    pizzaLarge('33',$productquantity,$fid,$today,$con);
			}
			else if($productid=='120')
			{ 
			    burger('110',$productquantity,$fid,$today,$con);
			}
			else if($productid=='121')
			{ 
			     pizzaSmall('4',$productquantity,$fid,$today,$con);
			}
			else if($productid=='122')
			{ 
			    burger('40',$productquantity,$fid,$today,$con);
			    coffee('60',$productquantity,$fid,$today,$con);
			}
			else if($productid=='123')
			{ 
			    pizzaLarge('36',$productquantity,$fid,$today,$con);
			    fries('47',$productquantity,$fid,$today,$con);
			}
				else if($productid=='124')
			{ 
			    pizzaSmall('25',$productquantity,$fid,$today,$con);
			    fries('47',$productquantity,$fid,$today,$con);
			    coffee('60',$productquantity,$fid,$today,$con);
			}
				else if($productid=='125')
			{ 
			    pizzaSmall('31',$productquantity,$fid,$today,$con);
			    fries('47',$productquantity,$fid,$today,$con);
			    coffee('60',$productquantity,$fid,$today,$con);
			}
				else if($productid=='126')
			{ 
			    pizzaSmall('1000',$productquantity,$fid,$today,$con);
			    pizzaSmall('1000',$productquantity,$fid,$today,$con);
			    pizzaSmall('1000',$productquantity,$fid,$today,$con);
			}
				else if($productid=='127')
			{ 
			    pizzaSmall('1000',$productquantity,$fid,$today,$con);
			    fries('47',$productquantity,$fid,$today,$con);
			    tea('129',$productquantity,$fid,$today,$con);
			}
				else if($productid=='128')
			{ 
			    burger('38',$productquantity,$fid,$today,$con);
			    fries('47',$productquantity,$fid,$today,$con);
			    coffee('60',$productquantity,$fid,$today,$con);
			}
			else if($productid=='130')
			{ 
			    pizzaMedium('32',$productquantity,$fid,$today,$con);
			    fries('47',$productquantity,$fid,$today,$con);
			}
			else if($productid=='131')
			{ 
			    pizzaMedium('32',$productquantity,$fid,$today,$con);
			    fries('99',$productquantity,$fid,$today,$con);
			}
			else if($productid=='132')
			{ 
			    burger('39',$productquantity,$fid,$today,$con);
			    fries('47',$productquantity,$fid,$today,$con);
			}
			else if($productid=='133')
			{ 
			    burger('40',$productquantity,$fid,$today,$con);
			}
			else if($productid=='134')
			{ 
			    burger('38',$productquantity,$fid,$today,$con);
			    coffee('60',$productquantity,$fid,$today,$con);
			}
			else if($productid=='135')
			{ 
			    burger('39',$productquantity,$fid,$today,$con);
			    
			}
			else if($productid=='136')
			{ 
			    pizzaMedium('14',$productquantity,$fid,$today,$con);
			    fries('47',$productquantity,$fid,$today,$con);
			    coffee('60',$productquantity,$fid,$today,$con);
			}
			else if($productid=='137')
			{ 
			    nuggets('53',$productquantity,$fid,$today,$con);
			    coffee('60',$productquantity,$fid,$today,$con);
			}
			else if($productid=='138')
			{ 
			    fries('47',$productquantity,$fid,$today,$con);
			    coffee('60',$productquantity,$fid,$today,$con);
			    burger('45',$productquantity,$fid,$today,$con);
			}
			else if($productid=='139')
			{ 
			    pizzaSmall('28',$productquantity,$fid,$today,$con);
			    fries('47',$productquantity,$fid,$today,$con);
			}
			else if($productid=='140')
			{ 
			    nuggets('55',$productquantity,$fid,$today,$con);
			    tea('129',$productquantity,$fid,$today,$con);
			}
			else if($productid=='142')
			{ 
			   pizzaLarge('36',$productquantity,$fid,$today,$con);
			   coffee('60',$productquantity,$fid,$today,$con);
			   coffee('60',$productquantity,$fid,$today,$con);
			}
			else if($productid=='143')
			{ 
			   pizzaLarge('36',$productquantity,$fid,$today,$con);
			   pizzaSmall('4',$productquantity,$fid,$today,$con);
			}
    }
    
}
		?>
