<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php 
include('../include/session.php');

$emp_id = $_GET['emp_id'];
include('../include/period_select_date.php');	

$single=$_GET['single'];
if ($single==1) {
	$store_item_id = $_GET['store_item_id'];
}
 
$table_name = $_SESSION['db_prefix']."_employee_supply_lines";
if ($single==1) {	 	
	$display_query = "SELECT issue_date, emp_id, store_item_id, quantity, price FROM $table_name WHERE issue_date >= '".$start."' AND issue_date <='".$end."' AND emp_id = '".$emp_id."' AND store_item_id = '".$store_item_id."' ";
}
else {
	$display_query = "SELECT issue_date, emp_id, store_item_id, quantity, price FROM $table_name WHERE issue_date >= '".$start."' AND issue_date <='".$end."' AND emp_id = '".$emp_id."' ";
}
$display_result = execsql($display_query);
$display_num = mysql_num_rows($display_result); 

$table_name2 = $_SESSION['db_prefix']."_employee";
$employee_query = "SELECT emp_first_name, emp_last_name FROM $table_name2 WHERE emp_id ='".$emp_id."' ";
$employee_result = mySQL_query($employee_query);
$employee_num = mysql_num_rows($employee_result);	
$emp_name = mysql_result($employee_result, 0, "emp_first_name").' '.mysql_result($employee_result, 0, "emp_last_name"); 
?> 

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

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


</head>


<body>
<?php
include ("../navigation/header.php");
include ("../navigation/hr_sidebar.php");
$page_name = "HR-main";
include ("../navigation/access.php");
if ($permission_num==1) {
?>
<div class="main_frame">
<div class="page_head_frame">
  <label class="label_page_head">Supplies to employee</label>&nbsp;&nbsp;&nbsp; 
  <label class="label_page_head_2"><?php echo $emp_name ?></label>
  </div>

<div class="page_middle_frame">

<?php
$page='issued_employee_list.php';
$reference_name='emp_id';
$reference=$emp_id;
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": "500px",
					"bPaginate": false,
					"bScrollCollapse": true,
					"aaSorting": [[ 1, "desc" ]],
					"aoColumns": [
								{"iDataSort": 1},
								{"bVisible": false},
                              	{"bSortable": true},
                             	{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true}					
								 ]
				} );
			} );
		</script>    	
<table width="661" id="scroll_table" class="data_display" >
	<thead>
		<tr>
		  <th width="76">Date</th>
		  <th width="26">&nbsp;</th>
		  <th width="236">Item</th>
          <th width="86" >Quantity</th>
		  <th width="101" >Price</th>
		  <th width="108" >Total</th>
		  </tr>
	</thead>
	<tbody>
  <?php
    $b5_tot=0;
    $i=0;
	while($i < $display_num){
		 $b1 = mysql_result($display_result, $i, "issue_date");
		 		   
		 $b2 = mysql_result($display_result, $i, "store_item_id"); 
		 	$table_name = $_SESSION['db_prefix']."_store_items";
			$name_query = "SELECT item_name, subCategory, location, minimumStock, maximumStock, price  FROM $table_name WHERE store_item_id = '".$b2."'  ";
			$name_result = mySQL_query($name_query);
			$b2a = mysql_result($name_result, 0, "item_name");
			$a1a = mysql_result($name_result, 0, "item_name");
			$a1b = mysql_result($name_result, 0, "subCategory");
			$a1c = mysql_result($name_result, 0, "location");
			$a1d = mysql_result($name_result, 0, "minimumStock");
			$a1e = mysql_result($name_result, 0, "maximumStock");
			$a1f = mysql_result($name_result, 0, "price");
		 $b3 = mysql_result($display_result, $i, "quantity"); 	
		 $b4 = mysql_result($display_result, $i, "price"); 		
		 $b5 = $b3 * $b4;
		 $b5_tot = $b5_tot + $b5;
		 
		 $itemTT = "<table id=table_tool_tip width=250 ><tr><td  width=75>Item name:</td><td width=175>".$a1a."</td></tr><tr><td>Group</td><td>".$a1b."</td></tr><tr><td>Location:</td><td>".$a1c."</td></tr><tr><td>Min. stock</td><td>".$a1d."</td></tr><tr><td>Max. stock</td><td>".$a1e."</td></tr><tr><td>Price</td><td>".$a1f."</td></tr></table><b>Click for details</b>";
		?>
		<tr >
		  <td ><?php echo date("d-m-Y", strtotime($b1 ))?></td>
		  <td ><?php echo $b1 ?></td>
		  <td align="left"><a href="../store/store_item_display.php?store_item_id=<?php echo $b2 ?>" onMouseover="ddrivetip('<?php echo $itemTT ?>', 250)"; onMouseout="hideddrivetip()"><?php echo $b2a ?></a></td>
			<td align="left"><?php echo $b3?></td>
			<td align="right"><?php echo number_format($b4, 2, '.', ',') ?></td>
			<td align="right"><?php echo number_format($b5, 2, '.', ',') ?></td>
	      </tr>
		     
		<?php
		$i++; 
	}
	?>
    </tbody>
    <tfoot>
    <tr >
		  <td colspan="5" align="right" >Total: &nbsp;&nbsp;</td>
		  <td align="right"><?php echo number_format($b5_tot, 2, '.', ',') ?>&nbsp;</td>
		  </tr>
        </tfoot>
	
</table>
		
</div>	
</div>    
</div>
</body>
<?php } else { 
    $_SESSION['denied_return'] = "store/store_main.php";	?>
<body onLoad="accessdenied(); return false">
</body>
<?php }
?>
<?php include ('../navigation/side_bar.php'); ?>