<?
session_start();
if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='../index.html'; </script>";
 return;
}
include("../opendb.php");
include("../test.php");
if($show)
{
?>
<style>

	td,th,body{font-size:14;font-family:'arial narrow';letter-spacing:1}
</style>
<center>
<?
 $dfrom=$y1.'-'.$m1.'-'.$d1;
 $dto=$y2.'-'.$m2.'-'.$d2;

$brres=mysqli_query($db,"select * from branch where brcode='$brcode'");
$brrow=mysqli_fetch_array($brres);
?>
<table>
<TR><TD COLSPAN=2 ALIGN=CENTER><b> PSN CONSTRUCTION EQUIPMENTS P LTD </b><BR>
	 <?print $brrow[braddr].",".$brrow[brcity].",<br><u> PH - ".$brrow[brphone]?></u>
TIN: <?print $brrow[tin]?>, CST: <?print $brrow[cstno]?>&nbsp;
</td></tr>
<tr><td COLSPAN=2 ALIGN=CENTER>
<?print "<h4><br>SPARE ORDER REPORT</H4>";

print " from ".datetohtml($dfrom).' to '.datetohtml($dto);
?>
</td></tr>
</table>

<?
$invre=mysqli_query($db,"select distinct brcode from saleorder_spare" );
while($invrow=mysqli_fetch_array($invre))
{
$gtot1=0;
$ttx=0;
$tcess=0;
$ttot=0;
$ttrnd=0;
$re=mysqli_query($db,"select * from saleorder_spare  where brcode='$invrow[0]' and date>='$dfrom' and date<='$dto'")or die('err'.mysqli_error());
print "<table border=0 cellspacing=1 cellpadding=4 bgcolor='lightsteelblue'>";
print "<th colspan=10><h3>Branch Code $invrow[0]</th></tr>";
print " <th>Order No <th>Order Date ";
print "<th>Customer<th>Partcode <th>Partname <th>Qty<th>Supplied<th>Closed";
while($row=mysqli_fetch_array($re))
{
 print "\n<tr bgcolor=white><td>$row[orderno]</td><td>".datetohtml($row[date]);
 print "<td>".strtoupper($row[orderto])."</td>";
 print "<td>".strtoupper($row[partcode])."</td>";
 print "<td>".strtoupper($row[partname])."</td>";
 print "<td>".strtoupper($row[qty])."</td>";
 print "<td>".strtoupper($row[sup_qty])."</td>";
 print "<td>".strtoupper($row[closed])."</td>";
  




}
}

 print "</tr></table><br>";

return;
}// end if
?>

<link rel="stylesheet" href="../style.css" type="text/css" />
<style>
//	tr{background-color:white}
	th{background-color:steelblue;color:white}
	td{font-size:13}
.right{text-align:right};
</style>

<center>
<h3>SALE ORDER REPORT</H3>
<form action='<?Print $PHP_SELF?>' method='post'>
<table cellspacing=1 cellpadding=1 bgcolor='steelblue'>
<tr><td bgcolor='white' align=center>
<table class=noprint>
<tr><td>Date from </td><td>dd <input type=text name='d1' size=2 value='<?print date("d")?>'>
mm <input type=text name='m1' size=2 value='<?print date("m")?>'>
yy <input type=text name='y1' size=4 value='<?print date("Y")?>'></td></tr>

<tr><td align=right>to </td><td>dd <input type=text name='d2' size=2 value='<?print date("d")?>'>
mm <input type=text name='m2' size=2 value='<?print date("m")?>'>
yy <input type=text name='y2' size=4 value='<?print date("Y")?>'>
</td></tr>

<tr><td colspan=2 align=center bgcolor='lightsteelblue'><input type=submit value='Show' name='show'></td></tr>
</table>
</td></tr>
</table>
</form>

