<?
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");
$jcno=$_REQUEST['jcno'];
$re=mysqli_query($db,"select * from jobcardq where jcno='$jcno' and brcode='$brcode'");
if(mysqli_num_rows($re)<=0)
 {
    print " does not exist";
    return;
 }
$jcrow=mysqli_fetch_array($re);

?>
<link rel="stylesheet" href="../style.css" type="text/css" />
<style>
.noprint, .print {display:none;}
@media screen {
.noprint, .printns {display:block;}
.print {display:none;}
}
@media print {
.print {display:block;}
.noprint, .printns, {display:none;}
}
	th{background-color:steelblue;color:white}
	td{font-size:12}
.right{text-align:right}
</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 CONSTRUCTION EQUIPMENT PVT. LTD., <br>
</th>
<tr><td colspan=10 align=center>
<font size=2>
<?PRINT $brrow[braddr].' ,'.$brrow[brcity].' <br>Tin: '.$brrow[tin] .',Service Tax no:AADCP8159RST001,<u>Phone: '.$brrow[brphone]?>

<br><br>
</font>
<b>
<?
 print "ESTIMATE";
?>
<br>

<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%>EST NO: <b>Q-<?print $jcno?></b><br>
 <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 : 
</td>
</tr>
</table>
<hr>
<table width=100% cellspacing=1 cellpadding=1 bgcolor='white'>

<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

<?

$jpres5=mysqli_query($db,"select distinct(grp) from jcardpartsq where jcno='$jcno' and brcode='$brcode'");
while($jprow5=mysqli_fetch_array($jpres5))
{


$jpres=mysqli_query($db,"select * from jcardpartsq where jcno='$jcno' and brcode='$brcode' and grp='$jprow5[0]'");


$i=1;
$ratetot=0;
$gtot=0;
$taxtot=0;
$cesstot=0;
while($jprow=mysqli_fetch_array($jpres))
{
if($jprow[gtot]<=0)
{
 print "<script> alert('Invalid Entry Total')</script>";
 print "<h1>Error</h1>";
}
if($jprow[taxamt]<=0)
{
 print "<script> alert('Invalid Entry Tax')</script>";
 print "<h1>Error</h1>";
}
if($jprow[cessamt]<=0)
{
 print "<script> alert('Invalid Entry Cess')</script>";
 print "<h1>Error</h1>";
}

 print "<tr><td align=right><b>$jprow5[0]</b> </td>";
 
 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];
$tot_g+=$jprow[gtot];
}
print "<tr><td colspan=10 align=right><b>Total Parts</td><td align=right><b>".putComa($tot_g)."</td></tr>";
?>


<?
$jsres=mysqli_query($db,"select * from jcardservq where jcno='$jcno' and brcode='$brcode' and grp='$jprow5[0]'");
//$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>";
$ss=$jsrow[servamt];
// print "<td>".(($jsrow[servamt]*12.5)/100)."</td>";
 print "<td></td>";
 $servtx=(($jsrow[servamt]*$jsrow[servtx])/100);
 print "<td></td><td align=right>".putcoma(($jsrow[servamt]*$jsrow[servtx])/100)."</td>";
 $edutx=(($servtx*$jsrow[edutx])/100);
 print "<td align=right>".(($servtx*$jsrow[edutx])/100)."</td>";
 $hredutx=(($servtx*$jsrow[hredutx])/100);
 print "<td align=right>".putcoma(($servtx*$jsrow[hredutx])/100)."</td>";
$tt=$ss+$servtx+$edutx+$hredutx;
 print "<td align=right>$tt</td></tr>";
 $ratetot+=$jsrow[servamt];
 $gtot+=$tt;
 //$taxtot+=(($jsrow[servamt]*$jsrow[servtx])/100);
 $txp+=($jsrow[edutx]+$jsrow[hredutx]);
 //$cesstot=($taxtot*$txp)/100;
 $totservtx+=$servtx;
 $totedutx+=$edutx;
 $tothredutx+=$hredutx;
 $gt_serv+=$tt;
}
print "<tr><td colspan=10 align=right><b>Total Service</td><td align=right><b>".putComa($gt_serv)."</td></tr>";
 
}


?>
<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($taxtot)?></td>
<td align=right><?print putcoma($cesstot)?></td>
<td align=right><?print putComa($totservtx)?></td>
<td align=right><?print putComa($totedutx)?></td>
<td align=right><?print putComa($tothredutx)?></td>
</tr>
<tr>
<td align=right colspan=11>
<?
print putcoma($gtot);
$rnd=round($gtot);
$dif=round(($rnd-$gtot),2);
print "</td></tr><tr><td colspan=10 align=right>Round Off </td><td align=right>".putComa($dif);

?></td></tr>
<tr><td colspan=10 align=right><b>Grand Total</td><td align=right><b><?print putComa(round($gtot))?></td></tr>
<tr><td colspan=11><hr></td></tr>
</table>
<br>
Amount in words: <?print word(round($gtot))?>

<tr align=right>
<br><br><b><u>Terms & Conditions:-</b></u><br>At the workshop the machine/ aggregates will be dismantled and inspected for analyzing condition of internal parts. Damaged and worn out parts will be replaced & reusable parts will be reworked. If necessary estimate will be reworked on the basis of parts to be replaced & service charges as per list price corresponding to activity. Rebuilt aggregates/machine will be released after receipt of payment full.50% advance required with work order. We are forced to charge 2000/- per day parking charge if the customer fail to receive the machine with in 20 days of completion of job and pending of work order with in 20 days of quotation receiving date. Transportation charge will be extra. </tr>


<p align=left>for PSN CONSTRUCTION EQUIPMENTS PVT. LTD.,
<BR><BR><BR><BR>
Service Engineer<br>
</P>

I agree the terms and conditions.<br><br><br>Signature of customer / representative<br><br>Name :
 
