<?php
session_start();
include("../includes/database.php");
include("../functions/functions.php");
if(!$_SESSION["customer_email"]){
header("location: ../checkout.php?error=Please-Provide-Your-Login-Details-Thanks.");
}else{
$user_a = @$_SESSION["customer_email"];
$user_ip_a = getIp();
$get_user_a = "select * from customers where customer_email = '$user_a' AND customer_ip = '$user_ip_a'";
$run_user_a = mysqli_query($con, $get_user_a);
$row_a = mysqli_fetch_array($run_user_a);
$cust_id_a = $row_a["customer_id"];
$cust_name_a = $row_a["customer_name"];
$cust_image_a = $row_a["customer_image"];
$cust_email_a = $row_a["customer_email"];
$cust_pass_a = $row_a["customer_pass"];
$cust_address_a = $row_a["customer_address"];
$cust_gender_a = $row_a["customer_gender"];
$cust_location_a = $row_a["customer_location"];
$cust_phone_a = $row_a["customer_phone"];
$grab_trakID = @$_GET["tracking_id"];
$grab_trakID = base64_decode($grab_trakID);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Delivery Process Tracking | <?php echo $comp_title; ?></title>
<?php include("includes/head.php"); ?>
</head>
<body class="cbp-spmenu-push">
<div class="main-content">
<!--left-fixed -navigation-->
<div class=" sidebar" role="navigation">
<div class="navbar-collapse">
<?php include("includes/menu.php"); ?>
</div>
</div>
<!--left-fixed -navigation-->
<!-- header-starts -->
<?php include("includes/header.php"); ?>
<!-- //header-ends -->
<!-- main content start-->
<div id="page-wrapper">
<div class="main-page">
<?php
if(isset($_GET["tracking_id"])){
?>
<div id="grab_result">
<table class="table table-striped shadow">
<thead>
<tr>
<th style="width: 25%">Invoice/Tracking ID</th>
<th style="width: 25%">Date and Time</th>
<th style="width: 50%">Description</th>
</tr>
</thead>
<tbody>
<?php
include("../includes/database.php");
$delDetails = "";
$get_trackingInfo_qu = "select * from order_tracking where invoice_no = '$grab_trakID' AND track_status = 'checked' ORDER BY trackID ASC";
$run_trackingInfo_qu = mysqli_query($con, $get_trackingInfo_qu);
$count_trackingInfo_qu = mysqli_num_rows($run_trackingInfo_qu);
if($count_trackingInfo_qu == 0){
echo "<script>alert('The Tracking Details Provided is not Valid, Please Try Again!')</script>";
echo "<script>window.open('my_orders.php','_self')</script>";
exit();
}
while($row_trackingInfo_qu = mysqli_fetch_array($run_trackingInfo_qu)){
$fetchDet = $row_trackingInfo_qu["delivery_details"];
$fetchPresTime = $row_trackingInfo_qu["present_time"];
if($fetchDet == "order_received"){
$delDetails = "Order Received";
}else if($fetchDet == "order_in_process"){
$delDetails = "Order In Process";
}else if($fetchDet == "order_ready_for_despatch"){
$delDetails = "Order Ready For Despatch";
}else if($fetchDet == "order_in_motion"){
$delDetails = "Order In Motion";
}else if($fetchDet == "order_arrival_at_destination"){
$delDetails = "Order Arrival at Destination";
}else if($fetchDet == "client_confirmation"){
$delDetails = "Client Check & Confirmation";
}else if($fetchDet == "product_delivered"){
$delDetails = "Product Delivered";
}else if($fetchDet == "order_complete"){
$delDetails = "Order Complete";
}else{
$delDetails = "";
}
?>
<tr>
<td><?php echo $grab_trakID; ?></td>
<td><time class="timeago" datetime="<?php echo $fetchPresTime; ?>"></time></td>
<td><?php echo $delDetails; ?></td>
</tr>
<?php } ?>
</tbody>
</table>
<?php
include("../includes/database.php");
$ret_driv_quer = "select * from assign_driver where invoice_no = '$grab_trakID'";
$run_ret_driv_quer = mysqli_query($con, $ret_driv_quer);
$count_ret_driv_quer = mysqli_num_rows($run_ret_driv_quer);
if($count_ret_driv_quer == 1){
$row_ret_driv_quer = mysqli_fetch_array($run_ret_driv_quer);
$ret_assgn_id = $row_ret_driv_quer["assign_id"];
$ret_driv_id = $row_ret_driv_quer["driver_id"];
$ret_driv_quer2 = "select * from driver where driver_id = '$ret_driv_id'";
$run_ret_driv_quer2 = mysqli_query($con, $ret_driv_quer2);
$row_ret_driv_quer2 = mysqli_fetch_array($run_ret_driv_quer2);
$ret_driv_fname = $row_ret_driv_quer2["driver_fullname"];
$ret_driv_img = $row_ret_driv_quer2["driver_picture"];
$ret_driv_mob = $row_ret_driv_quer2["driver_phone"];
?>
<hr />
<div style="padding: 20px;" class="col-md-4 shadow">
<h4>Driver Incharge Of Delivery</h4><hr />
<center><img src="../images/driver_images/<?php echo $ret_driv_img; ?>" class="img-responsive" width="200" height="200" /></center><br>
<div class="alert alert-info" role="alert">
<center><strong>Name: <?php echo $ret_driv_fname; ?> - Phone Number: <?php echo $ret_driv_mob; ?></strong></center>
</div>
</div>
<?php }else{} ?>
<!--<br><br><hr />
<div class="alert alert-primary" role="alert"><h4 align="center">The Tracking Details Provided is not Valid, Please Try Again!</h4></div>-->
</div>
<?php
}else{}
?>
<div class="clearfix"> </div>
</div>
</div>
<!--footer-->
<?php include("includes/footer.php"); ?>
<!--//footer-->
</div>
</body>
</html>
<?php } ?>