<!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>
<link rel="stylesheet" href="function/dataTables/media/css/demo_page.css">
<link rel="stylesheet" href="function/dataTables/media/css/demo_table_jui.css">
<link rel="stylesheet" href="function/dataTables/media/themes/smoothness/jquery-ui-1.8.4.custom.css">
<script type="text/javascript" src="function/dataTables/media/js/jquery.dataTables.js"></script>
<script type="text/javascript" language="javascript">
	$(document).ready(function(){ 
		$("#fromdate").datepicker({
			dateFormat : "yy-mm-dd",
			changeMonth : true,
			changeYear : true,
		});
	});
	$(document).ready(function(){
		$("#todate").datepicker({
			dateFormat : "yy-mm-dd",
			changeMonth : true,
			changeYear : true,
		});
	});
	$(document).ready( function () {
		var oTable = $('#myTables').dataTable( {
			 "sDom": 'R<"H"lfr>t<"F"ip>',
			 "bJQueryUI": true,
			 "sPaginationType": "full_numbers",
			 "iDisplayLength" :10
		});
	});
	function setTrColor(obj, color)
	{
		obj.style.backgroundColor=color;
		obj.onmouseout = function(){
				obj.style.backgroundColor=''; 
		}
	}
	function search_click(){
		form.action ='?page=Data-Aktivitas-User&cari=CARI';
		form.method = 'post';
		form.submit();		
		return true;
	}
	function excel_click(){
		form.action ='./master_data/user/excel_akt_user.php';
		form.method = 'post';
		form.submit();			
		return true;
	}
</script>
<?php
if(isset($_REQUEST['cari'])=="CARI"){
	 $fromdate	 = $_REQUEST['fromdate'];
	 $todate     = $_REQUEST['todate']; 	
 }else{
	 $fromdate	 = $start_date;
	 $todate     = date('Y-m-d');	
 }
?>
<form method="post" name="form" enctype="multipart/form-data">
<table width="100%">
	<tr>
		<th colspan="5">DATA AKTIVITAS USER</th>
	</tr>
	<tr>
	  <td colspan="5">Periode :
	      <input type="text" id="fromdate" name="fromdate" size="9" value="<?=$fromdate;?>" style="border-collapse:inherit"  readonly="true">&nbsp;s/d&nbsp;
	      <input type="text" id="todate" name="todate" size="9" value="<?=$todate;?>" style="border-collapse:inheri" readonly="true">
	      <input type="button" name="cari" value="CARI" style="cursor:pointer" onclick="search_click();">
		  <input type="button" name="excel" value="EXCEL" style="cursor:pointer" onclick="excel_click();">
		</td>
	</tr>
</table>
<table id="myTables" class="display" cellpadding="0" cellspacing="0">
	<thead>
	<tr>
		<th>No.</th>
		<th>User ID</th>
		<th>Aktivitas</th>
		<th>Tanggal</th>
		<th>Jam</th>
	</tr>
	</thead>
	<tbody>
	<?php		
	  	$no=1;
		$qd = mysql_query("SELECT * FROM user_activity WHERE user_date BETWEEN '$fromdate' AND '$todate' ORDER BY id DESC");
		while($dd=mysql_fetch_object($qd)){		
		?>
		  <tr onmouseover="setTrColor(this, '#FF9900');"> 
			<td align="center"><?=$no;?>.</td>
			<td align="center"><?=$dd->user_id;?></td>
			<td align="left"><?=$dd->user_act;?></td>
			<td align="center"><?=$dd->user_date;?></td>
			<td align="center"><?=$dd->user_time;?></td>
		  </tr>
      <?php $no++; }  ?>	
	  </tbody>
</table>
</form>