<?
session_start();
include_once('opendb.php');
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
//$br=$_SESSION['branch'];
if(strlen($user)<=0)
{
  print "<script> alert('Invalid User'); document.location='inde.php' </script>";
  return;
}

?>
<link href="css/form.css" type="text/css" rel="stylesheet" media="screen"  />
<html>
<body >

<title>Sale Summary Report</title>
<link rel="stylesheet" href="style.css" type="text/css" />
<script type="text/javascript" src="scripts/jquery-latest.js"></script>
<link type="text/css" href="includes/style1.css" rel="stylesheet" />

<script type="text/javascript">
$(function() {
if ($.browser.msie && $.browser.version.substr(0,1)<7)
{
	$('li').has('ul').mouseover(function(){
	$(this).children('ul').show();
	}).mouseout(function(){
	$(this).children('ul').hide();
	})
        }
});        
</script>
<script>
function valid()
{
}
</script>
<style>
#txt{
font-family: Arial, Helvetica;
background-color: #F2F2F2;
}
</style>
<link rel="stylesheet" type="text/css" media="all" href="jsDatePick_ltr.min.css" />
<script type="text/javascript" src="jsDatePick.min.1.3.js"></script>
<script type="text/javascript">
window.onload = function(){
new JsDatePick({
	useMode:2,
	target:"inputField",
	dateFormat:"%Y-%m-%d"
});
new JsDatePick({
	useMode:2,
	target:"inputField1",
	dateFormat:"%Y-%m-%d"
});
            
};
</script>

<SCRIPT LANGUAGE="JavaScript" SRC="util/PopupWindow.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="util/AnchorPosition.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="util/CalendarPopup.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="util/date.js"></SCRIPT>
<script>

var cal1 = new CalendarPopup();
cal1.showYearNavigation();

var cal2 = new CalendarPopup();
cal2.showYearNavigation();

</script>
<style>
    table.report td
{
 border:1px solid black;
}
.tdcls td
{
border:1px solid black;
font-family:Calibri;

}
th{
    // background-color: grey;
    font-weight: bold;
    color: white;
    border:1px solid #D7D7D1;
    border-collapse:collapse;
background: rgb(181,189,200); /* Old browsers */
background: -moz-linear-gradient(top, rgba(181,189,200,1) 0%, rgba(130,140,149,1) 36%, rgba(40,52,59,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(181,189,200,1)), color-stop(36%,rgba(130,140,149,1)), color-stop(100%,rgba(40,52,59,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(181,189,200,1) 0%,rgba(130,140,149,1) 36%,rgba(40,52,59,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(181,189,200,1) 0%,rgba(130,140,149,1) 36%,rgba(40,52,59,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(181,189,200,1) 0%,rgba(130,140,149,1) 36%,rgba(40,52,59,1) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(181,189,200,1) 0%,rgba(130,140,149,1) 36%,rgba(40,52,59,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#b5bdc8', endColorstr='#28343b',GradientType=0 ); /* IE6-9 */
}

table.report td
{	
    font-family:Calibri;

}
</style>
<body onload='window.print()'>
<?php //include('logo2.php'); ?>
<?php //include('includes/top.php'); ?>
<form action='<?print $PHP_SELF?>' method='post' >
<table class="container" ><tr><td>
<center>

<?
//$date = new DateTime('$df');
//$mfrom_date = $date->format('d-m-Y');
$df=$_REQUEST['df'];
$dt=$_REQUEST['dt'];
$mfrom_date = substr($df,8,2)."-".substr($df,5,2)."-".substr($df,0,4);
$mto_date  = substr($dt,8,2)."-".substr($dt,5,2)."-".substr($dt,0,4);
?>
<table>
<tr><td >SALES SUMMARY REPORT from <?print $mfrom_date?> to <?print $mto_date?> </td></tr>
</table>
<?
$tbl='sales_summ'.$brcode.$user;
$qry=mysqli_query($db,"select * from $tbl");
print "<table class='report' border=1>";
print "<tr><th>Group Name</th><th>Amount</th><th>MDA</th><th>State Rebate Normal</th><th>State Rebate Spl</th><th>Reduction</th><th>Net Cash</th><th>Tax</th><th>Total Amount</th><th>Debtors</th>";
$mtot_total = 0;
$mtot_mba= 0;
$mtot_strbtnml = 0;
$mtot_strbtspl = 0;
$mtot_redct = 0;
$mtot_befrtx = 0;
$mtot_taxamt = 0;
$mtot_nettot = 0;
$mtot_dbtr = 0;
while($row=mysqli_fetch_array($qry))
{  
	print "<tr><td>$row[0]</td><td align='right'>$row[1]</td><td align='right'>$row[2]</td><td align='right'>$row[3]</td><td align='right'>$row[4]</td><td align='right'>$row[5]</td><td align='right'>$row[6]</td><td align='right'>$row[7]</td><td align='right'>$row[8]</td><td align='right'>$row[9]</td></tr>";
	$mtot_total += $row[1];
	$mtot_mba += $row[2];
	$mtot_strbtnml += $row[3];
	$mtot_strbtspl += $row[4];
	$mtot_redct += $row[5];
	$mtot_befrtx += $row[6];
	$mtot_taxamt += $row[7];
	$mtot_nettot += $row[8];$mtot_dbtr += $row[9];
}
print "<tr><td><b>Grand Total</td><td align='right'><b>".number_format($mtot_total, 2, '.', '')."</td><td align='right'><b>".number_format($mtot_mba, 2, '.', '')."</td><td align='right'><b>".number_format($mtot_strbtnml, 2, '.', '')."</td><td align='right'><b>".number_format($mtot_strbtspl, 2, '.', '')."</td><td align='right'><b>".number_format($mtot_redct, 2, '.', '')."</td><td align='right'><b>".number_format($mtot_befrtx, 2, '.', '')."</td><td align='right'><b>".number_format($mtot_taxamt, 2, '.', '')."</td><td align='right'><b>".number_format($mtot_nettot, 2, '.', '')."</td><td align='right'><b>".number_format($mtot_dbtr, 2, '.', '')."</td></tr>";
?>
</table>