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

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Xpress</title>
 <script src=" rightclick_deactive.js"></script> 
</head>
<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>
 

<script type="text/javascript">
    $(document).ready(function() {
        var cont_left = $("#container").position().left;
        $("a img").hover(function() {
            // hover in
            //$(this).parent().parent().css("z-index", 1);
            $(this).animate({
               height: "110",
               width: "90",
              
            }, "fast");
        }, function() {
            // hover out
         //   $(this).parent().parent().css("z-index", 0);
            $(this).animate({
                height: "80",
                width: "80",
                
            }, "fast");
        });
        
        $(".img").each(function(index) {
            var left = (index * 160) + cont_left;
            $(this).css("left", left + "px");
        });
    });









/////

(function($){
    $.fn.enterNext = function(){
       var _i =0;
       $('input[type=text], select',this)
            .each(function(index){
            _i = index;
            $(this)
                .addClass('tab'+index)
                .keydown(function(event){
                    if(event.keyCode==13){
                        $('.tab'+(index+1)).focus();
                        event.preventDefault();
                    }
                });

        })
     $( "input[type=submit]",this ).addClass('tab'+(_i+1));
}})(jQuery);
    </script>
<body onload='window.print();'>
<div class='cont'>




<br/>



<table class="report" border='1' width="100%" align='center'>
<?

 $df=$y1.'-'.$m1.'-'.$d1;
 $dt=$y2.'-'.$m2.'-'.$d2;
?>
<tr ><td align=center colspan='17' ><h2><b><u><? echo $company; ?></b> <br>
<?
 if($chk=='j')
  {
?>
<b>Purchase Details-Jobcard wise:&nbsp;&nbsp;&nbsp;  <? print datetohtml($df) ?>&nbspto <?print datetohtml($dt)?> </h2></b> 
<?
}
?>

<?
 if($chk=='p')
  {
?>
<b>Purchase Details-Purchase wise:&nbsp;&nbsp;&nbsp;  <? print datetohtml($df) ?>&nbspto <?print datetohtml($dt)?> </h2></b> 
<?
}
?>


</td></tr>





 

<?

 if($chk=='j')
  {
 $sql1="select distinct(jcno) from pjcardparts where (edate>='$df' and edate<='$dt') and brcode='$brcode' order by jcno ";
}

 if($chk=='p')
  {
  $sql1="select distinct(invno) from pjcardparts where (edate>='$df' and edate<='$dt') and brcode='$brcode' order by invno ";
}


$re1=mysqli_query($db,$sql1) or die(mysqli_error($db));
 print "<tr><th>SNo </th><th><h3>Date </th><th>JobNo </th><th>P.No </th><th>RegNo.</th><th>Partcode </th><th>PartName  </th><th>Qty </th><th>Original <th>Commercial <th>Used </th><th>Total</th><th>Supplier</th><th>BillNo</th><th>Cash</th><th>Credit</th><th>Card</th></tr>";
  $i=1;
$net=0;
$usednet=0;
$comnet=0;
$orignet=0;
while($row1=mysqli_fetch_array($re1))
 {

 if($chk=='j')
  {
$sql="select * from pjcardparts where brcode='$brcode' and jcno='$row1[0]' ";

}

 if($chk=='p')
  {
$sql="select * from pjcardparts where brcode='$brcode' and invno='$row1[0]' ";

}


$re=mysqli_query($db,$sql) or die(mysqli_error($db));
 if(mysqli_num_rows($re)>0)
 {


  while($row=mysqli_fetch_array($re))
 {
$sql2=mysqli_query($db,"select ptype from pjobcard where brcode='$brcode' and jcno='$row[0]'");
$row2=mysqli_fetch_row($sql2);
$ptype=$row2[0];
$tot=0;

$tot=$row[gtot];

if($row[engineer]=='Used')
{
$used=$tot;
}
else
{
$used=0;
}


if($row[engineer]=='Commercial')
{
$commercial=$tot;
}
else
{
$commercial=0;
}

if($row[engineer]=='Orignial')
{
$orginal=$tot;
}
else
{
$orginal=0;
}


$reg=getregno($row[jcno],$brcode);
$sup=getsupplier($row[invno],$brcode);
$pbill=getpbill($row[invno],$brcode);



print "<tr><td align=center>".$i++."</td><td>".datetohtml($row[edate])."</td><td>$row[jcno]</td><td>$row[invno]</td><td>$reg</td><td>$row[partcode]</td><td>$row[partname]</td><td align=right>".(int)$row[qty]."</td><td align=right>$orginal</td><td align=right>$commercial</td><td align=right>$used</td><td align=right>".putcoma($tot)."</td><td>$sup</td><td>$pbill</td>";
if($ptype=='CASH'){
print "<td>".putcoma($tot)."</td><td></td><td></td></tr>";
$cash+=$tot;
}
elseif($ptype=='CREDIT'){
print "<td></td><td>".putcoma($tot)."</td><td></td></tr>";
$credit+=$tot;
}
elseif($ptype=='CARD'){
print "<td></td><td></td><td>".putcoma($tot)."</td></tr>";
$card+=$tot;
}
else
print "<td></td><td></td><td></td></tr>";
$net+=$tot;
$gnet+=$tot;
$usednet+=$used;
$comnet+=$commercial;
$orignet+=$orginal;



 }


 }



}

print "<tr><td colspan=8 align=right height='20' style='border-right:0;height:20px;'><b>  Total:&nbsp;&nbsp;&nbsp; </b></td><td align=right><b>".putcoma($orignet)."</b></td><td align=right><b>".putcoma($comnet)."</b></td><td align=right><b>".putcoma($usednet)."</b></td><td align=right><b>".putcoma($gnet)."</b></td><td colspan='2'></td><td align=right ><b>".putcoma($cash)."</b></td><td align=right><b>".putcoma($credit)."</b></td><td align=right><b>".putcoma($card)."</b></td></tr>";

?>

 
</table>

</body>
</html>