<? 
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;
}
$jvno=$_REQUEST['jvno'];
$crno=$_REQUEST['crno'];
$lednm=$_REQUEST['lednm'];
$custname=$_REQUEST['custname'];
$dd=$_REQUEST['dd'];
$mm=$_REQUEST['mm'];
$yy=$_REQUEST['yy'];
$crnotedt=$dd.'-'.$mm.'-'.$yy;
$totamt=$_REQUEST['totamt'];
$beframt=$_REQUEST['beframt'];
$taxp=$_REQUEST['taxp'];
$taxamt=round(($beframt*$taxp)/100,2);
$descript=$_REQUEST['descript'];
include("opendb.php");
include("test.php");
$ad=mysqli_query($db,"select * from branch where brcode='$brcode'");
$brrow=mysqli_fetch_array($ad);
$brname=explode(',',$branch);
if(($user=='kishore'||$user=='shahul')&&($brcode=='3776'||$brcode=='3810'))
{
?>
<br>
<center>
<table width=90% >
<tr><td align=center><p style={letter-spacing:2;font-size:15}><b>PSN AUTOMOTIVE MARKETING PRIVATE Ltd</TD></TR>
<TR><TD ALIGN=CENTER><font size=2>AUTHORISED DEALER FOR EICHER VEHICLES
</td></TR>

<TR><TD ALIGN=CENTER><font size=2><?print strtoupper($brrow['braddr'])?><br><?print strtoupper($brrow[4])?><br>Phone :<?print strtoupper($brrow[5])?><br>GSTIN :<?print strtoupper($brrow['cstno'])?></td></tr>
<tr><td align=center><br><U>CREDIT NOTE </U></TD></TR>
</table>
</center>

<br>
<left>

</left>
<table width=100%><tr><td >&nbsp&nbsp</td><td >
<?

//print $row1[1];
$re=mysqli_query($db,"select * from journal2 where brcode='$brcode' and jvno='$jvno' and type='Cr' and cramt>0");
$re3=mysqli_query($db,"select * from crnote where dbno='$jvno' and brcode='$brcode'") or die(mysqli_error($db));
  $rsrow=mysqli_fetch_array($re);

$re3c=mysqli_query($db,"select * from customer where acname='$custname'") or die(mysqli_error($db));
  $rsrowc=mysqli_fetch_array($re3c);
  
print "<table bgcolor='' border=0 cellspacing=0 cellpadding=5 width=90%> <font size=2><tr><td>Credit Note  No :&nbsp;$crno</td><td align='center'>&nbsp&nbsp&nbsp&nbspDate :&nbsp;".$crnotedt."</td> </tr></table><br>";
?>

<table  width=90%>
<tr><td align=left><p style={letter-spacing:2;font-size:15}><b><? print $rsrowc['acname']?></TD></TR>
<tr><td align=left><p style={letter-spacing:2;font-size:15}><b><? print $rsrowc['addr1']?></TD></TR>
<tr><td align=left><p style={letter-spacing:2;font-size:15}>GSTIN : <b><? print $rsrowc['cst']?></TD></TR>

</table><br>

<?

print "<table bgcolor='ivory' border=1 cellspacing=1 cellpadding=0 width=90%> <font size=2><tr><b> <td width=20><font size=2>Sr.No </td> <td width=200><font size=2>Account Head </td><td width=300><font size=2>Details</td><td width=100 ><font size=2>Before Tax Amount</td><td width=100 ><font size=2>TAX%</td><td width=100 ><font size=2>TAX Amount</td><td width=100 ><font size=2>Total</td></b></tr></table> ";
print "<table bgcolor='ivory' border=0 cellspacing=1 cellpadding=1 width=90%>";

    
        print "\n<tr><td width=20><font size=3>1 </td><td width=200><font size=3>$lednm </td>";
        print "<td width=1></td><td width=300 align=left><font size=3>$descript</td>";
        print "<td width=1></td><td width=100 align=left><font size=3>".nozero($beframt)."</td><td width=100 align=left><font size=3>".nozero($taxp)."</td><td width=100 align=left><font size=3>".nozero($taxamt)."</td><td width=100 align=left><font size=3>".nozero($totamt)."</td></tr>";
  
  
     //print "<tr><td colspan=9 bgcolor=''></td></tr>";
print "<tr><td colspan=9 ></td></tr></table>";
print "<br><br><br><br><br><br><br><br><br><br><br><br><br><hr>";
print "<table bgcolor='' border=0 cellspacing=3 cellpadding=1 width=100%> <font size=2><tr></tr><tr><br> <td width=300></td><td align=center>Grand Total:&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<font size=3>".nozero($totamt)."</td></tr></table>";

?>

<font size=3>( <?print word($totamt)?> Only)</font>

<?

print "<table bgcolor='' border=0 cellspacing=3 cellpadding=1 width=100%> <font size=2><tr></tr><tr><br> <td width=10></td><td align=left>We have credited your account during this financial year on account of discount given<br>$descript<br>Your account has been thus credited by Rs $totamt </td><br><br><td width=1></tr></table>";


print "<table bgcolor='' border=0 cellspacing=3 cellpadding=1 width=100%> <font size=2><tr></tr><tr> <td width=10></td><td align=left>For Psn Automotive Marketing Private Ltd</td><br><br><td width=1></tr></table>";


print "<table bgcolor='' border=0 cellspacing=3 cellpadding=1 width=100%> <font size=2><tr></tr><tr><br> <td width=10></td><td align=left>Authorised Signatory &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp 
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspChecked By</td><td width=1></tr></table><hr>";


?>
</td></tr></table>
<?
}
?>