<?php
require "mail.php";
if(!isset($_GET['id'])){
    header("Location: index");
}
else{
    $id=$_GET['id'];
    require "config.php";
    $get_order=mysqli_query($conn, "SELECT * FROM orders WHERE tracking_id='$id'");
    if(mysqli_num_rows($get_order)>0){
        $order=mysqli_fetch_assoc($get_order);
        $package_name=$order['item'];
        $first_name=$order['first_name'];
        $last_name=$order['last_name'];
        $photo=$order['photo'];
        $description=$order['description'];
        $sender=$order['sender'];
        $receivers_address=$order['receivers_address'];
        $phone=$order['phone'];
        $status=$order['status'];
        $created=$order['created'];
        $location=$order['location'];
        $status_num=0;
		if($status=="hold"){
			$status_num=0;
		}
        elseif($status=="processing"){
            $status_num=1;
        }
        elseif($status=="in transit"){
            $status_num=2;
        }
        else{
            $status_num=3;
        }

        if(isset($_GET['email'])){
            $email=$_GET['email'];
            $message="
            <p>Here is the package(#$id) you requested on Flyexcarriers.com</p>
            <p><strong>Package Name:</strong>  $package_name </p>
            <p><strong>Status:</strong>  $status </p>
            <p><strong>Receiver:</strong>  $first_name $last_name </p>
            <p><strong>Current Location:</strong>  $location </p>
            <p><strong>Receiver's Address:</strong>  $receivers_address </p>
            <p><strong>Sender:</strong>  $sender </p>
            <p><strong>Contact:</strong>   $phone</p>
            <p>$description</p>
            
            ";

            $subject="Package #$id Info";

            //sendmail($email,$subject,$message);
        }
    }
    else{
        header("Location: 404");
    }
}


require "header.php";
?>

<style>
    .page-title .title{
        font-size: 40px !important;
    }
   
    .hh-grayBox {
	background-color: #F8F8F8;
	margin-bottom: 20px;
	padding: 35px;
  margin-top: 20px;
}
.pt45{padding-top:45px;}
.order-tracking{
	text-align: center;
	width: 33.33%;
	position: relative;
	display: block;
}
.order-tracking .is-complete{
	display: block;
	position: relative;
	border-radius: 50%;
	height: 30px;
	width: 30px;
	border: 0px solid #AFAFAF;
	background-color: #f7be16;
	margin: 0 auto;
	transition: background 0.25s linear;
	-webkit-transition: background 0.25s linear;
	z-index: 2;
}
.order-tracking .is-complete:after {
	display: block;
	position: absolute;
	content: '';
	height: 14px;
	width: 7px;
	top: -2px;
	bottom: 0;
	left: 5px;
	margin: auto 0;
	border: 0px solid #AFAFAF;
	border-width: 0px 2px 2px 0;
	transform: rotate(45deg);
	opacity: 0;
}
.order-tracking.completed .is-complete{
	border-color: #27aa80;
	border-width: 0px;
	background-color: #27aa80;
}
.order-tracking.completed .is-complete:after {
	border-color: #fff;
	border-width: 0px 3px 3px 0;
	width: 7px;
	left: 11px;
	opacity: 1;
}
.order-tracking p {
	color: #A4A4A4;
	font-size: 16px;
	margin-top: 8px;
	margin-bottom: 0;
	line-height: 20px;
}
.order-tracking p span{font-size: 14px;}
.order-tracking.completed p{color: #000;}
.order-tracking::before {
	content: '';
	display: block;
	height: 3px;
	width: calc(100% - 40px);
	background-color: #f7be16;
	top: 13px;
	position: absolute;
	left: calc(-50% + 20px);
	z-index: 0;
}
.order-tracking:first-child:before{display: none;}
.order-tracking.completed:before{background-color: #27aa80;}

  .text-sm{
    font-size: small;
  }  
</style>
<section class="page-title" style="background-image: url(images/background/4.jpg);">
		<div class="auto-container">
			<div class="title-outer">
				<h3 class="title">Package #<?php echo $id; ?></h3>
				<ul class="page-breadcrumb">
					<li><a href="index">Home</a></li>
					<li>tracking</li>
				</ul>
			</div>
		</div>
	</section>
	<?php
	if($status=="hold"){
		?>

		<div class="alert alert-warning">
		<i class="fa fa-exclamation-triangle" aria-hidden="true"></i>
		<strong>
			This package is currently on hold
		</strong>
		</div>
	<?php
	}
	?>
	<!-- end main-content -->

	<!--Product Details Start-->
	<section class="product-details">
		<div class="container">
			<div class="row">
				<div class="col-lg-6 col-xl-6">
					<div class="bxslider">
						<div class="slider-content">
							<figure class="image-box"><a href="images/products/<?php echo $photo; ?>" class="lightbox-image" data-fancybox="gallery"><img src="images/products/<?php echo $photo; ?>" alt=""></a></figure>
							
						</div>
						
						<div class="slider-content">
							<figure class="image-box"><a href="images/products/<?php echo $photo; ?>" class="lightbox-image" data-fancybox="gallery"><img src="images/products/<?php echo $photo; ?>" alt=""></a></figure>
							
						</div>
					</div>
				</div>
				<div class="col-lg-6 col-xl-6">
					<div class="product-details__top">
						<h3 class="product-details__title"><?php echo $package_name; ?><span>#<?php  echo $id; ?></span> </h3>
					</div>
					
					<div class="product-details__content">
						






<div class="row py-4">
<div class="container">
  <div class="row">
						<div class="col-12 col-md-12 hh-grayBox pt45 pb20">
							<div class="row justify-content-between">
								<div class="order-tracking <?php if($status_num==1){echo 'completed';} ?>">
									<span class="is-complete" ></span>
									<p>Processing<br><span></span></p>
								</div>
								<div class="order-tracking <?php if($status_num>1){echo 'completed';} ?>">
									<span class="is-complete"></span>
									<p>Shipped<br><span></span></p>
								</div>
								<div class="order-tracking <?php if($status_num>2){echo 'completed';} ?>">
									<span class="is-complete"></span>
									<p>Delivered<br><span></span></p>
								</div>
							</div>
						</div>
					</div>
</div>
<div class="row p-0 m-0">
	<center>
    <div class="alert alert-success border-start  w-100">
        <h4>Latest Update</h4>
        
               <span class="text-sm"><b> <?php echo $description; ?></b></span>
               <hr/>
               <strong><?php echo $status; ?></strong>
            
    </div>
	</center>
	<div class="row">
		<div class="col-sm-12 col-md-12">
		<h6>
			Receiver Information
		</h6>
		<p class="p-2">
		<strong> <?php echo $first_name." ". $last_name; ?><br/></strong>
		<strong>Address: </strong><?php echo $receivers_address; ?><br/>
		<strong>Phone:</strong> <?php echo $phone; ?>
		</p>
		</div>
		
	</div>
   
</div>

                    </div>


                   
					</div>

					


					
					
				</div>
			</div>
		</div>
	</section>
	<!--Product Details End-->


<?php
require "footer.php";
?>