<link href="css/form.css" type="text/css" rel="stylesheet" media="screen"  />
<link href="css/printline.css" type="text/css" rel="stylesheet" media="print,screen"  />



<?
 session_start();
if(strlen($brcode)<=0)
{
  print "<script> alert('Invalid User'); parent.document.location='ind.php' </script>";
  return;
}

include("opendb.php");
include("test.php");

?>

<center>
<script>
var=partcode[];
var=partname[];
</script>
<font face=arial narrow size=3>
<?print $branch?><br>

<table width="100%" border="0" cellspacing="0" cellpadding="0" class="grid" >


<tr bgcolor='silver'><td ><center>SNO</td><td ><center>INVNO</td> <td ><center>DATE </td> <td ><center> DANO</td> 
 <td ><center>NETAMOUNT </td> <td><center>FERTCODE</td> 
<td ><center>CONFIGURATION</td><td ><center> CHASSIS_NO</td> <td><center>ENGINE_no</td><td><center>STATUS</td><td><center>Update</td>


</tr>

	<link type="text/css" href="css/redmond/jquery-ui-1.8.16.custom.css" rel="stylesheet" />	
		<script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
		<script type="text/javascript" src="js/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript">
$(function(){

$(".partcode").live("keydown.autocomplete",function(){

$partcode = $(this);

$row = $partcode.parent().parent();
$(this).autocomplete({
		source: function( request, response ) {

		$.ajax({
			url: "search1.php",
			dataType: "json",
			data: "key="+$partcode.val(),
			success: function( data ) {
				response( $.map( data, function( item ) {
					return {
						label: item.partcode+' | '+  item.partname   ,
						value: item.partcode,
						name:item.partname,
						qty:item.supqty,
						price:item.price,
						tax:item.tax,


					}
				}));
			}
		});
	}
	
,
	minLength: 2,
	select: function( event, ui ) {

	$row.find('.partname').val(ui.item.name);
	$row.find('.supqty').val(ui.item.qty);
	$row.find('.rate').val(ui.item.price);
	$row.find('.tax').val(ui.item.tax);
	
	/*log( ui.item ?
	"Selected: " + ui.item.label :
	"Nothing selected, input was " + this.value);
	*/
	 }
	
	});

					
});

});
</script>


<body bgcolor='ivory'>




<?

 $sq="select * from eichersap where brcode='$brcode' and invno not in (select invno from veh_purchase where brcode='$brcode') ";

$result1=mysqli_query($db,$sq)or die(mysqli_error());
$i=1;

while($row1=mysqli_fetch_array($result1))



{
print "\n<tr >";
print "\n<form action='veh/veh_purch2.php?mod=$partcode[0]'>";
 print "\n<input type=hidden name='invno' value='$row1[0]'>";
 print "\n<input type=hidden name='eng' value='$row1[11]'>";
 print "\n<input type=hidden name='cha' value='$row1[10]'>";
print "\n<input type=hidden name='dan' value='$row1[4]'>";
print "\n<input type=hidden name='net' value='$row1[7]'>";
print "\n<input type=hidden name='dat' value='$row1[1]'>";


if($row1[14]!='Billed By Eicher')
{
       print "<tr bgcolor=white align=right><td>".$i."</td><td>$row1[0]</td><td>".datetohtml($row1[1])."</td><td align=left>$row1[4]</td>";
}

else
{
      print "<tr bgcolor=pink align=right><td>".$i."</td><td>$row1[0]</td><td>".datetohtml($row1[1])."</td><td align=left>$row1[4]</td>";

}

       print "<td align=right>$row1[7]</td><td align=left>$row1[8]</td><td align=left>$row1[9]</td><td align=left>$row1[10]</td>";
       print "<td align=left>$row1[11]</td><td align=left>$row1[14]</td>";

//print "<td><input type=text name='partcode[]' id='partcode$i'  class='partcode' ></td>"; 
//print "<td><input type=text name='partname[]' id='partname$i'  class='partname' ></td>"; 

print "<td><input type=submit value='Purchase' name='upd'></td> ";

//print "<td><input type=button value='Received At Yard' onClick=javascript:prnfun('$row1[0]')></td>";  

print "<td><input type=button value='Del' onClick=javascript:prndel('$row1[0]')></td>";  

$i++;
$net+=$row1[7];

	
?>
</form>
</tr>
<?
    }

print "\n<tr bgcolor=silver ><td colspan=4 align=center><b>Total </td><td align=right>".putComa($net)."</td><td colspan=5></td></tr>";

//


?>

<script>


 function prnfun(x,b,c,d,e,f)
 {
  if(confirm('Do you want to insert into purchase '+f))
   document.location='veh/veh_purch.php?invno='+x+'&cha='+b+'&eng='+c+'&dan='+d+'&amt='+e+'&con='+f;

 }


 function prnfun(x)
 {

document.location='updportal.php?invno='+x ;
 		
}

 function prndel(x)
 {

document.location='delport.php?invno='+x ;
 		
}

</script>


