<!--Notice: (c)2013 This page is part of the management program for Tlhomeso Timbers, Gaborone, 
and developed by Customized Software (Pty) Ltd, Gaborone, Botswana. 
Customized Software holds the copyright on the source code on this and all other pages in the 
management program. For more info contact Customized Software on email: info@bwcustomized.com-->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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 ("../navigation/header.php");
$page_name = "HR-view petty cash";
include ("../navigation/access.php");

if ($permission_num==1) {
	include ("../navigation/hr_sidebar.php");
?>
<?php
require_once('../include/tc_calendar.php');
	$date = mysql_real_escape_string($_GET['date']);
	
	
	if ($date==1) {
	$start = mysql_real_escape_string($_GET['date1']);
    $end = mysql_real_escape_string($_GET['date2']);
	}
	else {
	$start = date("Y-m-d", strtotime("-1 month") ) ;
	$end = date("Y-m-d");
	}
		
	$ds = date("d", strtotime($start) );
	$ms = date("m", strtotime($start) );
	$ys = date("Y", strtotime($start) );
	
	
	$de = date("d", strtotime($end) );
	$me = date("m", strtotime($end) );
	$ye = date("Y", strtotime($end) );	 
	
	//$endsearch = date('Y-m-d', strtotime('+1 day', strtotime($end)));
	
	
	
$table_name2 = $_SESSION['db_prefix']."_pettycash";
$pettycash_query = "SELECT * FROM $table_name2 WHERE issue_date >= '".$start."' AND issue_date <= '".$end."' ";
$pettycash_result = mySQL_query($pettycash_query);
$pettycash_num = mysql_num_rows($pettycash_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 ('../include/tooltip.php'); ?>

<div class="main_frame">
  <table id="tableMain" > <!--begin of tableMain-->
    <tr>
      <td width="830" height="125" valign="top" ><div class="page_head_frame">
        
        <table width="809" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="385"><label class="label_page_head">Petty cash</label></td>
            <td width="253">&nbsp;</td>
            <td width="171" align="right">&nbsp;</td>
          </tr>
        </table>
      </div>
        <br />
<br />
<br />
<br />
  <form action="issued_list.php" method="get" name="dateform" class="today" id="dateform">
    <table width="831"  id='table_calendar'>
      <tr>
        <td height="20" colspan="3" align="left" valign="middle"><label class="label_std">Select time period to display</label></td>
        <td valign="middle">&nbsp;</td>
        <td valign="middle">&nbsp;</td>
        <td valign="middle">&nbsp;</td>
      </tr>
      <tr>
        <td width="34" height="25" valign="middle">&nbsp;&nbsp; </td>
        <td width="48" valign="middle"><label class="label_std">  from:</label> </td>
        <td width="236" valign="middle"><?php
		$myCalendar = new tc_calendar("date1", true);
		$myCalendar->setIcon("iconCalendar.gif");
		$myCalendar->setDate($ds, $ms, $ys);
		$myCalendar->setPath("./");
		$myCalendar->setYearInterval(2010, 2030);
	 	$myCalendar->writeScript();?></td>
        <td width="37" valign="middle"><label class="label_std">to:</label></td>
        <td width="254" valign="middle"><?php
		$myCalendar = new tc_calendar("date2", true);
		$myCalendar->setIcon("iconCalendar.gif");
		$myCalendar->setDate($de, $me, $ye);
		$myCalendar->setPath("./");
		$myCalendar->setYearInterval(2010, 2030);
		$myCalendar->writeScript();?></td>
        <td width="194" valign="middle">&nbsp;&nbsp;
          <label>
            <input name="button5" type="submit" class="linkbutton2"  id="button5" value="Go" />
            <input name="date" type="hidden" id="date" value="1" />
          </label></td>
      </tr>
    </table>
  </form>
</td> <!--center of tableMain-->
</tr>
<tr>
<td> <!--center of tableMain-->
<div class="page_middle_frame">
<table width="812" id="table_list" class="sortable-onload-0r rowstyle-alt no-arrow "  >
  <tr>
    <th class="sortable-date-dmy">date</th>
    <th class="sortable-text">employee</th>
    <th class="sortable-text">use</th>
    <th class="sortable-text">amount</th>
    <th class="sortable-date-dmy">&nbsp;</th>
    <th class="sortable-date-dmy">&nbsp;</th>
    </tr>
<?php 

$i=0;

while ($i<$pettycash_num) {

	$a =  mysql_result($pettycash_result, $i, "pettycash_id");
	$a0 = mysql_result($pettycash_result, $i, "issue_date");
		
	$a1 = mysql_result($pettycash_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");
		
	$a2 = mysql_result($pettycash_result, $i, "use");
	
	$a3 = mysql_result($pettycash_result, $i, "amount");
	
	
	$employeeTT = "<label class=tip_text_label>".$a1."</label><br><label class=tip_click_label>Click for details</label>";  
	$warningTT = "<label class=tip_text_label>".$a3."</label><br><label class=tip_click_label>Click to view warning</label>";  
	?>
    
  
  
  <tr>
    <td width="87" align="left"><?php echo date("d-m-Y", strtotime($a0 )) ?></td>
    <td width="222" align="left"><a href="employee-details.php?emp_id=<?php echo $a1a?>" onmouseover="ddrivetip('<?php echo $employeeTT ?>  ', 150)"; onmouseout="hideddrivetip()"><?php echo $a1a ?></a></td>
    <td width="71" align="left"><?php echo $a2 ?></td>
    <td width="274" align="left"><a href="warning_details.php?warning_id=<?php echo $a ?> " onMouseover="ddrivetip('<?php echo $warningTT ?>', 150)"; onMouseout="hideddrivetip()"> <?php echo $a3 ?>  </a></td>
    <td width="57" align="right">&nbsp;</td>
    <td width="71" align="left">&nbsp;</td>
    </tr>
  <?php
  $i++;
}
?>

</table>
<div align="left"><label class="label_end">end of list</label></div>
</div></td>
</tr>
</table>  <!--end of tableMain-->
  
</div>
</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>