<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

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

$date = $_GET['date'];

$set = $_GET['set'];

if ($set=='yes') {
	  $saved_report_id = $_GET['saved_report_id'];
		$table_name = $_SESSION['db_prefix']."_saved_hr_reports";
		$read_query = "UPDATE $table_name SET read_done = 'yes' WHERE saved_report_id = '".$saved_report_id."' ";
		execsql($read_query);
}

if ($set=='all') {
	  	$table_name = $_SESSION['db_prefix']."_saved_hr_reports";
		$read_query = "UPDATE $table_name SET read_done = 'yes' WHERE user_name =  '".$_SESSION['username']."' AND department = 'HR' ";
		execsql($read_query);
}


$table_name2 = $_SESSION['db_prefix']."_saved_hr_reports";
$report_query = "SELECT * FROM $table_name2 WHERE user_name =  '".$_SESSION['username']."' ORDER BY saved_report_date DESC ";
$report_result = mySQL_query($report_query);
$report_num = mysql_num_rows($report_result);	

?>
<!--style sheets-->
<link rel="stylesheet" type="text/css" href="../css/tooltip.css" />
<link rel="stylesheet" type="text/css" href="../css/scroll_table.css" />

<!--jscript-->
<script language="JavaScript" src="../jscript/tooltip.js"  type="text/javascript"></script> 

</head>
<body>
<?php
include ("../navigation/header.php");
$page_name = "hr-main";
include ("../navigation/access.php");

if ($permission_num==1) {
	include ("../navigation/hr_sidebar.php");
?>
<div class="main_frame">
  <div class="page_head_frame">
  <table width="809" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="385"><label class="label_page_head">HR reports</label></td>
              <td width="253">&nbsp;</td>
              <td width="171" align="right">&nbsp;</td>
            </tr>
          </table>
        </div>
       
        <div class="page_middle_frame">
        

<?php
$page='hr_report_list.php';
$reference_name='set';
$reference='';
include('../include/period_select_block.php');
?>

<div class="page_inside_frame">        
      
<script type="text/javascript" language="javascript" src="../jscript/jquery.dataTables.js"></script>
<script type="text/javascript" charset="utf-8">
			$(document).ready(function() {
				$('#scroll_table').dataTable( {
					"sScrollY": "485px",
					"bPaginate": false,
					"bScrollCollapse": true,
					"aaSorting": [[ 3, "desc" ]],
					"aoColumns": [
					            {"bSortable": true}, 
								{"iDataSort": 3},
								{"bSortable": true},
								{"bVisible": false}
															
								 ]
				} );
			} );
		</script>
 
        <table width="742"  id="scroll_table" class="data_display" >
           
           <thead>
            <tr>
              <th width="58" align="center" ><a href="hr_report_list.php?set=all&date=1&date1=<?php echo $start?>&date2=<?php echo $end?>&delete=" onMouseover="ddrivetip('Click to set all to read.', 110)"; onMouseout="hideddrivetip()"><img src="../images/round_red_green.png" width="18" height="12" /></a></th>
              <th width="145" >Report date </th>
              <th align="left" >Report name</th>
              <th >&nbsp;</th>
            </tr>
            </thead>
            <?php 
$i=0;
$a7tot=0;
while ($i<$report_num) {
	$a0 = mysql_result($report_result, $i, "saved_report_id");
	$a1 = mysql_result($report_result, $i, "saved_report_date");
	$a2 = mysql_result($report_result, $i, "saved_report_name");
	$a3 = mysql_result($report_result, $i, "read_done");
	$a4 = mysql_result($report_result, $i, "report_date");
	
	$reportTT ='Report: '.$a2.'<br>'.date("d-m-Y", strtotime($a4)).'<br><b>Click to open report.</b>';	
	?>
            <tr>
              <td  style="padding-left:0px;" align="center"><?php if ($a3=='yes') { ?>
                <img src="../images/round_green.png" width="12" height="12" />
                <?php } else {?>
                <a href="hr_report_list.php?set=yes&saved_report_id=<?php echo $a0 ?>&date=1&date1=<?php echo $start?>&date2=<?php echo $end?>&delete=" onMouseover="ddrivetip('Click to set to read.', 100)"; onMouseout="hideddrivetip()"><img src="../images/round_red.png" width="12" height="12" /></a>
              <?php } ?></td>
              <td  style="padding-left:0px;" align="left"><a href="attendance_report.php?saved_report_id=<?php echo $a0 ?>" onmouseover="ddrivetip('<?php echo $reportTT?>', 250)"; onmouseout="hideddrivetip()"><?php echo date("d-m-Y, h:i", strtotime($a1)) ?></a></td>
              <td width="451" align="left"><a href="attendance_report.php?saved_report_id=<?php echo $a0 ?>" onmouseover="ddrivetip('<?php echo $reportTT?>', 250)"; onmouseout="hideddrivetip()"><?php echo $a2 ?></a></td>
              <td width="68" align="left"><?php echo $a1?></td>
            </tr>
            <?php
  $i++;
}
?>
           
          </table>
          
        </div>
  
 </div> 
</div>
<?php include ('../navigation/side_bar.php'); ?>
</body>
<?php } else {
$_SESSION['denied_return'] = "hr_module/hr_main.php";	
include ("../navigation/hr_sidebar.php");?>
<body onload="accessdenied(); return false">
</body>
<?php }
?>
</html>