<?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>Total Quantities Sold</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;'>DishName</th>
<th id='th'style='width:10.5%; background:#9f9f9f; color:#f2f2f2; border: 1px solid #9f9f9f; text-shadow:1px 0px 1px #747474; font-size:16px;'>Dish Category</th>
<th id='th'style='width:5px; background:#bbbfa5; color:#efefef; border: 1px solid #bbbfa5; text-shadow:1px 0px 1px #747474;'>Qty Sold</th>
</tr>       
<?php    
$query=mysqli_query($conn, "SELECT *,SUM(Quantity) AS Total FROM sales WHERE DATE(Date)=DATE(NOW()) AND TransactionStatus = 'Completed' GROUP BY DishName ORDER BY Total DESC"); 
while($spec=mysqli_fetch_assoc($query)){
echo "<tr id='tr' class='tbody' style='background:#f4f4f4;'>"; 
echo "<td id='td' style='width:50%; font-size:18px; text-shadow:1px 0px 1px #dbdbdb;'>".$spec['DishName']."</td>";
echo "<td id='td' style='width:30%; font-size:16px; text-shadow:1px 0px 1px #dbdbdb; color:#a0a0a0'>".$spec['Category']."</td>";
echo "<td id='td' style='width:20%; font-size:16px; text-shadow:1px 0px 1px #dbdbdb; color:#656565;'>".$spec['Total']."</td>";
echo "</tr>";
}  
                                                   
?>

</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:3px;">

<?php    
$query=mysqli_query($conn, "SELECT *,SUM(Quantity) AS Total FROM sales WHERE DATE(Date)=DATE(NOW()) AND TransactionStatus = 'Completed'"); 
while($spec=mysqli_fetch_assoc($query)){
echo "<tr id='tr' class='tbody' style='display:; background:white;'>"; 
echo "<td id='td' style='border-left:none; width:800px; border-top:none;font-size:17px;'><b>TOTAL QT'IES SOLD</b>: </td>";
echo "<td id='td' style='border-right:none; width:70%; border-top:none; text-align:right;'>".$spec['Total']."</span></b></td>";
echo "</tr>";
}
?>
     
</table>    
</div>
</div>    

  

<div class='col-md-5' style='margin-left:6px;'>

<?php 
    
