<?session_start();
if(strlen($brcode)<=0)
{
  print "<script> alert('Invalid User'); parent.document.location='ind.php' </script>";
  return;
}

include("opendmsdb.php");
include("../test.php");
?>
<link rel="stylesheet" href="style.css" type="text/css" />
<style>
body,td{font-family:'arial narrow';letter-spacing:1;font-size:.8em}
th{background-color:c1d799;font-size:.8em}
.mnu{margin-left:5}
</style>
<center>
<form action='<?print $PHP_SELF?>'>
<table>
<th colspan=2> SEARCH STOCK</th>
<tr><td>Part Code </td><td><input type=text name='pcode' size=30></td></tr>
<th colspan=2><input type=submit value='Search' name='sea'> <input type=button value='Cancel' onClick=document.location='blank.html'></th>
</table>
</form>

<?
if($sea)
{
if(strlen($pcode)<=0)
{
 print "<script>alert('Invalid Partcode'); </script>";
 return;
}
$res=mysqli_query($db,"select distinct a.brcode,a.brname,b.upddate from branch a,dailystock b where a.brcode=b.brcode order by a.brcode")or die(mysqli_error());
while($brrow=mysqli_fetch_array($res))
{
 $sql="select * from dailystock where partcode like '$pcode%' and brcode='$brrow[0]'";

 $rr=mysqli_query($db,$sql) or die(mysqli_error());
  if(mysqli_num_rows($rr)>0)
  {
   print "<h3>STOCK AT <FONT COLOR=DARK BROWN>$brrow[1]</FONT> <br>Updated on ".$brrow[2]."</h3>";
?>
<table cellspacing=1 cellpadding=1 bgcolor=gray width=100%>
<th width=10>No <th width=30>Location <th width=60>Part Code <th>Part Name <th>Unit <th>ROL <th>Opening Bal <th>INW Qty
<th>OUT Qty <th>Bal Qty <th>NDP Rate <th>Total 
<?
$i=1;
$tb=0;
$tinw=$toutw=$tbal=$tndp=0;
$gt=0;
    while($row=mysqli_fetch_array($rr))
     {
print "<tr BGCOLOR=WHITE><td align=center>".$i++."</td><td>$row[2]</td><td>$row[3]</td><td>$row[4]</td>";
 print "<td align=center>$row[5]</td><td align=center>$row[6]</td><td align=right>$row[7]</td>";
 print "<td align=right>$row[8]</td><td align=right>$row[9]</td>";
 print "<td align=right>$row[10]</td><td align=right>$row[11]</td><td align=right>$row[12]</td>";
 print "</tr>";
 $tb+=$row[opbal];
 $tinw+=$row[inwqty];
 $toutw+=$row[outwqty];
 $tbal+=$row[balqty];
 $tndp+=$row[ndprate];
 $gt+=$row[tot];
}
 print "<tr bgcolor=c1d799><td colspan=6 align=center><b>Total</td><td align=right>".putComa($tb)."</td>";
print "<td align=right>".putComa($tinw)."</td><td align=right>".putComa($toutw)."</td>";
print "<td align=right>".putComa($tbal)."</td><td align=right>".putComa($tndp)."</td>";
print "<td align=right>".putComa($gt)."</td>";

print "</table>";
}
}
}
?>


