<?php
$PageSecurity = 15;
$title = _('Other Deduction Charge');
$_SESSION['modid']=$_REQUEST['modid'];
$_SESSION['frmid']=$_REQUEST['frmid'];
$frmpermission= $px->GetFileAccess($_SESSION['modid'],$_SESSION['frmid'],$_SESSION['ACGRoleId']);
$_SESSION['frmAdd']=$frmpermission[0];
$_SESSION['frmEdit']=$frmpermission[1];
$_SESSION['frmDelete']=$frmpermission[2];echo "<br>";

if(isset($_GET['id']) and $_GET['act']=='del')
{
$SQL="delete from other_deduction_master where id='".$_GET['id']."'";
$ErrMsg = _('The Other Deduction Master  record could not be deleted because');
$result = DB_query($SQL,$db,$ErrMsg);
prnMsg( _(' Other Deduction Code Has Deleted!'),'success');
echo "<script>location.href='index.php?route=HRModule/OtherDeductionMaster&modid=".$_SESSION['modid']."&frmid=".$_SESSION['frmid']."'</script>";
}

if($_POST['edit'] =='' && $_REQUEST['act']=='edit' and $_GET['id']!='')
{
$SQL="select code,name from other_deduction_master where id='".$_GET['id']."'";
$result=DB_query($SQL,$db,$ErrMsg);
$resrow=DB_fetch_array($result);
$_POST['code']=$resrow['code'];
$_POST['name']=$resrow['name'];
$_POST['status']=$resrow['status'];
}

if($_POST['edit']!='' && $_REQUEST['act'] == 'edit' and $_GET['id']!='')
{
$SQL="update other_deduction_master set code='".$_POST['code']."', name ='".$_POST['name']."', status ='".$_POST['status']."' where id='".$_GET['id']."'";
$result = DB_query($SQL,$db,$ErrMsg);
prnMsg( _(' Other Deduction  Code Has Updated!'),'success');
echo "<script>location.href='index.php?route=HRModule/OtherDeductionMaster&modid=".$_SESSION['modid']."&frmid=".$_SESSION['frmid']."'</script>";
unset($_POST);
}

if(isset($_POST['add']) and !empty($_POST['code']) and !empty($_POST['name']) and $_GET['act']!='edit')
{
	
		
		$SQL = "insert into other_deduction_master(id, code, name,CompanyId,status)values ('','".$_POST['code']."','".$_POST['name']."','".$_SESSION['ACGCompanyId']."','".$_POST['status']."')";	
		$InsResult=DB_query($SQL,$db,$ErrMsg);
		prnMsg( _('A New Other Deduction Code Has Inserted!'),'success');
		echo "<script>location.href='index.php?route=HRModule/OtherDeductionMaster&modid=".$_SESSION['modid']."&frmid=".$_SESSION['frmid']."'</script>";
		unset($_POST);
	//prnMsg( _('This Deduction Code All Ready Exit please Enter New Group Code!'),'error');
}
?>
<h2 align="center"><strong>Other Deduction Charge</strong></h2>
<form method="post" action="">
<table width="35%" border="0" align="center">
<tr>
<th>Employee Code</th>
<td><input type="text" name="emp_code" id="emp_code" value="<?php echo $_POST['emp_code'];?>" /></td>
<th>Employee Name</th>
<td>




<input type="text" name="emp_code" id="emp_code" value="<?php echo $s->GetFieldValue('empmaster','id="'.$_POST['emp_id'].'"','emp_code');?>" /></td>
</tr>
</table>
<table width="35%" border="0" align="center">
<tr>
<th><strong>DEDUCTION CODE </strong></th>
<td><input name="code" type="text" id="code" value="<?php echo $_POST['code'];?>" size="30"/></td>
</tr>
<tr>
<th><strong>DEDUCTION NAME </strong></th>
<td><input name="name" type="text" id="name"  value="<?php echo $_POST['name'];?>" size="30"/></td>
</tr>
<tr>
<th><strong>STATUS </strong></th>
<td>
<input type="radio" name="status" value="A"  />Active&nbsp;&nbsp;&nbsp;<input type="radio" name="status" value="I"  />Inactive
</tr>
</table>
<p align="center">
<?php if($_GET['act']=='edit'){?>
<input type="submit" name="edit"  value="Edit" />
<input type="hidden" name='uiqeid' value="<?php echo $_GET['id'];?>" />
<?php }else{ if($_SESSION['frmAdd']=='1'){?>
<input type="submit" name="add"  value="Accept" />
<input type="submit" name="cancel"  value="Cancel" /> <?php } } ?></p>
</form>
<br />
<table width="50%" border="0" align="center">
<tr>
<th><strong>DEDUCTION CODE </strong></th>
<th><strong>DEDUCTION NAME </strong></th>
<th><strong>DEDUCTION STATUS </strong></th>
<th><strong>EDIT</strong></th>
<th><strong>DELETE</strong></th>
</tr>
<?php
$SQL ="select * from other_deduction_master";	
$result=DB_query($SQL,$db,$ErrMsg); 
while($resrow=DB_fetch_array($result)){?>
<tr class="tdclass">
<td><?php echo $resrow['code']?></a></td>
<td><?php echo $resrow['name']?></td>
<td><?php if($resrow['status']=="A"){echo "Active";}else{echo "Inactive";}?></td>
<td><?php if($_SESSION['frmEdit']=='1'){?><a href="index.php?route=HRModule/OtherDeductionMaster&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>&act=edit&id=<?php echo $resrow['id']?>" class="link"><img src="images/icon-edit.png" height="15" width="15"></a><?php }else echo "No Permission";?></td>
<td><?php if($_SESSION['frmDelete']=='1'){?><a href="index.php?route=HRModule/OtherDeductionMaster&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>&act=del&id=<?php echo $resrow['id']?>" onclick="return confirm('Are you sure you want to delete this record?')" class="link"><img src="images/Icon_Delete.png" height="15" width="15"></a><?php } else echo "No Permission";?></td>
</tr>
<?php }?>
</table>
<?php
include('includes/footer.inc');
?>
<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";
}
</style>