<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--style sheets-->
<link href="../css/main.css" rel="stylesheet" type="text/css" />
<!--jscript-->
<script language="JavaScript" src="../jscript/go_to_url.js"  type="text/javascript"></script> 

</head>

<body>
<?php 
include ("../navigation/header.php");
$page_name = "HR-time recording";

$page_name = "HR-time recording";
include ("../navigation/access.php");


//$today = date("Y-m-d");
//$m = date("m");
//$month = date("F");
//$year = date("Y");

$m=$_GET['m'];
$Y=$_GET['Y'];

$select_date = date($Y."-".$m."-d");

switch ($m) {
    case 1: $select_month_name = 'January'; break;
	case 2: $select_month_name = 'February'; break;
	case 3: $select_month_name = 'March'; break;
	case 4: $select_month_name = 'April'; break;
	case 5: $select_month_name = 'May'; break;
	case 6: $select_month_name = 'June'; break;
	case 7: $select_month_name = 'July'; break;
	case 8: $select_month_name = 'August'; break;
	case 9: $select_month_name = 'September'; break;
	case 10: $select_month_name = 'October'; break;
	case 11: $select_month_name = 'November'; break;
	case 12: $select_month_name = 'December'; break;
}

$select_year = $Y;

if (($m==1) OR ($m==3) OR ($m==5) OR ($m==7) OR ($m==8) OR ($m==10) OR ($m==12)) { $day_no = 32; }
if (($m==4) OR ($m==6) OR ($m==9) OR ($m==11) ) { $day_no = 31; }
if (($m==2) ) { $day_no = 30; }


include ("../navigation/access.php");
if ($permission_num==1) {
	include ("../navigation/hr_sidebar.php");?>

<div class="main_frame">
<div class="page_head_frame">
        <table width="630" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="385"><label class="label_page_head">Time recording</label></td>
            <td align="right">&nbsp;</td>
          </tr>
        </table>
      </div>

<div class="page_middle_frame">
   <div class="page_inside_frame">
   <div style="width:550px; float:left;">
      Time recording for <?php echo $select_month_name.' '.$select_year ?>        
      <table width="470" id="table_details_display">
         <tr>
          <th width="55">Date</th>
          <th width="107">Day</th>
          <th width="136" align="center">Clock-in</th>
          <th width="152" align="center">Clock-out</th>
        </tr>
       
       <tbody>
       <?php
	   $i=1;
	   while ($i<$day_no) {
	   if ($i<10) {
		   $d='0'.$i;
		   
	   }
	   else {
		   $d=$i;
		   
	   }
	   
	   $day = date("l", strtotime($select_year.'-'.$m.'-'.$d));
	   	   
	   $recording_date = $select_year.'-'.$m.'-'.$d;
	  
	  
	   $table_name = $_SESSION['db_prefix']."_time_sheet";
	   $check_query = "SELECT emp_id, rec_in, rec_out FROM $table_name WHERE attendance_date = '".$recording_date."' ";
		$check_result = mySQL_query($check_query);
		$check_num = mysql_num_rows($check_result);
		
		if ($check_num>0) {
			    $rec_in = mysql_result($check_result, 0, "rec_in");
				$rec_out = mysql_result($check_result, 0, "rec_out");
		}
		else {
			$rec_in='0';
			$rec_out='0';
		}
		
	  
	   
	   $w='no';
	   $day_date = $i;
	   if (($day=='Saturday') OR ($day =='Sunday')) {
		      $day_date = '';
			  $day = '';
			  $w='yes';
			  $i++;
	   }
	   
	   	
	   ?>
        <tr>
          <td valign="middle"><?php echo $day_date ?></td>
          <td valign="middle"><?php echo $day ?></td>
          <td align="center" valign="middle"><?php if ($w=='no') { if ($rec_in=='0') { ?><a href="time_in_recording.php?recording_date=<?php echo $recording_date ?>"><img src="../images/clock.fw.png" width="20" height="16"></a><?php } else { ?><img src="../images/check_mark_blue.png" width="16" height="16"><?php } } ?></td>
          <td align="center" valign="middle"><?php if (($rec_in=='1') AND ($rec_out=='0')) { ?><a href="time_out_recording.php?recording_date=<?php echo $recording_date ?>"><img src="../images/clock.fw.png" width="20" height="16"></a><?php }?><?php if (($rec_in=='1') AND ($rec_out=='1')) { ?><img src="../images/check_mark_blue.png" width="16" height="16"><?php } ?></td>
        </tr>
      <?php
	  $i++;
	   }
	   ?>
       </tbody>
      </table>
      </div>
      
<div  style=" width:100px; float:left;">
<?php 
if ($m!=12) {$m_next=$m+1; $y_next=$Y;} else { $m_next=1; $y_next=$Y+1;}
if ($m!=1)  {$m_prev=$m-1; $y_prev=$Y;} else { $m_prev=12; $y_prev=$Y-1;}
?>
<a href="time_recording.php?m=<?php echo $m_prev ?>&Y=<?php echo $y_prev ?> "><input name="prev_button" type="button" value="< previous month" class="imagebutton" style="width:120px;"></a>
<a href="time_recording.php?m=<?php echo $m_next ?>&Y=<?php echo $y_next ?> "><input name="next_button" type="button" value="next month >" class="imagebutton" style="width:120px;"></a>
</div>      
      
      
      <div style="width:80px; float:left;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="overtime_rec.php?emp_id="><input type="button" name="overtime_button" id="overtime_button" value="Over time" class="imagebutton"></a>
    </div>
    </div>
</div>






</div>

<?php include ('../navigation/side_bar.php'); ?>


<?php } else {
    $_SESSION['denied_return'] = "hr_module/hr_main.php";	
    include ("../navigation/hr_sidebar.php");?>
    <?php include ('../navigation/side_bar.php'); ?>
	<body onLoad="accessdenied(); return false">	
	</body>
<?php }
?>

</body>
</html>