<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<link href="../css/main.css" rel="stylesheet" type="text/css" />

<?php
include('../include/session.php');


date_default_timezone_set('Africa/Gaborone');
$entry_date = date("Y-m-d H:i:s", time()); 

$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 = 31; }
if (($m==4) OR ($m==6) OR ($m==9) OR ($m==11) ) { $day_no = 30; }
if (($m==2) ) { $day_no = 29; }

//$table_name = $_SESSION['db_prefix']."_settings";
//$work_week_query = "SELECT setting_value  FROM $table_name WHERE setting_name = 'work_week'  ";
//$work_week_result = mySQL_query($work_week_query);
//$work_week = mysql_result($work_week_result, 0, "setting_value");
?>
<script type="text/javascript">
function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}
</script>
</head>



<?php
include ("../navigation/header.php");
$page_name = "HR-time recording";
include ("../navigation/access.php");
if ($permission_num==1) {
	include ("../navigation/hr_sidebar.php");
?>

<body>


<div class="main_frame"  style="height:auto; min-height:570px;">

<div class="page_head_frame">
        <label class="label_page_head">Day time recording</label>&nbsp;&nbsp;&nbsp;&nbsp;<label class="label_page_head_2"><?php echo $select_month_name.' '.$select_year ?></label>
        
      </div>
        <br /><br />
        <div class="page_middle_frame">
        
<div class="page_inside_frame">
  <div class="lay_out_frame" style="float:left;"> Time recording for <?php echo $select_month_name.' '.$select_year ?>
    <table width="256" id="table_list">
      <tr>
        <th width="49">Date</th>
        <th width="62">Day</th>
        <th width="129" align="center">Clock-in</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, check_in, check_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 ($work_week=='5') {
	   if (($day=='Saturday') OR ($day =='Sunday')) {
		      $day_date = '';
			  $day = '';
			  $w='yes';
			  $i++;
	   }
//	   }
//	  
//	   if ($work_week=='5.5') {
//	   if ( ($day =='Sunday')) {
//		      $day_date = '';
//			  $day = '';
//			  $w='yes';			  
//	   }
//	   }
	   	
	   ?>
        <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_day_recording.php?recording_date=<?php echo $recording_date ?>"><img src="../images/clock_green.png" alt="" width="20" height="16"></a>
            <?php } else { ?>
            <img src="../images/check_mark_green.png" alt="" width="16" height="16">
            <?php } } ?></td>
        </tr>
        <?php
	  $i++;
	   }
	   ?>
      </tbody>
    </table>
  </div>
  <div class="lay_out_frame" style="float:right;">
    <?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_day.php?m=<?php echo $m_prev ?>&Y=<?php echo $y_prev ?> ">
      <input name="prev_button" type="button" value="< previous month" class="imagebutton">
      </a> <a href="time_recording_day.php?m=<?php echo $m_next ?>&Y=<?php echo $y_next ?> ">
        <input name="next_button" type="button" value="next month >" class="imagebutton">
      </a> </div>
  <br>
<br>
</div>

<div class="hidden_frame" id="hidden_frame">
<br>
<br>


<div class="page_inside_frame">
<br>
<br>
 
 
</div>
<div class="page_inside_frame"></div>

</div>     
</div>
</div>


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


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



</html>