<?
session_start();
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='../ind.php'; </script>";
 return;
}
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(isset($_POST['show']))
{
$d1=$_REQUEST['d1'];
$m1=$_REQUEST['m1'];
$y1=$_REQUEST['y1'];

$d2=$_REQUEST['d2'];
$m2=$_REQUEST['m2'];
$y2=$_REQUEST['y2'];
 $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 AUTOMOBILES PVT 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>
</td></tr>
</table>

<h3>STOCK TRANSFER INWARD</H3>
<? print " from ".datetohtml($dfrom).' to '.datetohtml($dto);
?>

<?
$sq="select tr_no, sum(a.qty),sum(amount*qty),b.brname,a.entrydate from sparetransin a,branch b where a.from_branch=b.brcode and a.brcode='$brcode' and a.entrydate>='$dfrom' and a.entrydate<='$dto' group by tr_no";
//print $sq;
$re=mysqli_query($db,$sq)or die(mysqli_error($db));
print "<table border=0 cellspacing=1 cellpadding=3 bgcolor='lightsteelblue'>";
print "<th>Tr No <th>Date <th>Branch <th>Amount";
while($row=mysqli_fetch_array($re))
{
 print "<tr bgcolor=white><td>$row[tr_no]</td><td>".datetohtml($row[entrydate])."</td>";
 print "<td>$row[3]</td><td align=right>$row[2]</td>";
 print "</tr>";
 $tqty+=$row[1];
 $tamt+=$row[2];
}
?>
<tr><td colspan=3><center><b>Total</td>
 <td align=right><b><?print putComa($tamt)?></td></tr>
</table>
<?
 return;
} // end if show
?>

<center>
<h3>STOCK TRANSFER INWARD</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>
