<?php
if($_REQUEST['id']!='' && $_REQUEST['action']=='delete')
{
	$del_sql="Delete from shift_master where id='".$_REQUEST['id']."'";
	$del_res=DB_query($del_sql,$db);
	echo "<script>location.href='index.php?route=HRModule/shift_master&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']."'</script>";
}
?>
<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain" >
<div class="tab_div">
<h1><?php echo $s->getField('modules_form','id',$_REQUEST['frmid'],'frm_name'); ?></h1>
 <?php if($_SESSION['frmcreate']=='1'){?>
<p align="left"><a href="index.php?route=HRModule/shift_master_add<?php echo $rurl;?>&action=AddNew"><input type="button" class="search" value="Add New" /></a></p><?php } ?>
<?php 
$shift_sql=DB_query("Select * from shift_master",$db);
?>
<table width="100%" border="0" cellspacing="0" cellpadding="3" class="thborder">
<tr>
	<th rowspan="2" width="10%">Branch</th>
	<th rowspan="2" width="6%">Code</th>
	<th rowspan="2">Name</th>
	<th rowspan="2" width="6%">Shift For</th>
	<th rowspan="2" width="12%">Shift Category</th>
	<th rowspan="2" width="8%">Shift Start</th>
	<th rowspan="2" width="8%">Shift End</th>
	<th rowspan="2" width="8%">Working Hours</th>
	<th rowspan="2" width="8%">Grace Period IN(Min.)</th>
	<th rowspan="2" width="8%">Grace Period OUT(Min.)</th>
	<th colspan="2" style="text-align:center;">Action</th>
</tr>
<tr>
	<th width="4%" style="text-align:center;">Edit</th>
	<th width="4%" style="text-align:center;">Delete</th>
</tr>
<?php
if(DB_num_rows($shift_sql)>0){
while($shift_row=DB_fetch_array($shift_sql))
{ 
?>
<tr>
<td><?php 
$loc=DB_query("SELECT locationname, loccode FROM locations where loccode= '".$shift_row['site']."'", $db);
$loc_row=DB_fetch_array($loc);
echo $loc_row['locationname'];
?></td>
<td><?php echo $shift_row['shift_code']; ?></td>
<td><?php echo $shift_row['shift_name']; ?></td>
<td><?php echo $shift_row['shift_for'];?></td>
<td><?php echo $s->getField('shift_category_master','id',$shift_row['shift_category'],'shift_category');?></td>
<td><?php echo $shift_row['shift_start']." ".$shift_row['start_AMPM'];?></td>
<td><?php echo $shift_row['shift_end']." ".$shift_row['end_AMPM'];?></td>
<td><?php echo $shift_row['working_hrs'];?></td>
<td><?php echo $shift_row['grace_period'];?></td>
<td><?php echo $shift_row['grace_period_out'];?></td>
<td align="center"><?php if($_SESSION['frmEdit']=='1'){?><a href="index.php?route=HRModule/shift_master_add&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>&id=<?php echo $shift_row['id'];?>&action=edit"><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/shift_master&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>&id=<?php echo $shift_row['id'];?>&action=delete" onClick="return confirm('Are you sure you want to delete this record?')"><img src="images/Icon_Delete.png" width="15" title="Delete Document" /></a><?php }else{ ?><img src="images/Icon_Delete.png" width="15" style="opacity:0.6;" title="No Permission to Delete Document" /><?php } ?></td>
</tr>
<?php  } }
else
{?>
<tr>
<td colspan="7" align="center"><font color="#FF0000">NO RECORD FOUND!</font></td>
</tr>
<?php 
}?>
</table>
</div>
</div>