<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!--style sheets--> 
<link href="../css/main.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="../css/scroll_table.css" />
<!--jscript-->

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

if ($date==5) {
	  $emp_id=$_GET['emp_id'];
}
else {
	$emp_id='all';
}

	
$table_name2 = $_SESSION['db_prefix']."_severance";
if ($emp_id=='all') {
$severance_query = "SELECT * FROM $table_name2 WHERE pay_out_date >= '".$start."' AND pay_out_date <= '".$end."' ";
}
else {
$severance_query = "SELECT * FROM $table_name2 WHERE emp_id = '".$emp_id."' AND pay_out_date >= '".$start."' AND pay_out_date <= '".$end."' ";
}
$severance_result = mySQL_query($severance_query);
$severance_num = mysql_num_rows($severance_result);


?>
<script type="text/javascript" src="../jscript/tablesort.js"></script>
<script language="javascript" src="../jscript/calendar.js"></script>
</head>
<link rel="stylesheet" type="text/css" href="../css/tooltip.css" />
<body>
<?php
include ("../navigation/header.php");
$page_name = "HR-severance";
include ("../navigation/access.php");

if ($permission_num==1) {
	include ("../navigation/hr_sidebar.php");
    include ('../include/tooltip.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">Severance</label></td>
            <td width="253">&nbsp;</td>
            <td width="171" align="right">&nbsp;</td>
          </tr>
        </table>
      </div>
<div class="page_middle_frame">
<?php
$page='severance_list.php';
$reference_name='';
$reference='';
include('../include/period_select_block.php');
?>
<div class="page_inside_frame">
<!--jscript-->
<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": "500px",
					"bPaginate": false,
					"bScrollCollapse": true,
					"aaSorting": [[ 0, "desc" ]],
					"aoColumns": [
					     		{"iDataSort": 7},
                              	{"bSortable": true},
                             	{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bVisible": false}
								 ]
				} );
			} );
		</script>
<table width="680" id="scroll_table" class="data_display"  >
  <thead>
  <tr>
    <th>Date</th>
    <th>Employee</th>
    <th>Amount</th>
    <th>Period</th>
    <th>From</th>
    <th>To</th>
    <th>Authorised</th>
    <th width="40">&nbsp;</th>
    </tr>
    </thead>
<?php 

$i=0;
$a3_total=0;
$a6_total=0;
while ($i<$severance_num) {

	$a =  mysql_result($severance_result, $i, "severance_id");
	$a0 = mysql_result($severance_result, $i, "pay_out_date");
		
	$a1 = mysql_result($severance_result, $i, "emp_id");
	   	$table_name = $_SESSION['db_prefix']."_employee";
    	$employee_query = "SELECT emp_first_name, emp_last_name, department  FROM $table_name WHERE emp_id = $a1 ";
		$employee_result = mySQL_query($employee_query);
        $a1a = mysql_result($employee_result, 0, "emp_first_name")." ".mysql_result($employee_result, 0, "emp_last_name");
		
	$a3 = mysql_result($severance_result, $i, "amount");
	$a4 = mysql_result($severance_result, $i, "period_years");
	$a5 = mysql_result($severance_result, $i, "period_months");
	$a6 = mysql_result($severance_result, $i, "period_from");
	$a7 = mysql_result($severance_result, $i, "period_to");
	$a8 = mysql_result($severance_result, $i, "authorised_by");
		
	$a3_total = $a3_total + $a3;
	$a6_total = $a6_total + $a6;
	$employeeTT = "<label class=tip_text_label>".$a1."</label><br><label class=tip_click_label>Click for details</label>";  
	
	?>

  <tr>
    <td width="60" align="left"><?php echo date("d-m-Y", strtotime($a0 )) ?></td>
    <td width="137" align="left"><a href="employee_details.php?emp_id=<?php echo $a1?>" onmouseover="ddrivetip('<?php echo $employeeTT ?>  ', 150)"; onmouseout="hideddrivetip()"><?php echo $a1a ?></a></td>
    <td width="60" align="right"><?php echo number_format($a3, 2, '.', ',') ?></td>
    <td width="76" align="center"><?php echo $a4.'y - '.$a5.'m' ?></td>
    <td width="107" align="center"><?php echo date("d-m-Y", strtotime($a6)) ?></td>
    <td width="82" align="center"><?php echo date("d-m-Y", strtotime($a7)) ?></td>
    <td width="82" align="center"><?php echo $a8 ?></td>
    <td><?php echo $a0 ?></td>
    </tr>
  
  <?php
  $i++;
}
?>
<tfoot>
<tr>
    <td colspan="2" align="right">Totals:</td>
    <td align="right"><?php echo number_format($a3_total, 2, '.', ',') ?></td>
    <td colspan="5" align="right">&nbsp;</td>
    </tr>
  </tfoot>
</table>
</div>
</div>
</div>

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


</body>
</html>