<?php 
$url_cancel= "index.php?route=ToolPlants/maintenance/amc_entry_bill_posting_index".$rurl;
$url_add= "index.php?route=ToolPlants/maintenance/amc_entry_bill_posting".$rurl;
?>
<?php
if(isset($_REQUEST['save']))
{	
		//print_r($_REQUEST); exit;
		$date=FormatDateForSQL($_REQUEST['tpl_amc_billposting']['bill_date']);
		$amc_date=FormatDateForSQL($_REQUEST['tpl_amc_billposting']['amc_date']);
		$_REQUEST['tpl_amc_billposting']['amc_date']=$amc_date;
		$_REQUEST['tpl_amc_billposting']['bill_date']=$date;
		
		extract($_REQUEST['tpl_amc_billposting']);
		if($s->RecordInsert('tpl_amc_billposting',$_REQUEST['tpl_amc_billposting']))
		{	
				//print_r($_REQUEST); exit;
				$_SESSION['success_msg']="Saved Successfully";
				echo "<script>location.href='$url_cancel'</script>";			
		}
	
}
if(isset($_REQUEST['action']) && isset($_REQUEST['amcid']))
{
	if($_REQUEST['action']=='edit' && !empty($_REQUEST['amcid']))
	{	
		$recEdit=DB_fetch_array($s->GetRecordById('tpl_amc_billposting','id='.$_REQUEST['amcid']));
		extract($recEdit);
		
	}
}
if(isset($_REQUEST['update']))
{
			$date=FormatDateForSQL($_REQUEST['tpl_amc_billposting']['bill_date']);
			$amc_date=FormatDateForSQL($_REQUEST['tpl_amc_billposting']['amc_date']);
			$_REQUEST['tpl_amc_billposting']['amc_date']=$amc_date;
			$_REQUEST['tpl_amc_billposting']['bill_date']=$date;
			extract($_REQUEST['tpl_amc_billposting']);
		
		if($s->RecordEdit('tpl_amc_billposting',$_REQUEST['tpl_amc_billposting'],"id=".$_REQUEST['tpl_amc_billposting']['id']))
		{
			//print_r($_REQUEST);exit;
			unset($_REQUEST['tpl_amc_billposting']);
			$_SESSION['success_msg']="Saved Successfully";
			echo "<script>location.href='$url_cancel'</script>";
		}
	
}

?><head>

</head>

<form name="" id="" method="POST">
<div align="center">
<fieldset style="width:800px"><legend><strong>AMC Entry Bill 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">
      
        <input type="hidden" value="<?php if($_REQUEST['action']=='edit') echo $id; ?>" name="tpl_amc_billposting[id]">
          <tr style="height:25px">
          <th> Vendor</th>
          <td width="30%" align="left" >
          	<select name="tpl_amc_billposting[vendor]" id="vendor" style="width:100%;">
			<option value="">Select</option>
			</select>
          </td>
         <th>Bill Date</th>
         <td><input type="text"  value="<?php if($bill_date!='') echo ConvertSqlDate($bill_date);?>" style="width:98%;"   name="tpl_amc_billposting[bill_date]" id="bill_date" class="datepicker"></td>
       </tr>
      	<tr style="height:25px">
          <th> AMC Ref No.</th>
          <td width="30%" align="left" >
          	<select name="tpl_amc_billposting[amc_refno]" id="amc_refno" style="width:100%;">
			<option value="">Select</option>
			</select>
          </td>
         <th>Amc Date</th>
         <td><input type="text" value="<?php if($amc_date!='') echo ConvertSqlDate($amc_date);?>" style="width:98%;"   name="tpl_amc_billposting[amc_date]" id="amc_date" class="datepicker"></td>
       </tr>
        <tr style="height:25px">
          <th> Invoice No.</th>
          <td width="30%" align="left" >
          	<input type="text" value="<?php echo $invoice_no;?>" style="width:98%;"   name="tpl_amc_billposting[invoice_no]" id="invoice_no">
          </td>
         <th>Bill Reference Number</th>
         <td><input type="text" value="<?php echo $bill_referenceno;?>" style="width:98%;"   name="tpl_amc_billposting[bill_referenceno]" id="bill_referenceno"></td>
        </tr>
         <tr style="height:25px">
          <th> Remarks</th>
          <td width="30%" align="left">
          	<input type="text" value="<?php echo $remarks;?>" style="width:98%;"   name="tpl_amc_billposting[remarks]" id="remarks">
          </td>
         </tr>
        <tr>
		<input type="hidden" name="tpl_amc_billposting[created]" value="<?php echo date('Y-m-d')?>">
		<input type="hidden" name="tpl_amc_billposting[created_by]" value="<?php echo $_SESSION['UserID']?>">
        <td style="padding:5px; text-align:center;" colspan="4" align="right">
		  <input type="submit" value="Save" 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>
</td>
        </tr>
      </table></td>
  
  </tr>
</table></fieldset>
</div></form>

<div align="center">
<div style="overflow:auto; width:800px; height:150px">
<table width="100%" border="0" align="center">
<tr>
<td bgcolor="#c6c6c6" ><table width="100%" border="0" cellspacing="1" cellpadding="5" align="center">
  <tr>
   	<th><strong>Asset Code</strong></th>
    <th><strong>Asset Name</strong></th>
    <th><strong>Bill Date</strong></th>
   	<th><strong>AMC Amount</strong></th>
   	<th><strong>Available AMC Amount</strong></th>
   	<th><strong>Amount To Be Billed</strong></th>
   	<th><strong>Additional Amount</strong></th>
   	<th><strong>Deduction Amount</strong></th>
    <th><strong>Tax</strong></th>
  </tr>
<tr bgcolor="#ffffff">
 </tr>
 </table>
</td>
</tr>
</table>
</div>
</div>
