<?
session_start();
if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='../index.html'; </script>";
 return;
}
include ("../opendb.php");
include ("test.php");
$re=mysqli_query($db,"select * from jobcardamc where jcno='$jcno' and brcode='$brcode'");
if(mysqli_num_rows($re)<=0)
 {
    print "Jobcard does not exist";
    return;
 }
$jcrow=mysqli_fetch_array($re);

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

<table width=100% border=0>
<th colspan=3>
<?
 $brres=mysqli_query($db,"select * from branch where brcode='$brcode'");
 $brrow=mysqli_fetch_array($brres);
?>


</th>
<tr><td colspan=11 align=center>
<font size=2>
</u>
<br><br>
<br><br>
</font>
<?
if($jcrow[invtype]=='-')
 print " PENDING ";
?>
<b>SERVICE INVOICE </b>
<br>

<hr>
<tr><td width=310>
Customer Name and Address: <br>
<?
$cusres=mysqli_query($db,"select * from customer where acname='$jcrow[cname]'");
$cusrow=mysqli_fetch_array($cusres);
print $jcrow[cname]."<br>".$cusrow[addr1].", ".
$cusrow[dist1].", ".$cusrow[state1].", ".$cusrow[pin1];
?>
</td>
  <td align=center width=40%>Invoice NO: <b>AMC-<?print $jcrow[invno]?></b><br>
 
Date: <b><?print datetohtml($jcrow[entrydate])?></b><br>
</td>
  <td>  <B><?print $jcrow[msno]?></b> <br>
         <?Print $jcrow[model]?> <br>
         <?print $jcrow[servtype]?>
</td>
</tr>
</table>
<hr>
<table border=0 width=100%>
<th>Sno. <th>Description <th><th>Quantity <th>Rate
<th>Serv Tx<br>(12.00%)<th>Edu.Cess <br>(2.00%)<th>High.Edu.Cess<br>(1.00%)<th>Total

<?
$jpres=mysqli_query($db,"select * from jcardpartsamc where jcno='$jcno' and brcode='$brcode'");
$i=1;
$ratetot=0;
$gtot=0;
$taxtot=0;
$cesstot=0;
while($jprow=mysqli_fetch_array($jpres))
{
 print "<tr><td align=center>".$i++."</td><td>$jprow[2]</td><td>$jprow[3]</td>";
 print "<td align=right>$jprow[qty]</td><td align=right>$jprow[rate]</td>";
 print "<td align=right>$jprow[taxamt] </td><td align=right>$jprow[cessamt]</td>";
 print "<td></td><td></td><td></td>";
 print "<td align=right>$jprow[gtot]</td></tr>";
 $ratetot+=$jprow[rate];
 $gtot+=$jprow[gtot];
 $taxtot+=$jprow[taxamt];
 $txp+=$jprow[cessp];
$cesstot+=$jprow[cessamt];
}
?>

<?
$jsres=mysqli_query($db,"select * from jcardservamc where jcno='$jcno' and brcode='$brcode'");
$i=1;
while($jsrow=mysqli_fetch_array($jsres))
{
 print "<tr><td></td><td></td><td></td><td></td><td></td><td align=center><b></b></td></tr>"; 
?>
<tr><td colspan=11> <hr></td></tr>
<?
 print "<tr><td align=center>".$i++."</td><td>$jsrow[2]</td><td></td><td align=center>1</td>";
 print "<td align=center>$jsrow[servamt]</td>";
 $mvat = (($jsrow[servamt]*$jsrow[vat])/100);
// print "<td align=right>".putcoma($mvat)."</td>";
 $mcess = $mvat*$jsrow[cess]/100;
// print "<td align=right>".putcoma($mcess)."</td>";
 $servtx=(($jsrow[servamt]*$jsrow[servtx])/100);
 print "<td align=right>".putcoma(($jsrow[servamt]*$jsrow[servtx])/100)."</td>";
 $edutx=(($servtx*$jsrow[edutx])/100);
 print "<td align=right>".putcoma(($servtx*$jsrow[edutx])/100)."</td>";
 $hredutx=(($servtx*$jsrow[hredutx])/100);
 print "<td align=right>$hredutx</td>";
 print "<td align=right>$jsrow[tot]</td></tr>";
 $ratetot+=$jsrow[servamt];
 $gtot+=$jsrow[tot];
 $taxtot+=$mvat;
 $txp+=($jsrow[edutx]+$jsrow[hredutx]);
 $cesstot+=$mcess;
 $totservtx+=$servtx;
 $totedutx+=$edutx;
 $tothredutx+=$hredutx;
}
?>
<tr><td colspan=11> <hr></td></tr>
<tr><td colspan=4 align=right><b>Total &nbsp;</td><td align=center><?
//print putcoma($ratetot)
?></td>
<td align=right><?print putComa($totservtx)?></td>
<td align=right><?print putComa($totedutx)?></td>
<td align=right><?print putComa($tothredutx)?></td>
<td align=right><?print putComa($gtot)?></td>
</tr>
<tr>

<?
$rnd=round($gtot);
$dif=round(($rnd-$gtot),2);
print "</td></tr><tr><td colspan=8 align=right>Round Off </td><td align=right>".putComa($dif);

?></td></tr>
<tr><td colspan=8 align=right><b>Grand Total</td><td align=right><b><?print putComa(round($gtot))?></td></tr>
<tr><td colspan=10><hr></td></tr>
</table>
<br>
Amount in words: <?print word(round($gtot))?> ONLY
<p align=right>for PSN AUTOMOTIVE MARKETING PVT. LTD.
<BR><BR><BR><BR><BR><BR>
Authorised signatory

</P>

 
