<? 
session_start();
$brcode = $_SESSION['brcode'];
$user   = $_SESSION['user'];
if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out11'); parent.document.location='../ind.php'; </script>";
 return;
}

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

//newly added

$us=mysqli_query($db,"select level from bruser where username='$user'")or die(mysqli_error());
$r=mysqli_fetch_row($us);
$user_level=$r[0];
$dt=$y.'-'.$m.'-'.$d;
//print $user_level;
//print $dt;



$sprint=$_REQUEST['sprint'];
if($sprint)
{ 
    
    $invno=$_REQUEST['invno'];
    $billtovl=$_REQUEST['billtovl'];
    $billaddrvl=$_REQUEST['billaddrvl'];
    $billpinvl=$_REQUEST['billpinvl'];
    $billdistvl=$_REQUEST['billdistvl'];
    $billstatevl=$_REQUEST['billstatevl'];
    $billpanvl=$_REQUEST['billpanvl'];
    $billgstvl=$_REQUEST['billgstvl'];
    
    
    
    
    $shiptovl=$_REQUEST['shiptovl'];
    $shipaddrvl=$_REQUEST['shipaddrvl'];
    $shippinvl=$_REQUEST['shippinvl'];
    $shipdistvl=$_REQUEST['shipdistvl'];
    $shistatevl=$_REQUEST['shistatevl'];
    $shipanvl=$_REQUEST['shipanvl'];
    $shigstvl=$_REQUEST['shigstvl'];
    
    
   
    
    
    
    if(strlen($brcode)<=0)
    {
        print "<script> alert('Session timed out'); parent.document.location='../ind.php'; </script>";
        return;
    }
    
    
       
 

    
    
    
    
    
   
        $sql="insert into profinv_addr(invno,brcode,billaddr,billto,billpin,billdist,billstate,billpan,billgst,shipto,shipaddr,shippin,shipdist,shipstate,shippan,shipgst) values('$invno','$brcode','$billaddrvl','$billtovl','$billpinvl','$billdistvl','$billstatevl','$billpanvl','$billgstvl','$shiptovl','$shipaddrvl','$shippinvl','$shipdistvl','$shistatevl','$shipanvl','$shigstvl')";
        
echo $sql;
    mysqli_query($db,$sql) or die(mysqli_error());
     
    print "<script>alert('Data has been updated')</script>";
			print "<script> document.location='updshipadr_proforma.php'; </script>";
    
      
      
} // end save

?>
<link type="text/css" href="../jquery/jquery-ui.min.css" rel="stylesheet" />	
<script type="text/javascript" src="../jquery/jquery-1.7.min.js"></script>
<script type="text/javascript" src="../jquery/jquery-ui.min.js"></script>
<script type="text/javascript" src="../jquery/jquery.jqEasyCharCounter.min.js"></script>
<style>
select,input,body,td{font-family:'arial narrow';letter-spacing:1;font-size:13}
tr{background-color:c1d7bb}
.mnu{margin-left:5}
</style>
<body bgcolor='ivory'>
  <script type="text/javascript">
    var cur=1;
	 var prevcur=0;
	 var gst='';
	 var marginpr='';
	 var custstt='';
	 var shipdistvl='';
	 var shippinvl='';
