<?php
session_start();
include 'load.php';
require_once 'db_connection.php';
$branch_id = $_SESSION['branch_id'];
?>

<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0">
	<meta name="description" content="POS - Payroll | Pos & Invetory System | Dashboard">
	<meta name="keywords" content="Payroll | Pos & Invetory System | Dashboard">
	<meta name="author" content="Payroll | Pos & Invetory System | Dashboard">
	<meta name="robots" content="noindex, nofollow">

	<title>Seller Wise Sales Report | Payroll | Pos & Invetory System | Dashboard</title>

	<?php
	require_once 'headercss.php';
	?>
	
</head>

<body>

	<div id="global-loader">
		<div class="whirly-loader"> </div>
	</div>

	<div class="main-wrapper">

		<?php
		require_once 'header.php';
		?>

		<?php
		require_once 'navbar.php';
		?>

		<div class="page-wrapper">
			<div class="content">
				<div class="page-header">
					<div class="page-title">
						<h4>Daily Summery Report</h4>
						<h6>Manage your Sales</h6>
					</div>
				</div>

				<div class="card">
					<div class="card-body">
						<div class="table-top">
						
						</div>

						<div class="card mb-0">
							<div class="card-body pb-0">
								<div class="row">
									<div class="col-lg-12 col-sm-12">
										<form method="POST" enctype="multipart/form-data">
											<div class="row">
												<div class="col-lg-3 col-sm-3 col-12">
													<div class="form-group">
														<label for="start-date">Start Date:</label>
														<input type="date" id="start-date" name="start_date" value="<?php echo $_POST['start_date']; ?>"
															class="form-control">
													</div>
												</div>
												<div class="col-lg-3 col-sm-3 col-12">
													<div class="form-group">
														<label for="end-date">End Date:</label>
														<input type="date" id="end-date" name="end_date" value="<?php echo $_POST['end_date']; ?>"
															class="form-control">
													</div>
												</div>
                                                <div class="col-lg-4 col-sm-4 col-12">
													<div class="form-group">

														<label for="start-date">Users</label>

														<select class="form-control select2" name="users" required> 

														<option selected disabled>Select Users</option>
														
														<option value="0">All</option>

														<?php 

														$sql = "SELECT * FROM mobileusers where status='1'";

														$result = $conn->query($sql);

														if ($result->num_rows > 0) {

														while($row = $result->fetch_assoc()) { 
                                                            if($_POST['users']==$row['user_id']){
                                                            ?>

														<option value="<?php echo $row['user_id']; ?>" selected><?php echo $row['fullname']; ?></option>

														<?php }else{ ?>
                                                            <option value="<?php echo $row['user_id']; ?>"><?php echo $row['fullname']; ?></option>
                                                       <?php } }

														}

														?>

														</select>
													</div>
												 </div>
												 <div class="col-lg-2 col-sm-2 col-12" style="margin-top: 30px;">
													<div class="form-group">
														<button type="submit" name="search" class="btn btn-primary btn-block" style="width:100%;"><i class="fa fa-search" style="font-size:18px;color:#ffffff"></i> Search</button>
													</div>
												 </div>
											</div>
										</form>
									</div>
								</div>
							</div>
						</div>

						<div class="table-responsive">
							<table class="table">
								<thead>
									<tr>
										<th>Shop Name</th>
                                        <th>Invoice No</th>
										<th>Watalappan</th>
                                        <th>R T N</th>
                                       
                                        <th>Free</th>
                                        <th>Sample</th>
										<th>Milk Pudding</th>
                                        <th>R T N</th>
                                        
                                        <th>Free</th>
                                        <th>Sample</th>
                                        <th>Jelly Custard</th>
                                        <th>R T N</th>
                                        
                                        <th>Free</th>
                                        <th>Sample</th>
                                        <th>Fuluda Pudding</th>
                                        <th>R T N</th>
                                      
                                        <th>Free</th>
                                        <th>Sample</th>
                                        <th>Strawberry Jelly</th>
                                        <th>R T N</th>
                                        
                                        <th>Free</th>
                                        <th>Sample</th>
                                        <th>Milk Fruit Jelly</th>
                                        <th>R T N</th>
                                       
                                        <th>Free</th>
                                        <th>Sample</th>
                                        <th>Apple Jelly</th>
                                        <th>R T N</th>
                                        
                                        <th>Free</th>
                                        <th>Sample</th>

                                        <th>CASH SALE</th>
                                        <th>CREDIT SALE</th>
                                        <th>TOTAL SALE</th>
										
									</tr>
								</thead>
								<tbody>
									<?php
                                   
									if (isset($_POST['search'])) {
                                        $tsaale = 0;
                                        $watalapantot = 0;
                                        $watalapanreturntot = 0;
                                        $milkpuddingtot = 0;
                                        $wmilkpuddingreturntot = 0;
                                        $jelycusterdtot = 0;
                                        $jelycusterdreturntot = 0;
                                        $faludatot = 0;
                                        $faludareturntot = 0;
                                        $stoberrytot = 0;
                                        $stoberryreturntot = 0;
                                        $milktot = 0;
                                        $milkreturntot = 0;
                                        $appletot = 0;
                                        $applereturntot = 0;
                                        $wmilkpuddingreturn = 0;
                                        $cashsaletot = 0;
                                        $creditsaletot = 0;
    
                                        $watalapanmarketreturntot = 0;
                                        $watalapfreeitemtot = 0;
                                        $watalapsampletot = 0;
                                        
                                        $milkpuddingnmarketreturntot = 0;
                                        $milkpuddingfreeitemtot = 0;
                                        $milkpuddingsampletot = 0;
    
                                        $jelycusterdnmarketreturntot = 0;
                                        $jelycusterdfreeitemtot = 0;
                                        $jelycusterdsampletot = 0;
    
                                        $faludanmarketreturntot= 0;
                                        $faludanfreeitemtot= 0;
                                        $faludasampletot= 0;
    
    
                                        $stoberrymarketreturntot= 0;
                                         $stoberryfreeitemtot = 0;
                                        $stoberrysampletot= 0;
    
                                        $milkarketreturntot = 0;
                                        $milkfreeitemtot = 0;
                                         $milksampletot = 0;
    
                                         $applearketreturntot = 0;
                                         $applefreeitemtot = 0;
                                         $applesampletot = 0;

                                        $start_date = $_POST['start_date'];
                                        $end_date = $_POST['end_date'];
										
                                        $users = $_POST['users'];
										
										if ($branch_id == '1') {

                                        if(!empty($start_date) && !empty($end_date)){
                                            if($start_date==$end_date){
                                                $searchdate = "AND DATE(create_at) = '$start_date'";
                                            }else{
                                                $searchdate = "AND create_at BETWEEN '$start_date' AND '$end_date'";
                                            }
                                        }else{
                                            $searchdate = "";
                                        } 

                                        if(!empty($users)){
                                          
                                               if($users==0){
                                                $searchuser = "";
                                               }else{
                                                $searchuser = "AND  user_id = '$users'";
                                               }
                                                
                                           
                                        }else{
                                            $searchuser = "";
                                        }

                                        $mobileorders = mysqli_query($conn, "SELECT * FROM mobileorders WHERE order_id != '0' $searchdate $searchuser");
										
										} else {
											
										if(!empty($start_date) && !empty($end_date)){
                                            if($start_date==$end_date){
                                                $searchdate = "AND DATE(create_at) = '$start_date'";
                                            }else{
                                                $searchdate = "AND create_at BETWEEN '$start_date' AND '$end_date'";
                                            }
                                        }else{
                                            $searchdate = "";
                                        } 

                                        if(!empty($users)){
                                          
                                               if($users==0){
                                                $searchuser = "";
                                               }else{
                                                $searchuser = "AND  user_id = '$users'";
                                               }
                                                
                                           
                                        }else{
                                            $searchuser = "";
                                        }

											
										$mobileorders = mysqli_query($conn, "SELECT * FROM mobileorders WHERE branch_id='$branch_id' AND order_id != '0' $searchdate $searchuser");
										
										}
										
                                        if ($mobileorders->num_rows > 0) {
                                            $tsaale = 0;
                                            while($row = $mobileorders->fetch_assoc()) { 
                                                $creditsale = 0;
                                                 $cashsale = 0;
                                                $customer = $row['customer']; 
                                                if($customer==0){
                                                    $cus = "Walk-in Customer";
                                                }else if($customer=="dc"){
                                                    $cus = "Delivery Customer";
                                                }else{
                                                    $customersinfo = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobilecustomers WHERE coid  ='$customer'"));
                                                    $cus = $customersinfo['cname'];
                                                }
                                                
                                               $pay_option =  $row['pay_option'];
                                                ?>
                                            <tr>
                                                <td><?php echo $cus; ?></td>
                                                <td><?php echo $row['orid']; ?></td>
                                                 <td>
                                                <?php $order_id = $row['order_id'];
                                                     $watalapan = mysqli_fetch_array(mysqli_query($conn, "SELECT SUM(pro_price*pro_qty) as sale,pro_qty FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='155' AND market_return='0' AND freeitem='0' AND sample='0'"));
                                                     echo empty($watalapan['pro_qty']) ? '0' : $watalapan['pro_qty'];
                                                    if($pay_option=="Cash"){
                                                        $cashsale = $cashsale + $watalapan['sale'];
                                                    }else if($pay_option=="Credit"){
                                                        $creditsale = $creditsale + $watalapan['sale'];
                                                    }
                                                    $watalapantot = $watalapantot + $watalapan['pro_qty'];
                                                    $watalapanmarketreturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='155' AND market_return='1'"));
                                                    $watalapfreeitem = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='155' AND freeitem='1'"));
                                                    $watalapsample = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='155' AND sample='1'"));
                                                    $watalapanmarketreturntot = $watalapanmarketreturntot + $watalapanmarketreturn['pro_qty'];
                                                    $watalapfreeitemtot = $watalapfreeitemtot + $watalapfreeitem['pro_qty'];
                                                    $watalapsampletot = $watalapsampletot + $watalapsample['pro_qty'];
                                                ?>
                                                </td>
                                               
                                                <td>
                                                    <?php 
                                                         $watalapanreturn = mysqli_fetch_array(mysqli_query($conn, "SELECT SUM(qty) as qty FROM tbl_return_items WHERE order_id ='$order_id' AND prid='155'"));
                                                         
                                                        // echo empty($watalapanreturn['qty']) ? '0' : $watalapanreturn['qty'];
                                                         echo empty($watalapanmarketreturn['pro_qty']) ? '0' : $watalapanmarketreturn['pro_qty'];
                                                         $watalapanreturntot =  $watalapanreturntot + $watalapanmarketreturn['pro_qty']; 
                                                         

                                                         
                                                    ?>
                                                </td>
                                               
                                                <td><?php echo empty($watalapfreeitem['pro_qty']) ? '0' : $watalapfreeitem['pro_qty']; ?></td>
                                                <td><?php echo empty($watalapsample['pro_qty']) ? '0' : $watalapsample['pro_qty']; ?></td>
                                                <td>
                                                <?php $order_id = $row['order_id'];
                                                     $milkpudding = mysqli_fetch_array(mysqli_query($conn, "SELECT SUM(pro_price*pro_qty) as sale,pro_qty FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='149' AND market_return='0' AND freeitem='0' AND sample='0'"));
                                                     echo empty($milkpudding['pro_qty']) ? '0' : $milkpudding['pro_qty'];
                                                    if($pay_option=="Cash"){
                                                        $cashsale = $cashsale + $milkpudding['sale'];
                                                    }else if($pay_option=="Credit"){
                                                        $creditsale = $creditsale + $milkpudding['sale'];
                                                    }
                                                    $milkpuddingtot = $milkpuddingtot + $milkpudding['pro_qty'];

                                                    $milkpuddingmarketreturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='149' AND market_return='1'"));
                                                    $milkpuddingfreeitem = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='149' AND freeitem='1'"));
                                                    $milkpuddingsample = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='149' AND sample='1'"));

                                                    $milkpuddingnmarketreturntot  = $milkpuddingnmarketreturntot  + $milkpuddingmarketreturn['pro_qty'];
                                                    $milkpuddingfreeitemtot = $milkpuddingfreeitemtot + $milkpuddingfreeitem['pro_qty'];
                                                    $milkpuddingsampletot = $milkpuddingsampletot + $milkpuddingsample['pro_qty'];
                                                ?>
                                                </td>
                                                <td>
                                                    <?php 
                                                         $wmilkpuddingreturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM tbl_return_items WHERE order_id ='$order_id' AND prid='149'"));
                                                         
                                                       //  echo empty($wmilkpuddingreturn['qty']) ? '0' : $wmilkpuddingreturn['qty'];
                                                        echo empty($milkpuddingmarketreturn['pro_qty']) ? '0' : $milkpuddingmarketreturn['pro_qty'];
                                                         $wmilkpuddingreturntot = $wmilkpuddingreturntot + $milkpuddingmarketreturn['pro_qty'];
                                                    ?>
                                                </td>
                                               
                                                <td><?php echo empty($milkpuddingfreeitem['pro_qty']) ? '0' : $milkpuddingfreeitem['pro_qty']; ?></td>
                                                <td><?php echo empty($milkpuddingsample['pro_qty']) ? '0' : $milkpuddingsample['pro_qty']; ?></td>


                                                <td>
                                                <?php $order_id = $row['order_id'];
                                                     $jelycusterd = mysqli_fetch_array(mysqli_query($conn, "SELECT SUM(pro_price*pro_qty) as sale,pro_qty FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='151' AND market_return='0' AND freeitem='0' AND sample='0'"));
                                                     echo empty($jelycusterd['pro_qty']) ? '0' : $jelycusterd['pro_qty'];
                                                    if($pay_option=="Cash"){
                                                        $cashsale = $cashsale + $jelycusterd['sale'];
                                                    }else if($pay_option=="Credit"){
                                                        $creditsale = $creditsale + $jelycusterd['sale'];
                                                    }
                                                    $jelycusterdtot = $jelycusterdtot + $jelycusterd['pro_qty'];

                                                    $jelycusterdgmarketreturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='151' AND market_return='1'"));
                                                    $jelycusterdfreeitem = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='151' AND freeitem='1'"));
                                                    $jelycusterdsample = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='151' AND sample='1'"));

                                                    $jelycusterdnmarketreturntot  = $jelycusterdnmarketreturntot  + $jelycusterdgmarketreturn['pro_qty'];
                                                    $jelycusterdfreeitemtot  = $jelycusterdfreeitemtot  + $jelycusterdfreeitem['pro_qty'];
                                                    $jelycusterdsampletot = $jelycusterdsampletot + $jelycusterdsample['pro_qty'];
                                                ?>
                                                </td>
                                                <td>
                                                    <?php 
                                                         $jelycusterdreturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM tbl_return_items WHERE order_id ='$order_id' AND prid='151'"));
                                                         
                                                         //echo empty($jelycusterdreturn['qty']) ? '0' : $jelycusterdreturn['qty'];
                                                         echo empty($jelycusterdgmarketreturn['pro_qty']) ? '0' : $jelycusterdgmarketreturn['pro_qty'];
                                                         $jelycusterdreturntot = $jelycusterdreturntot + $jelycusterdgmarketreturn['pro_qty'];
                                                    ?>
                                                </td>
                                               
                                                <td><?php echo empty($jelycusterdfreeitem['pro_qty']) ? '0' : $jelycusterdfreeitem['pro_qty']; ?></td>
                                                <td><?php echo empty($jelycusterdsample['pro_qty']) ? '0' : $jelycusterdsample['pro_qty']; ?></td>
                                                <td>
                                                <?php $order_id = $row['order_id'];
                                                     $faluda = mysqli_fetch_array(mysqli_query($conn, "SELECT SUM(pro_price*pro_qty) as sale,pro_qty FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='150' AND market_return='0' AND freeitem='0' AND sample='0'"));
                                                     echo empty($faluda['pro_qty']) ? '0' : $faluda['pro_qty'];
                                                    if($pay_option=="Cash"){
                                                        $cashsale = $cashsale + $faluda['sale'];
                                                    }else if($pay_option=="Credit"){
                                                        $creditsale = $creditsale + $faluda['sale'];
                                                    }
                                                    $faludatot = $faludatot + $faluda['pro_qty'];

                                                    $faludamarketreturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='150' AND market_return='1'"));
                                                    $faludafreeitem = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='150' AND freeitem='1'"));
                                                    $faludasample = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='150' AND sample='1'"));

                                                    $faludanmarketreturntot  = $faludanmarketreturntot  + $faludamarketreturn['pro_qty'];
                                                    $faludanfreeitemtot  = $faludanfreeitemtot  + $faludafreeitem['pro_qty'];
                                                    $faludasampletot = $faludasampletot + $faludasample['pro_qty'];
                                                ?>
                                                </td>
                                                <td>
                                                    <?php 
                                                         $faludareturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM tbl_return_items WHERE order_id ='$order_id' AND prid='150'"));
                                                         
                                                         //echo empty($faludareturn['qty']) ? '0' : $faludareturn['qty'];
                                                         echo empty($faludamarketreturn['pro_qty']) ? '0' : $faludamarketreturn['pro_qty'];
                                                         $faludareturntot = $faludareturntot + $faludamarketreturn['pro_qty'];
                                                    ?>
                                                </td>
                                                
                                                <td><?php echo empty($faludafreeitem['pro_qty']) ? '0' : $faludafreeitem['pro_qty']; ?></td>
                                                <td><?php echo empty($faludasample['pro_qty']) ? '0' : $faludasample['pro_qty']; ?></td>
                                                <td>
                                                <?php $order_id = $row['order_id'];
                                                     $stoberry = mysqli_fetch_array(mysqli_query($conn, "SELECT SUM(pro_price*pro_qty) as sale,pro_qty FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='154' AND market_return='0' AND freeitem='0' AND sample='0'"));
                                                     echo empty($stoberry['pro_qty']) ? '0' : $stoberry['pro_qty'];
                                                    if($pay_option=="Cash"){
                                                        $cashsale = $cashsale + $stoberry['sale'];
                                                    }else if($pay_option=="Credit"){
                                                        $creditsale = $creditsale + $stoberry['sale'];
                                                    }
                                                    $stoberrytot = $stoberrytot + $stoberry['pro_qty'];

                                                    $stoberryarketreturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='154' AND market_return='1'"));
                                                    $stoberryfreeitem = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='154' AND freeitem='1'"));
                                                    $stoberrysample = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='154' AND sample='1'"));

                                                    $stoberrymarketreturntot  = $stoberrymarketreturntot  + $stoberryarketreturn['pro_qty'];
                                                    $stoberryfreeitemtot  = $stoberryfreeitemtot  + $stoberryfreeitem['pro_qty'];
                                                    $stoberrysampletot = $stoberrysampletot + $stoberrysample['pro_qty'];
                                                ?>
                                                </td>
                                                <td>
                                                    <?php 
                                                         $stoberryreturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM tbl_return_items WHERE order_id ='$order_id' AND prid='154'"));
                                                         
                                                         //echo empty($stoberryreturn['qty']) ? '0' : $stoberryreturn['qty'];
                                                          echo empty($stoberryarketreturn['pro_qty']) ? '0' : $stoberryarketreturn['pro_qty'];
                                                         $stoberryreturntot = $stoberryreturntot + $stoberryarketreturn['pro_qty'];
                                                    ?>
                                                </td>
                                                
                                                <td><?php echo empty($stoberryfreeitem['pro_qty']) ? '0' : $stoberryfreeitem['pro_qty']; ?></td>
                                                <td><?php echo empty($stoberrysample['pro_qty']) ? '0' : $stoberrysample['pro_qty']; ?></td>
                                                <td>
                                                <?php $order_id = $row['order_id'];
                                                     $milk = mysqli_fetch_array(mysqli_query($conn, "SELECT SUM(pro_price*pro_qty) as sale,pro_qty FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='153' AND market_return='0' AND freeitem='0' AND sample='0'"));
                                                     echo empty($milk['pro_qty']) ? '0' : $milk['pro_qty'];
                                                    if($pay_option=="Cash"){
                                                        $cashsale = $cashsale + $milk['sale'];
                                                    }else if($pay_option=="Credit"){
                                                        $creditsale = $creditsale + $milk['sale'];
                                                    }
                                                    $milktot = $milktot + $milk['pro_qty'];

                                                    $milkarketreturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='153' AND market_return='1'"));
                                                    $milkfreeitem = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='153' AND freeitem='1'"));
                                                    $milksample = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='153' AND sample='1'"));

                                                    $milkarketreturntot  = $milkarketreturntot  + $milkarketreturn['pro_qty'];      
                                                    $milkfreeitemtot  = $milkfreeitemtot  + $milkfreeitem['pro_qty'];
                                                    $milksampletot = $milksampletot + $milksample['pro_qty'];
                                                ?>
                                                </td>
                                                <td>
                                                    <?php 
                                                         $milkreturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM tbl_return_items WHERE order_id ='$order_id' AND prid='153'"));
                                                          echo empty($milkarketreturn['pro_qty']) ? '0' : $milkarketreturn['pro_qty'];
                                                         //echo empty($milkreturn['qty']) ? '0' : $milkreturn['qty'];
                                                         $milkreturntot = $milkreturntot + $milkarketreturn['pro_qty'];
                                                    ?>
                                                </td>
                                               
                                                <td><?php echo empty($milkfreeitem['pro_qty']) ? '0' : $milkfreeitem['pro_qty']; ?></td>
                                                <td><?php echo empty($milksample['pro_qty']) ? '0' : $milksample['pro_qty']; ?></td>
                                                <td>
                                                <?php $order_id = $row['order_id'];
                                                     $apple = mysqli_fetch_array(mysqli_query($conn, "SELECT SUM(pro_price*pro_qty) as sale,pro_qty FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='152' AND market_return='0' AND freeitem='0' AND sample='0'"));
                                                     echo empty($apple['pro_qty']) ? '0' : $apple['pro_qty'];
                                                    if($pay_option=="Cash"){
                                                        $cashsale = $cashsale + $apple['sale'];
                                                    }else if($pay_option=="Credit"){
                                                        $creditsale = $creditsale + $apple['sale'];
                                                    }
                                                    $appletot = $appletot + $apple['pro_qty'];

                                                    $applearketreturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='152' AND market_return='1'"));
                                                    $applefreeitem = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='152' AND freeitem='1'"));
                                                    $applesample = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='152' AND sample='1'"));


                                                    $applearketreturntot  = $applearketreturntot  + $applearketreturn['pro_qty'];      
                                                    $applefreeitemtot  = $applefreeitemtot  + $applefreeitem['pro_qty'];
                                                    $applesampletot = $applesampletot + $applesample['pro_qty'];
                                                ?>
                                                </td>
                                                <td>
                                                    <?php 
                                                         $applereturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM tbl_return_items WHERE order_id ='$order_id' AND prid='152'"));
                                                         
                                                         //echo empty($applereturn['qty']) ? '0' : $applereturn['qty'];
                                                         echo empty($applearketreturn['pro_qty']) ? '0' : $applearketreturn['pro_qty'];
                                                         $applereturntot =  $applereturntot + $applearketreturn['pro_qty'];
                                                    ?> 
                                                </td>
                                                
                                                <td><?php echo empty($applefreeitem['pro_qty']) ? '0' : $applefreeitem['pro_qty']; ?></td>
                                                <td><?php echo empty($applesample['pro_qty']) ? '0' : $applesample['pro_qty']; ?></td>
                                                <td>
                                                    <?php echo $cashsale; ?>
                                                </td>
                                                <td>
                                                    <?php echo $creditsale; ?>
                                                </td>
                                                <td>
                                                    <?php echo $creditsale + $cashsale; 
                                                    $tsaale = $tsaale + ($creditsale + $cashsale);
                                                    $cashsaletot = $cashsaletot + $cashsale;
                                                    $creditsaletot = $creditsaletot + $creditsale;
                                                    ?>
                                                </td>
                                            </tr>
                                  <?php  }
                                }  
                            
                                        
								 }else{
									 
                                    $tsaale = 0;
                                    $watalapantot = 0;
                                    $watalapanreturntot = 0;
                                    $milkpuddingtot = 0;
                                    $wmilkpuddingreturntot = 0;
                                    $jelycusterdtot = 0;
                                    $jelycusterdreturntot = 0;
                                    $faludatot = 0;
                                    $faludareturntot = 0;
                                    $stoberrytot = 0;
                                    $stoberryreturntot = 0;
                                    $milktot = 0;
                                    $milkreturntot = 0;
                                    $appletot = 0;
                                    $applereturntot = 0;
                                    $wmilkpuddingreturn = 0;
                                    $cashsaletot = 0;
                                    $creditsaletot = 0;

                                    $watalapanmarketreturntot = 0;
                                    $watalapfreeitemtot = 0;
                                    $watalapsampletot = 0;
                                    
                                    $milkpuddingnmarketreturntot = 0;
                                    $milkpuddingfreeitemtot = 0;
                                    $milkpuddingsampletot = 0;

                                    $jelycusterdnmarketreturntot = 0;
                                    $jelycusterdfreeitemtot = 0;
                                    $jelycusterdsampletot = 0;

                                    $faludanmarketreturntot= 0;
                                    $faludanfreeitemtot= 0;
                                    $faludasampletot= 0;


                                    $stoberrymarketreturntot= 0;
                                     $stoberryfreeitemtot = 0;
                                    $stoberrysampletot= 0;

                                    $milkarketreturntot = 0;
                                    $milkfreeitemtot = 0;
                                     $milksampletot = 0;

                                     $applearketreturntot = 0;
                                     $applefreeitemtot = 0;
                                     $applesampletot = 0;
									 
									 if ($branch_id == '1') {

                                        $mobileorders = mysqli_query($conn, "SELECT * FROM mobileorders");
									
									} else {

										$mobileorders = mysqli_query($conn, "SELECT * FROM mobileorders WHERE branch_id='$branch_id'");
										
									}
										
                                        if ($mobileorders->num_rows > 0) {
                                            $tsaale = 0;
                                            while($row = $mobileorders->fetch_assoc()) { 
                                                $creditsale = 0;
                                                 $cashsale = 0;
                                                 $customer = $row['customer']; 
                                                if($customer==0){
                                                    $cus = "Walk-in Customer";
                                                }else if($customer=="dc"){
                                                    $cus = "Delivery Customer";
                                                }else{
                                                    $customersinfo = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobilecustomers WHERE coid  ='$customer'"));
                                                    $cus = $customersinfo['cname'];
                                                }
                                               $pay_option =  $row['pay_option'];
                                                ?>
                                            <tr>
                                                <td><?php echo $cus; ?></td>
                                                <td><?php echo $row['orid']; ?></td>
                                                <td>
                                                <?php $order_id = $row['order_id'];
                                                     $watalapan = mysqli_fetch_array(mysqli_query($conn, "SELECT SUM(pro_price*pro_qty) as sale,pro_qty FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='155' AND market_return='0' AND freeitem='0' AND sample='0'"));
                                                     echo empty($watalapan['pro_qty']) ? '0' : $watalapan['pro_qty'];
                                                    if($pay_option=="Cash"){
                                                        $cashsale = $cashsale + $watalapan['sale'];
                                                    }else if($pay_option=="Credit"){
                                                        $creditsale = $creditsale + $watalapan['sale'];
                                                    }
                                                    $watalapantot = $watalapantot + $watalapan['pro_qty'];
                                                    $watalapanmarketreturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='155' AND market_return='1'"));
                                                    $watalapfreeitem = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='155' AND freeitem='1'"));
                                                    $watalapsample = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='155' AND sample='1'"));
                                                    $watalapanmarketreturntot = $watalapanmarketreturntot + $watalapanmarketreturn['pro_qty'];
                                                    $watalapfreeitemtot = $watalapfreeitemtot + $watalapfreeitem['pro_qty'];
                                                    $watalapsampletot = $watalapsampletot + $watalapsample['pro_qty'];
                                                ?>
                                                </td>
                                               
                                                <td>
                                                    <?php 
                                                         $watalapanreturn = mysqli_fetch_array(mysqli_query($conn, "SELECT SUM(qty) as qty FROM tbl_return_items WHERE order_id ='$order_id' AND prid='155'"));
                                                         
                                                         //echo empty($watalapanreturn['qty']) ? '0' : $watalapanreturn['qty'];
                                                         echo empty($watalapanmarketreturn['pro_qty']) ? '0' : $watalapanmarketreturn['pro_qty'];
                                                         $watalapanreturntot =  $watalapanreturntot + $watalapanmarketreturn['pro_qty']; 
                                                         

                                                         
                                                    ?>
                                                </td>
                                                
                                                <td><?php echo empty($watalapfreeitem['pro_qty']) ? '0' : $watalapfreeitem['pro_qty']; ?></td>
                                                <td><?php echo empty($watalapsample['pro_qty']) ? '0' : $watalapsample['pro_qty']; ?></td>
                                                <td>
                                                <?php $order_id = $row['order_id'];
                                                     $milkpudding = mysqli_fetch_array(mysqli_query($conn, "SELECT SUM(pro_price*pro_qty) as sale,pro_qty FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='149' AND market_return='0' AND freeitem='0' AND sample='0'"));
                                                     echo empty($milkpudding['pro_qty']) ? '0' : $milkpudding['pro_qty'];
                                                    if($pay_option=="Cash"){
                                                        $cashsale = $cashsale + $milkpudding['sale'];
                                                    }else if($pay_option=="Credit"){
                                                        $creditsale = $creditsale + $milkpudding['sale'];
                                                    }
                                                    $milkpuddingtot = $milkpuddingtot + $milkpudding['pro_qty'];

                                                    $milkpuddingmarketreturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='149' AND market_return='1'"));
                                                    $milkpuddingfreeitem = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='149' AND freeitem='1'"));
                                                    $milkpuddingsample = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='149' AND sample='1'"));

                                                    $milkpuddingnmarketreturntot  = $milkpuddingnmarketreturntot  + $milkpuddingmarketreturn['pro_qty'];
                                                    $milkpuddingfreeitemtot = $milkpuddingfreeitemtot + $milkpuddingfreeitem['pro_qty'];
                                                    $milkpuddingsampletot = $milkpuddingsampletot + $milkpuddingsample['pro_qty'];
                                                ?>
                                                </td>
                                                <td>
                                                    <?php 
                                                         $wmilkpuddingreturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM tbl_return_items WHERE order_id ='$order_id' AND prid='149'"));
                                                         
                                                        // echo empty($wmilkpuddingreturn['qty']) ? '0' : $wmilkpuddingreturn['qty'];
                                                          echo empty($milkpuddingmarketreturn['pro_qty']) ? '0' : $milkpuddingmarketreturn['pro_qty'];
                                                         $wmilkpuddingreturntot = $wmilkpuddingreturntot + $milkpuddingmarketreturn['pro_qty'];
                                                    ?>
                                                </td>
                                                
                                                <td><?php echo empty($milkpuddingfreeitem['pro_qty']) ? '0' : $milkpuddingfreeitem['pro_qty']; ?></td>
                                                <td><?php echo empty($milkpuddingsample['pro_qty']) ? '0' : $milkpuddingsample['pro_qty']; ?></td>


                                                <td>
                                                <?php $order_id = $row['order_id'];
                                                     $jelycusterd = mysqli_fetch_array(mysqli_query($conn, "SELECT SUM(pro_price*pro_qty) as sale,pro_qty FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='151' AND market_return='0' AND freeitem='0' AND sample='0'"));
                                                     echo empty($jelycusterd['pro_qty']) ? '0' : $jelycusterd['pro_qty'];
                                                    if($pay_option=="Cash"){
                                                        $cashsale = $cashsale + $jelycusterd['sale'];
                                                    }else if($pay_option=="Credit"){
                                                        $creditsale = $creditsale + $jelycusterd['sale'];
                                                    }
                                                    $jelycusterdtot = $jelycusterdtot + $jelycusterd['pro_qty'];

                                                    $jelycusterdgmarketreturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='151' AND market_return='1'"));
                                                    $jelycusterdfreeitem = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='151' AND freeitem='1'"));
                                                    $jelycusterdsample = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='151' AND sample='1'"));

                                                    $jelycusterdnmarketreturntot  = $jelycusterdnmarketreturntot  + $jelycusterdgmarketreturn['pro_qty'];
                                                    $jelycusterdfreeitemtot  = $jelycusterdfreeitemtot  + $jelycusterdfreeitem['pro_qty'];
                                                    $jelycusterdsampletot = $jelycusterdsampletot + $jelycusterdsample['pro_qty'];
                                                ?>
                                                </td>
                                                <td>
                                                    <?php 
                                                         $jelycusterdreturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM tbl_return_items WHERE order_id ='$order_id' AND prid='151'"));
                                                         
                                                        // echo empty($jelycusterdreturn['qty']) ? '0' : $jelycusterdreturn['qty'];
                                                        echo empty($jelycusterdgmarketreturn['pro_qty']) ? '0' : $jelycusterdgmarketreturn['pro_qty'];
                                                         $jelycusterdreturntot = $jelycusterdreturntot + $jelycusterdgmarketreturn['pro_qty'];
                                                    ?>
                                                </td>
                                                
                                                <td><?php echo empty($jelycusterdfreeitem['pro_qty']) ? '0' : $jelycusterdfreeitem['pro_qty']; ?></td>
                                                <td><?php echo empty($jelycusterdsample['pro_qty']) ? '0' : $jelycusterdsample['pro_qty']; ?></td>
                                                <td>
                                                <?php $order_id = $row['order_id'];
                                                     $faluda = mysqli_fetch_array(mysqli_query($conn, "SELECT SUM(pro_price*pro_qty) as sale,pro_qty FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='150' AND market_return='0' AND freeitem='0' AND sample='0'"));
                                                     echo empty($faluda['pro_qty']) ? '0' : $faluda['pro_qty'];
                                                    if($pay_option=="Cash"){
                                                        $cashsale = $cashsale + $faluda['sale'];
                                                    }else if($pay_option=="Credit"){
                                                        $creditsale = $creditsale + $faluda['sale'];
                                                    }
                                                    $faludatot = $faludatot + $faluda['pro_qty'];

                                                    $faludamarketreturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='150' AND market_return='1'"));
                                                    $faludafreeitem = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='150' AND freeitem='1'"));
                                                    $faludasample = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='150' AND sample='1'"));

                                                    $faludanmarketreturntot  = $faludanmarketreturntot  + $faludamarketreturn['pro_qty'];
                                                    $faludanfreeitemtot  = $faludanfreeitemtot  + $faludafreeitem['pro_qty'];
                                                    $faludasampletot = $faludasampletot + $faludasample['pro_qty'];
                                                ?>
                                                </td>
                                                <td>
                                                    <?php 
                                                         $faludareturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM tbl_return_items WHERE order_id ='$order_id' AND prid='150'"));
                                                         
                                                        // echo empty($faludareturn['qty']) ? '0' : $faludareturn['qty'];
                                                        echo empty($faludamarketreturn['pro_qty']) ? '0' : $faludamarketreturn['pro_qty'];
                                                         $faludareturntot = $faludareturntot + $faludamarketreturn['pro_qty'];
                                                    ?>
                                                </td>
                                               
                                                <td><?php echo empty($faludafreeitem['pro_qty']) ? '0' : $faludafreeitem['pro_qty']; ?></td>
                                                <td><?php echo empty($faludasample['pro_qty']) ? '0' : $faludasample['pro_qty']; ?></td>
                                                <td>
                                                <?php $order_id = $row['order_id'];
                                                     $stoberry = mysqli_fetch_array(mysqli_query($conn, "SELECT SUM(pro_price*pro_qty) as sale,pro_qty FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='154' AND market_return='0' AND freeitem='0' AND sample='0'"));
                                                     echo empty($stoberry['pro_qty']) ? '0' : $stoberry['pro_qty'];
                                                    if($pay_option=="Cash"){
                                                        $cashsale = $cashsale + $stoberry['sale'];
                                                    }else if($pay_option=="Credit"){
                                                        $creditsale = $creditsale + $stoberry['sale'];
                                                    }
                                                    $stoberrytot = $stoberrytot + $stoberry['pro_qty'];

                                                    $stoberryarketreturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='154' AND market_return='1'"));
                                                    $stoberryfreeitem = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='154' AND freeitem='1'"));
                                                    $stoberrysample = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='154' AND sample='1'"));

                                                    $stoberrymarketreturntot  = $stoberrymarketreturntot  + $stoberryarketreturn['pro_qty'];
                                                    $stoberryfreeitemtot  = $stoberryfreeitemtot  + $stoberryfreeitem['pro_qty'];
                                                    $stoberrysampletot = $stoberrysampletot + $stoberrysample['pro_qty'];
                                                ?>
                                                </td>
                                                <td>
                                                    <?php 
                                                         $stoberryreturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM tbl_return_items WHERE order_id ='$order_id' AND prid='154'"));
                                                         
                                                        // echo empty($stoberryreturn['qty']) ? '0' : $stoberryreturn['qty'];
                                                        echo empty($stoberryarketreturn['pro_qty']) ? '0' : $stoberryarketreturn['pro_qty'];
                                                         $stoberryreturntot = $stoberryreturntot + $stoberryarketreturn['pro_qty'];
                                                    ?>
                                                </td>
                                                
                                                <td><?php echo empty($stoberryfreeitem['pro_qty']) ? '0' : $stoberryfreeitem['pro_qty']; ?></td>
                                                <td><?php echo empty($stoberrysample['pro_qty']) ? '0' : $stoberrysample['pro_qty']; ?></td>
                                                <td>
                                                <?php $order_id = $row['order_id'];
                                                     $milk = mysqli_fetch_array(mysqli_query($conn, "SELECT SUM(pro_price*pro_qty) as sale,pro_qty FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='153' AND market_return='0' AND freeitem='0' AND sample='0'"));
                                                     echo empty($milk['pro_qty']) ? '0' : $milk['pro_qty'];
                                                    if($pay_option=="Cash"){
                                                        $cashsale = $cashsale + $milk['sale'];
                                                    }else if($pay_option=="Credit"){
                                                        $creditsale = $creditsale + $milk['sale'];
                                                    }
                                                    $milktot = $milktot + $milk['pro_qty'];

                                                    $milkarketreturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='153' AND market_return='1'"));
                                                    $milkfreeitem = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='153' AND freeitem='1'"));
                                                    $milksample = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='153' AND sample='1'"));

                                                    $milkarketreturntot  = $milkarketreturntot  + $milkarketreturn['pro_qty'];      
                                                    $milkfreeitemtot  = $milkfreeitemtot  + $milkfreeitem['pro_qty'];
                                                    $milksampletot = $milksampletot + $milksample['pro_qty'];
                                                ?>
                                                </td>
                                                <td>
                                                    <?php 
                                                         $milkreturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM tbl_return_items WHERE order_id ='$order_id' AND prid='153'"));
                                                         echo empty($milkarketreturn['pro_qty']) ? '0' : $milkarketreturn['pro_qty'];
                                                         //echo empty($milkreturn['qty']) ? '0' : $milkreturn['qty'];
                                                         $milkreturntot = $milkreturntot + $milkarketreturn['pro_qty'];
                                                    ?>
                                                </td>
                                               
                                                <td><?php echo empty($milkfreeitem['pro_qty']) ? '0' : $milkfreeitem['pro_qty']; ?></td>
                                                <td><?php echo empty($milksample['pro_qty']) ? '0' : $milksample['pro_qty']; ?></td>
                                                <td>
                                                <?php $order_id = $row['order_id'];
                                                     $apple = mysqli_fetch_array(mysqli_query($conn, "SELECT SUM(pro_price*pro_qty) as sale,pro_qty FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='152' AND market_return='0' AND freeitem='0' AND sample='0'"));
                                                     echo empty($apple['pro_qty']) ? '0' : $apple['pro_qty'];
                                                    if($pay_option=="Cash"){
                                                        $cashsale = $cashsale + $apple['sale'];
                                                    }else if($pay_option=="Credit"){
                                                        $creditsale = $creditsale + $apple['sale'];
                                                    }
                                                    $appletot = $appletot + $apple['pro_qty'];

                                                    $applearketreturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='152' AND market_return='1'"));
                                                    $applefreeitem = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='152' AND freeitem='1'"));
                                                    $applesample = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='152' AND sample='1'"));


                                                    $applearketreturntot  = $applearketreturntot  + $applearketreturn['pro_qty'];      
                                                    $applefreeitemtot  = $applefreeitemtot  + $applefreeitem['pro_qty'];
                                                    $applesampletot = $applesampletot + $applesample['pro_qty'];
                                                ?>
                                                </td>
                                                <td>
                                                    <?php 
                                                         $applereturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM tbl_return_items WHERE order_id ='$order_id' AND prid='152'"));
                                                         
                                                         //echo empty($applereturn['qty']) ? '0' : $applereturn['qty'];
                                                         echo empty($applearketreturn['pro_qty']) ? '0' : $applearketreturn['pro_qty'];
                                                         $applereturntot =  $applereturntot + $applearketreturn['pro_qty'];
                                                    ?> 
                                                </td>
                                               
                                                <td><?php echo empty($applefreeitem['pro_qty']) ? '0' : $applefreeitem['pro_qty']; ?></td>
                                                <td><?php echo empty($applesample['pro_qty']) ? '0' : $applesample['pro_qty']; ?></td>
                                                <td>
                                                    <?php echo $cashsale; ?>
                                                </td>
                                                <td>
                                                    <?php echo $creditsale; ?>
                                                </td>
                                                <td>
                                                    <?php echo $creditsale + $cashsale; 
                                                    $tsaale = $tsaale + ($creditsale + $cashsale);
                                                    $cashsaletot = $cashsaletot + $cashsale;
                                                    $creditsaletot = $creditsaletot + $creditsale;
                                                    ?>
                                                </td>
                                            </tr>
                                  <?php  }
                                }  
                            }
									?>
                                    
								</tbody>
                                <tfoot>
                                <tr>
                                <td colspan="2">Total</td> 
                                <td><?php echo $watalapantot; ?></td>
                                <td><?php echo $watalapanreturntot; ?></td>
                               
                                <td><?php echo $watalapfreeitemtot; ?></td>
                                <td><?php echo $watalapsampletot; ?></td>
                                <td><?php echo $milkpuddingtot; ?></td>
                                <td><?php echo $wmilkpuddingreturntot; ?></td>
                               
                                <td><?php echo $milkpuddingfreeitemtot; ?></td>
                                <td><?php echo $milkpuddingsampletot; ?></td>
                                <td><?php echo $jelycusterdtot; ?></td>     
                                <td><?php echo $jelycusterdreturntot; ?></td>
                              
                                <td><?php echo $jelycusterdfreeitemtot; ?></td>
                                <td><?php echo $jelycusterdsampletot; ?></td>
                                <td><?php echo $faludatot; ?></td>
                                <td><?php echo $faludareturntot; ?></td> 
                               
                                <td><?php echo $faludanfreeitemtot; ?></td>
                                <td><?php echo $faludasampletot; ?></td>
                                <td><?php echo $stoberrytot; ?></td>
                                <td><?php echo $stoberryreturntot; ?></td>
                               
                                <td><?php echo $stoberryfreeitemtot; ?></td>
                                <td><?php echo $stoberrysampletot; ?></td>
                                <td><?php echo $milktot; ?></td>
                                <td><?php echo $milkreturntot; ?></td>
                               
                                <td><?php echo $milkfreeitemtot; ?></td>
                                <td><?php echo $milksampletot; ?></td>
                                <td><?php echo $appletot; ?></td>
                                <td><?php echo $applereturntot; ?></td>
                                
                                <td><?php echo $applefreeitemtot; ?></td>
                                <td><?php echo $applesampletot; ?></td>

                                <td><?php echo $cashsaletot; ?></td>
                                <td><?php echo $creditsaletot; ?></td>
                                <td><?php echo $tsaale; ?></td>
                                </tr>
                            </tfoot>
							</table>
							<div id="printableArea" style="display:none;">
								<table class="table">
									<thead>
                                        <th>Shop Name</th>
                                        <th>Invoice No</th>
										<th>Watalappan</th>
                                        <th>R T N</th>
										<th>Milk Pudding</th>
                                        <th>R T N</th>
                                        <th>Jelly Custard</th>
                                        <th>R T N</th>
                                        <th>Fuluda Pudding</th>
                                        <th>R T N</th>
                                        <th>Strawberry Jelly</th>
                                        <th>R T N</th>
                                        <th>Mix Fruit Jelly</th>
                                        <th>R T N</th>
                                        <th>Apple Jelly</th>
                                        <th>R T N</th>
                                        <th>CASH SALE</th>
                                        <th>CREDIT SALE</th>
                                        <th>TOTAL SALE</th>
									</thead>
                                    <tbody>
									<?php
                                   
									if (isset($_POST['search'])) {
                                        $watalapantot = 0;
                                        $watalapanreturntot = 0;
                                        $milkpuddingtot = 0;
                                        $wmilkpuddingreturntot = 0;
                                        $jelycusterdtot = 0;
                                        $jelycusterdreturntot = 0;
                                        $faludatot = 0;
                                        $faludareturntot = 0;
                                        $stoberrytot = 0;
                                        $stoberryreturntot = 0;
                                        $milktot = 0;
                                        $milkreturntot = 0;
                                        $appletot = 0;
                                        $applereturntot = 0;
                                        $wmilkpuddingreturn = 0;
                                        $cashsaletot = 0;
                                        $creditsaletot = 0;
										$tsaale = 0;
                                        $start_date = $_POST['start_date'];
                                        $end_date = $_POST['end_date'];
										
                                        $users = $_POST['users'];
                                        
                                        if(!empty($start_date) && !empty($end_date)){
                                            if($start_date==$end_date){
                                                $searchdate = "AND DATE(create_at) = '$start_date'";
                                            }else{
                                                $searchdate = "AND create_at BETWEEN '$start_date' AND '$end_date'";
                                            }
                                        }else{
                                            $searchdate = "";
                                        } 

                                        if(!empty($users)){
                                          
                                               if($users==0){
                                                $searchuser = "";
                                               }else{
                                                $searchuser = "AND  customer = '$users'";
                                               }
                                                
                                           
                                        }else{
                                            $searchuser = "";
                                        } 
                                        
                                        $mobileorders = mysqli_query($conn, "SELECT * FROM mobileorders WHERE order_id != '0' $searchdate $searchuser");
                                        if ($mobileorders->num_rows > 0) {
                                            $tsaale = 0;
                                            while($row = $mobileorders->fetch_assoc()) { 
                                                $creditsale = 0;
                                                 $cashsale = 0;
                                                 $customer = $row['customer']; 
                                                if($customer==0){
                                                    $cus = "Walk-in Customer";
                                                }else if($customer=="dc"){
                                                    $cus = "Delivery Customer";
                                                }else{
                                                    $customersinfo = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobilecustomers WHERE coid  ='$customer'"));
                                                    $cus = $customersinfo['cname'];
                                                }
                                               $pay_option =  $row['pay_option'];
                                                ?>
                                            <tr>
                                                <td><?php echo $cus; ?></td>
                                                <td><?php echo $row['orid']; ?></td>
                                                <td>
                                                <?php $order_id = $row['order_id'];
                                                     $watalapan = mysqli_fetch_array(mysqli_query($conn, "SELECT SUM(pro_price*pro_qty) as sale,pro_qty FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='155'"));
                                                     echo empty($watalapan['pro_qty']) ? '0' : $watalapan['pro_qty'];
                                                    if($pay_option=="Cash"){
                                                        $cashsale = $cashsale + $watalapan['sale'];
                                                    }else if($pay_option=="Credit"){
                                                        $creditsale = $creditsale + $watalapan['sale'];
                                                    }
                                                    $watalapantot = $watalapantot + $watalapan['pro_qty'];
                                                ?>
                                                </td>
                                                <td>
                                                    <?php 
                                                         $watalapanreturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM tbl_return_items WHERE order_id ='$order_id' AND prid='155'"));
                                                         
                                                         echo empty($watalapanreturn['qty']) ? '0' : $watalapanreturn['qty'];
                                                         $watalapanreturntot =  $watalapanreturntot + $watalapanreturn['qty'];
                                                    ?>
                                                </td>
                                                <td>
                                                <?php $order_id = $row['order_id'];
                                                     $milkpudding = mysqli_fetch_array(mysqli_query($conn, "SELECT SUM(pro_price*pro_qty) as sale,pro_qty FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='149'"));
                                                     echo empty($milkpudding['pro_qty']) ? '0' : $milkpudding['pro_qty'];
                                                    if($pay_option=="Cash"){
                                                        $cashsale = $cashsale + $milkpudding['sale'];
                                                    }else if($pay_option=="Credit"){
                                                        $creditsale = $creditsale + $milkpudding['sale'];
                                                    }
                                                    $milkpuddingtot = $milkpuddingtot + $milkpudding['pro_qty'];
                                                ?>
                                                </td>
                                                <td>
                                                    <?php 
                                                         $wmilkpuddingreturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM tbl_return_items WHERE order_id ='$order_id' AND prid='149'"));
                                                         
                                                         echo empty($wmilkpuddingreturn['qty']) ? '0' : $wmilkpuddingreturn['qty'];
                                                         $wmilkpuddingreturntot =  $wmilkpuddingreturntot + $wmilkpuddingreturn['qty'];
                                                    ?>
                                                </td>
                                                <td>
                                                <?php $order_id = $row['order_id'];
                                                     $jelycusterd = mysqli_fetch_array(mysqli_query($conn, "SELECT SUM(pro_price*pro_qty) as sale,pro_qty FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='151'"));
                                                     echo empty($jelycusterd['pro_qty']) ? '0' : $jelycusterd['pro_qty'];
                                                    if($pay_option=="Cash"){
                                                        $cashsale = $cashsale + $jelycusterd['sale'];
                                                    }else if($pay_option=="Credit"){
                                                        $creditsale = $creditsale + $jelycusterd['sale'];
                                                    }
                                                    $jelycusterdtot = $jelycusterdtot + $jelycusterd['pro_qty'];
                                                ?>
                                                </td>
                                                <td>
                                                    <?php 
                                                         $jelycusterdreturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM tbl_return_items WHERE order_id ='$order_id' AND prid='151'"));
                                                         
                                                         echo empty($jelycusterdreturn['qty']) ? '0' : $jelycusterdreturn['qty'];
                                                         $jelycusterdreturntot = $jelycusterdreturntot + $jelycusterdreturn['qty']; 
                                                    ?>
                                                </td>
                                                <td>
                                                <?php $order_id = $row['order_id'];
                                                     $faluda = mysqli_fetch_array(mysqli_query($conn, "SELECT SUM(pro_price*pro_qty) as sale,pro_qty FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='150'"));
                                                     echo empty($faluda['pro_qty']) ? '0' : $faluda['pro_qty'];
                                                    if($pay_option=="Cash"){
                                                        $cashsale = $cashsale + $faluda['sale'];
                                                    }else if($pay_option=="Credit"){
                                                        $creditsale = $creditsale + $faluda['sale'];
                                                    }
                                                    $faludatot = $faludatot + $faluda['pro_qty'];
                                                ?>
                                                </td>
                                                <td>
                                                    <?php 
                                                         $faludareturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM tbl_return_items WHERE order_id ='$order_id' AND prid='150'"));
                                                         
                                                         echo empty($faludareturn['qty']) ? '0' : $faludareturn['qty'];
                                                         $faludareturntot = $faludareturntot + $faludareturn['qty'];
                                                    ?>
                                                </td>
                                                <td>
                                                <?php $order_id = $row['order_id'];
                                                     $stoberry = mysqli_fetch_array(mysqli_query($conn, "SELECT SUM(pro_price*pro_qty) as sale,pro_qty FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='154'"));
                                                     echo empty($stoberry['pro_qty']) ? '0' : $stoberry['pro_qty'];
                                                    if($pay_option=="Cash"){
                                                        $cashsale = $cashsale + $stoberry['sale'];
                                                    }else if($pay_option=="Credit"){
                                                        $creditsale = $creditsale + $stoberry['sale'];
                                                    }
                                                    $stoberrytot = $stoberrytot + $stoberry['pro_qty'];
                                                ?>
                                                </td>
                                                <td>
                                                    <?php 
                                                         $stoberryreturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM tbl_return_items WHERE order_id ='$order_id' AND prid='154'"));
                                                         
                                                         echo empty($stoberryreturn['qty']) ? '0' : $stoberryreturn['qty'];
                                                         $stoberryreturntot = $stoberryreturntot + $stoberryreturn['qty'];
                                                    ?>
                                                </td>
                                                <td>
                                                <?php $order_id = $row['order_id'];
                                                     $milk = mysqli_fetch_array(mysqli_query($conn, "SELECT SUM(pro_price*pro_qty) as sale,pro_qty FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='153'"));
                                                     echo empty($milk['pro_qty']) ? '0' : $milk['pro_qty'];
                                                    if($pay_option=="Cash"){
                                                        $cashsale = $cashsale + $milk['sale'];
                                                    }else if($pay_option=="Credit"){
                                                        $creditsale = $creditsale + $milk['sale'];
                                                    }
                                                    $milktot = $milktot + $milk['pro_qty'];
                                                ?>
                                                </td>
                                                <td>
                                                    <?php 
                                                         $milkreturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM tbl_return_items WHERE order_id ='$order_id' AND prid='153'"));
                                                         
                                                         echo empty($milkreturn['qty']) ? '0' : $milkreturn['qty'];
                                                         $milkreturntot = $milkreturntot + $milkreturn['qty'];
                                                    ?>
                                                </td>
                                                <td>
                                                <?php $order_id = $row['order_id'];
                                                     $apple = mysqli_fetch_array(mysqli_query($conn, "SELECT SUM(pro_price*pro_qty) as sale,pro_qty FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='152'"));
                                                     echo empty($apple['pro_qty']) ? '0' : $apple['pro_qty'];
                                                    if($pay_option=="Cash"){
                                                        $cashsale = $cashsale + $apple['sale'];
                                                    }else if($pay_option=="Credit"){
                                                        $creditsale = $creditsale + $apple['sale'];
                                                    }
                                                    $appletot = $appletot + $apple['pro_qty'];
                                                ?>
                                                </td>
                                                <td>
                                                    <?php 
                                                         $applereturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM tbl_return_items WHERE order_id ='$order_id' AND prid='152'"));
                                                         
                                                         echo empty($applereturn['qty']) ? '0' : $applereturn['qty'];
                                                         $applereturntot =  $applereturntot + $applereturn['qty'];
                                                    ?>
                                                </td>
                                                <td>
                                                    <?php echo $cashsale; ?>
                                                </td>
                                                <td>
                                                    <?php echo $creditsale; ?>
                                                </td>
                                                <td>
                                                    <?php echo $creditsale + $cashsale; 
                                                    $tsaale = $tsaale + ($creditsale + $cashsale);
                                                    $cashsaletot = $cashsaletot + $cashsale;
                                                    $creditsaletot = $creditsaletot + $creditsale;
                                                    ?>
                                                </td>
                                            </tr>
                                  <?php  }
                                }  
                            
                                        
								 }else{
                                    $watalapantot = 0;
                                    $watalapanreturntot = 0;
                                    $milkpuddingtot = 0;
                                    $wmilkpuddingreturntot = 0;
                                    $jelycusterdtot = 0;
                                    $jelycusterdreturntot = 0;
                                    $faludatot = 0;
                                    $faludareturntot = 0;
                                    $stoberrytot = 0;
                                    $stoberryreturntot = 0;
                                    $milktot = 0;
                                    $milkreturntot = 0;
                                    $appletot = 0;
                                    $applereturntot = 0;
                                    $wmilkpuddingreturn = 0;
                                    $cashsaletot = 0;
                                    $creditsaletot = 0;
                                        $mobileorders = mysqli_query($conn, "SELECT * FROM mobileorders");
                                        if ($mobileorders->num_rows > 0) {
                                            $tsaale = 0;
                                            while($row = $mobileorders->fetch_assoc()) { 
                                                $creditsale = 0;
                                                 $cashsale = 0;
                                                 $customer = $row['customer']; 
                                                if($customer==0){
                                                    $cus = "Walk-in Customer";
                                                }else if($customer=="dc"){
                                                    $cus = "Delivery Customer";
                                                }else{
                                                    $customersinfo = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobilecustomers WHERE coid  ='$customer'"));
                                                    $cus = $customersinfo['cname'];
                                                }
                                               $pay_option =  $row['pay_option'];
                                                ?>
                                            <tr>
                                                <td><?php echo $cus; ?></td>
                                                <td><?php echo $row['orid']; ?></td>
                                                <td>
                                                <?php $order_id = $row['order_id'];
                                                     $watalapan = mysqli_fetch_array(mysqli_query($conn, "SELECT SUM(pro_price*pro_qty) as sale,pro_qty FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='155'"));
                                                     echo empty($watalapan['pro_qty']) ? '0' : $watalapan['pro_qty'];
                                                    if($pay_option=="Cash"){
                                                        $cashsale = $cashsale + $watalapan['sale'];
                                                    }else if($pay_option=="Credit"){
                                                        $creditsale = $creditsale + $watalapan['sale'];
                                                    }
                                                    $watalapantot = $watalapantot + $watalapan['pro_qty'];
                                                ?>
                                                </td>
                                                <td>
                                                    <?php 
                                                         $watalapanreturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM tbl_return_items WHERE order_id ='$order_id' AND prid='155'"));
                                                         
                                                         echo empty($watalapanreturn['qty']) ? '0' : $watalapanreturn['qty'];
                                                         $watalapanreturntot =  $watalapanreturntot + $watalapanreturn['qty'];
                                                    ?>
                                                </td>
                                                <td>
                                                <?php $order_id = $row['order_id'];
                                                     $milkpudding = mysqli_fetch_array(mysqli_query($conn, "SELECT SUM(pro_price*pro_qty) as sale,pro_qty FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='149'"));
                                                     echo empty($milkpudding['pro_qty']) ? '0' : $milkpudding['pro_qty'];
                                                    if($pay_option=="Cash"){
                                                        $cashsale = $cashsale + $milkpudding['sale'];
                                                    }else if($pay_option=="Credit"){
                                                        $creditsale = $creditsale + $milkpudding['sale'];
                                                    }
                                                    $milkpuddingtot = $milkpuddingtot + $milkpudding['pro_qty'];
                                                ?>
                                                </td>
                                                <td>
                                                    <?php 
                                                         $wmilkpuddingreturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM tbl_return_items WHERE order_id ='$order_id' AND prid='149'"));
                                                         
                                                         echo empty($wmilkpuddingreturn['qty']) ? '0' : $wmilkpuddingreturn['qty'];
                                                         $wmilkpuddingreturntot = $wmilkpuddingreturntot + $wmilkpuddingreturn['qty'];
                                                    ?>
                                                </td>
                                                <td>
                                                <?php $order_id = $row['order_id'];
                                                     $jelycusterd = mysqli_fetch_array(mysqli_query($conn, "SELECT SUM(pro_price*pro_qty) as sale,pro_qty FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='151'"));
                                                     echo empty($jelycusterd['pro_qty']) ? '0' : $jelycusterd['pro_qty'];
                                                    if($pay_option=="Cash"){
                                                        $cashsale = $cashsale + $jelycusterd['sale'];
                                                    }else if($pay_option=="Credit"){
                                                        $creditsale = $creditsale + $jelycusterd['sale'];
                                                    }
                                                    $jelycusterdtot = $jelycusterdtot + $jelycusterd['pro_qty'];
                                                ?>
                                                </td>
                                                <td>
                                                    <?php 
                                                         $jelycusterdreturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM tbl_return_items WHERE order_id ='$order_id' AND prid='151'"));
                                                         
                                                         echo empty($jelycusterdreturn['qty']) ? '0' : $jelycusterdreturn['qty'];
                                                         $jelycusterdreturntot = $jelycusterdreturntot + $jelycusterdreturn['qty'];
                                                    ?>
                                                </td>
                                                <td>
                                                <?php $order_id = $row['order_id'];
                                                     $faluda = mysqli_fetch_array(mysqli_query($conn, "SELECT SUM(pro_price*pro_qty) as sale,pro_qty FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='150'"));
                                                     echo empty($faluda['pro_qty']) ? '0' : $faluda['pro_qty'];
                                                    if($pay_option=="Cash"){
                                                        $cashsale = $cashsale + $faluda['sale'];
                                                    }else if($pay_option=="Credit"){
                                                        $creditsale = $creditsale + $faluda['sale'];
                                                    }
                                                    $faludatot = $faludatot + $faluda['pro_qty'];
                                                ?>
                                                </td>
                                                <td>
                                                    <?php 
                                                         $faludareturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM tbl_return_items WHERE order_id ='$order_id' AND prid='150'"));
                                                         
                                                         echo empty($faludareturn['qty']) ? '0' : $faludareturn['qty'];
                                                         $faludareturntot = $faludareturntot + $faludareturn['qty'];
                                                    ?>
                                                </td>
                                                <td>
                                                <?php $order_id = $row['order_id'];
                                                     $stoberry = mysqli_fetch_array(mysqli_query($conn, "SELECT SUM(pro_price*pro_qty) as sale,pro_qty FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='154'"));
                                                     echo empty($stoberry['pro_qty']) ? '0' : $stoberry['pro_qty'];
                                                    if($pay_option=="Cash"){
                                                        $cashsale = $cashsale + $stoberry['sale'];
                                                    }else if($pay_option=="Credit"){
                                                        $creditsale = $creditsale + $stoberry['sale'];
                                                    }
                                                    $stoberrytot = $stoberrytot + $stoberry['pro_qty'];
                                                ?>
                                                </td>
                                                <td>
                                                    <?php 
                                                         $stoberryreturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM tbl_return_items WHERE order_id ='$order_id' AND prid='154'"));
                                                         
                                                         echo empty($stoberryreturn['qty']) ? '0' : $stoberryreturn['qty'];
                                                         $stoberryreturntot = $stoberryreturntot + $stoberryreturn['qty'];
                                                    ?>
                                                </td>
                                                <td>
                                                <?php $order_id = $row['order_id'];
                                                     $milk = mysqli_fetch_array(mysqli_query($conn, "SELECT SUM(pro_price*pro_qty) as sale,pro_qty FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='153'"));
                                                     echo empty($milk['pro_qty']) ? '0' : $milk['pro_qty'];
                                                    if($pay_option=="Cash"){
                                                        $cashsale = $cashsale + $milk['sale'];
                                                    }else if($pay_option=="Credit"){
                                                        $creditsale = $creditsale + $milk['sale'];
                                                    }
                                                    $milktot = $milktot + $milk['pro_qty'];
                                                ?>
                                                </td>
                                                <td>
                                                    <?php 
                                                         $milkreturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM tbl_return_items WHERE order_id ='$order_id' AND prid='153'"));
                                                         
                                                         echo empty($milkreturn['qty']) ? '0' : $milkreturn['qty'];
                                                         $milkreturntot = $milkreturntot + $milkreturn['qty'];
                                                    ?>
                                                </td>
                                                <td>
                                                <?php $order_id = $row['order_id'];
                                                     $apple = mysqli_fetch_array(mysqli_query($conn, "SELECT SUM(pro_price*pro_qty) as sale,pro_qty FROM mobiletemporarycart WHERE orderid ='$order_id' AND proid='152'"));
                                                     echo empty($apple['pro_qty']) ? '0' : $apple['pro_qty'];
                                                    if($pay_option=="Cash"){
                                                        $cashsale = $cashsale + $apple['sale'];
                                                    }else if($pay_option=="Credit"){
                                                        $creditsale = $creditsale + $apple['sale'];
                                                    }
                                                    $appletot = $appletot + $apple['pro_qty'];
                                                ?>
                                                </td>
                                                <td>
                                                    <?php 
                                                         $applereturn = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM tbl_return_items WHERE order_id ='$order_id' AND prid='152'"));
                                                         
                                                         echo empty($applereturn['qty']) ? '0' : $applereturn['qty'];
                                                         $applereturntot =  $applereturntot + $applereturn['qty'];
                                                    ?> 
                                                </td>
                                                <td>
                                                    <?php echo $cashsale; ?>
                                                </td>
                                                <td>
                                                    <?php echo $creditsale; ?>
                                                </td>
                                                <td>
                                                    <?php echo $creditsale + $cashsale; 
                                                    $tsaale = $tsaale + ($creditsale + $cashsale);
                                                    $cashsaletot = $cashsaletot + $cashsale;
                                                    $creditsaletot = $creditsaletot + $creditsale;
                                                    ?>
                                                </td>
                                            </tr>
                                  <?php  }
                                }  
                            }
									?>
                                    
								</tbody>
                                <tfoot>
                                <tr>
                                <td colspan="2">Total</td> 
                                <td><?php echo $watalapantot; ?></td>
                                <td><?php echo $watalapanreturntot; ?></td>
                                <td><?php echo $milkpuddingtot; ?></td>
                                <td><?php echo $wmilkpuddingreturntot; ?></td>
                                <td><?php echo $jelycusterdtot; ?></td>     
                                <td><?php echo $jelycusterdreturntot; ?></td>
                                <td><?php echo $faludatot; ?></td>
                                <td><?php echo $faludareturntot; ?></td> 
                                <td><?php echo $stoberrytot; ?></td>
                                <td><?php echo $stoberryreturntot; ?></td>
                                <td><?php echo $milktot; ?></td>
                                <td><?php echo $milkreturntot; ?></td>
                                <td><?php echo $appletot; ?></td>
                                <td><?php echo $applereturntot; ?></td>
                                <td><?php echo $cashsaletot; ?></td>
                                <td><?php echo $creditsaletot; ?></td>
                                <td><?php echo $tsaale; ?></td>
                                </tr>
                            </tfoot>
								</table>
							</div>
						</div>
					</div>
				</div>

			</div>
		</div>
	</div>
