<?
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 jobcard 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);
?>

PSN AUTOMOBILES P LTD. <br>
</th>
<tr><td colspan=10 align=center>
<font size=2>
<?PRINT $brrow[braddr].' ,'.$brrow[brcity].' <br><u>Phone: '.$brrow[brphone]?>
</u>
<br><br>
</font>
JOB CARD RETAIL INVOICE <br>Form 8B
<?
//print $jcrow[invtype]
?><hr><TH>
<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>JC-<?print $jcrow[invno]?></b><br>
 Job Card No: <?print $jcno?><br>
Date: <b><?print datetohtml($jcrow[date])?></b><br>
</td>
  <td>MSNO : <B><?print $jcrow[msno]?></b> <br>
      Model : <?Print $jcrow[model]?> <br>
      Serv Type : <?print $jcrow[servtype]?>

</td>
</tr>
</table>
<hr>
<table border=0 width=100%>
<th>Sno. <th>Part Code <th> Description <th>Quantity <th>Rate <th>Tax <th>Cess 
<th>Serv Tx <th>Edu. Cess <th>Hr Edu Cess
<th>Total
<tr><td><b>P A R T S</td></tr>
<?
$jpres=mysqli_query($db,"select * from jcardparts 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=center>$jprow[qty]</td><td align=center>$jprow[rate]</td>";
 print "<td align=center>$jprow[taxamt] </td><td align=center>$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];
}
?>

<tr><td><b>S E R V I C E</td></tr>
<?
$jsres=mysqli_query($db,"select * from jcardserv where jcno='$jcno' and brcode='$brcode'");
$i=1;
while($jsrow=mysqli_fetch_array($jsres))
{
 print "<tr><td align=center>".$i++."</td><td>$jsrow[2]</td><td></td><td></td>";
 print "<td align=center>$jsrow[servamt]</td>";
// print "<td>".(($jsrow[servamt]*12.5)/100)."</td>";
 print "<td></td>";
 $servtx=(($jsrow[servamt]*$jsrow[servtx])/100);
 print "<td></td><td align=center>".putcoma(($jsrow[servamt]*$jsrow[servtx])/100)."</td>";
 $edutx=(($servtx*$jsrow[edutx])/100);
 print "<td align=center>".(($servtx*$jsrow[edutx])/100)."</td>";
 $hredutx=(($servtx*$jsrow[hredutx])/100);
 print "<td align=center>".putcoma(($servtx*$jsrow[hredutx])/100)."</td>";
 print "<td align=right>$jsrow[tot]</td></tr>";
 $ratetot+=$jsrow[servamt];
 $gtot+=$jsrow[tot];
 //$taxtot+=(($jsrow[servamt]*$jsrow[servtx])/100);
 $txp+=($jsrow[edutx]+$jsrow[hredutx]);
 $cesstot=($taxtot*$txp)/100;
 $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></td>
<td align=center><?print putcoma($taxtot)?></td>
<td align=center><?print putcoma(round($cesstot,2))?></td>
<td align=center><?print putComa($totservtx)?></td>
<td align=center><?print putComa($totedutx)?></td>
<td align=center><?print putComa($tothredutx)?></td>
<?$gtot+=$cesstot;?>
<td align=right><?print putcoma($gtot)?></td></tr>
<tr><td colspan=11><hr></td></tr>
</table>
<br>
Amount in words: <?print word($gtot)?>
<p align=right>for PSN AUTOMOBILES P LTD.,
<BR><BR><BR><BR><BR><BR>
Authorised signatory

</P>

 
