<?php
require_once("../config/config.php");
$engid = base64_decode($_REQUEST['id']);
$traveldate = base64_decode($_REQUEST['travel_date']);
$totdist = base64_decode($_REQUEST['total_distance']);
?>
<!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">
</head>
<body>
<div class="container-fluid">
 <div class="row content">
	<?php 
    include("../includes/leftnav2.php");
    ?>
   <div class="col-sm-9">
      <h2 align="center"><i class="fa fa-child"></i> Distance Covered</h2>
   <div class="panel-group">
    <div class="panel panel-info table-responsive">
        <div class="panel-heading">User Information</div>
         <div class="panel-body">
          <table class="table table-bordered" width="100%">
            <tbody>
              <tr>
                <td width="20%"><label class="control-label">Eng Id</label></td>
                <td width="30%"><?php echo str_replace("~",",",getAdminDetails($engid,"name,username",$link1));?></td>
                <td width="20%"><label class="control-label">Travel Date</label></td>
                <td width="30%"><?php echo $traveldate;?></td>
              </tr>
              <tr>
                <td><label class="control-label">Total Distance</label></td>
                <td><?=$totdist?> KM</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
            </tbody>
          </table>
        </div><!--close panel body-->
    </div><!--close panel-->
    <div class="panel panel-info table-responsive">
      <div class="panel-heading">Distance Information</div>
      <div class="panel-body">
       <table class="table table-bordered" width="100%">
            <thead>
              <tr class="<?=$tableheadcolor?>">
                <th style="text-align:center" width="15%">From Location</th>
                <th style="text-align:center" width="10%">From Time</th>
                <th style="text-align:center" width="10%">To Location</th>
                <th style="text-align:center" width="10%">To Time</th>
                <th style="text-align:center" width="10%">Distance Covered</th>
                </tr>
            </thead>
            <tbody>
            <?php
			$arr_from = array();
			$arr_from_time = array();
			$arr_to = array();
			$arr_to_time = array();
			$arr_distance = array();
			$i = 1;
			$sql = "SELECT travel_date,travel_time, address,travel_km FROM lead_user_track where eng_id='".$engid."' and travel_date='".$traveldate."' order by id";
			$res = mysqli_query($link1,$sql);
			while($row = mysqli_fetch_assoc($res)){
				if($i%2 == 1){
					$arr_from[] = $row["address"];
					$arr_from_time[] = $row["travel_date"]." ".$row["travel_time"];
				}
				if($i%2 == 0){
					$arr_to[] = $row["address"];
					$arr_to_time[] = $row["travel_date"]." ".$row["travel_time"];
					$arr_distance[] = $row["travel_km"];
				}
				$i++;
			}
			for($j=0; $j<count($arr_from); $j++){
			?>
              <tr>
                <td><?=$arr_from[$j]?></td>
                <td align="center"><?=$arr_from_time[$j]?></td>
                <td><?=$arr_to[$j]?></td>
                <td align="center"><?=$arr_to_time[$j]?></td>
                <td align="right"><?=$arr_distance[$j]?></td>
                </tr>
            <?php
			}
			?>
            <tr>
                 <td colspan="5" align="center">
                 <input title="Back" type="button" class="btn <?=$btncolor?>" value="Back" onClick="window.location.href='track_total_distance.php?<?=$pagenav?>'"></td>
                </tr>
            </tbody>
          </table>
      </div><!--close panel body-->
    </div><!--close panel-->

  </div><!--close panel group-->
 </div><!--close col-sm-9-->
</div><!--close row content-->
</div><!--close container-fluid-->
<?php
include("../includes/footer.php");
include("../includes/connection_close.php");
?>
</body>
</html>