<? 
session_start();
include("test.php");
include("opendb.php");
include("includes/function.php");
include("calstock.php");

if(strlen($user)<=0)
{
  print "<script> alert('Invalid User'); document.location='inde.php' </script>";
  return;
}
$qry=mysqli_query($db,"select * from workshop_purmast where prno='$prn' and brcode='$brcode'");
if(mysqli_num_rows($qry)<=0)
{
 print"<script>alert('invalid purchase number');document.location='printlub1.php';</script>";
} 
else
{
 print "<script>window.print();</script>";
}
?>
<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>Xpress</title>
<style>



.tble1 input {
background-color:transparent;
border: 0px solid;
height:20px;
//width:160px;
color:black;
}
/* .tble1 { 
border:0px; 
}
.tble1 td{ 
border-left:1px solid red;
}	*/
.tble1 th{ 
height:2px;
}
table 
{
font-size:11px;
}

</style>

            
       <br>

<?
$qry=mysqli_query($db,"select * from workshop_purmast where prno='$prn' and brcode='$brcode'");
$row=mysqli_fetch_array($qry);       
$date = $row[5];
$newDate = date("d-m-Y", strtotime($date));
$bildate = $row[12];
$newDatebl = date("d-m-Y", strtotime($bildate));
?>                                    
   <table border='0' width='100%'>
<tr>
<td align='left' width='33%'> 
<?
$qry1=mysqli_query($db,"select * from company_master where brcode='$brcode'");
$row1=mysqli_fetch_array($qry1);
print $row1[2]."<br>".$row1[4]."<br>".$row1[5]."<br>".$row1[6];
if(($row1[7]>0)&&($row1[7]!=''))
    print "<br>Tel: ".$row1[7];
 if(($row1[8]>0)&&($row1[8]!=''))
   print " Fax: ".$row1[8];
     if($row1[10]!='')
        print "<br>Email: ".$row1[10];
       if($row1[11]!='')
          print ",<br>".$row1[11];
           if($row1[12]!='')
             print "<br>Web: ".$row1[12];
?>
  </td>
<td align='center'  width='33%'><h2>LUBRICANT PURCHASE</h2></td>
<td align='right'  width='33%'> <img src="images/head.jpg" width="450" height="60" />  </td>
</tr></table>
<center ></center >
<table width=100%>


<tr><td align='left'><b>Purchase No</b></td><td ><b>:</b></td><td align='left'><? echo $row[4]; ?></td><td width=40%></td><td align='left'><b>Purchase Date </b></td><td><b> :</b></td><td align='left'><? echo $newDate; ?></td></tr>
<tr><td align='left'><b>Purchase Bill No</b></td><td ><b>:</b></td><td align='left'><? echo $row[11]; ?></td><td width=40%></td><td align='left'><b>Purchase Bill Date </b></td><td><b> :</b></td><td align='left'><?  echo $newDatebl; ?></td></tr>
<tr><td align='left'><b>Supplier</b></td><td ><b>:</b></td><td align='left'><? echo $row[13]; ?></td></tr>

</table>

<table width=100% class='tble1' FRAME=BOX BORDER=1 CELLPADDING=7 CELLSPACING=0 
    RULES=COLS>

<tr ><th>Sl No<th height='10'>Item<th>Subgroup<th>Group<th>Part type<th>Unit<th>Quantity<th>Unit Price<th>Total<br>Amount<th>Disc<th>Net<br>Amount
<?
$i=1;
$ntot=0;

$res=mysqli_query($db,"select * from workshop_purmast where prno='$prn' and brcode='$brcode' order by grp");


//print "select sum(qty),group1,sum(dis),sum(total) from invoice where invno='$inno' group by group1";
while($res1=mysqli_fetch_array($res))
  {
   $tots=$res1[8]+$res1[9];
   print "<tr><td>".$i."</td><td>".$res1[1]."</td><td>".$res1[2]."</td><td>".$res1[3]."</td><td>".$res1[17]."</td><td> litre</td><td>".$res1[6]."</td><td>".$res1[7]."</td><td>".$tots."</td><td>".$res1[8]."</td><td>".$res1[9]."</td></tr>";
   $i++;
   $ntot+= $res1[9]; 
  }
?>



</table>

<br><br>


       <table align='right' width=20%> 
<tr><td> 
                   <b> Grand Total</b>
               </td>
               
<td>:</td> 
                   <td> 

                   <b> <?echo putcoma($ntot); ?></b>

                 </td></tr></table>

    <br><br><br><br>
<script type="text/javascript" src="tabjs/jquery_004.js"></script>
    <script type="text/javascript">

        $('#default_notes_textarea, #to_address, #from_address').jqEasyCounter({
            'maxChars': 1000,
            'maxCharsWarning': 980,
            'msgFontSize': '10px',
            'msgFontColor': 'silver',
            'msgFontFamily': 'Arial',
            'msgTextAlign': 'right',
            'msgWarningColor': 'red',
            'msgAppendMethod': 'insertAfter',
            'allocateSpace': true
        });
        
        reCalculate(document.getElementById('sum_discount'),'dataTable','0.00');

        function loadReceiptLayer(obj){
            var to_id = $('#to_name').val();

            if (obj.checked){
                $('#receipts_layer').show(100, function(){
                    if (!$(this).attr('rloaded')){
                        $(this).attr('rloaded','true');
                        $('#receipts_layer').html('<img src="images/loadingsmall.gif">');

                        $.ajax({

                            url: "showExpenses.php?action=displayReceiptList&customer_id="+to_id+"&list=",
                            type: 'GET',
                            cache: false,
                            async: true,
                            dataType : 'json',
                            success:function(response){
                                if (response && response.success)
                                    $('#receipts_layer').html(response.html);
                                else
                                    $('#receipts_layer').html('Fail to load. Try Again');
                            },
                            error:function(){
                                $('#receipts_layer').html('There was an error. Try Again');
                            }
                        });




                    }
                }) ;
            }
            else{
                $('#receipts_layer').hide();
            }
        }

        $(function(){
            /*
            $('#to_name').change(function(){
                $('#receipts_layer').attr('rloaded','');
                document.getElementById('receipts_include').checked = false;
                $('#receipts_layer').hide();

            });
            */



        });
        $('#receipts_include').click(function(){


            var obj = $('#receipts_layer');
            if (document.getElementById('receipts_include').checked){


                if (obj.attr('rloaded') == 'true'){
                    obj.show();
            <b><b elssssssshbuhuuhbuhb);
     }else{
                obj.hide();
            }



        })

    </script>


    
						
		
		
		<!-- end main table wrapper -->
		</td></tr></tbody></table>
		
</body></html>


