<?php
require_once("../config/config.php");
@extract($_GET);
////// filters value/////
## selected username


//////End filters value/////

?>
<!DOCTYPE html>
<html>
<head>
 <meta charset="utf-8">
 <meta name="viewport" content="width=device-width, initial-scale=1">
 <title><?=siteTitle?></title>
 <script src="../js/jquery.min.js"></script>
 <link href="../css/font-awesome.min.css" rel="stylesheet">
 <link href="../css/abc.css" rel="stylesheet">
 <script src="../js/bootstrap.min.js"></script>
 <link href="../css/abc2.css" rel="stylesheet">
 <link rel="stylesheet" href="../css/bootstrap.min.css">
 <link rel="stylesheet" href="../css/jquery.dataTables.min.css">
 <script type="text/javascript" src="../js/jquery.dataTables.min.js"></script>
 <script>
$(document).ready(function(){
    $('#myTable').dataTable();
});
</script>
</head>
<body>
<div class="container-fluid">
  <div class="row content">
	<?php 
    include("../includes/leftnav2.php");
    ?>
    <div class="col-sm-9 tab-pane fade in active" id="home">
      <h2 align="center"><i class="fa fa-map-marker"></i>&nbsp;Track Location</h2>
      <?php if($_REQUEST[msg]){?><br>
      <h4 align="center" style="color:#FF0000"><?=$_REQUEST[msg]?></h4>
      <?php }?>
	  <form class="form-horizontal" role="form" name="form1" action="" method="get">
	   <div class="form-group">
          <div class="col-sm-6 col-md-6 col-lg-6"><label class="col-sm-5 col-md-5 col-lg-5 control-label">Users:</label>
             <div class="col-sm-5 col-md-5 col-lg-5">
                <select name="isp_name" id="isp_name" class="form-control" onChange="document.form1.submit();">
                                        <option value="">All</option>
                                        <?php    
                                        $sql = "Select eng_id from lead_user_track  group by eng_id order by id desc";
                                        $sqlres1 = mysqli_query($link1, $sql);                                        
                                        while($ispname1 = mysqli_fetch_assoc($sqlres1)){ 
                                        $ispname = mysqli_fetch_assoc(mysqli_query($link1, "select name,username from admin_users where username ='$ispname1[eng_id]' group by username order by uid desc"));
                                         if($ispname['username'] !=''){   ?>
                                        <option value="<?=$ispname['username']?>" <?php if($ispname['username']==$_REQUEST['isp_name']){ echo 'selected'; } ?>><?=$ispname['name']?></option>
                                        <?php } } ?>
                                    </select>
             </div>
          </div> 
          <div class="col-md-6"><label class="col-md-5 control-label"></label>	  
			<div class="col-md-5" align="left">
	
            </div>
          </div>
	    </div><!--close form group-->
	    
        <div class="form-group">
          <div class="col-md-6"><label class="col-md-5 control-label"></label>
            <div class="col-md-5">
               <input name="pid" id="pid" type="hidden" value="<?=$_REQUEST[pid]?>"/>
               <input name="hid" id="hid" type="hidden" value="<?=$_REQUEST[hid]?>"/>
               <input name="Submit" type="submit" class="btn btn-primary" value="GO"  title="Go!">
            </div>
          </div>
		  <div class="col-md-6"><label class="col-md-5 control-label"></label>	  
			<div class="col-md-5" align="left">	
			<?php 
			if($_REQUEST[isp_name] == '' ){
			?>
               <a href="excelexport.php?rname=<?=base64_encode("trackuser")?>&rheader=<?=base64_encode("Track User")?>&user=<?=base64_encode($_REQUEST['$isp_name'])?>" title="Export Track details in excel"><i class="fa fa-file-excel-o fa-2x" title="Export Track details in excel"></i></a>
			<?php }?>
            </div>
          </div>
	    </div><!--close form group-->
	  </form>
      <form class="form-horizontal" role="form">
	   <div class="col-md-12"><label class="col-md-5 control-label"></label>	  
      <div class="form-group"  id="page-wrap" style="margin-left:10px;"><br/><br/>
       <table  width="100%" id="myTable" class="table-striped table-bordered table-hover" align="center">
          <thead>
            <tr>
              <th><a href="#" name="entity_id" title="asc" ></a>#</th>
			   <th><a href="#" name="name" title="asc" class="not-sort"></a>Eng Id</th>
              <th><a href="#" name="name" title="asc" class="not-sort"></a>Address</th>
			  <th><a href="#" name="name" title="asc" class="not-sort"></a>Travel Date</th>
			  <th><a href="#" name="name" title="asc" class="not-sort"></a>Travel Time</th>
             
             
			  
              
            </tr>
          </thead>
          <tbody>
             <?php $i=1;
			 if($isp_name!=""){
			$sql1 = "SELECT distinct(eng_id), address,update_date FROM lead_user_track where eng_id='$isp_name'  order by travel_date desc";
			}else{
			 $sql1 = "SELECT distinct(eng_id), address,update_date FROM lead_user_track order by travel_date desc ";
				}
       $rs1 = mysqli_query($link1,$sql1) or die(mysqli_error($link1));
	   while($row1=mysqli_fetch_assoc($rs1)) { 
	       $datetime = $row1[update_date];
		  $t = explode(" ",$datetime);
	   ?>
	    <tr class="even pointer">
		<td><?php echo $i ;?><div align="left"></div></td>
		<td><?php echo $row1['eng_id']?></td>
          <td><?php echo $row1['address']?></td>
		  <td><?php  echo $t[0];?></td>
		  <td><?php echo $t[1];?></td>
            </tr>
	   <?php 
	  $i++;
	   }?>
	   
	  
          </tbody>
          </table>
      </div>
      </form>
    </div>
  </div>
</div>
</div>
<?php
include("../includes/footer.php");
include("../includes/connection_close.php");
?>
</body>
</html>