<?php
include('session.php');
include('/home/armeatsh/etc/pw.php');	
@session_start();
?>

<!DOCTYPE html>
<!-- Website template by freewebsitetemplates.com -->
<html>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>A&R Meatshop</title>

<link rel="stylesheet" type="text/css" href="chrometheme/chromestyle.css" />

<link rel="stylesheet" type="text/css" href="datepicker/print.css" />
<script type="text/javascript" src="datepicker/print.js"></script> 

<script src="filter/app.js" type="text/javascript" charset="utf-8"></script>
		<script src="filter/application.js" type="text/javascript" charset="utf-8"></script>

<link rel="stylesheet" type="text/css" href="facebox/facebox.css" />
		<script language="javascript" src="facebox/facebox.js"></script>

		<script language="javascript">
		jQuery(document).ready(function($) {
			  $('a[rel*=facebox]').facebox({
				loadingImage : 'facebox/loading.gif',
			
			  })
			})
		</script>

<script type="text/javascript" src="chromejs/chrome.js">

/***********************************************
* Chrome CSS Drop Down Menu- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

</script>
<style>
tr:nth-child(even) {
  background-color: #dddddd;
}
</style>

</head>
<body>

<?php
if(isset($_POST['daily']))
{

		$startDate = $_POST['startDate'];
		$endDate = $_POST['endDate'];
		$branch = $_POST['branch'];
		$group = $_POST['group'];

}
?>


	<script type="text/javascript">
	cssdropdown.startchrome("chromemenu")
	</script>
			<center>
			<div id="contents">
				<h1>A&R MEATSHOP</h1>
        </div>
        <div id="tooplate_content">
            <h2>Total Sales of <?php echo $group; ?>  Products from <?php echo $startDate; ?> To <?php echo $endDate; ?> for <?php echo $branch; ?></br>
            
            </h2>
            <table cellpadding='2px' border='0' width='70%'>

			<tr bgcolor='#5e8ce9'>
				<td  align='left' width='20%'><font face='verdana' size='2px' ><b>PRODUCT</b></font></td>
				<td  align='left' width='5%'><font face='verdana' size='2px' ><b>UNIT</b></font></td>
				<td  align='right' width='5%'><font face='verdana' size='2px' ><b>QTY</b></font></td> 
				<td  align='right' width='5%'><font face='verdana' size='2px' ><b>AMOUNT</b></font></td>
				
			</tr>
			
				<?php
				
				$totalQty = 0;
				$totalAmount = 0;
				$totalSales = $query->query("SELECT product, sum(qty) as qty, unit, sum(qty*price) as amount from dailySalesNoHours where branch = '$branch' 
				        and productGroup = '$group' and date >= '$startDate' and date <= '$endDate' group by product ORDER BY product asc");
					while($sale = mysqli_fetch_array($totalSales))
					{
					    $totalQty += $sale['qty'];
					    $totalAmount += $sale['amount'];
						echo"
							<tr>
							<td align='left'><font face='verdana' size='2px' >$sale[product]</font></td>
							<td align='left'><font face='verdana' size='2px' >$sale[unit]</font></td>
							<td align='right'><font face='verdana' size='2px' >$sale[qty]</font></td>
							<td align='right'><font face='verdana' size='2px' >" . number_format($sale['amount'], 2) . "</font></td></tr>";
					}
					echo "<tr><td colspan='2'>TOTALS ====>>></td><td align='right'>" . number_format($totalQty, 2) . "</td><td align='right'>" 
					    . number_format($totalAmount, 2) . "</td></tr>";  
	
				?>
				

			
			
	</div>
</body>
</html>