<?
 session_start();
 $brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='inde.php'; </script>";
 return;
}
$tr_no=$_REQUEST['tr_no'];
 include("../opendb.php");
 include ("../test.php");
 $re=mysqli_query($db,"select * from sparetransoutexcess where tr_no='$tr_no' and brcode='$brcode' order by partcode");
 $rr=mysqli_fetch_array($re);
 if(mysqli_num_rows($re)<=0)
 {
  print "<center> <font color=red>Record does not exist";
  return;
 }
 $brre=mysqli_query($db,"select * from branch where brcode='$rr[to_branch]'")or die('err2'.mysqli_error($db));
 $brr=mysqli_fetch_array($brre)or die('err3'.mysqli_error($db));

 $brre1=mysqli_query($db,"select * from branch where brcode='$brcode'")or die('err2'.mysqli_error($db));
 $brr1=mysqli_fetch_array($brre1)or die('err3'.mysqli_error($db));

?>
<center>
<style>
th,td,body{font-family:'arial narrow';letter-spacing:1;font-size:16}
</style>

<TABLE width=100% border=0>
<TR><TD>Stock Transfer No: 
<?
//print '['.substr($brcode,0,3).']';
print $tr_no;
?>

</td><td align=right>Date: <?print datetohtml($rr['entrydate'])?></td></tr>
<TR><TD>Ref: 
<?
//print '['.substr($brcode,0,3).']';
print $rr['saprefno'];
?>

</td></TR>
<tr><td colspan=2 align=center><b>PSN AUTOMOTIVE MARKETING Pvt. Ltd </b><BR>
CIN U50300KL1996PTC010842<br>
<?print $brr1['braddr']?><br> <?print $brr1['brcity']?><br><?print $brr1['brstate']?><br>
<u>PH :<?print $brr1['brphone']?></u>
</td></tr>
<tr><td colspan=2 align=center>Reg. Off.:<br>34/652 C1, CIVIL LINE ROAD
PADIVATTOM, EDAPPALLY P.O
COCHIN- 682 024
<br>Ph:0484 4098309 Email :psnsales@eth.net Website:www.psn.in
<tr><td colspan=2 align=center><B>Stock Transfer </b><br></td></tr>
<tr>
<td colspan=2 align=left> Customer:<b> PSN AUTOMOTIVE MARKETING Pvt. Ltd  </b><br>
<blockquote><?print $brr['braddr']?><br> <?print $brr['brcity']?><br><?print $brr['brstate']?><br>
PIN:<?print $brr['brphone']?><br>

GST: <?print $brr['cstno']?>
</td></tr>
</table>
<br>
<table border=1 width=90% cellpadding=2>
<th> No <th>Location <th>Part Code<th>Description of Goods <th>Quantity <th>Rate <th>Amount
<?
$t=0;
$amt=0;
$i=1;
 $re1=mysqli_query($db,"select * from sparetransoutexcess where tr_no='$tr_no' and brcode='$brcode' order by partcode");
 while($row=mysqli_fetch_array($re1))
{
  //$loc=getLocation($row['partcode'],$brcode,$db);
  print "<tr><td>".$i++."</td><td>$loc</td><td>$row[partcode]</td><td>$row[partname]</td><td align=right>".($row['qty']+$row['telcqty'])."</td><td align=right>".putComa($row['amount'])."</td>";
 $qty=($row['qty']+$row['telcqty']);
  print "<td align=right>".putComa($row['amount']*$qty)."</tr>";
  $t+=$qty;
  $aamount=$row['amount']*$qty;
  $amt+=$aamount;
}
print "<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td align=right><b>Total </td><td align=right><b>$t Nos</td><td>&nbsp;</td><td align=right><b>".putComa($amt)."</td></tr>";
?>
</table>
</center><br>
Amount chargeable (in words)
Rs <?print word($amt)?> ONLY
<?
?>
<table width=100%>
<tr><td>Company's PAN : <?print $brr1['tin']?></td></tr>
<tr><td>Company's GST No :<?print $brr1['cstno']?></td></tr>
<BR>
<tr><td></td></tr>
<tr><td>Declaration</td><td align=right>for PSN AUTOMOTIVE MARKETING P LTD</td></tr>
<tr><td colspan=2> We declare that this invoice shows the actual price of the goods described and <br>that all particulars are true and correct</td> </tr>
<tr><td colspan=2 align=right>Authorised Signatory</td></tr>

<?
 function getLocation($cde,$br)
 {
  $sql="select location from sparelocmast where itemcode='$cde' and brcode='$br'";
  $locre=mysqli_query($db,$sql)or die(mysqli_error($db));
  $locrow=mysqli_fetch_array($locre);
  return $locrow[0];
 }
?>

