<?php
session_start();
require_once 'dbconfig.php';
require_once 'db_connection.php';  
date_default_timezone_set('Asia/Colombo');
$today = date('Y-m-d H:i:s');

$user_id = $_SESSION['user_id'];
                    $branch_id = $_SESSION['branch_id'];
                    $total_amount = 0;
                    $total_dis = 0;
                    $servicechargetot = 0;
                    if (isset($_SESSION['order_id']) && $_SESSION['order_id'] != 0) {
                        $orderid = $_SESSION['order_id'];




                        ///	$sql = "SELECT SUM(pro_qty) AS pro_qty , tempid,  pro_dis,pro_price,proid,proname,cover  FROM mobiletemporarycart LEFT JOIN mobileproducts ON mobileproducts.prid=mobiletemporarycart.proid
                        //WHERE mobiletemporarycart.user_id='$user_id' AND mobiletemporarycart.hold=0 AND mobiletemporarycart.orderid=0 GROUP BY  mobiletemporarycart.proid,mobiletemporarycart.pro_dis   ORDER BY mobiletemporarycart.tempid  DESC";
                        $sql = "SELECT
    SUM(mobiletemporarycart.pro_qty) AS pro_qty,
    mobiletemporarycart.tempid,
    mobiletemporarycart.pro_dis,
    mobiletemporarycart.pro_price,
    mobiletemporarycart.proid,
	mobiletemporarycart.pro_name,
    mobileproducts.proname,
	mobileproducts.price,
	mobileproducts.prid,
    mobileproducts.discount1,
    mobileproducts.discount_type1,
    mobileproducts.tax1,
    mobileproducts.tax_type1,
	mobiletemporarycart.pro_discount,
    mobiletemporarycart.tax,
    mobiletemporarycart.tax_type,
    mobileproducts.cover,
	mobiletemporarycart.pro_dis_price,
    mobiletemporarycart.discount_type
FROM
    mobiletemporarycart
LEFT JOIN
    mobileproducts ON mobileproducts.prid = mobiletemporarycart.proid
WHERE
   mobiletemporarycart.user_id='$user_id' AND mobiletemporarycart.branch_id='$branch_id' AND mobiletemporarycart.hold = 0 AND mobiletemporarycart.orderid = '$orderid' OR mobiletemporarycart.orderid = '0'
GROUP BY
    mobiletemporarycart.tempid, mobiletemporarycart.pro_dis, mobiletemporarycart.pro_price, mobiletemporarycart.proid, mobileproducts.proname, mobileproducts.cover, mobileproducts.prid
ORDER BY
    mobiletemporarycart.tempid DESC";
                    } else {

                        $sql = "SELECT
    SUM(mobiletemporarycart.pro_qty) AS pro_qty,
    mobiletemporarycart.tempid,
    mobiletemporarycart.pro_dis,
    mobiletemporarycart.pro_price,
    mobiletemporarycart.proid,
	mobiletemporarycart.pro_name,
    mobileproducts.proname,
	mobileproducts.price,
	mobileproducts.prid,
    mobileproducts.discount1,
    mobileproducts.discount_type1,
    mobileproducts.tax1,
    mobileproducts.tax_type1,
	mobiletemporarycart.pro_discount,
    mobiletemporarycart.tax,
    mobiletemporarycart.tax_type,
	mobiletemporarycart.pro_discount,
    mobileproducts.cover,
	mobiletemporarycart.pro_dis_price,
    mobiletemporarycart.discount_type
FROM
    mobiletemporarycart
LEFT JOIN
    mobileproducts ON mobileproducts.prid = mobiletemporarycart.proid
WHERE
   mobiletemporarycart.user_id='$user_id' AND mobiletemporarycart.branch_id='$branch_id' AND mobiletemporarycart.hold = 0 AND mobiletemporarycart.orderid = 0
GROUP BY
    mobiletemporarycart.tempid, mobiletemporarycart.pro_dis, mobiletemporarycart.pro_price, mobiletemporarycart.proid, mobileproducts.proname, mobileproducts.cover, mobileproducts.prid
ORDER BY
    mobiletemporarycart.tempid DESC";
                    }

                    $result = $conn->query($sql);
                    $td = 0;
                    $total_row = 0;
                    $row = 0;
                    if ($result->num_rows > 0) {
                        $c = 1;
                        $qtyprice = 0;
                        $pro_discount = 0;
                        $pro_qty = 0;
                        $td = 0;
                        $total_dis = 0;
                        $taxx = 0;
                        $taxvaltot = 0;
                        
                        while ($row = $result->fetch_assoc()) {
                            $td = 0;
                            $pro_qty = 0;
                            $tempid = $row["tempid"];
                            $prid = $row["prid"];
                            $proid = $row["proid"];
                            $price = $row["price"];
                            $pro_name = $row["pro_name"];
                            $proname = $row["proname"];
                            $cover = $row["cover"];
                            $pro_dis = $row["pro_dis"];

                            $pro_dis_price = $row['pro_dis_price'];
                           // $discount_type = $row["discount_type"];

                           // $pro_discount = $row["pro_discount"];

                            if($row["pro_discount"]==0){
                                $discount_type = $row["discount_type1"];
                                $pro_discount = $row["discount1"];
                            }else{
                                if($row["pro_discount"]==-1){
                                    $discount_type = 0;
                                    $pro_discount = 0;
                                }else{
                                    $discount_type = $row["discount_type"];
                                    $pro_discount = $row["pro_discount"];
                                }
                                
                            }
                            if($row["tax"]==0){
                                $tax_type = $row["tax_type1"];
                                $tax = $row["tax1"];
                            }else{
                                if($row["tax"]==-1){
                                    $tax_type = 0;
                                    $tax = 0;
                                }else{
                                    $tax_type = $row["tax_type"];
                                    $tax = $row["tax"];
                                }
                                
                            }




                            $pro_price = $row["pro_price"];
                            $pro_qty = $row["pro_qty"];
                            $total_row = $total_row + 1;

                            $ordertypeinfo = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM order_type WHERE order_type_id ='1'"));   
                            $order_type = $ordertypeinfo['order_type'];

                            if($order_type=="Table" || $order_type=="Dine In"){
                                $prodcutinformation = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobileproducts,mobilecategory WHERE mobileproducts.category=mobilecategory.ctid AND mobileproducts.prid='$prid'"));
                                $servicecharge = $prodcutinformation['servicecharge'];
                                $servicestatus = $prodcutinformation['servicestatus'];
                                if($servicestatus==1){
                                    $servicecharge = (($row["pro_price"]*$row["pro_qty"]) /100) *  $servicecharge;
                                    $servicechargetot = $servicechargetot +  $servicecharge;
                                }
                            }
                            //$discounted_price = ($pro_price / 100) * $pro_dis;
                            // $discounted_price = ($pro_price / 100) * $pro_discount;
                            //var_dump($pro_discount);

                            //$product_price = ($pro_price - $discounted_price) * $pro_qty;
                            $productinfo = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobileproducts WHERE prid ='$prid'"));
                            $sellprice = $productinfo['sellprice'];


                            $qtyprice = $pro_price * $pro_qty;
                            if ($discount_type == 1) {


                                if ($sellprice != $pro_price) {
                                    if($proid==148){
                                      /*  $pdis =  ($pro_price / 100) * $pro_discount;
                                        $pd = $pdis * $pro_qty;
                                        $p = ($qtyprice / 100) * $pro_discount; //


                                        $product_price = $qtyprice - $p;
                                        $product_price = $pro_price - $pd;

                                        $product_price = $pro_price-$pdis; */
                                        $pdis =  ($pro_price / 100) * $pro_discount;
                                        $pdis = $pdis *$pro_qty;
                                        $product_price = ($pro_price *$pro_qty) - $pdis;
                                    }else{
                                        $pdis =  ($pro_price / 100) * $pro_discount;
                                        $pd = $pdis;
                                        $p = ($qtyprice / 100) * $pro_discount;


                                        $product_price = $qtyprice - $p;
                                        $product_price = $pro_price - $pd;

                                        //$product_price = $pro_price-$pdis;
                                        $product_price = ($pro_price * $pro_qty)-($pdis*$pro_qty);
                                    }
                                } else {
                                    $pdis =  ($pro_price / 100) * $pro_discount;
                                    $pd = $pdis * $pro_qty;
                                    $p = ($qtyprice / 100) * $pro_discount;


                                    $product_price = $qtyprice - $p;
                                    // $product_price = $pro_price-$pdis;
                                }
                            } else {


                                $products = mysqli_query($conn, "SELECT * FROM mobileproducts WHERE prid ='$prid'");
                                $prinfo = mysqli_fetch_array($products);
                                $productprice = $prinfo['sellprice'];
                                if ($sellprice != $pro_price) {
                                    if($proid==148){
                                        $pd = $pro_discount * $pro_qty;
                                        $product_price =  ($pro_price * $pro_qty) - $pd;
                                    }else{
                                        $pd = $pro_discount * $pro_qty;
                                       // $pd = $pro_discount;
                                        $product_price = ($pro_price * $pro_qty) - $pd;
                                    
                                    }
                                    
                                } else {
                                    $pd = $pro_discount * $pro_qty;
                                    $product_price =  ($pro_price * $pro_qty) - $pd;
                                }

                                // $product_price = $pro_price-$pro_discount;
                            }

                            //if($price != $pro_price){


                            // $product_price = $product_price;
                            // if($row["pro_dis_price"]==0){
                            //$product_price = $product_price;
                            //}else{
                            //	$product_price = $row["pro_dis_price"];
                            //}
                            if ($tax_type == 1) {
                                $taxval1 = ($pro_price/100) * $tax;
                                $taxval1 = $taxval1 * $pro_qty;
                            }else{
                                $taxval1 = $tax * $pro_qty;
                            }
                            $taxvaltot = $taxvaltot + $taxval1;
                            $total_amount = $total_amount + $product_price;
                            if ($discount_type == 1) {
                                if ($sellprice != $pro_price) {
                                    $total_dis = $total_dis + $pdis;
                                    $td =  $total_dis;
                                } else {
                                    $total_dis = $total_dis + ($pdis * $pro_qty);
                                    $td =  $total_dis;
                                }
                            } else {
                                if ($sellprice != $pro_price) {
                                    $total_dis = $total_dis + $pro_discount;
                                    $td =  $total_dis;
                               } else {
                                    $total_dis = $total_dis + ($pro_discount * $pro_qty);
                                    $td =  $total_dis;
                               }
                            }



                            //  $total_dis= $total_dis + ($pro_price-$row["pro_dis_price"]);
                            if ($pro_name == null) {
                                $pname = $proname;
                            } else {
                                $pname = $pro_name;
                            }


                            if ($pro_discount == 0) {
                                $dis = $pro_dis;
                            } else {
                                $dis = $pro_discount;
                            }

                            if ($discount_type == 1) {
                                $dtype = "%";
                            } else {
                                $dtype = "";
                            }

                            $stockinfo = mysqli_query($conn, "SELECT * FROM tbl_stock WHERE prid ='$prid'");
                            $stock = mysqli_fetch_array($stockinfo);

                           $sqty = $stock['qty'];



                           
                        }
                    }
                             


