<?php
$modid=$_REQUEST['modid'];
$frmid=$_REQUEST['frmid'];
$rurl="&modid=".$modid."&frmid=".$frmid;
 if(isset($_POST['Update']))
 {
$sqlcheck="select * from local_fright where branch_code='".$_REQUEST['site']."' and  vouchar_no='".$_REQUEST['vouchar']."' 
           and party='".$_REQUEST['party']."'and bill_no='".$_REQUEST['bill_no']."'  where CompanyId='".$_SESSION['ACGCompanyId']."'";
$query=DB_query($sqlcheck,$db);
 $num=DB_num_rows($query);
if($num>0)
{
$update="update local_fright set branch_code='".$_REQUEST['site']."' , vouchar_no='".$_REQUEST['vouchar']."' 
          ,party='".$_REQUEST['party']."', bill_no='".$_REQUEST['bill_no']."',fright_amount='".$_REQUEST['fright_amount']."',description='".$_REQUEST['description']."',narration='".$_REQUEST['narration']."' where 
          id='".$_REQUEST['Id']."'";	
$query1=DB_query($update,$db);		  
}		   	
 else {
     
 }	
	$s->pageLocation("index.php?route=viewlocal_fright&daction=Updated".$rurl);
	
 }




 
 $sql11="select* from local_fright where id='".$_REQUEST['Id']."' ";
$row1=DB_query($sql11,$db);
$result1=DB_fetch_array($row1);
?>
<h2 align="center"><strong>Edit Local Freight Payment</strong></h2>
<form name="form1" action="" method="post">
<div align="center">
<table width="60%" cellpadding="2" cellspacing="2" align="center">
<tr>
    <th><strong>Branch</strong></th>
    <td>
	<?php
		$sql = 'SELECT loccode, locationname FROM locations';
		$resultStkLocs = DB_query($sql,$db);
		?>
	<select name="site" style="width:100px" onchange="generateCode(this.value);">
	<option value="000">Select</option>
      <?php 
			while ($myrow=DB_fetch_array($resultStkLocs))
				{
				$k='';
				if($myrow['loccode']==$result1['branch_code'])
				{
				$k="selected";	
				}	
				?>
      <option value="<?php echo $myrow['loccode']; ?>"<?php echo $k;?>><?php echo $myrow['locationname'];?></option>
      <?php  }	?>
    </select></td>
    <th>Vouchar No</th>
    <td id="codeId"><input type="text" name="vouchar" id="vouchar" value="<?php echo $result1['vouchar_no'];?>"></td>
</tr>
<tr>
	<th><strong>Party</strong></th>
    <td>
	<?php
		$sql21= 'SELECT vendor_code, vendor_name FROM suppliers ';
		$resultStkLocs1 = DB_query($sql21,$db);
		?>
	<select name="party" style="width:100px">
	<option value="0">Select</option>
      <?php 
			while ($myrow1=DB_fetch_array($resultStkLocs1))
				{
				$j='';
				if($result1['party']==$myrow1['vendor_code'])
				{
				$j="selected";	
				}	
				?>
      <option value="<?php echo $myrow1['vendor_code']; ?>"<?php echo $j;?>><?php echo $myrow1['vendor_name'];?></option>
      <?php  }	?>
    </select></td>
     <th>Bill No</th>
    <td><input type="text" name="bill_no" id="vouchar" value="<?php echo $result1['bill_no']; ?>"></td>
	
</tr>
<tr>	
     <th >Fright Amount</th>
    <td ><input type="text" name="fright_amount" id="fright_amount" value="<?php echo $result1['fright_amount']; ?>"></td>
	<th ><strong>Description</strong></th>
    <td ><textarea  name="description"><?php echo $result1['description']; ?></textarea></td>
</tr>

<tr>
<th colspan="2"> Narration</th>
    <td colspan="2"><textarea name="narration" id="narration" cols="45" rows="5" style="width:100%; height:40px;">
    <?php echo $result1['narration']; ?>	
	</textarea></td>
	
</tr>
  
</table>
</div>
<p align="center"><input type="submit" name="Update" value="Update" /></p>
</form>
<script language="JavaScript">
function generateCode(str)
{
	
	if (str.length==0)
  {
  document.getElementById("codeId").innerHTML="";
  return;
  }
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)
    {
    document.getElementById("codeId").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","getlocalcode.php?site="+str,true);
xmlhttp.send();
}
	
	
</script>