<?php
include('../../connection/conn.php');
include('../../servair/session.php'); 
require_once("header_print.php");     
?>

<style>
#td{
border: 1px solid #a5a4a1;     
padding: 4px;
}
</style>
        
<?php
$from = $_GET['from']; 
$to = $_GET['to'];
 
?>
        
    
<div id="content_holder">
<div id="ele1" class="" >
<div style='text-align:center; margin-top:-400px; margin:0% auto;'>
<p><img src='../../library/images/images/servair_lincoln.jpg' width='60%'></p>

<h1 style='font-size:12px; font-family:sans-serif;'>SERVAIR GHANA COMPANY LTD</h1>
<p style='font-size:10px; font-family:sans-serif;'>AIRPORT CITY 2
<br>P.O.Box KA 18108 KIA
<br>Accra - Ghana
<br>TEL: 0302730367 / 0577707889
<br><?php echo date('l jS \of F Y h:i:s A');?></p>

    
 
    
<?php if(empty($from) && empty($to)){ ?>    
    
<div class='col-md-6' style='margin-left:6px;'>
    
<div class='row text-center'>
<div class='col-md-12'>
<h2>Cash Analysis</h2>
</div>
</div>
    
<div class='row' style="margin-left:8px; width:100.0%;" >
    
<div class='col-md-11' id='results_sales11112' style='background:#ffffff; '>
    
<div class='row'>
<div class='col-md-12' style='padding:0px;'>
<table id='table' style="margin-left:16px; width:94.4%">
<tr id='tr' class="header" >
<th id='th'style='width:20.5%; background:#9f9f9f; color:#f2f2f2; border: 1px solid #9f9f9f; text-shadow:1px 0px 1px #747474; font-size:16px;'>Description</th>
<th id='th'style='width:5px; background:#bbbfa5; color:#efefef; border: 1px solid #bbbfa5; text-shadow:1px 0px 1px #747474;'>Amount</th>
</tr>      
<?php    
    
$query=mysqli_query($conn, "SELECT * FROM preorder_payment WHERE Date = '$todays_date' "); 
while($spec=mysqli_fetch_assoc($query)){
$ppayment = $spec['PreorderPayment'];
}     
    
$query=mysqli_query($conn, "SELECT *,SUM(Total) AS Total FROM sales WHERE DATE(Date)=DATE(NOW()) AND PaymentMode = 'Cash' AND TransactionStatus = 'Completed'  GROUP BY PaymentMode"); 
while($spec=mysqli_fetch_assoc($query)){
$cash_sales = $spec['Total'];
$spec['Total'] = $spec['Total'];
if(empty($spec['Total'])){
$spec['Total'] = 0.00;
}
echo "<tr id='tr' class='tbody' style='background:#f4f4f4;'>"; 
echo "<td id='td' style='width:60%; font-size:18px; text-shadow:1px 0px 1px #dbdbdb;'>Cash Sales</td>";
echo "<td id='td' style='width:20%; font-size:16px; text-shadow:1px 0px 1px #dbdbdb; color:#656565;'><input type='number' style='width:100%; height:40px; text-align:center;' placeholder='800' class='cash' value='".$spec['Total']."' hidden>¢ ".$spec['Total']."</td>";
echo "</tr>";
 
}   
    
if(empty($cash_sales)){
echo "<input type='number' style='width:100%; height:40px; text-align:center;' placeholder='800' class='cash' value='0.00' hidden>";
}
                               
$query=mysqli_query($conn, "SELECT *,SUM(AmountLoaded) AS Total FROM card_loading_transactions WHERE DATE(Date)=DATE(NOW())"); 
while($spec=mysqli_fetch_assoc($query)){
$card_loading = $spec['Total'];
$spec['Total'] = $spec['Total'];
if(empty($spec['Total'])){
$spec['Total'] = 0.00;
}
echo "<tr id='tr' class='tbody' style='background:#f4f4f4;'>"; 
echo "<td id='td' style='width:60%; font-size:18px; text-shadow:1px 0px 1px #dbdbdb;'>Card Loading</td>";
echo "<td id='td' style='width:20%; font-size:16px; text-shadow:1px 0px 1px #dbdbdb; color:#656565;'><input type='number' style='width:100%; height:40px; text-align:center;' placeholder='800' class='cardloading' value='".$spec['Total']."' hidden>¢ ".$spec['Total']."</td>";
echo "</tr>";
}
                               
$query=mysqli_query($conn, "SELECT *,SUM(Total) AS Total FROM sales WHERE DATE(Date)=DATE(NOW()) AND PaymentMode = 'Coupon'"); 
while($spec=mysqli_fetch_assoc($query)){
//$preorder_eaten = $spec['Total'];
echo "<tr id='tr' class='tbody' style='background:#f4f4f4;'>"; 
echo "<td id='td' style='width:60%; font-size:18px; text-shadow:1px 0px 1px #dbdbdb;'><input type='date' style='width:100%; height:40px; text-align:center; border:none;' value='".$todays_date."' placeholder='enter amount' class='date' hidden>
Preorder Payment</td>";
    
if(!empty($ppayment)){
echo "<td id='td' style='width:20%; font-size:16px; text-shadow:1px 0px 1px #dbdbdb; color:#656565; padding:0px;'><input type='number' style='width:100%; height:40px; text-align:center; border:none; background:none;' value='".$ppayment."' placeholder='enter amount' class='preorderpayment'></td>";
}
else{
echo "<td id='td' style='width:20%; font-size:16px; text-shadow:1px 0px 1px #dbdbdb; color:#656565; padding:0px;'><input type='number' style='width:100%; height:40px; text-align:center; border:none; background:none;' value='0.00' placeholder='enter amount' class='preorderpayment'></td>";
}

echo "</tr>";
 
}  
                               
$total = $cash_sales + $card_loading + $preorder_eaten;                            
?>

</table>   

</div>
    
</div>
</div>
    
</div>
    
<div class='row' style="margin-left:px; width:94%; margin-bottom:10px; border: 1px solid #a7a7a7;  margin-left:24px; " >   
<div class='col-md-12' id='results_sales11' style='padding:1px 8px 0px 0px; background:white;'>
<table id='table' style="margin-left:0px; ">

<?php    

echo "<tr id='tr' class='tbody' style='display:; background:white;'>"; 
echo "<td id='td' style='border-left:none; width:600px; border-top:none;font-size:17px;'><b>TOTAL CASH</b>: </td>";
echo "<td id='td' style=' border-top:none; padding:0px;'>GH <b style='font-size:18px;'><span style='color:#408000;'>¢<input type='number' style='width:60%; height:40px; text-align:center; border:none; color:#408000; font-weight:600; background:none;' placeholder='800' class='total' value='".$total."' readonly></span></b></td>";
echo "</tr>";
   
?>
     
</table>    
</div>
</div>
  
<div class='row text-center'>
<div class='col-md-12' style='padding:10px;'>
<h2>Sales Analysis</h2>
</div>
</div>
 
<div class='row' style="margin-left:8px; width:100%;" >
    
<div class='col-md-11' id='results_sales11112' style='background:#ffffff; '>
    
<div class='row'>
<div class='col-md-12' style='padding:0px;'>
<table id='table' style="margin-left:16px; width:94.4%">
<tr id='tr' class="header" >
<th id='th'style='width:20.5%; background:#9f9f9f; color:#f2f2f2; border: 1px solid #9f9f9f; text-shadow:1px 0px 1px #747474; font-size:16px;'>Description</th>
<th id='th'style='width:5px; background:#bbbfa5; color:#efefef; border: 1px solid #bbbfa5; text-shadow:1px 0px 1px #747474;'>Amount</th>
</tr>      
<?php    
$query=mysqli_query($conn, "SELECT *,SUM(Total) AS Total FROM sales WHERE DATE(Date)=DATE(NOW()) AND PaymentMode = 'Cash' AND TransactionStatus = 'Completed'  GROUP BY PaymentMode"); 
while($spec=mysqli_fetch_assoc($query)){
$cash_sales = $spec['Total'];
echo "<tr id='tr' class='tbody' style='background:#f4f4f4;'>"; 
echo "<td id='td' style='width:60%; font-size:18px; text-shadow:1px 0px 1px #dbdbdb;'>Cash Sales</td>";
echo "<td id='td' style='width:20%; font-size:16px; text-shadow:1px 0px 1px #dbdbdb; color:#656565;'>¢ ".$spec['Total']."</td>";
echo "</tr>";
 
}   
                               
$query=mysqli_query($conn, "SELECT *,SUM(Total) AS Total FROM sales WHERE DATE(Date)=DATE(NOW()) AND PaymentMode = 'Credit Card' AND TransactionStatus = 'Completed'  GROUP BY PaymentMode"); 
while($spec=mysqli_fetch_assoc($query)){
$card_eaten = $spec['Total'];
echo "<tr id='tr' class='tbody' style='background:#f4f4f4;'>"; 
echo "<td id='td' style='width:60%; font-size:18px; text-shadow:1px 0px 1px #dbdbdb;'>Card Eaten</td>";
echo "<td id='td' style='width:20%; font-size:16px; text-shadow:1px 0px 1px #dbdbdb; color:#656565;'>¢ ".$spec['Total']."</td>";
echo "</tr>";
 
}   
                               
                               
$query=mysqli_query($conn, "SELECT *,SUM(Total) AS Total FROM sales WHERE DATE(Date)=DATE(NOW()) AND PaymentMode = 'Credit Card' AND TransactionStatus = 'Completed'  GROUP BY PaymentMode"); 
while($spec=mysqli_fetch_assoc($query)){
//$coupon = $spec['Total'];
echo "<tr id='tr' class='tbody' style='background:#f4f4f4;'>"; 
echo "<td id='td' style='width:60%; font-size:18px; text-shadow:1px 0px 1px #dbdbdb;'>Coupon</td>";
echo "<td id='td' style='width:20%; font-size:16px; text-shadow:1px 0px 1px #dbdbdb; color:#656565;'>-</td>";
echo "</tr>";
 
}                                  

                               
$query=mysqli_query($conn, "SELECT *,SUM(Total) AS Total FROM sales WHERE DATE(Date)=DATE(NOW()) AND PaymentMode = 'Coupon'"); 
while($spec=mysqli_fetch_assoc($query)){
$preorder_eaten = $spec['Total'];
echo "<tr id='tr' class='tbody' style='background:#f4f4f4;'>"; 
echo "<td id='td' style='width:60%; font-size:18px; text-shadow:1px 0px 1px #dbdbdb;'>Preorder Eaten</td>";
echo "<td id='td' style='width:20%; font-size:16px; text-shadow:1px 0px 1px #dbdbdb; color:#656565;'>¢ ".$spec['Total']."</td>";
echo "</tr>";
 
}  
                               
$total = $cash_sales + $card_eaten + $preorder_eaten;                            
?>

</table>   

</div>
    
</div>
</div>
    
</div>
    
<div class='row' style="margin-left:px; width:94%; margin-bottom:10px; border: 1px solid #a7a7a7;  margin-left:24px; ">   
<div class='col-md-12' id='results_sales11' style='padding:1px 8px 0px 0px; background:#ffffff;'>
<table id='table' style="margin-left:3px; ">

<?php    

echo "<tr id='tr' class='tbody' style='display:; background:white;'>"; 
echo "<td id='td' style='border-left:none; width:600px; border-top:none;  font-size:17px;'><b>ACTUAL SALES</b>: </td>";
echo "<td id='td' style='width:80%; border-top:none; text-align:right;'>GH <b style='font-size:18px;'><span style='color:#408000;'>¢".$total."</span></b></td>";
echo "</tr>";
   
?>
     
</table>    
</div>
</div>    
          
</div>
    
<?php }elseif(!empty($from) && empty($to)){?>
    
<div class='col-md-6' style='margin-left:6px;'>
    
<div class='row text-center'>
<div class='col-md-12'>
<h2>Cash Analysis</h2>
</div>
</div>
    
<div class='row' style="margin-left:8px; width:100.0%;" >
    
<div class='col-md-11' id='results_sales11112' style='background:#ffffff; '>
    
<div class='row'>
<div class='col-md-12' style='padding:0px;'>
<table id='table' style="margin-left:16px; width:94.4%">
<tr id='tr' class="header" >
<th id='th'style='width:20.5%; background:#9f9f9f; color:#f2f2f2; border: 1px solid #9f9f9f; text-shadow:1px 0px 1px #747474; font-size:16px;'>Description</th>
<th id='th'style='width:5px; background:#bbbfa5; color:#efefef; border: 1px solid #bbbfa5; text-shadow:1px 0px 1px #747474;'>Amount</th>
</tr>      
<?php    
    
$query=mysqli_query($conn, "SELECT * FROM preorder_payment WHERE Date = '$from' "); 
while($spec=mysqli_fetch_assoc($query)){
$ppayment = $spec['PreorderPayment'];
}     
    
$query=mysqli_query($conn, "SELECT *,SUM(Total) AS Total FROM sales WHERE DATE(Date) = '$from'
AND PaymentMode = 'Cash' AND TransactionStatus = 'Completed'  GROUP BY PaymentMode"); 
while($spec=mysqli_fetch_assoc($query)){
$cash_sales = $spec['Total'];
$spec['Total'] = $spec['Total'];
if(empty($spec['Total'])){
$spec['Total'] = 0.00;
}
echo "<tr id='tr' class='tbody' style='background:#f4f4f4;'>"; 
echo "<td id='td' style='width:60%; font-size:18px; text-shadow:1px 0px 1px #dbdbdb;'>Cash Sales</td>";
echo "<td id='td' style='width:20%; font-size:16px; text-shadow:1px 0px 1px #dbdbdb; color:#656565;'><input type='number' style='width:100%; height:40px; text-align:center;' placeholder='800' class='cash' value='".$spec['Total']."' hidden>¢ ".$spec['Total']."</td>";
echo "</tr>";
 
}  
    
if(empty($cash_sales)){
echo "<input type='number' style='width:100%; height:40px; text-align:center;' placeholder='800' class='cash' value='0.00' hidden>";
}
                               
$query=mysqli_query($conn, "SELECT *,SUM(AmountLoaded) AS Total FROM card_loading_transactions WHERE DATE(Date) = '$from'"); 
while($spec=mysqli_fetch_assoc($query)){
$card_loading = $spec['Total'];
$spec['Total'] = $spec['Total'];
if(empty($spec['Total'])){
$spec['Total'] = 0.00;
}
echo "<tr id='tr' class='tbody' style='background:#f4f4f4;'>"; 
echo "<td id='td' style='width:60%; font-size:18px; text-shadow:1px 0px 1px #dbdbdb;'>Card Loading</td>";
echo "<td id='td' style='width:20%; font-size:16px; text-shadow:1px 0px 1px #dbdbdb; color:#656565;'><input type='number' style='width:100%; height:40px; text-align:center;' placeholder='800' class='cardloading' value='".$spec['Total']."' hidden>¢ ".$spec['Total']."</td>";
echo "</tr>";
}
                               
$query=mysqli_query($conn, "SELECT *,SUM(Total) AS Total FROM sales WHERE DATE(Date) = '$from'
AND PaymentMode = 'Coupon'"); 
while($spec=mysqli_fetch_assoc($query)){
//$preorder_eaten = $spec['Total'];
echo "<tr id='tr' class='tbody' style='background:#f4f4f4;'>"; 
echo "<td id='td' style='width:60%; font-size:18px; text-shadow:1px 0px 1px #dbdbdb;'><input type='date' style='width:100%; height:40px; text-align:center; border:none;' value='".$from."' placeholder='enter amount' class='date' hidden>
Preorder Payment</td>";
if(!empty($ppayment)){
echo "<td id='td' style='width:20%; font-size:16px; text-shadow:1px 0px 1px #dbdbdb; color:#656565; padding:0px;'><input type='number' style='width:100%; height:40px; text-align:center; border:none; background:none;' value='".$ppayment."' placeholder='enter amount' class='preorderpayment'></td>";
}
else{
echo "<td id='td' style='width:20%; font-size:16px; text-shadow:1px 0px 1px #dbdbdb; color:#656565; padding:0px;'><input type='number' style='width:100%; height:40px; text-align:center; border:none; background:none;' value='0.00' placeholder='enter amount' class='preorderpayment'></td>";
}
echo "</tr>";
 
}  
                               
$total = $cash_sales + $card_loading + $preorder_eaten;                            
?>

</table>   

</div>
    
</div>
</div>
    
</div>
    
<div class='row' style="margin-left:px; width:94%; margin-bottom:10px; border: 1px solid #a7a7a7;  margin-left:24px; " >   
<div class='col-md-12' id='results_sales11' style='padding:1px 8px 0px 0px; background:white;'>
<table id='table' style="margin-left:0px; ">

<?php    

echo "<tr id='tr' class='tbody' style='display:; background:white;'>"; 
echo "<td id='td' style='border-left:none; width:600px; border-top:none;font-size:17px;'><b>TOTAL CASH</b>: </td>";
echo "<td id='td' style=' border-top:none; padding:0px;'>GH <b style='font-size:18px;'><span style='color:#408000;'>¢<input type='number' style='width:60%; height:40px; text-align:center; border:none; color:#408000; font-weight:600; background:none;' placeholder='800' class='total' value='".$total."' readonly></span></b></td>";
echo "</tr>";
   
?>
     
</table>    
</div>
</div>
  
<div class='row text-center'>
<div class='col-md-12' style='padding:10px;'>
<h2>Sales Analysis</h2>
</div>
</div>
 
<div class='row' style="margin-left:8px; width:100%;" >
    
<div class='col-md-11' id='results_sales11112' style='background:#ffffff; '>
    
<div class='row'>
<div class='col-md-12' style='padding:0px;'>
<table id='table' style="margin-left:16px; width:94.4%">
<tr id='tr' class="header" >
<th id='th'style='width:20.5%; background:#9f9f9f; color:#f2f2f2; border: 1px solid #9f9f9f; text-shadow:1px 0px 1px #747474; font-size:16px;'>Description</th>
<th id='th'style='width:5px; background:#bbbfa5; color:#efefef; border: 1px solid #bbbfa5; text-shadow:1px 0px 1px #747474;'>Amount</th>
</tr>      
<?php    
$query=mysqli_query($conn, "SELECT *,SUM(Total) AS Total FROM sales WHERE DATE(Date) = '$from' AND PaymentMode = 'Cash' AND TransactionStatus = 'Completed'  GROUP BY PaymentMode"); 
while($spec=mysqli_fetch_assoc($query)){
$cash_sales = $spec['Total'];
echo "<tr id='tr' class='tbody' style='background:#f4f4f4;'>"; 
echo "<td id='td' style='width:60%; font-size:18px; text-shadow:1px 0px 1px #dbdbdb;'>Cash Sales</td>";
echo "<td id='td' style='width:20%; font-size:16px; text-shadow:1px 0px 1px #dbdbdb; color:#656565;'>¢ ".$spec['Total']."</td>";
echo "</tr>";
 
}   
                               
$query=mysqli_query($conn, "SELECT *,SUM(Total) AS Total FROM sales WHERE DATE(Date) = '$from' AND PaymentMode = 'Credit Card' AND TransactionStatus = 'Completed'  GROUP BY PaymentMode"); 
while($spec=mysqli_fetch_assoc($query)){
$card_eaten = $spec['Total'];
echo "<tr id='tr' class='tbody' style='background:#f4f4f4;'>"; 
echo "<td id='td' style='width:60%; font-size:18px; text-shadow:1px 0px 1px #dbdbdb;'>Card Eaten</td>";
echo "<td id='td' style='width:20%; font-size:16px; text-shadow:1px 0px 1px #dbdbdb; color:#656565;'>¢ ".$spec['Total']."</td>";
echo "</tr>";
 
}   
                               
                               
$query=mysqli_query($conn, "SELECT *,SUM(Total) AS Total FROM sales WHERE DATE(Date) = '$from' AND PaymentMode = 'Credit Card' AND TransactionStatus = 'Completed'  GROUP BY PaymentMode"); 
while($spec=mysqli_fetch_assoc($query)){
//$coupon = $spec['Total'];
echo "<tr id='tr' class='tbody' style='background:#f4f4f4;'>"; 
echo "<td id='td' style='width:60%; font-size:18px; text-shadow:1px 0px 1px #dbdbdb;'>Coupon</td>";
echo "<td id='td' style='width:20%; font-size:16px; text-shadow:1px 0px 1px #dbdbdb; color:#656565;'>-</td>";
echo "</tr>";
 
}                                  

                               
$query=mysqli_query($conn, "SELECT *,SUM(Total) AS Total FROM sales WHERE DATE(Date) = '$from' AND PaymentMode = 'Coupon'"); 
while($spec=mysqli_fetch_assoc($query)){
$preorder_eaten = $spec['Total'];
echo "<tr id='tr' class='tbody' style='background:#f4f4f4;'>"; 
echo "<td id='td' style='width:60%; font-size:18px; text-shadow:1px 0px 1px #dbdbdb;'>Preorder Eaten</td>";
echo "<td id='td' style='width:20%; font-size:16px; text-shadow:1px 0px 1px #dbdbdb; color:#656565;'>¢ ".$spec['Total']."</td>";
echo "</tr>";
 
}  
                               
$total = $cash_sales + $card_eaten + $preorder_eaten;                            
?>

</table>   

</div>
    
</div>
</div>
    
</div>
    
<div class='row' style="margin-left:px; width:94%; margin-bottom:10px; border: 1px solid #a7a7a7;  margin-left:24px; ">   
<div class='col-md-12' id='results_sales11' style='padding:1px 8px 0px 0px; background:#ffffff;'>
<table id='table' style="margin-left:3px; ">

<?php    

echo "<tr id='tr' class='tbody' style='display:; background:white;'>"; 
echo "<td id='td' style='border-left:none; width:600px; border-top:none;  font-size:17px;'><b>ACTUAL SALES</b>: </td>";
echo "<td id='td' style='width:80%; border-top:none; text-align:right;'>GH <b style='font-size:18px;'><span style='color:#408000;'>¢".$total."</span></b></td>";
echo "</tr>";
   
?>
     
</table>    
</div>
</div>    
          
</div>
    
<?php }elseif(!empty($from) && !empty($to)){?>
    
<div class='col-md-6' style='margin-left:6px;'>
    
<div class='row text-center'>
<div class='col-md-12'>
<h2>Cash Analysis</h2>
</div>
</div>
    
<div class='row' style="margin-left:8px; width:100.0%;" >
    
<div class='col-md-11' id='results_sales11112' style='background:#ffffff; '>
    
<div class='row'>
<div class='col-md-12' style='padding:0px;'>
<table id='table' style="margin-left:16px; width:94.4%">
<tr id='tr' class="header" >
<th id='th'style='width:20.5%; background:#9f9f9f; color:#f2f2f2; border: 1px solid #9f9f9f; text-shadow:1px 0px 1px #747474; font-size:16px;'>Description</th>
<th id='th'style='width:5px; background:#bbbfa5; color:#efefef; border: 1px solid #bbbfa5; text-shadow:1px 0px 1px #747474;'>Amount</th>
</tr>      
<?php    
$query=mysqli_query($conn, "SELECT SUM(PreorderPayment) AS TOTAL FROM preorder_payment WHERE DATE(Date) BETWEEN '$from' AND '$to' "); 
while($spec=mysqli_fetch_assoc($query)){
$ppayment = $spec['TOTAL'];
}                                            
                                            
$query=mysqli_query($conn, "SELECT *,SUM(Total) AS Total FROM sales WHERE DATE(Date) BETWEEN '$from' AND '$to' AND PaymentMode = 'Cash' AND TransactionStatus = 'Completed'  GROUP BY PaymentMode"); 
while($spec=mysqli_fetch_assoc($query)){
$cash_sales = $spec['Total'];
$spec['Total'] = $spec['Total'];
if(empty($spec['Total'])){
$spec['Total'] = 0.00;
}
echo "<tr id='tr' class='tbody' style='background:#f4f4f4;'>"; 
echo "<td id='td' style='width:60%; font-size:18px; text-shadow:1px 0px 1px #dbdbdb;'>Cash Sales</td>";
echo "<td id='td' style='width:20%; font-size:16px; text-shadow:1px 0px 1px #dbdbdb; color:#656565;'><input type='number' style='width:100%; height:40px; text-align:center;' placeholder='800' class='cash' value='".$spec['Total']."' hidden>¢ ".$spec['Total']."</td>";
echo "</tr>";
 
}   
    
if(empty($cash_sales)){
echo "<input type='number' style='width:100%; height:40px; text-align:center;' placeholder='800' class='cash' value='0.00' hidden>";
}
                               
$query=mysqli_query($conn, "SELECT *,SUM(AmountLoaded) AS Total FROM card_loading_transactions WHERE DATE(Date) BETWEEN '$from' AND '$to'"); 
while($spec=mysqli_fetch_assoc($query)){
$card_loading = $spec['Total'];
$spec['Total'] = $spec['Total'];
if(empty($spec['Total'])){
$spec['Total'] = 0.00;
}
echo "<tr id='tr' class='tbody' style='background:#f4f4f4;'>"; 
echo "<td id='td' style='width:60%; font-size:18px; text-shadow:1px 0px 1px #dbdbdb;'>Card Loading</td>";
echo "<td id='td' style='width:20%; font-size:16px; text-shadow:1px 0px 1px #dbdbdb; color:#656565;'><input type='number' style='width:100%; height:40px; text-align:center;' placeholder='800' class='cardloading' value='".$spec['Total']."' hidden>¢ ".$spec['Total']."</td>";
echo "</tr>";
}
                               
$query=mysqli_query($conn, "SELECT *,SUM(Total) AS Total FROM sales WHERE DATE(Date) BETWEEN '$from' AND '$to'
AND PaymentMode = 'Coupon'"); 
while($spec=mysqli_fetch_assoc($query)){
//$preorder_eaten = $spec['Total'];
echo "<tr id='tr' class='tbody' style='background:#f4f4f4;'>"; 
echo "<td id='td' style='width:60%; font-size:18px; text-shadow:1px 0px 1px #dbdbdb;'><input type='date' style='width:100%; height:40px; text-align:center; border:none;' value='".$todays_date."' placeholder='enter amount' class='date' hidden>
Preorder Payment</td>";
if(!empty($ppayment)){
echo "<td id='td' style='width:20%; font-size:16px; text-shadow:1px 0px 1px #dbdbdb; color:#656565; padding:0px;'><input type='number' style='width:100%; height:40px; text-align:center; border:none; background:none;' value='".$ppayment."' placeholder='enter amount' class='preorderpayment' readonly></td>";
}
else{
echo "<td id='td' style='width:20%; font-size:16px; text-shadow:1px 0px 1px #dbdbdb; color:#656565; padding:0px;'><input type='number' style='width:100%; height:40px; text-align:center; border:none; background:none;' value='0.00' placeholder='enter amount' class='preorderpayment' readonly></td>";
}
echo "</tr>";
 
}  
                               
$total = $cash_sales + $card_loading + $preorder_eaten;                            
?>

</table>   

</div>
    
</div>
</div>
    
</div>
    
<div class='row' style="margin-left:px; width:94%; margin-bottom:10px; border: 1px solid #a7a7a7;  margin-left:24px; " >   
<div class='col-md-12' id='results_sales11' style='padding:1px 8px 0px 0px; background:white;'>
<table id='table' style="margin-left:0px; ">

<?php    

echo "<tr id='tr' class='tbody' style='display:; background:white;'>"; 
echo "<td id='td' style='border-left:none; width:600px; border-top:none;font-size:17px;'><b>TOTAL CASH</b>: </td>";
echo "<td id='td' style=' border-top:none; padding:0px;'>GH <b style='font-size:18px;'><span style='color:#408000;'>¢<input type='number' style='width:60%; height:40px; text-align:center; border:none; color:#408000; font-weight:600; background:none;' placeholder='800' class='total' value='".$total."' readonly></span></b></td>";
echo "</tr>";
   
?>
     
</table>    
</div>
</div>
  
<div class='row text-center'>
<div class='col-md-12' style='padding:10px;'>
<h2>Sales Analysis</h2>
</div>
</div>
 
<div class='row' style="margin-left:8px; width:100%;" >
    
<div class='col-md-11' id='results_sales11112' style='background:#ffffff; '>
    
<div class='row'>
<div class='col-md-12' style='padding:0px;'>
<table id='table' style="margin-left:16px; width:94.4%">
<tr id='tr' class="header" >
<th id='th'style='width:20.5%; background:#9f9f9f; color:#f2f2f2; border: 1px solid #9f9f9f; text-shadow:1px 0px 1px #747474; font-size:16px;'>Description</th>
<th id='th'style='width:5px; background:#bbbfa5; color:#efefef; border: 1px solid #bbbfa5; text-shadow:1px 0px 1px #747474;'>Amount</th>
</tr>      
<?php    
$query=mysqli_query($conn, "SELECT *,SUM(Total) AS Total FROM sales WHERE DATE(Date) BETWEEN '$from' AND '$to' AND PaymentMode = 'Cash' AND TransactionStatus = 'Completed'  GROUP BY PaymentMode"); 
while($spec=mysqli_fetch_assoc($query)){
$cash_sales = $spec['Total'];
echo "<tr id='tr' class='tbody' style='background:#f4f4f4;'>"; 
echo "<td id='td' style='width:60%; font-size:18px; text-shadow:1px 0px 1px #dbdbdb;'>Cash Sales</td>";
echo "<td id='td' style='width:20%; font-size:16px; text-shadow:1px 0px 1px #dbdbdb; color:#656565;'>¢ ".$spec['Total']."</td>";
echo "</tr>";
 
}   
                               
$query=mysqli_query($conn, "SELECT *,SUM(Total) AS Total FROM sales WHERE DATE(Date) BETWEEN '$from' AND '$to' AND PaymentMode = 'Credit Card' AND TransactionStatus = 'Completed'  GROUP BY PaymentMode"); 
while($spec=mysqli_fetch_assoc($query)){
$card_eaten = $spec['Total'];
echo "<tr id='tr' class='tbody' style='background:#f4f4f4;'>"; 
echo "<td id='td' style='width:60%; font-size:18px; text-shadow:1px 0px 1px #dbdbdb;'>Card Eaten</td>";
echo "<td id='td' style='width:20%; font-size:16px; text-shadow:1px 0px 1px #dbdbdb; color:#656565;'>¢ ".$spec['Total']."</td>";
echo "</tr>";
 
}   
                               
                               
$query=mysqli_query($conn, "SELECT *,SUM(Total) AS Total FROM sales WHERE DATE(Date) BETWEEN '$from' AND '$to' AND PaymentMode = 'Credit Card' AND TransactionStatus = 'Completed'  GROUP BY PaymentMode"); 
while($spec=mysqli_fetch_assoc($query)){
//$coupon = $spec['Total'];
echo "<tr id='tr' class='tbody' style='background:#f4f4f4;'>"; 
echo "<td id='td' style='width:60%; font-size:18px; text-shadow:1px 0px 1px #dbdbdb;'>Coupon</td>";
echo "<td id='td' style='width:20%; font-size:16px; text-shadow:1px 0px 1px #dbdbdb; color:#656565;'>-</td>";
echo "</tr>";
 
}                                  

                               
$query=mysqli_query($conn, "SELECT *,SUM(Total) AS Total FROM sales WHERE DATE(Date) BETWEEN '$from' AND '$to' AND PaymentMode = 'Coupon'"); 
while($spec=mysqli_fetch_assoc($query)){
$preorder_eaten = $spec['Total'];
echo "<tr id='tr' class='tbody' style='background:#f4f4f4;'>"; 
echo "<td id='td' style='width:60%; font-size:18px; text-shadow:1px 0px 1px #dbdbdb;'>Preorder Eaten</td>";
echo "<td id='td' style='width:20%; font-size:16px; text-shadow:1px 0px 1px #dbdbdb; color:#656565;'>¢ ".$spec['Total']."</td>";
echo "</tr>";
 
}  
                               
$total = $cash_sales + $card_eaten + $preorder_eaten;                            
?>

</table>   

</div>
    
</div>
</div>
    
</div>
    
<div class='row' style="margin-left:px; width:94%; margin-bottom:10px; border: 1px solid #a7a7a7;  margin-left:24px; ">   
<div class='col-md-12' id='results_sales11' style='padding:1px 8px 0px 0px; background:#ffffff;'>
<table id='table' style="margin-left:3px; ">

<?php    

echo "<tr id='tr' class='tbody' style='display:; background:white;'>"; 
echo "<td id='td' style='border-left:none; width:600px; border-top:none;  font-size:17px;'><b>ACTUAL SALES</b>: </td>";
echo "<td id='td' style='width:80%; border-top:none; text-align:right;'>GH <b style='font-size:18px;'><span style='color:#408000;'>¢".$total."</span></b></td>";
echo "</tr>";
   
?>
     
</table>    
</div>
</div>    
          
</div>
    
<?php }?>  
    

    
<p>For enquiries and concerns, please call <br>0302730367 / 0577707889<br>Thank you for your business</p>
</div>

</div>

</div>
    

    

<?php
require_once("footer_print.php");    
?>

<script>
$(document).ready(function(){ 
    
var cash = $('.cash').val();
var card_loading = $('.cardloading').val();
var preorder_payment = $('.preorderpayment').val();
    
var total = parseFloat(cash) + parseFloat(card_loading) + parseFloat(preorder_payment);
$('.total').val(total);
    
    
    
$('#ele1').print();
window.location = "../../supervisors/report1.php";
});
</script>