<?
session_start();
include("../opendb.php");
include("../test.php");
include_once('includes/top.php');

$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
$ordres=mysqli_query($db,"select max(orderno) from saleorder_sparedc where brcode='$brcode'");
$ordrow=mysqli_fetch_row($ordres);
$ordnumber=$ordrow[0]+1;

?>
<html>
<body >
<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>
<link href="../css/form.css" type="text/css" rel="stylesheet" media="screen"  />
<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,

					}
				}));
			}
		});
	}
	
,
	minLength: 2,
	select: function( event, ui ) {
	$row.find('.partname1').val(ui.item.name);
	$row.find('.supqty').val(ui.item.qty);
	$row.find('.rate').val(ui.item.price);
	
	/*log( ui.item ?
	"Selected: " + ui.item.label :
	"Nothing selected, input was " + this.value);
	*/
	 }
	
	});

					
});




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

$partcode = $(this);

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

		$.ajax({
			url: "search1.php?type=name",
			dataType: "json",
			data: "key="+$partcode.val(),
			success: function( data ) {
				response( $.map( data, function( item ) {
					return {
						label: item.partcode+' | '+  item.partname+' | '+  item.grp   ,
						value: item.partcode,
						code:item.brcode,
						adr:item.grp,

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

	$row.find('.partcode1').val(ui.item.acname);
	$row.find('.addr').val(ui.item.adr);
	$row.find('.rate').val(ui.item.price);
	
	/*log( ui.item ?
	"Selected: " + ui.item.label :
	"Nothing selected, input was " + this.value);
	*/
	 }
	
	});

					
});



});
</script>




<BASE TARGET=main22>
<style>
	tr{background-color:white}
	th{background-color:steelblue;color:white}
</style>
<?
$tbl="sparetmp".$brcode.$user;
//include("calcsparestock.php");
?>

<script>
var pna=[];
var qty=[];
var hand=[];
var price=[];
var disc=[];

function getn()
{
document.f1.sup.value=document.f1.part.value;
}


function valid()
{
 if(document.f1.partcode.selectedIndex<=0)
 {
  alert('Invalid Item code');spareprmast
  return false;
 }

if(document.f1.partname.value.length<=0)
 {
   
   alert('Invalid Customer/s');
return false; 
}

/*if(parseFloat(document.f1.sqty.value)<=0)
{
alert('Invalid Quantity');
document.f1.sqty.value=0;
document.f1.sqty.focus();
return false;
}*/
/*
var x=document.getElementById("mselect")
 document.f1.partcode1.value=x.options[x.selectedIndex].text
x.remove(x.selectedIndex)
*/
}
</script>
<body bgcolor='ivory'>
<center>
<form name='f1' method='post' action='invtempnew11dc.php' onSubmit='return valid()'>
<input type=hidden name='code' value='<?print $sup?>'>


<table>
<th colspan=10><h3>SPARE INVOICE ORDER - (<?print $ordnumber?>)</h3></th>
<tr>



<td>Part Code<input type=text name=partcode id=partcode  class='partcode' size=20>

partname<input type=text name=partname id=partname  class='partname' size=30>

HSN<input type=text name=hsn id=hsn  class='hsn' size=30>

</td></tr><tr>
    <td>Customer<input type=richtext  name=cust id=cust  class='cust' size=40>


Order qty <input type=text name='sqty' size=6 >
Rate <input type=text name='rate' size=10 ></td>

<td></tr>

<tr><td colspan=6 align=center bgcolor='steelblue'><input type=submit value='Add' name='add'></td></tr>

<tr></tr>


</table>

</form>







