<html>
<body >

<?
session_start();
include("opendb.php");
include("test.php");
if(strlen($user)<=0)
{
  print "<script> alert('Invalid User'); document.location='inde.php' </script>";
  return;
}
?>
<title>Demo</title>

<style type="text/css">
table,tr,td{border-collapse:collapse;padding:1px;border: 1px solid black;}
body{font-family:Verdana;font-size:8px;color:black;}
td{font-family:Verdana;font-size:10px;color:black;height:30px;}
th{font-family:Verdana;font-size:11px;color:black;}
select,input[type=text], textarea{  
background: #eeeeee; /* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2VlZWVlZSIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjIzJSIgc3RvcC1jb2xvcj0iI2ZmZmZmZiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgPC9saW5lYXJHcmFkaWVudD4KICA8cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2dyYWQtdWNnZy1nZW5lcmF0ZWQpIiAvPgo8L3N2Zz4=);
background: -moz-linear-gradient(top, #eeeeee 0%, #ffffff 23%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#eeeeee), color-stop(23%,#ffffff)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #eeeeee 0%,#ffffff 23%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #eeeeee 0%,#ffffff 23%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #eeeeee 0%,#ffffff 23%); /* IE10+ */
background: linear-gradient(top, #eeeeee 0%,#ffffff 23%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eeeeee', endColorstr='#ffffff',GradientType=0 ); /* IE6-8 */
border:1px solid #999; padding:3px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;


}
p{padding:0px;}
em{font-size:14px;}
h2{color:#000;font-size:14px;margin:0px;padding:5px 20px;}

</style>
<body onload='window.print();'>



<?

$df=$fromdt;
$dt=$todt;
$qry1=mysqli_query($db,"select * from pjobcard where (date>='$df' and date<='$dt') and brcode='$brcode' order by ptype,jcno desc");
print "<table cellspacing=1 cellpadding=5 width='100%' bgcolor='white' border='1' style='border-collapse:collapse;'>";
print "<tr ><td align=center colspan='6' ><h2><b><u>".$company."</b> <br>";
?>
<b>Purchase Register:&nbsp;&nbsp;&nbsp;  <? print datetohtml($df) ?>&nbspto <?print datetohtml($dt)?> </h2></b></td></tr> 
<?
print  "<tr><th>Sl no<th>Entry date<th>jcno<th>purchase bill no<th>Supplier<th>Net Amt</tr>";
$i=1;
$tot_amt=0;
$total=0;
$pre_ptype='x';
while($row=mysqli_fetch_array($qry1))
{
   if($pre_ptype!=$row[18]){
      if($total>'0'){
         print "<tr><td align='right' colspan='6'><b>".putcoma($total)."</b></td></tr>";  
      }
   print "<tr><td align='left' colspan='6'><b>$row[18]:</b></td></tr>";
   $total=0;
   }
$total+=$row[22];
print "<tr><td>".$i."</td><td>".datetoHtml($row[date])."</td>";
print "<td>$row[0]</td><td>$row[pbillno]</td><td>$row[5]</td><td align='right'>$row[22]</td></tr>";

$tot_amt+=$row[22];
$i++;
$pre_ptype=$row[18];
}
print "<tr><td align='right' colspan='6'><b>".putcoma($total)."</b></td></tr>";  

print "<tr><td colspan='5' align='right'><b>Grand Total:</b></td><td align='right'><b>".putcoma($tot_amt)."</b></td></tr>";
print "</table>";
?>
