<?php
if(isset($_POST['Save']))
{
  $start_date=FormatDateForSQL($_REQUEST['sub_retention_release_request']['request_date']);
		     
	     $_REQUEST['sub_retention_release_request']['request_date']=$start_date;
		
	    
		extract($_REQUEST['sub_retention_release_request']);
		if($s->RecordInsert('sub_retention_release_request',$_REQUEST['sub_retention_release_request']))
		{
		
		}
				unset($_REQUEST['sub_retention_release_request']);	
				
				$_SESSION['success_msg']="Saved Successfully";	
				echo "<script>location.href='index.php?route=SubContractors/retentionRelease/retention_release_request_index&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']."'</script>";
}
if($_REQUEST['action']=='edit' and $_REQUEST['pre']!='')
{
$sql=DB_query("select * from sub_retention_release_request where id='".$_REQUEST['pre']."'",$db);
$query=DB_fetch_array($sql);	
extract($query);	
	
}
if(isset($_POST['Update']))
{
	    $start_date=FormatDateForSQL($_REQUEST['sub_retention_release_request']['request_date']);
		
	     $_REQUEST['sub_retention_release_request']['request_date']=$start_date;
		
	    
		extract($_REQUEST['sub_retention_release_request']);
		 $s->RecordEdit('sub_retention_release_request',$_REQUEST['sub_retention_release_request'],"id=".$_REQUEST['pre']);
		$_SESSION['success_msg']="Update Successfully";
				
				echo "<script>location.href='index.php?route=SubContractors/retentionRelease/retention_release_request_index&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']."'</script>";
}
?>
<h3>Retention Release Request</h3>
<form action="" method="post">
<table width="100%" border="0" cellspacing="2" cellpadding="2">
  <tr>
    <td><table width="80%" border="0" cellspacing="2" cellpadding="2">
      <tr>
        <td width="12%" class="label"><strong>Contractor</strong></td>
        <td width="26%"><select name="sub_retention_release_request[contractor]" id="contractor">
          <option value="">Select Contractor </option>
          <?php
		$sqlcategory=DB_query("select * from sub_contractor_definition",$db);
		while($category_row=DB_fetch_array($sqlcategory))
		{
				$s='';
				if($contractor==$category_row['id'])
				$s="selected";
		?>
          <option value="<?php echo $category_row['id'];?>" <?php echo $s;?>><?php echo $category_row['contractor_name'];?></option>
          <?php } ?>
        </select></td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
      </tr>
	  <tr>
        <td width="12%" class="label"><strong>Request No. </strong></td>
        <td width="26%"><input type="text" name="sub_retention_release_request[request_no]" id="request_no" value="<?php echo $request_no; ?>"/></td>
		 <td width="24%" class="label"><strong>Request Date </strong></td>
        <td width="38%"><input type="text" name="sub_retention_release_request[request_date]" id="request_date" value="<?php echo ConvertSQLDate($request_date); ?>" class="datepicker" /></td>
      </tr>
    </table>
	<br />
	
	<table width="100%" border="0" cellspacing="2" cellpadding="2">
      <tr>
       
        <td width="91%">&nbsp;</td>
        <td width="9%"><input type="button" name="show_bills" value="Show Bills"/></td>
      </tr>
    </table>
	<br />
	<div align="center">
		<div style="overflow: auto;  width: 800px; height: 150px">
	<table width="100%" border="0" cellspacing="2" cellpadding="2" >
      <tr class="label" >
        <td><strong>Project Name </strong></td>
        <td><strong>Work Order No. </strong></td>
        <td><strong>Bill No. </strong></td>
        <td><strong>Bill Date </strong></td>
        <td><strong>Retention Amount </strong></td>
        <td><strong>Balance Amount </strong></td>
        <td><strong>Current Amount </strong></td>
        <td><strong>New Balance Amount </strong></td>
        <td><strong>Remarks</strong></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
	  <tr>
	  <td  colspan="3"></td>
	    <td align="center" colspan="2"><strong>Total Amount </strong></td>
		<td width="26%"><input type="text" name="sub_retention_release_request[total_amount]" id="total_amount" value="<?php echo $total_amount; ?>"/></td>
		<td  colspan="2"></td>
	  </tr>
    </table>
    </div>
	</div>
	<table width="100%" border="0" cellspacing="2" cellpadding="2">
      <tr>
       
        <td width="70%">&nbsp;</td>
        <td ><input type="submit" name="SaveContinue" value="Save & Continue" />
        	<input type="submit" name="<?php if($_REQUEST['action']=='edit') echo "Update"; else echo "Save"; ?>" value="<?php if($_REQUEST['action']=='edit') echo "Update"; else echo "Save"; ?>"/><input type="submit" name="Close" value="Close"/></td>
      </tr>
    </table>
	</td>
  </tr>
</table>
</form>
