<!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_log_in";
$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);


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

<!--jscript-->
<script language="javascript" src="../jscript/calendar.js"></script>
<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": 5},
                              	{"bSortable": true},
                             	{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bVisible": false}
								 ]
				} );
			} );
		</script>
</head>
<link rel="stylesheet" type="text/css" href="../css/tooltip.css" />
<body>
<?php include ('../include/tooltip.php'); ?>

<div class="main_frame">
<div class="page_head_frame">
        
        <table width="600" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="523"><label class="label_page_head">Log in tracking</label></td>
            <td width="287">&nbsp;</td>
          </tr>
        </table>
      </div>

<div class="page_middle_frame">	
<form action="tracking_login.php" method="get" name="dateform" class="today" id="dateform">
    <table width="665" >
      <tr>
        <td height="26" 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="16" height="25" valign="middle">&nbsp;&nbsp; </td>
        <td width="60" valign="middle"><label class="label_std">  from:</label> </td>
        <td width="232" 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="11" valign="middle"><label class="label_std">to:</label></td>
        <td width="266" 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="52" 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>
  </div>
  
<div class="page_middle_frame">

<table width="675" id="scroll_table" class="data_display"  >
  <thead>
  <tr>
    <th>date</th>
    <th>time</th>
    <th>user</th>
    <th>action</th>
    <th>details</th>
    <th>&nbsp;</th>
    </tr>
    </thead>
<?php 

$i=0;

while ($i<$tracking_num) {
    $b0  =  mysql_result($tracking_result, $i, "log_in_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="74" align="left"><?php echo date("d-m-Y", strtotime($b1 )) ?></td>
    <td width="64" align="left"><?php echo date("H:i", strtotime($b1 ))  ?></td>
    <td width="83" align="left"><?php echo $b2 ?></td>
    <td width="89" align="left"><?php echo $b3 ?></td>
    <td width="281" align="left"><?php echo $b4 ?></td>
    <td width="56" align="left"><?php echo $b1 ?></td>
    </tr>
  <?php
  $i++;
}
?>

</table>

<br />
</div>
</div>
</body>
<?php include ('../navigation/side_bar.php'); ?>

<?php } else { 
    $_SESSION['denied_return'] = "admin_module/user_list.php";	?>
<body onLoad="accessdenied(); return false">
</body>
<?php }
?>

</html>