<?php
$PageSecurity = 15;
$title = _('Late Count Master') ;
$cur_date=date('Y-m-d');
if(!empty($_GET['id']) and $_REQUEST['act']=='del')
{
$SQL="delete from late_count_master where id='".$_GET['id']."'";
//$ErrMsg = _('The record could not be deleted because');
$result = DB_query($SQL,$db);
prnMsg( _(' Record Has been Deleted!'),'success');
echo "<script>location.href='index.php?route=HRModule/late_count_master&modid=".$_SESSION['modid']."&frmid=".$_SESSION['frmid']."'</script>";
}



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

if($_POST['edit'] && $_REQUEST['act'] == 'edit')
{
	
    	 $SQL="update late_count_master set late_allow = '".$_REQUEST['late_allow']."', modified_date='".$cur_date."',modified_by='".$_SESSION['UserID']."' where id='".$_GET['id']."'";
         $result = DB_query($SQL,$db);
        prnMsg( _(' Record has been Updated!'),'success');
         echo "<script>location.href='index.php?route=HRModule/late_count_master&modid=".$_SESSION['modid']."&frmid=".$_SESSION['frmid']."'</script>";
         unset($_POST);
      
}

if(isset($_POST['add']) and $_GET['act']!='edit')
{
	
		$SQL = "INSERT into late_count_master(late_allow,CompanyId,created_by,created_date) 
					 values('".$_REQUEST['late_allow']."','".$_SESSION['ACGCompanyId']."','".$_SESSION['UserID']."','".$cur_date."')";	
		
		$InsResult=DB_query($SQL,$db);
		prnMsg( _('Record Inserted Successfully'),'success');
		echo "<script>location.href='index.php?route=HRModule/late_count_master&modid=".$_SESSION['modid']."&frmid=".$_SESSION['frmid']."'</script>";
}
?>
<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div"> 
<form method="post" action="">
<h1><strong>Late Count Master</strong></h1>
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="0">
<tr class="row1">
    <td width="15%" style="text-align:right;"><strong>No. of Late Allowed</strong></td>
	<td width="35%"><input name="late_allow" type="text" id="late_allow" value="<?php echo $late_allow; ?>" style="width:98%;" onkeyup="leftTrim(this)" autocomplete="off"/></td>

</tr>
<tr class="row1">
  <td colspan="4"><p align="center"><?php
if($_GET['act']=='edit'){?><input type="submit" name="edit" class="search" value="Update" onclick="return validate();" /> <input type="hidden" name='uiqeid' class="search" value="<?php echo $_GET['id']; ?>" />
<?php }else{ 
if($_SESSION['frmAdd']=='1'){?>
<input type="submit" name="add" class="search" value="Submit" onclick="return validate();" /> <input type="reset" name="cancel" class="search"  value="Reset" /><?php }} ?>
</td>
  </tr>
</table>

</form>
<br>
<table width="50%" border="1" align="center" cellpadding="3" cellspacing="0" style="border:#808080 1px solid; border-collapse:collapse;">
<tr>
    <th width="20%"><strong>No. Of Days Allowed</strong></th>
    <th width="6%"><strong>Edit</strong></th>
    <th width="6%"><strong>Delete</strong></th>
</tr>
<?php
$SQL ="select * from late_count_master where companyId='".$_SESSION['ACGCompanyId']."'";	
$result=DB_query($SQL,$db,$ErrMsg); 
while($resrow=DB_fetch_array($result)){?>
<tr bgcolor="#fff">
<td><?php echo $resrow['late_allow']; ?></td>
<td align="center">
<?php if($_SESSION['frmEdit']=='1'){?>
<a href="index.php?route=HRModule/late_count_master&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 align="center">
<?php if($_SESSION['frmDelete']=='1') {?>
<a href="index.php?route=HRModule/late_count_master&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_Delete3.gif' width="14" title="Delete Document" /></a><?php }else {?><img src='images/Icon_Delete3.gif' width="14" style="opacity:0.6;" title="No Permission to Delete Document" /><?php }?></td>
</tr>
<?php }?>
</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>
<script type="text/javascript">
	
	function validate()
	{
		if($("#deptcode").val()=='')
		{
			alert("Please Enter Department Code");
			$("#deptcode").focus();
			return false;
		}
		else if($("#deptname").val()=='')
		{
			alert("Please Enter Department Name");
			$("#deptname").focus();
			return false;
		}


	}

	function leftTrim(element)
{
	if(element)
		element.value=element.value.replace(/^\s+/,"");
}

</script>