
<? session_start();
date_default_timezone_set("Pacific/Auckland");
$outlet_id = $_GET['outlet_id'];

$date_from1	= date("Y-m-d");
$date_to1 	= date("Y-m-d");


$date_from 	= date("Y-m-d");
$date_to 	=date("Y-m-d");

$date_from = date("Y-m-d");
$date_to = date("Y-m-d");



 //echo '<a href="#" title="content_1" onclick="javascript: printpagedivtodaysalesshop()" class="tab active">Print Report</a><br><br>';
 
 echo '<div id="divtodaysalesshop" style="overflow:scroll; height:700px; color: black;">';
echo '<span style="font-size: 18px">Sales Report for Today from '.$date_from1.' to '.$date_to1 . '</span><br>';
echo "Report created ".date('d-m-Y H:i')."<br><br>";


		



echo '        <div class="section full mb-2" style="width: 50%">
            <div class="section-title">Completed Sales</div>
            <div class="content-header mb-05">
               Report created '.date('d-m-Y H:i').'
            </div>
            <div class="wide-block p-0" >

                <div class="table-responsive">
                    <table class="table table-striped">
                        <thead>
                            <tr>
                                <th scope="col" width="100px">Sales ID</th>
                                <th scope="col">Time</th>
                                <th scope="col">Customer</th>
								 <th scope="col">Status</th>
                                <th scope="col">Total</th>
                            </tr>
                        </thead>
                        <tbody>';

$w_total1 = 0;
$w_total2 = 0;
$w_total3 = 0;
$w_total4 = 0;

	include("configi.php");
	
	//$curdate = date("Y-m-d");


		




$query = "SELECT " . $_COOKIE['phxcrmclient_id'] . "_st.st_id, " . $_COOKIE['phxcrmclient_id'] . "_client.comp_name as full_name, " . $_COOKIE['phxcrmclient_id'] . "_st.* from " . $_COOKIE['phxcrmclient_id'] . "_client RIGHT JOIN " . $_COOKIE['phxcrmclient_id'] . "_st ON " . $_COOKIE['phxcrmclient_id'] . "_client.uid_client = " . $_COOKIE['phxcrmclient_id'] . "_st.uid_client where " . $_COOKIE['phxcrmclient_id'] . "_st.status = 'Paid' and date(sales_datetime) >= '".$date_from."' and date(sales_datetime) <= '".$date_to."' and st_outlet_id=".$outlet_id;
//echo $query;
$result=mysqli_query($conn, $query);
$i = 1;

 while($row=mysqli_fetch_array($result)) { 

$customer_name = $row['full_name'];
echo "<td>";
echo "<label style='font-size:12px'><a href='' onclick='load_cart_fromreport(".$row['st_id'].")'>".$row['st_id']."</a></label>"; 
echo "</td>";
echo "<td  width='180px'>";
echo "<label style='font-size:12px'>" . date('d/m/Y H:i:s',strtotime($row['sales_datetime']))  . "</label>"; 
echo "</td>";
echo "<td  width='180px'>";
echo "<label style='font-size:12px'>" . $customer_name  . "</label>"; 
echo "</td>";
echo "<td  width='70px' align='left'>";
echo "<label style='font-size:12px'>" . $row['status']  . "</label>"; 
echo "</td>";
echo "<td  width='80px' align='right'>";
echo "<label style='font-size:12px'>$" . number_format($row['total_paid'], 2, '.', ',') . "</label>";
$w_total1 = $row['total_sale'] + $w_total1;
echo "</td>";


echo "</tr>";
echo "<tr>";


 $i = $i+1;
 } 

                        echo '</tbody>
						
						<tfoot>
						        <tr>
            <th scope="row">Total </th>
			<td></td>
			<td></td>

			
            <td colspan="2" style="text-align: right">$ '.number_format($w_total1, 2, '.', ',').'</td>
        </tr>
						</tfoot>
                    </table>
                </div>

            </div>
        </div>';
		

$w_total_overall1 = 0;
$w_total_overall1 = $w_total_overall1 + $w_total1;


//dave

echo '        <div class="section full mb-2"  style="width: 50%">
            <div class="section-title">Sales In Progress</div>

            <div class="wide-block p-0">

                <div class="table-responsive">
                    <table class="table table-striped">
                        <thead>
                            <tr>
                                <th scope="col">Sales ID</th>
                                <th scope="col">Time</th>
                                <th scope="col">Customer</th>
								 <th scope="col">Status</th>
                                <th scope="col">Total</th>
                            </tr>
                        </thead>
                        <tbody>';

$w_total1 = 0;
$w_total2 = 0;
$w_total3 = 0;
$w_total4 = 0;

	include("configi.php");
	
	$curdate = date("Y-m-d");

$query = "SELECT " . $_COOKIE['phxcrmclient_id'] . "_client.comp_name as full_name, " . $_COOKIE['phxcrmclient_id'] . "_st.* from " . $_COOKIE['phxcrmclient_id'] . "_client RIGHT JOIN " . $_COOKIE['phxcrmclient_id'] . "_st ON " . $_COOKIE['phxcrmclient_id'] . "_client.uid_client = " . $_COOKIE['phxcrmclient_id'] . "_st.uid_client where " . $_COOKIE['phxcrmclient_id'] . "_st.status <> 'Paid' and date(sales_datetime) = '".$curdate."'  and st_outlet_id=".$outlet_id;
//echo $query;
$result=mysqli_query($conn, $query);
$i = 1;

 while($row=mysqli_fetch_array($result)) { 

$customer_name = $row['full_name'];
echo "<td>";
echo "<label style='font-size:12px'><a href='' onclick='load_cart_fromreport(".$row['st_id'].")'>".$row['st_id']."</a></label>"; 
echo "</td>";
echo "<td  width='180px'>";
echo "<label style='font-size:12px'>" . date('d/m/Y H:i:s',strtotime($row['sales_datetime']))  . "</label>"; 
echo "</td>";
echo "<td  width='180px'>";
echo "<label style='font-size:12px'>" . $customer_name  . "</label>"; 
echo "</td>";
echo "<td  width='100px' align='left'>";
echo "<label style='font-size:12px'>" . $row['status']  . "</label>"; 
echo "</td>";
echo "<td  width='50px' align='right'>";
echo "<label style='font-size:12px'>$" . number_format($row['total_sale'], 2, '.', ',') . "</label>";
$w_total1 = $row['total_sale'] + $w_total1;
echo "</td>";


echo "</tr>";
echo "<tr>";


 $i = $i+1;
 } 

                        echo '</tbody>
						
						<tfoot>
						        <tr>
            <th scope="row">Total</th>
			<td></td>
			<td></td>

			
            <td colspan="2" style="text-align: right">$ '.number_format($w_total1, 2, '.', ',').'</td>
        </tr>
						</tfoot>
                    </table>
                </div>

            </div>
        </div>';



//dave


echo '        <div class="section full mb-2"  style="width: 50%">


            <div class="wide-block p-0">

                <div class="table-responsive">
                    <table class="table table-striped">


						
						<tfoot>
						        <tr>
            <th scope="row">Overall Total</th>
			<td></td>
			<td></td>

			
            <td colspan="2" style="text-align: right">$ '.number_format($w_total_overall1, 2, '.', ',').'</td>
        </tr>
						</tfoot>
                    </table>
                </div>

            </div>
        </div>';



?>

