<?
session_start();
include("../opendb.php");
include("../test.php");
?>
<link rel="stylesheet" href="../style.css" type="text/css" />
<style>
//	tr{background-color:white}
	th{background-color:steelblue;color:white}
.right{text-align:right};
</style>
<center>
<?
if($show)
{
 $dfrom=$y.'-'.$m.'-'.$d;
 $dto=$y1.'-'.$m1.'-'.$d1;
print "<center><h3>PSN TELCON $branch <br>SPARE TRANSFER IN REPORT </H3> From ".datetohtml($dfrom).' to '.datetohtml($dto);
$re=mysqli_query($db,"select * from sparetransin where brcode='$brcode' and entrydate>='$dfrom' and entrydate<='$dto'");
print "<table border=0 cellspacing=1 cellpadding=3 bgcolor='lightsteelblue'> <th>Tr No <th>Tr Date <th>Part Code <th>Part Name";
print "<th>Pur.Ord <br>No <th>Qty <th>From Branch <th>Location";
while($row=mysqli_fetch_array($re))
{
 print "\n<tr bgcolor=white><td>$row[tr_no]</td><td>".datetohtml($row[trdate])."</td><td>$row[partcode]</td>";
 print "<td>$row[partname]</td><td><center>$row[pord_no]</td><td>$row[qty]</td>";
  $br=mysqli_query($db,"select * from branch where brcode='$row[from_branch]'");
  $br_row=mysqli_fetch_row($br);
  print "<td>$br_row[1]</td>\n<td>".getLocation($row[partcode],$brcode)."</td></tr>";
}
return;
}

function getLocation($x,$bc)
{
 $sq="select location from sparelocmast where itemcode='$x' and brcode='$bc'";
 $locres=mysqli_query($db,$sq);//or die(mysqli_error($db));
  $locrow=mysqli_fetch_array($locres);//or die(mysqli_error($db));
   return $locrow[0];
}
?>
<tr><td colspan=10></td>
</table>

<form action='<?print $PHP_SELF?>' name='f1' target='x'>
<table>
<tr><td bgcolor='steelblue' colspan=2><center><b><font color=white>SPARE TRANSFER IN REGISTER</td></tr>
<tr><td>Date From </td><td>dd<input type=text name='d' size=2 value='<?print date("d");?>'>
			mm<input type=text name='m' size=2 value='<?print date("m");?>'>
			yy<input type=text name='y' size=4 value='<?print date("Y");?>'>
</td></tr>
<tr><td>Date To </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>
<th colspan=2><INPUT TYPE=SUBMIT VALUE='SHOW / PRINT' name='show'></td></tr>
</table>
</form>

