<?php
$PageSecurity = 15;
$title = _('Apprisal Policy Master') ;
$table='apprisal_policy_master';

if(isset($_REQUEST['add']))
{  $resrw=DB_fetch_array(DB_query("select * from apprisal_policy_master",$db));

	if($resrw['id']!=''){
	$dataArr['apprisal_type']=$_REQUEST['apprisal_type'];
	$data['apprisal_per']=$_REQUEST['apprisal_per'];
	//$dataArr['post_hd_dr']=$_REQUEST['post_hd_dr'];
	//$dataArr['post_hd_cr']=$_REQUEST['post_hd_cr'];
    $dataArr['companyId']=$_SESSION['ACGCompanyId'];
    $dataArr['modified_date']=date('Y-m-d');
    $dataArr['modified_by']=$_SESSION['UserID'];
    $cond="id='".$resrw['id']."'";
	$s->RecordEdit($table,$dataArr,$cond);

prnMsg( _('Data Update Successfully'),'success');
	}else{
$data['apprisal_type']=$_REQUEST['apprisal_type'];
$data['apprisal_per']=$_REQUEST['apprisal_per'];
//$data['post_hd_dr']=$_REQUEST['post_hd_dr'];
//$data['post_hd_cr']=$_REQUEST['post_hd_cr'];
$data['companyId']=$_SESSION['ACGCompanyId'];
$data['created_date']=date('Y-m-d');
$data['created_by']=$_SESSION['UserID'];
$s->RecordInsert($table,$data);
prnMsg( _('Data Inserted Successfully'),'success');
}
}
$SQL="select * from apprisal_policy_master";
$result=DB_query($SQL,$db,$ErrMsg);
$resrow=DB_fetch_array($result);
?>
<script>
function chkdatavalid(){
    if(document.getElementById('apprisal_type').value==''){
       alert("Please Select Apprisal Type");
       document.getElementById('apprisal_type').focus();
       return false;
	}
	/*else if(document.getElementById('post_hd_dr').value==''){
       alert("Please Select Posting Head Dr");
       document.getElementById('post_hd_dr').focus();
       return false;
	}
	else if(document.getElementById('post_hd_cr').value==''){
       alert("Please Select Posting Head Cr");
       document.getElementById('post_hd_cr').focus();
       return false;
	}*/
	else{
		return true;
	}
}
</script>
<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div"> 
<h1><?php echo $s->GetFieldValue("modules_form","id='".$_REQUEST['frmid']."' and moduleid='".$_REQUEST['modid']."'","frm_name");?></h1>
<form method="post" action="">
<table width="35%" border="0" align="center" cellpadding="3" cellspacing="0">
<tr class="row1">
    <td class="tabledata1"><strong>Type Of Apprisal</strong></td>
<td><select name="apprisal_type">
	<option>-- Select --</option>
	<option value="y" <?php echo ($resrow['apprisal_type']=='y'?'selected':'')?>>Yearly</option>
	<option value="f" <?php echo ($resrow['apprisal_type']=='f'?'selected':'')?>>Finance Year</option>
</select></td>
<td>Apprisal %</td>
<td><input type="text" name="apprisal_per" id="apprisal_per" value="<?php echo $resrow['apprisal_per']; ?>"> </td>

</tr>
<!--<tr class="row1">
    <td class="tabledata1"><strong>Posting Head Dr</strong></td>
<td>
<?php $dr_sql=DB_query("SELECT AccountsID,AccountName FROM accountledger WHERE CompanyId='".$_SESSION['ACGCompanyId']."' AND openingtype='DR'",$db);?>
<select name="post_hd_dr">
	<option>-- Select --</option>
	<?php while($dr_row=DB_fetch_array($dr_sql)){?>
	<option value="<?php echo $dr_row['AccountsID'];?>"<?php echo ($resrow['post_hd_dr']==$dr_row['AccountsID']?'selected':'')?>><?php echo $dr_row['AccountName'];?></option>
	<?php } ?>
</select></td>
</tr>
<tr class="row1">
    <td class="tabledata1"><strong>Posting Head Cr</strong></td>
<td>
<?php $cr_sql=DB_query("SELECT AccountsID,AccountName FROM accountledger WHERE CompanyId='".$_SESSION['ACGCompanyId']."' AND openingtype='CR'",$db);?><select name="post_hd_cr">
	<option>-- Select --</option>
	<?php while($cr_row=DB_fetch_array($cr_sql)){?>
	<option value="<?php echo $cr_row['AccountsID'];?>"<?php echo ($resrow['post_hd_cr']==$cr_row['AccountsID']?'selected':'')?>><?php echo $cr_row['AccountName'];?></option>
	<?php } ?>
</select></td>
</tr>-->
</table>
<p align="center">
<?php if($_SESSION['frmAdd']=='1'){?>
<input type="submit" name="add" class="search"  value="Submit" onclick="return chkdatavalid();"/>
<?php }?>
</form>

</table>
<style type="text/css" >
.button{ background-color:#666666;
color: #FFFFFF;
height:25px;
margin:0px 5px 0px 5px;
border:1px solid #359CA2;
}
.link{ color:#9900CC; font-family:"Comic Sans MS"; letter-spacing:1px
}
</style>