<style>
    .label-success {
    background-color: #5cb85c;
}
.label {
    display: inline;
    padding: .2em .6em .3em;
    font-size: 75%;
    font-weight: 700;
    line-height: 1;
    color: #fff;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: .25em;
}
</style>
	<script>

		function printDiv(printableArea) {

			var printContents = document.getElementById(printableArea).innerHTML;
			var originalContents = document.body.innerHTML;

			document.body.innerHTML = printContents;

			window.print();

			document.body.innerHTML = originalContents;

		}

	</script>

	<script src="assets/js/jquery-3.6.0.min.js"></script>

	<script src="assets/js/feather.min.js"></script>

	<script src="assets/js/jquery.slimscroll.min.js"></script>

	<script src="assets/js/jquery.dataTables.min.js"></script>
	<script src="assets/js/dataTables.bootstrap4.min.js"></script>

	<script src="assets/js/bootstrap.bundle.min.js"></script>

	<script src="assets/js/moment.min.js"></script>
	<script src="assets/js/bootstrap-datetimepicker.min.js"></script>

	<script src="assets/plugins/select2/js/select2.min.js"></script>

	<script src="assets/plugins/sweetalert/sweetalert2.all.min.js"></script>
	<script src="assets/plugins/sweetalert/sweetalerts.min.js"></script>

	<script src="assets/js/script.js"></script>
</body>

</html>