$query1=mysqli_query($conn, "SELECT *,SUM(Quantity) AS Total FROM sales WHERE DATE(Date)=DATE(NOW()) AND TransactionStatus = 'Completed'  GROUP BY Vendor ORDER BY Total DESC"); 
while($spec=mysqli_fetch_assoc($query1)){    
$vendor = $spec['Vendor'];
    
    
echo "<div class='row text-center'>
<div class='col-md-12' style='padding:1px;'>
<h2><u>".$vendor."</u></h2>
</div>
</div>";
    
echo "
<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:15px; width:93.4%'>";

echo "<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;'>DishName</th>
<th id='th'style='width:20.5%; background:#9f9f9f; color:#f2f2f2; border: 1px solid #9f9f9f; text-shadow:1px 0px 1px #747474; font-size:16px;'>Dish Category</th>
<th id='th'style='width:5px; background:#bbbfa5; color:#efefef; border: 1px solid #bbbfa5; text-shadow:1px 0px 1px #747474;'>Qty Sold</th>
</tr>";           
    
$query=mysqli_query($conn, "SELECT *,SUM(Quantity) AS Total FROM sales WHERE DATE(Date)=DATE(NOW()) AND TransactionStatus = 'Completed' AND Vendor = '$vendor'  GROUP BY DishName ORDER BY Total DESC"); 
while($spec=mysqli_fetch_assoc($query)){
    

echo "<tr id='tr' class='tbody' style='background:#ede8d5;'>"; 
echo "<td id='td' style='width:40%; font-size:18px; text-shadow:1px 0px 1px #dbdbdb;'>".$spec['DishName']."</td>";
echo "<td id='td' style='width:30%; font-size:16px; text-shadow:1px 0px 1px #dbdbdb; color: #a3a3a3;'>".$spec['Category']."</td>";
echo "<td id='td' style='width:20%; font-size:16px; text-shadow:1px 0px 1px #dbdbdb; color:#656565;'> ".$spec['Total']."</td>";
echo "</tr>";
    

 
}
    
echo "</table>   
      </div>
      </div>
      </div>
      </div>";
    
echo "<div class='row' style='margin-left:px; width:93%; 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:3px;'>";
   
$query=mysqli_query($conn, "SELECT *,SUM(Quantity) AS Total FROM sales WHERE DATE(Date)=DATE(NOW()) AND TransactionStatus = 'Completed' AND Vendor = '$vendor'"); 
while($spec=mysqli_fetch_assoc($query)){                               
echo "<tr id='tr' class='tbody' style='display:; background:white;'>"; 
echo "<td id='td' style='border-left:none; width:800px; border-top:none;font-size:17px;'><b>TOTAL QTY SOLD</b>: </td>";
echo "<td id='td' style='border-right:none; width:70%; border-top:none; text-align:right;'><b style='font-size:18px;'><span style='color:#408000;'>".$spec['Total']."</span></b></td>";
echo "</tr>";
}  
echo "</table>    
</div>
</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>Total Quantities Sold</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;'>DishName</th>
<th id='th'style='width:10.5%; background:#9f9f9f; color:#f2f2f2; border: 1px solid #9f9f9f; text-shadow:1px 0px 1px #747474; font-size:16px;'>Dish Category</th>
<th id='th'style='width:5px; background:#bbbfa5; color:#efefef; border: 1px solid #bbbfa5; text-shadow:1px 0px 1px #747474;'>Qty Sold</th>
</tr>       
<?php    
$query=mysqli_query($conn, "SELECT *,SUM(Quantity) AS Total FROM sales WHERE DATE(Date) = '$from' AND TransactionStatus = 'Completed' GROUP BY DishName ORDER BY Total DESC"); 
while($spec=mysqli_fetch_assoc($query)){
echo "<tr id='tr' class='tbody' style='background:#f4f4f4;'>"; 
echo "<td id='td' style='width:50%; font-size:18px; text-shadow:1px 0px 1px #dbdbdb;'>".$spec['DishName']."</td>";
echo "<td id='td' style='width:30%; font-size:16px; text-shadow:1px 0px 1px #dbdbdb; color:#a0a0a0'>".$spec['Category']."</td>";
echo "<td id='td' style='width:20%; font-size:16px; text-shadow:1px 0px 1px #dbdbdb; color:#656565;'>".$spec['Total']."</td>";
echo "</tr>";
}  
                                                   
?>

</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:3px;">

<?php    
$query=mysqli_query($conn, "SELECT *,SUM(Quantity) AS Total FROM sales WHERE DATE(Date) = '$from' AND TransactionStatus = 'Completed'"); 
while($spec=mysqli_fetch_assoc($query)){
echo "<tr id='tr' class='tbody' style='display:; background:white;'>"; 
echo "<td id='td' style='border-left:none; width:800px; border-top:none;font-size:17px;'><b>TOTAL QT'IES SOLD</b>: </td>";
echo "<td id='td' style='border-right:none; width:70%; border-top:none; text-align:right;'>".$spec['Total']."</span></b></td>";
echo "</tr>";
}
?>
     
</table>    
</div>
</div>    

  

<div class='col-md-5' style='margin-left:6px;'>

<?php 
    
$query1=mysqli_query($conn, "SELECT *,SUM(Quantity) AS Total FROM sales WHERE DATE(Date) = '$from' AND TransactionStatus = 'Completed'  GROUP BY Vendor ORDER BY Total DESC"); 
while($spec=mysqli_fetch_assoc($query1)){    
$vendor = $spec['Vendor'];
    
    
echo "<div class='row text-center'>
<div class='col-md-12' style='padding:1px;'>
<h2><u>".$vendor."</u></h2>
</div>
</div>";
    
echo "
<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:15px; width:93.4%'>";

echo "<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;'>DishName</th>
<th id='th'style='width:20.5%; background:#9f9f9f; color:#f2f2f2; border: 1px solid #9f9f9f; text-shadow:1px 0px 1px #747474; font-size:16px;'>Dish Category</th>
<th id='th'style='width:5px; background:#bbbfa5; color:#efefef; border: 1px solid #bbbfa5; text-shadow:1px 0px 1px #747474;'>Qty Sold</th>
</tr>";           
    
$query=mysqli_query($conn, "SELECT *,SUM(Quantity) AS Total FROM sales WHERE DATE(Date) = '$from' AND TransactionStatus = 'Completed' AND Vendor = '$vendor'  GROUP BY DishName ORDER BY Total DESC"); 
while($spec=mysqli_fetch_assoc($query)){
    

echo "<tr id='tr' class='tbody' style='background:#ede8d5;'>"; 
echo "<td id='td' style='width:40%; font-size:18px; text-shadow:1px 0px 1px #dbdbdb;'>".$spec['DishName']."</td>";
echo "<td id='td' style='width:30%; font-size:16px; text-shadow:1px 0px 1px #dbdbdb; color: #a3a3a3;'>".$spec['Category']."</td>";
echo "<td id='td' style='width:20%; font-size:16px; text-shadow:1px 0px 1px #dbdbdb; color:#656565;'> ".$spec['Total']."</td>";
echo "</tr>";
    

 
}
    
echo "</table>   
      </div>
      </div>
      </div>
      </div>";
    
echo "<div class='row' style='margin-left:px; width:93%; 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:3px;'>";
   
$query=mysqli_query($conn, "SELECT *,SUM(Quantity) AS Total FROM sales WHERE DATE(Date) = '$from' AND TransactionStatus = 'Completed' AND Vendor = '$vendor'"); 
while($spec=mysqli_fetch_assoc($query)){                               
echo "<tr id='tr' class='tbody' style='display:; background:white;'>"; 
echo "<td id='td' style='border-left:none; width:800px; border-top:none;font-size:17px;'><b>TOTAL QTY SOLD</b>: </td>";
echo "<td id='td' style='border-right:none; width:70%; border-top:none; text-align:right;'><b style='font-size:18px;'><span style='color:#408000;'>".$spec['Total']."</span></b></td>";
echo "</tr>";
}  
echo "</table>    
</div>
</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>Total Quantities Sold</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;'>DishName</th>
<th id='th'style='width:10.5%; background:#9f9f9f; color:#f2f2f2; border: 1px solid #9f9f9f; text-shadow:1px 0px 1px #747474; font-size:16px;'>Dish Category</th>
<th id='th'style='width:5px; background:#bbbfa5; color:#efefef; border: 1px solid #bbbfa5; text-shadow:1px 0px 1px #747474;'>Qty Sold</th>
</tr>       
<?php    
$query=mysqli_query($conn, "SELECT *,SUM(Quantity) AS Total FROM sales WHERE DATE(Date) BETWEEN '$from' AND '$to' AND TransactionStatus = 'Completed' GROUP BY DishName ORDER BY Total DESC"); 
while($spec=mysqli_fetch_assoc($query)){
echo "<tr id='tr' class='tbody' style='background:#f4f4f4;'>"; 
echo "<td id='td' style='width:50%; font-size:18px; text-shadow:1px 0px 1px #dbdbdb;'>".$spec['DishName']."</td>";
echo "<td id='td' style='width:30%; font-size:16px; text-shadow:1px 0px 1px #dbdbdb; color:#a0a0a0'>".$spec['Category']."</td>";
echo "<td id='td' style='width:20%; font-size:16px; text-shadow:1px 0px 1px #dbdbdb; color:#656565;'>".$spec['Total']."</td>";
echo "</tr>";
}  
                                                   
?>

</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:3px;">

<?php    
$query=mysqli_query($conn, "SELECT *,SUM(Quantity) AS Total FROM sales WHERE DATE(Date) BETWEEN '$from' AND '$to' AND TransactionStatus = 'Completed'"); 
while($spec=mysqli_fetch_assoc($query)){
echo "<tr id='tr' class='tbody' style='display:; background:white;'>"; 
echo "<td id='td' style='border-left:none; width:800px; border-top:none;font-size:17px;'><b>TOTAL QT'IES SOLD</b>: </td>";
echo "<td id='td' style='border-right:none; width:70%; border-top:none; text-align:right;'>".$spec['Total']."</span></b></td>";
echo "</tr>";
}
?>
     
</table>    
</div>
</div>    

  

<div class='col-md-5' style='margin-left:6px;'>

<?php 
    
$query1=mysqli_query($conn, "SELECT *,SUM(Quantity) AS Total FROM sales WHERE DATE(Date) BETWEEN '$from' AND '$to' AND TransactionStatus = 'Completed'  GROUP BY Vendor ORDER BY Total DESC"); 
while($spec=mysqli_fetch_assoc($query1)){    
$vendor = $spec['Vendor'];
    
    
echo "<div class='row text-center'>
<div class='col-md-12' style='padding:1px;'>
<h2><u>".$vendor."</u></h2>
</div>
</div>";
    
echo "
<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:15px; width:93.4%'>";

echo "<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;'>DishName</th>
<th id='th'style='width:20.5%; background:#9f9f9f; color:#f2f2f2; border: 1px solid #9f9f9f; text-shadow:1px 0px 1px #747474; font-size:16px;'>Dish Category</th>
<th id='th'style='width:5px; background:#bbbfa5; color:#efefef; border: 1px solid #bbbfa5; text-shadow:1px 0px 1px #747474;'>Qty Sold</th>
</tr>";           
    
$query=mysqli_query($conn, "SELECT *,SUM(Quantity) AS Total FROM sales WHERE DATE(Date) BETWEEN '$from' AND '$to' AND TransactionStatus = 'Completed' AND Vendor = '$vendor'  GROUP BY DishName ORDER BY Total DESC"); 
while($spec=mysqli_fetch_assoc($query)){
    

echo "<tr id='tr' class='tbody' style='background:#ede8d5;'>"; 
echo "<td id='td' style='width:40%; font-size:18px; text-shadow:1px 0px 1px #dbdbdb;'>".$spec['DishName']."</td>";
echo "<td id='td' style='width:30%; font-size:16px; text-shadow:1px 0px 1px #dbdbdb; color: #a3a3a3;'>".$spec['Category']."</td>";
echo "<td id='td' style='width:20%; font-size:16px; text-shadow:1px 0px 1px #dbdbdb; color:#656565;'> ".$spec['Total']."</td>";
echo "</tr>";
    

 
}
    
echo "</table>   
      </div>
      </div>
      </div>
      </div>";
    
echo "<div class='row' style='margin-left:px; width:93%; 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:3px;'>";
   
$query=mysqli_query($conn, "SELECT *,SUM(Quantity) AS Total FROM sales WHERE DATE(Date) BETWEEN '$from' AND '$to' AND TransactionStatus = 'Completed' AND Vendor = '$vendor'"); 
while($spec=mysqli_fetch_assoc($query)){                               
echo "<tr id='tr' class='tbody' style='display:; background:white;'>"; 
echo "<td id='td' style='border-left:none; width:800px; border-top:none;font-size:17px;'><b>TOTAL QTY SOLD</b>: </td>";
echo "<td id='td' style='border-right:none; width:70%; border-top:none; text-align:right;'><b style='font-size:18px;'><span style='color:#408000;'>".$spec['Total']."</span></b></td>";
echo "</tr>";
}  
echo "</table>    
</div>
</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(){ 
$('#ele1').print();
window.location = "../../supervisors/quantity_sold.php";
});
</script>