<?php
$modid=$_REQUEST['modid'];
$frmid=$_REQUEST['frmid'];
$rurl="&modid=".$modid."&frmid=".$frmid;
if($_REQUEST['Save'])
{
$insert="update  sale_budget set ledger_id='".$_REQUEST['client']."' where id='".$_REQUEST['Id']."'";	
$query1=DB_query($insert,$db);
$qty=$_REQUEST['item'];
for($j=0;$j<count($qty);$j++)
{
	if($_REQUEST['item'][$j]!='')
	{
	$insert2="update  sale_budget_details   set 
expected_order='".$_REQUEST['expected_order'][$j]."'
,confirm_order='".$_REQUEST['quantity'][$j]."',rate_per_pice='".$_REQUEST['priceper'][$j]."'
,confirm_value='".$_REQUEST['confirmvalue'][$j]."',expected_value='".$_REQUEST['allocated_budget'][$j]."',
item_code='".$_REQUEST['item'][$j]."' where id='".$_REQUEST['id'][$j]."'";	
$query2=DB_query($insert2,$db);	
	}
}		
	$s->pageLocation("index.php?route=sale_budgetlist&daction=Updated".$rurl);
}



?>
<?php
$sql=DB_query("select * from sale_budget where id='".$_REQUEST['Id']."'",$db);
$row=DB_fetch_array($sql,$db);

?>
<form action="" method="post">
<table  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><strong>Sales Budget</strong></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><table  border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <th >Client</th>
        <td ><select name="client"  onchange="getdata(this.value);" >
    
    <?php $sql11 ="SELECT client_code,c_name FROM clientmaster where client_code='".$row['ledger_id']."'";
		$resultStkLocs1=DB_query($sql11,$db);
		while ($myrow1=DB_fetch_array($resultStkLocs1))
				{
				?>
				<option value="<?php echo $myrow1['client_code']; ?>"><?php echo $myrow1['c_name']; ?></option>
    	<?php } ?>
    	
    	
    </select></td>
      </tr>
      <tr><td>&nbsp;</td></tr>
    </table></td>
  </tr>
  <tr>
    <td>
    	
    </td>
  </tr>
  <tr>
    <td id="data"><table  border="0" cellspacing="2" cellpadding="5" align="center">
             
	  	  <tr>
        <th >Sr No.</th>
        <th>Item Name</th>
        <th>Expected Order</th>
         <th>Confirm  Order</th>
         <th>Rate/1000</th>
           <th>Confirm Value</th>
             <th>Expect Value</th>
        </tr>
        <?php 
        $i=1;
        $sqldata=DB_query("select * from sale_budget_details where parent_id='".$_REQUEST['Id']."'",$db);
		while($data=DB_fetch_array($sqldata))
		{
        ?>
        <tr>
        <td><?php echo $i; ?></td>
          <td><input type="text" name="item[]" value="<?php echo $data['item_code']; ?>" readonly/>
      <td><input type="text" name="expected_order[]"  value="<?php echo $data['expected_order']; ?>"/></td>
       <td><input type="text" name="quantity[]" value="<?php echo $data['confirm_order']; ?>"readonly>
       	</td>
        <td><input type="text" name="priceper[]"  value="<?php echo $data['rate_per_pice']?>"readonly></td>
         <td><input type="text" name="confirmvalue[]" value="<?php echo $data['confirm_value']; ?>" readonly/>
         </td>
      <td><input type="text" name="allocated_budget[]" value="<?php echo $data['expected_value']; ?>" />
      	<input type="hidden" name="id[]" value="<?php echo $data['id']; ?>" />
      	  </td>          	
        </tr>
        <?php $i++; } ?>
	  	
    </table></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td align="center" valign="top"></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
</table>
<p align="center"><input type="submit" name="Save" value="Save" /></p>
</form>



<script language="JavaScript"> 
  
function getdata(str) 
{	 
		
if (str.length==0)
  {
  document.getElementById("data").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("data").innerHTML=xmlhttp.responseText;
      }
  }
 
xmlhttp.open("GET","get_sale_budget.php?site="+str,true);
xmlhttp.send();
}
	
	
	
</script>

