<!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 = "AD-tracking";
include ("../navigation/access.php");

if ($permission_num==1) {
	include ("../navigation/admin_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-01");
	$end = date("Y-m-31");
	}
		
	if ($date!=1) {
	   $ds = "1"; }
	   else {
		$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']."_tracking_admin";
$tracking_query = "SELECT * FROM $table_name2 WHERE entry_date >= '".$start."' AND entry_date <= '".$end."' ";
$tracking_result = mySQL_query($tracking_query);
$tracking_num = mysql_num_rows($tracking_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="825" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="523"><label class="label_page_head">Admin tracking</label></td>
            <td width="287">&nbsp;</td>
            </tr>
        </table>
      </div>
        <br />
<br />
<br />
<br />

	
  <form action="tracking_HR.php" method="get" name="dateform" class="today" id="dateform">
    <table width="690"  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 colspan="2" valign="middle">&nbsp;</td>
        </tr>
      <tr>
        <td width="45" height="25" valign="middle">&nbsp;&nbsp; </td>
        <td width="64" valign="middle"><label class="label_std">  from:</label> </td>
        <td width="230" valign="middle"><?php
		$myCalendar = new tc_calendar("date1", true);
		$myCalendar->setIcon("iconCalendar.gif");
		$myCalendar->setDate($ds, $ms, $ys);
		$myCalendar->setPath("./");
		$myCalendar->setYearInterval(2014, 2090);
	 	$myCalendar->writeScript();?></td>
        <td width="42" valign="middle"><label class="label_std">to:</label></td>
        <td width="250" valign="middle"><?php
		$myCalendar = new tc_calendar("date2", true);
		$myCalendar->setIcon("iconCalendar.gif");
		$myCalendar->setDate($de, $me, $ye);
		$myCalendar->setPath("./");
		$myCalendar->setYearInterval(2014, 2090);
		$myCalendar->writeScript();?></td>
        <td width="172" valign="middle"><input name="button5" type="submit" class="linkbutton"  id="button5" value="Go" />
          <input name="date" type="hidden" id="date" value="1" />
          </td>
        </tr>
    </table>
  </form></td> <!--center of tableMain-->
</tr>
<tr>
<td> <!--center of tableMain-->
<div class="scroll_frame_long">
<table width="659" id="table_list" class="sortable-onload-0r rowstyle-alt no-arrow "  >
  <tr>
    <th class="sortable-date-dmy">date</th>
    <th class="sortable-date-dmy">time</th>
    <th class="sortable-text">user</th>
    <th class="sortable-text">action</th>
    <th class="sortable-text">details</th>
    <th >&nbsp;</th>
    <th >&nbsp;</th>
    
    </tr>
<?php 

$i=0;

while ($i<$tracking_num) {
    $b0  =  mysql_result($tracking_result, $i, "action_id");
	$b1 =  mysql_result($tracking_result, $i, "entry_date");
	$b2 =  mysql_result($tracking_result, $i, "user");
	$b3 =  mysql_result($tracking_result, $i, "action");
	$b4 = mysql_result($tracking_result, $i, "details");
	
	
	//$bookingTT = "<label class=tip_text_label_bold>Booking for  ".$comp_name."</label><br><label class=tip_text_label>from ".date("d-m-Y", strtotime($a0))." to ".date("d-m-Y", strtotime($t1))."</label></br><br><label class=tip_click_label>Click for details";  
	//$equipmentTT = "<label class=tip_text_label_bold>".$a2." ".$a2a." ".$a2b."</label><br><br><label class=tip_click_label>Click for details"; 
   // $deliveryTT =  "<label class=tip_text_label_bold>Delivery note ".$a3."</label><br><br><label class=tip_click_label>Click for details";  
	
	?>
  
  
  <tr>
    <td width="84" align="left"><?php echo date("d-m-Y", strtotime($b1 )) ?></td>
    <td width="68" align="left"><?php echo date("H:m", strtotime($b1 ))  ?></td>
    <td width="126" align="left"><?php echo $b2 ?></td>
    <td width="97" align="left"><?php echo $b3 ?></td>
    <td width="146" align="left"><?php echo $b4 ?></td>
    <td width="57" align="left"></td>
    <td width="49" 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'] = "admin_module/user_list.php";	
    include ("../navigation/admin_sidebar.php");?>
	<body onLoad="accessdenied(); return false">
<?php }
?>
<?php include ('../navigation/side_bar.php'); ?>
</html>