$(function(){
    
$(".orderto").live("keydown.autocomplete",function(){

$orderto = $(this);

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

		$.ajax({
			url: "searchcust.php",
			dataType: "json",
			data: "key="+$orderto.val(),
			success: function( data ) {
				response( $.map( data, function( item ) {
					return {
						label: item.orderto+' | '+  item.partname +' | '+  item.price  +' | '+  item.supqty  ,
						value: item.orderto,
						code:item.partname,
							adr:item.price,
							gst:item.supqty,
							marginpr:item.mrgnprc,
						    custstt:item.custstt,
						    shipdistvl:item.shidist,
						    shippinvl:item.shipin,

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

	$row.find('.orderto').val(ui.item.orderto);
	var cusstr=ui.item.code+','+ui.item.adr+','+ui.item.gst+','+marginpr+','+custstt;
    cusstr=cusstr.trim();
	document.f1.addr.value=cusstr;

	
	//document.f1.msno.focus();
	/*log( ui.item ?
	"Selected: " + ui.item.label :
	"Nothing selected, input was " + this.value);
	*/
	 }
	
	});

					
});











});
</script>    
    
    
    
    
    
    
<script>
var adr=[];
var ar1=[]; 
var config=[];
var config2=[];
var model=[];
var rep=[];
var area=[];
var color=[];
var engno=[];
var chasis=[];
var em_code=[];
var cess_amt=[];
var hsncode=[];
var tax_perc=[];
function fun1()
{
    
}


</script>


<style>
body,td{font-family:'arial narrow';letter-spacing:1;}
th{background-color:green;color:white}
.mnu{margin-left:5}
</style>
<body bgcolor='ivory'>


<form name='f1' action='<?print $PHP_SELF?>' method='POST' onSubmit="return valid()">

<CENTER>
<table cellspacing=1 cellpadding=1 bgcolor=green>
<tr  bgColor='c1d7bb'><td align=center>
<table border=1 cellspacing=1 cellpadding=2>
<tr bgColor='c1d7bb'><td colspan=7 align=center bgcolor='green'>
<font color='ivory'><STRONG>

<?
$rs=mysqli_query($db,"select invno from profinv where brcode='$brcode' order by invno desc")or die(mysqli_error());


?>

</TD></TR>
<tr>

</tr>
<tr>
<td>Invoice No </td><td><select name='invno' onChange='fun1(this.value)' width="60px">
<option value='select'>select</option>
<?
while($p_row=mysqli_fetch_array($rs))
{
?>
<option value='<? echo $p_row[0] ?>'><? echo $p_row[0] ?></option>
<?
}
?>
</select></td>

</tr>
<tr><td>Billed To</td><td><input type='text' name='billtovl' id='billtovl' size=100></td></tr>
<tr><td>Billing Address</td><td><input type='text' name='billaddrvl' id='billaddrvl' size=100></td></tr>

   <tr><td>Billed Pin</td><td><input type='text' name='billpinvl' id='billpinvl'></td><td>Bill District</td><td><input type='text' name='billdistvl' id='billdistvl' ></td>
   <td>Billed State</td><td><input type='text' name='billstatevl' id='billstatevl' ></td>
   </tr> 
       <tr><td>Billed Pan</td><td><input type='text' name='billpanvl' id='billpanvl'></td><td>Bill GST</td><td><input type='text' name='billgstvl' id='billgstvl' ></td>
   
   </tr> 

<tr><td>Ship To</td><td><input type='text' name='shiptovl' id='shiptovl' size=100></td></tr>
<tr><td>Ship Address</td><td><input type='text' name='shipaddrvl' id='shipaddrvl' size=100></td></tr>

   <tr><td>Ship Pin</td><td><input type='text' name='shippinvl' id='shippinvl'></td><td>Ship District</td><td><input type='text' name='shipdistvl' id='shipdistvl' ></td>
   <td>Ship State</td><td><input type='text' name='shistatevl' id='shistatevl' ></td>
   </tr> 
       <tr><td>Ship Pan</td><td><input type='text' name='shipanvl' id='shipanvl'></td><td>Ship GST</td><td><input type='text' name='shigstvl' id='shigstvl' ></td>
   
   </tr> 

<tr><td colspan=6 align=center bgcolor='green'> 

<input type=submit  value='Update' name='sprint'>

<input type=button value='  CANCEL  ' onClick=history.back(1)></td></tr>

<div id="aditem_panel" class="itemalist" style="display:none;position: absolute;"></div>


</table>
</form>
</td></tr>
</table>
<script>
    function fun1(str)
{
    

	if (window.XMLHttpRequest)
  	{// code for IE7+, Firefox, Chrome, Opera, Safari
  		xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
  		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
		    //alert(xmlhttp.responseText)

            			document.getElementById('aditem_panel').innerHTML=xmlhttp.responseText;
            			
            			document.getElementById('shiptovl').value=document.getElementById('shipto').value;
            			document.getElementById('shipaddrvl').value=document.getElementById('shipadr').value;
            			document.getElementById('shippinvl').value=document.getElementById('shippin').value;
            			document.getElementById('shipdistvl').value=document.getElementById('shipdist').value;
            			document.getElementById('shistatevl').value=document.getElementById('shipstate').value;
            			
            			document.getElementById('shipanvl').value=document.getElementById('shippan').value;
            			document.getElementById('shigstvl').value=document.getElementById('shipgst').value;
            			
			
             			
		}
	}


	var url="getshipdtls.php?invno="+str;

	xmlhttp.open("GET",url,true);
	xmlhttp.send();

  //}//else close
}
</script>