<?php
$PageSecurity = 15;
$title = _('Other Deduction Master');
$_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,type,status 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['type']=$resrow['type'];
$_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']."', type ='".$_POST['type']."', 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 !empty($_POST['type']) and $_GET['act']!='edit')
{		
		$SQL = "insert into other_deduction_master(id, code, name, type,CompanyId,status)values ('','".$_POST['code']."','".$_POST['name']."','".$_POST['type']."','".$_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');
}
?>
<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div"> 
<h1><strong><?php echo $s->GetFieldValue('modules_form','id="'.$_REQUEST['frmid'].'"','description');?></strong></h1>
<form method="post" action="">
<table width="100%" border="0" cellpadding="3" cellspacing="0">
	<tr class="row1">
		<td width="13%" align="right">Code</td>
		<td width="30%"><input name="code" type="text" id="code" value="<?php echo $_POST['code'];?>" size="30" /></td>
		<td width="20%" align="right">Name</td>
		<td><input name="name" type="text" id="name" value="<?php echo $_POST['name'];?>" size="30" /></td>
	</tr>
	<tr class="row1">
		<td align="right">Type</td>
		<td style="padding-left:15px;"><input type="radio" name="type" value="D" <?php if($_POST['type']=='D'){ echo "checked='checked'";}?>  />Deduction &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="type" value="A" <?php if($_POST['type']=='A'){ echo "checked='checked'";}?> />Addition</td>
		<td align="right">Status</td>
		<td style="padding-left:15px;"><input type="radio" name="status" value="A" <?php if($_POST['status']=='A'){echo "checked='checked'";}?>  />Active &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="status" value="I" <?php if($_POST['status']=='I'){echo "checked='checked'";}?> />Inactive</td>
	</tr>
	<tr class="row1">
		<td colspan="4" align="center">
		<?php if($_GET['act']=='edit'){?>
		<input type="submit" name="edit"  value="Update" class="search" />
		<input type="hidden" name='uiqeid' value="<?php echo $_GET['id'];?>" class="search"  />
		<?php }else{ if($_SESSION['frmAdd']=='1'){?>
		<input type="submit" name="add"  value="Accept" class="search" />
		<input type="submit" name="cancel"  value="Cancel" class="search" /> <?php } } ?></td>
	</tr>
</table>
</form>

<br />

<table width="100%" border="0" cellspacing="0" cellpadding="3" class="thborder">
<tr>
	<th width="12%" rowspan="2">Code</th>
	<th rowspan="2">Name</th>
	<th width="18%" rowspan="2">Type</th>
	<th width="6%" rowspan="2">Status</th>
	<th colspan="2" class="text-center">Action</th>
</tr>
<tr>
	<th width="5%" class="text-center">Edit</th>
	<th width="5%" class="text-center">Delete</th>
</tr>
<?php
$SQL ="select * from other_deduction_master";	
$result=DB_query($SQL,$db,$ErrMsg); 
while($resrow=DB_fetch_array($result)){?>
<tr>
	<td><?php echo $resrow['code']?></a></td>
	<td><?php echo $resrow['name']?></td>
	<td><?php if($resrow['type']=="A"){echo "Addition";}else if($resrow['type']=="D"){echo "Deduction";}?></td>
	<td><?php if($resrow['status']=="A"){echo "Active";}else{echo "Inactive";}?></td>
	<td class="text-center"><?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" title="Edit Document" /></a><?php }else { ?><img src="images/icon-edit.png" height="15" width="15" style="opacity:0.6;" title="No Permission to Edit Document" /><?php } ?></td>
	<td class="text-center"><?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" title="Delete Document" /></a><?php } else {?><img src="images/Icon_Delete.png" height="15" width="15" style="opacity:0.6;" title="No Permission to Delete Document" /><?php } ?></td>
</tr>
<?php } ?>
</table>
</div></div>
<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>