<?php 
$url_cancel= "index.php?route=ToolPlants/Assets_sales/FixedAssetsSalesinvoice_index".$rurl;
$url_add= "index.php?route=ToolPlants/Assets_sales/FixedAssetsSalesinvoice".$rurl;
?>
<?php
if(isset($_REQUEST['save']))
{		
		    //$purchase_date=FormatDateForSQL($_REQUEST['tpl_fixed_assetsales_invoiceposting']['vouchar_date']);
			//$_REQUEST['tpl_fixed_assetsales_invoiceposting']['invoice_date']=$purchase_date;
			//extract($_REQUEST['tpl_fixed_assetsales_invoiceposting']);
		if($s->RecordInsert('tpl_fixed_assetsales_invoiceposting',$_REQUEST['tpl_fixed_assetsales_invoiceposting']))
		{				
				$_SESSION['success_msg']="Saved Successfully";
				echo "<script>location.href='$url_cancel'</script>";
		 }	
}
if(isset($_REQUEST['action']) && isset($_REQUEST['isid']))
{
	if($_REQUEST['action']=='edit' && !empty($_REQUEST['isid']))
	{	
		$recEdit=DB_fetch_array($s->GetRecordById('tpl_fixed_assetsales_invoiceposting','id='.$_REQUEST['isid']));
		extract($recEdit);
		
	}
}
if(isset($_REQUEST['update']))
{			
		extract($_REQUEST['tpl_fixed_assetsales_entry']);		
		if($s->RecordEdit('tpl_fixed_assetsales_invoiceposting',$_REQUEST['tpl_fixed_assetsales_invoiceposting'],"id=".$_REQUEST['tpl_fixed_assetsales_invoiceposting']['id']))
		{
		unset($_REQUEST['tpl_fixed_assetsales_invoiceposting']);
		$_SESSION['success_msg']="Saved Successfully";
		echo "<script>location.href='$url_cancel'</script>";
	}	
}
?>
<form name="" id="" method="POST">
<div align="center">
<fieldset style="width:800px"><legend><strong>Fixed Asset Sales Invoice Posting</strong></legend>	
<table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr>
    <td style="padding:5px"><!-- General details -->
      <table width="100%" cellspacing="4" cellpadding="4" border="0" style="color:#FF0000">
        <tr>
          <td style="padding:5px; text-align:center;" colspan="4" align="right"></td>
        </tr>
        <tr>
          <td style="text-align:center;" colspan="4"><b></b></td>
        </tr>
         <input type="hidden" value="<?php if($_REQUEST['action']=='edit') echo $id; ?>" name="tpl_fixed_assetsales_invoiceposting[id]">
          <tr style="height:25px">
          <th>Vouchar Date</th>         
          <td width="30%" align="left" >
         <select name="tpl_fixed_assetsales_invoiceposting[vouchar_date]" id="project" class="vouchar_date" style="width:100%;" onchange="getdata(this.value);">
          <option value="0">Select</option>
         <?php
         $sql=DB_query("select invoice,id from tpl_fixed_assetsales_entry",$db); 
		 while($row=DB_fetch_array($sql))
		 {
		 $sel='';
		 if($_REQUEST['vouchar_date']==$row['id'])
		 {
		 $sel="selected";	
		 }		
         ?>
         <option value="<?php echo $row['id']; ?>" <?php echo $sel; ?>><?php echo $row['invoice']; ?></option>
         <?php } ?>        
        </select>
       <!--  <input type="text" name="tpl_fixed_assetsales_invoiceposting[vouchar_date]"  id="vouchar_date" class="datepicker" style="width: 100%"/> -->
          </td>
          <td></td>
          <td width="30%" align="left"  >
          	          	
		  </td>
        </tr>
      </table></td>
  
  </tr>
</table></fieldset>
</div>

<div align="center">
<div style="overflow:auto; width:800px;" >
<table width="100%" border="0" align="center">
<tr>
<td bgcolor="#c6c6c6" id="data1" ><table width="100%" border="0" cellspacing="1" cellpadding="5" align="center">
  <tr>   
    <th><strong>Select</strong></th>
    <th><strong>Vendor</strong></th>
    <th><strong>Bil No</strong></th>
    <th><strong>Bill Date</strong></th>
    <th><strong>Project Name</strong></th>
    <th><strong>Net Amount</strong></th>
    <th><strong>Tax Addition Amt</strong></th>
    <th><strong>Tax Deduction Amt </strong></th>
    </tr>
 </table>
</td>
</tr>
</table>
</div>
</div> 
<p align="cenet">
		<input type="hidden" name="tpl_fixed_asset_definition[created]" value="<?php echo date('Y-m-d')?>">
		   <input type="hidden" name="tpl_fixed_asset_definition[created_by]" value="<?php echo $_SESSION['UserID']?>">

         
		  <input type="submit" value="Show Invoice Posting" name="<?php if($_REQUEST['action']=='edit') echo 'update'; else echo 'save'; ?>" class="add">    <a href="<?php echo $url_cancel;?>"><input type="button" value="Cancel" name="button" class="add"></a>
</p></form>
<script language="JavaScript">
	
function getdata(str)
{	
   if(str=="")
  {
  document.getElementById("data1").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("data1").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","assetsalesinvoicecode_prefix.php?code="+str,true);
xmlhttp.send();
}
</script>	
	

	
	
	