if(isset($_POST['method'])){
  $method = $_POST['method'];
  $ordertypeinfo = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM order_type WHERE order_type_id ='1'"));   
  $ordrtype = $ordertypeinfo['order_type'];
  $content = "";
if($method!=10){

$content .= '<div class="col-12 mt-3">
                    <label style="color:#fff; margin-bottom:3px;">Customer</label>
					<select class="form-control select2 inputele" id="billcustomer" onchange="creditcustomerchange(this.value);">
						<option value="0">Walk-in Customer</option>
						<option value="dc">Delivery Customer</option>';
                        $cus2 = "SELECT * FROM mobilecustomers WHERE status=1";
						$result = $conn->query($cus2);
						if ($result->num_rows > 0) {
							while ($row = $result->fetch_assoc()) {
								$coid = $row["coid"];
								$creditbalance = $row["ccredit"];
								$cname = $row["cname"];
								$cphone = $row["cphone"];
								$content .= '<option value="' . $coid . '">' . $cname . ' | ' . $cphone . ' | Rs.' . $creditbalance . '</option>';
							}
						}
 $content .= '</select></div>';
    
 if($ordrtype=="Table"){
    $content .= '<div class="col-12 mt-3">
                    <label style="color:#fff; margin-bottom:3px;">Tables</label>
					<select class="form-control select2 inputele" id="tables">
						<option value="0">None</option>';
                        $cus2 = "SELECT * FROM mobile_tables WHERE status=1";
						$result = $conn->query($cus2);
						if ($result->num_rows > 0) {
							while ($row = $result->fetch_assoc()) {
								$table_id = $row["table_id"];
								$table_no = $row["table_no"];
								
								$content .= '<option value="' . $table_no . '">' . $table_no . '</option>';
							}
						}
 $content .= '</select></div>
 

 
 ';
 }else{
         $content .= '<input type="hidden" id="tables" value="0">';
 }
 if($ordrtype!="Table" && $ordrtype!="Delivery" && $ordrtype!="None" && $ordrtype!="Dine In" && $ordrtype!="Take Away"){
    $content .= '<div class="col-12 mt-3">
                    <label style="color:#fff; margin-bottom:3px;">Rooms</label>
					<select class="form-control select2 inputele" id="rooms">
						<option value="0">None</option>';
                        $cus2 = "SELECT * FROM mobileproducts WHERE status='1' AND producttype='Room'";
						$result = $conn->query($cus2);
						if ($result->num_rows > 0) {
							while ($row = $result->fetch_assoc()) {
								$prid = $row["prid"];
                                $roomname = $row["proname"];
								 $itemcode = $row["itemcode"];
								
								$content .= '<option value="' . $itemcode . '">'.$itemcode.' / ' . $roomname . '</option>';
							}
						}
 $content .= '</select></div>';
 }else{
    $content .= '<input type="hidden" id="rooms" value="0">';
 }
}
if($method==1){
    
    
            $content .= '<input type="hidden" id="cash_type" value="cash"><input type="hidden" class="form-control" readonly="" id="creditAmountvalue" value="0" placeholder="Credit Amount">
                        <input type="hidden" class="form-control" readonly="" value="0" id="totalAmountvalue" placeholder="Credit Amount Left">
                        <input type="hidden" class="form-control" id="cardno" name="payment_option_number" value="0" placeholder="Card Number">
                        <input type="hidden" class="form-control" id="cheque_date" value="" placeholder="Cheque Date">
                        <input type="hidden" class="form-control" id="cheque_number" value="" placeholder="Cheque Number">
                        <input type="hidden" class="form-control" id="mobile_payment_method" value="0">
                        <input type="hidden" class="form-control" id="gift_number" value="0">
                        <input type="hidden" class="form-control" id="cardpayment" value="0" name="cardpayment" placeholder="Card Payment">
                        ';


}else if($method==2){
    $content .= '<input type="hidden" id="cash_type" value="credit">';


        $content .= '<div class="col-12 mt-2">
        <label style="color:#fff; margin-bottom:3px;">Credit Amount</label>
            <input type="text" class="form-control" readonly="" id="creditAmountvalue" placeholder="Credit Amount">
        </div>
        <div class="col-12 mt-2">
        <label style="color:#fff; margin-bottom:3px;">Credit Amount Left</label>
        <input type="text" class="form-control" readonly="" id="totalAmountvalue" placeholder="Credit Amount Left">
        </div>
        <input type="hidden" class="form-control" id="cardno" name="payment_option_number" value="0" placeholder="Card Number">
                        <input type="hidden" class="form-control" id="cheque_date" value="" placeholder="Cheque Date">
                        <input type="hidden" class="form-control" id="cheque_number" value="" placeholder="Cheque Number">
                        <input type="hidden" class="form-control" id="mobile_payment_method" value="0">
                        <input type="hidden" class="form-control" id="gift_number" value="0">
                        <input type="hidden" class="form-control" id="cardpayment" value="0" name="cardpayment" placeholder="Card Payment">
        
        ';
}else if($method==3){
    $content .= '<input type="hidden" id="cash_type" value="card"><div class="col-12 mt-2">
    <label style="color:#fff; margin-bottom:3px;">Card Number</label>
        <input type="number" class="form-control inputele" id="cardno" name="payment_option_number" placeholder="Card Number">
        <input type="hidden" class="form-control" readonly="" id="creditAmountvalue" value="0" placeholder="Credit Amount">
                        <input type="hidden" class="form-control" readonly="" value="0" id="totalAmountvalue" placeholder="Credit Amount Left">
                        <input type="hidden" class="form-control" id="cardno" name="payment_option_number" value="0" placeholder="Card Number">
                        <input type="hidden" class="form-control" id="cheque_date" value="" placeholder="Cheque Date">
                        <input type="hidden" class="form-control" id="cheque_number" value="" placeholder="Cheque Number">
                        <input type="hidden" class="form-control" id="mobile_payment_method" value="0">
                        <input type="hidden" class="form-control" id="gift_number" value="0">
                        <input type="hidden" class="form-control" id="cardpayment" value="0" name="cardpayment" placeholder="Card Payment">
                        
        </div>
        ';
}else if($method==4){
    $content .= '<input type="hidden" id="cash_type" value="banktransfer"><div class="col-12 mt-2">
    <label style="color:#fff; margin-bottom:3px;">Referece Number</label>
    <input type="number" class="form-control inputele" id="cardno" name="payment_option_number" placeholder="Referece Number">
    </div>
    <input type="hidden" class="form-control" readonly="" id="creditAmountvalue" value="0" placeholder="Credit Amount">
                        <input type="hidden" class="form-control" readonly="" value="0" id="totalAmountvalue" placeholder="Credit Amount Left">
                        <input type="hidden" class="form-control" id="cardno" name="payment_option_number" value="0" placeholder="Card Number">
                        <input type="hidden" class="form-control" id="cheque_date" value="" placeholder="Cheque Date">
                        <input type="hidden" class="form-control" id="cheque_number" value="" placeholder="Cheque Number">
                        <input type="hidden" class="form-control" id="mobile_payment_method" value="0">
                        <input type="hidden" class="form-control" id="gift_number" value="0">
                        <input type="hidden" class="form-control" id="cardpayment" value="0" name="cardpayment" placeholder="Card Payment">
    ';

}else if($method==5){
    $content .= '
    <input type="hidden" id="cash_type" value="cheques"><div class="col-12 mt-2">
    <label style="color:#fff; margin-bottom:3px;">Cheque Date</label>
    <input type="text" class="form-control inputele" id="cheque_date" value="" placeholder="Cheque Date">
    </div>
    <div class="col-12 mt-2">
    <label style="color:#fff; margin-bottom:3px;">Cheque Number</label>
    <input type="text" class="form-control inputele" id="cheque_number" value="" placeholder="Cheque Number">
    </div>               
                        
                        <input type="hidden" class="form-control" readonly="" id="creditAmountvalue" value="0" placeholder="Credit Amount">
                        <input type="hidden" class="form-control" readonly="" value="0" id="totalAmountvalue" placeholder="Credit Amount Left">
                        <input type="hidden" class="form-control" id="cardno" name="payment_option_number" value="0" placeholder="Card Number">
                        <input type="hidden" class="form-control" id="mobile_payment_method" value="0">
                        <input type="hidden" class="form-control" id="gift_number" value="0">
                        <input type="hidden" class="form-control" id="cardpayment" value="0" name="cardpayment" placeholder="Card Payment">
    ';

}else if($method==6){
    $content .= '
    <input type="hidden" id="cash_type" value="mobile"><div class="col-12 mt-2">
    <input type="hidden" class="form-control" id="cheque_date" value="0" placeholder="Cheque Date">
    </div>
    <div class="col-12 mt-3">
    <input type="hidden" class="form-control" id="cheque_number" value="0" placeholder="Cheque Number">
    <label style="color:#fff; margin-bottom:3px;">Payment Method</label>
    <select name="m-pay" id="mobile_payment_method" class="form-control inputele">
        <option value="google">Google Pay</option>
        <option value="apple">Apple Pay</option>
        
    </select>
   
    </div>               
                        
                        <input type="hidden" class="form-control" readonly="" id="creditAmountvalue" value="0" placeholder="Credit Amount">
                        <input type="hidden" class="form-control" readonly="" value="0" id="totalAmountvalue" placeholder="Credit Amount Left">
                        <input type="hidden" class="form-control" id="cardno" name="payment_option_number" value="0" placeholder="Card Number">
                        <input type="hidden" class="form-control" id="gift_number" value="0">
                        <input type="hidden" class="form-control" id="cardpayment" value="0" name="cardpayment" placeholder="Card Payment">
    ';
}else if($method==7){
    $content .= '
    <input type="hidden" id="cash_type" value="gift"><div class="col-12 mt-3">
    <input type="hidden" class="form-control" id="cheque_date" value="0" placeholder="Cheque Date">
    </div>
    <div class="col-12 mt-2">
    <input type="hidden" class="form-control" id="cheque_number" value="0" placeholder="Cheque Number">
    <label style="color:#fff; margin-bottom:3px;">Gift Card Number</label>
    <input type="text" class="form-control inputele" id="gift_number" value="" placeholder="Gift Card Number">
    </div>               
                        
                        <input type="hidden" class="form-control" readonly="" id="creditAmountvalue" value="0" placeholder="Credit Amount">
                        <input type="hidden" class="form-control" readonly="" value="0" id="totalAmountvalue" placeholder="Credit Amount Left">
                        <input type="hidden" class="form-control" id="cardno" name="payment_option_number" value="0" placeholder="Card Number">
                        <input type="hidden" class="form-control" id="mobile_payment_method" value="0">
                        <input type="hidden" class="form-control" id="cardpayment" value="0" name="cardpayment" placeholder="Card Payment">
    ';
}else if($method==8){
    $content .= '
    <input type="hidden" id="cash_type" value="other"><div class="col-12 mt-2">
    <input type="hidden" class="form-control" id="cheque_date" value="0" placeholder="Cheque Date">
    </div>
    <div class="col-12 mt-3">
    <input type="hidden" class="form-control" id="cheque_number" value="0" placeholder="Cheque Number">
    </div>               
                        
                        <input type="hidden" class="form-control" readonly="" id="creditAmountvalue" value="0" placeholder="Credit Amount">
                        <input type="hidden" class="form-control" readonly="" value="0" id="totalAmountvalue" placeholder="Credit Amount Left">
                        <input type="hidden" class="form-control" id="cardno" name="payment_option_number" value="0" placeholder="Card Number">
                        <input type="hidden" class="form-control" id="mobile_payment_method" value="0">
                        <input type="hidden" class="form-control" id="gift_number" value="0">
                        <input type="hidden" class="form-control" id="cardpayment" value="0" name="cardpayment" placeholder="Card Payment">
    ';
}else if($method==9){
     
    $content .= ' 
    <input type="hidden" id="cash_type" value="cash_and_card">
    <input type="hidden" class="form-control" id="cheque_date" value="0" placeholder="Cheque Date">
     <input type="hidden" class="form-control" id="cheque_number" value="0" placeholder="Cheque Number">
        
                       <input type="hidden" class="form-control" readonly="" id="creditAmountvalue" value="0" placeholder="Credit Amount">
                       <input type="hidden" class="form-control" readonly="" value="0" id="totalAmountvalue" placeholder="Credit Amount Left">
                      
                       <input type="hidden" class="form-control" id="mobile_payment_method" value="0">
                       <input type="hidden" class="form-control" id="gift_number" value="0">

    <div class="col-12 mt-2"><label style="color:#fff; margin-bottom:3px;">Card Number</label>
                   <input type="number" class="form-control inputele" id="cardno" name="cardno" placeholder="Card Number">
                </div>
                <div class="col-12 mt-2"><label style="color:#fff; margin-bottom:3px;">Card Payment</label>
                   <input type="number" class="form-control inputele" id="cardpayment" name="cardpayment" placeholder="Card Payment" value="0" onkeyup="getCash();">
                </div>
                
                ';
}
$dis2 = 0;
$alldis = 0;
$t2 = $total_amount;
$dis = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM all_discount_tbl WHERE all_discount_tbl_id ='1' AND status='1'")); 
if($dis['discount_type']==0){ 
   // $alldis =  $t2-$dis['discount_val'];
    $dis2 =  $dis['discount_val'];
}else{
    $disval = $dis['discount_val'];
    
    $dis2 =  ($t2/100)*$disval;
    
    //$alldis = $t2-$dis2;
}

$taxx = 0;
$tax = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM tax WHERE tax_id ='1' AND status='1'")); 
$taxval = 0;
$taxvaltot = 0;
$tott = $total_amount;
if($tax['tax_type']==0){
    $taxx =  $tax['tax'];
 //$tott = $tott + $tax['tax'];
}else{
// echo $tax['tax']."%";
 $taxx = ($tott /100) * $tax['tax'];
 //$tott = $tott + $tval;
}

$tot3 = $total_amount;
$tot3  = $tot3 - $dis2;
$tot3 = $tot3 + $taxx;
$tot3 = $tot3 + $taxvaltot;
$tot3 = $tot3 + $servicechargetot;

$content .= '
 <div class="col-12 mt-2">
        <label style="color:#fff; margin-bottom:3px;">Date</label>
        <input type="datetime-local" class="form-control" id="billdate" placeholder="Select Bill Date" value="'.$today.'">
        </div>

<div class="col-12 mt-2">
<label style="color:#fff; margin-bottom:3px;">Cash</label>
<input type="text" class="form-control inputele" id="cashamount"  onkeyup="getCash(); creditcustomerchange();" placeholder="Cash Amount" value="'.$tot3.'">

</div>
<div class="col-12 mt-2">
<input type="hidden" class="form-control" id="cashamounthidden"  placeholder="Cash Amount" value="'.$tot3.'">
<input type="hidden" class="form-control" id="servicechargetot" value="'.$servicechargetot.'">
<label style="color:#fff; margin-bottom:3px;">Balance</label>
<input type="text" class="form-control" id="balance"  placeholder="Balance" value="0" readonly>

</div>
<input type="hidden" class="form-control" readonly="" id="billcustomer" value="0" placeholder="billcustomer">
<input type="hidden" class="form-control" readonly="" id="creditAmountvalue" value="0" placeholder="Credit Amount">
<input type="hidden" class="form-control" readonly="" value="0" id="totalAmountvalue" placeholder="Credit Amount Left">
<input type="hidden" class="form-control" id="cardno" name="payment_option_number" value="0" placeholder="Card Number">
';


?>
<!--<div class="col-12"> <div class="row mt-3 g-1">
<div class="col-3">
    <div class="number inputele" tabindex="0" onclick="clickpad(1)">1</div>
</div>
<div class="col-3">
    <div class="number inputele" tabindex="0" onclick="clickpad(2)">2</div>
</div>
<div class="col-3">
    <div class="number inputele" tabindex="0" onclick="clickpad(3)">3</div>
</div>
<div class="col-3">
    <div class="number inputele" tabindex="0" onclick="clickpad(-1)"><i class="bi bi-backspace"></i></div>
</div>
<div class="col-3">
    <div class="number inputele" tabindex="0" onclick="clickpad(4)">4</div>
</div>
<div class="col-3">
    <div class="number inputele" tabindex="0" onclick="clickpad(5)">5</div>
</div>
<div class="col-3">
    <div class="number inputele" tabindex="0" onclick="clickpad(6)">6</div>
</div>
<div class="col-3">
    <div class="number">:</div>
</div>
<div class="col-3">
    <div class="number inputele" tabindex="0" onclick="clickpad(7)">7</div>
</div>
<div class="col-3">
    <div class="number inputele" tabindex="0" onclick="clickpad(8)">8</div>
</div>
<div class="col-3">
    <div class="number inputele" tabindex="0" onclick="clickpad(9)">9</div>
</div>
<div class="col-3">
    <div class="number inputele" tabindex="0" onclick="clickpad(.)">.</div>
</div>
<div class="col-3">
    <div class="number">*</div>
</div>
<div class="col-3">
    <div class="number inputele" tabindex="0" onclick="clickpad(0)">0</div>
</div>
<div class="col-3">
    <div class="number">#</div>
</div>
<div class="col-3">
    <div class="number inputele" tabindex="0" onclick="clickpad(-2)">C</div>
</div>
<div class="col-3">
    <div class="number inputele" tabindex="0" onclick="clickpad(10)">10</div>
</div>
<div class="col-3">
    <div class="number inputele" tabindex="0" onclick="clickpad(20)">20</div>
</div>
<div class="col-3">
    <div class="number inputele" tabindex="0" onclick="clickpad(30)">30</div>
</div>
<div class="col-3">
    <div class="number inputele" tabindex="0" onclick="clickpad(40)">40</div>
</div>
</div></div>
-->

<?php

echo $content;






}





?>