<?php  
include '../db.php';
include '../config.php';

if (isset($_POST['trackingsub'])) {
    $trackId = trim($_POST['trackId']);
    $select = mysqli_query($link, "SELECT * FROM tracking WHERE tracking_number = '$trackId' ");
    if (mysqli_num_rows($select) > 0) {
      $row = mysqli_fetch_assoc($select);
         $senders_name = $row['sender_name'];  
         $senders_contact = $row['sender_contact'];  
         $senders_mail = $row['sender_email'];  
         $senders_address = $row['sender_address'];
         $receivers_name = $row['receiver_name'];  
         $receivers_contact = $row['receiver_contact'];  
         $receivers_mail = $row['receiver_email'];  
         $receivers_address = $row['receiver_address'];
         $statuss = $row['status'];  
         $dispatch_l = $row['dispatch_location'];  
         $dispatchh = $row['dispatch_date'];  
         $deliveryy = $row['delivery_date'];
         $current_location = $row['current_location'];
         $desc = $row['pdesc'];
         $carrier = $row['carrier'];
         $carrier_ref = $row['carrier_ref'];
         $weight = $row['weight'];
         $payment_mode = $row['payment_mode'];
         $ship_mode = $row['ship_mode'];
         $quantity = $row['quantity'];
         $delivery_time = $row['delivery_time'];
         $image = $row['image'];
         $destination = $row['destination'];

    }else{
      echo "<script>alert('Invalid Tracking Number');window.location.href = '../tracking.php'; </script>";
    }
  }
  // else{
  //   echo "<script>window.location.href = 'index.html'; </script>";
  // }
?>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="keywords" content="Courier DEPRIXA-Integral Web System">
    <meta name="author" content="Jaomweb">
    <meta name="description" content="">
    <!-- For IE -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- For Resposive Device -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- For Window Tab Color -->
    <!-- Chrome, Firefox OS and Opera -->
    <meta name="theme-color" content="#fff">
    <!-- Windows Phone -->
    <meta name="msapplication-navbutton-color" content="#fff">
    <!-- iOS Safari -->
    <meta name="apple-mobile-web-app-status-bar-style" content="#fff">
    <title>Track and Trace | <?php echo $sitename ?></title>
    <!-- favicon -->
    <link rel="icon" type="image/png" sizes="16x16" href="image/1702706121_Courier services.png">
    <!-- Bootstrap -->
    <link href="css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <!-- Icons -->
    <link href="css/materialdesignicons.min.css" rel="stylesheet" type="text/css" />
    <!-- Main css -->
    <link href="css/stylesss.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="css/styless.css">
    <link rel="stylesheet" href="css/bundle.css">
    <link rel="stylesheet" type="text/css" href="css/main.css">
    <link rel="stylesheet" href="css/themify-icons.css">
    <link rel="stylesheet" href="css/track_online_shopping.css">

    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">

    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/themify-icons@1.0.1/css/themify-icons.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">

    <link rel="icon" href="https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/72x72/1f4e6.png" type="image/png">

    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" rel="stylesheet">

    <script>
        function mostrarMensaje(id) {
            var popup = document.getElementById("myPopup_" + id);
            popup.classList.toggle("show");
        }
    </script>

</head>

<body>

    <!-- Loader -->
    <div id="preloader">
        <div id="status">
            <div class="spinner">
                <div class="double-bounce1"></div>
                <div class="double-bounce2"></div>
            </div>
        </div>
    </div>
    <!-- Loader -->

    <!-- Navbar STart -->
    <header id="topnav" class="defaultscroll sticky">
        <div class="container">
            <!-- Logo container-->
            <div>
                <a class="logo" href="../index.html">
                    <img src="../admin/images/logo-small-2.png" alt="<?php echo $sitename ?>" width="190"
                        height="45" /> </a>
            </div>
            <div class="buy-button">
                <a href="../index.html" class="btn btn-secondary btn-sm"> Home</a>
            </div>
            <!--end login button-->
            <div class="menu-extras">
                <div class="menu-item">
                    <!-- Mobile menu toggle-->
                    <a class="navbar-toggle">
                        <div class="lines">
                            <span></span>
                            <span></span>
                            <span></span>
                        </div>
                    </a>
                    <!-- End mobile menu toggle-->
                </div>
            </div>
        </div>
    </header>
    <!-- Navbar End -->


    <!-- ERROR PAGE -->
    <section class="bg-home">
        <div class="home-center">
            <div class="home-desc-center">
                <div class="container">
                    <div class="checkout-form">
                        <div class="row">

                            <div class="col-lg-7">
                                <div class="user-profile-data">

                                    <br><br><br>
                                    <div class="row">
                                        <div class="col-md-3">
                                        <div class="trackstatus-title">
                                        <p>
                                            <span class="align-top" style="font-size: 30px; color: #5a6d90;">
                                                <i class="fas fa-box"></i>
                                            </span>
                                            <b><?php echo $statuss ?></b>
                                        </p>
                                        <label></label>
                                    </div>


                                        </div>
                                        <div class="col-md-5">
                                            <div class="trackstatus-title">
                                                <label>Shipment Tracking <b><?php echo $trackId ?></b></label>
                                            </div>
                                        </div>

                                        <div class="col-md-4">
                                            <?php  
                                            if ($allow_print == "Yes") {
                                            ?>
                                                <div class="trackstatus-title">
                                                    <a class="btn btn-secondary btn-sm" target="_blank" href="../invoice/receipt.php?tnum=<?php echo $trackId ?>">
                                                        <i style="color:white" class="fas fa-print"></i>&nbsp;Print Shipment
                                                    </a>
                                                </div>
                                            <?php } ?>
                                        </div>
                                        
                                       
                                         <center> <p><b>Package Image</b></p></center>
                                
                                        <div class="container">
						                    <center><img src="../uploads/<?php echo $image ?>"> </center>
						                </div>
						                
                                    </div>


                                    <!-- General Information -->
                                    <div class="payment-wrap">
                                        <div class="row">
                                            <div class="col-md-12">
                                                <div class="track-title">
                                                <h5 class="form_sub"
                                                    style="background-color: #5a6d90; border-radius: 3px; color:white">
                                                    <i class="fas fa-user" style="margin-right: 8px;"></i> Sender
                                                </h5>

                                                </div>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-md-6">
                                            <div class="track-title">
                                            <span class="align-top" style="font-size: 30px; color: #5a6d90;">
                                                <i class="fas fa-map-marker-alt"></i>
                                            </span>
                                            <label>
                                            Origin City</br>
                                                <b><?php echo $dispatch_l ?></b>
                                            </label>
                                        </div>

                                            </div>
                                            <div class="col-md-6">
                                            <div class="track-title">
                                            <span class="align-top" style="font-size: 30px; color: #5a6d90;">
                                                <i class="fas fa-map-marker-alt"></i>
                                            </span>
                                            <label>
                                                Origin Location</br>
                                                <b><?php echo $dispatch_l ?></b>
                                            </label>
                                        </div>

                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-md-6">
                                            <div class="track-title">
                                                    <span class="align-top" style="font-size: 30px; color: #5a6d90;">
                                                        <i class="fas fa-calendar-alt"></i>
                                                    </span>
                                                    <label>
                                                        Date of shipment</br>
                                                        <b><?php echo $dispatchh ?></b>
                                                    </label>
                                                </div>

                                            </div>
                                            <!-- <div class="col-md-6">
                                                <div class="form-group">
                                                <div class="track-title">
                                                    <span class="align-top" style="font-size: 30px; color: #5a6d90;">
                                                        <i class="fas fa-clock"></i>
                                                    </span>

                                                    <label>
                                                        Shipping time</br>
                                                        <b>24 Hours</b>
                                                    </label>

                                                </div>

                                                </div>
                                            </div> -->
                                        </div>
                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="track-title">
                                                    <label>Contact Name</br> <b><?php echo $senders_name ?></b></label>
                                                </div>
                                            </div>
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                <div class="track-title">
                                                    <span class="align-top" style="font-size: 30px; color: #5a6d90;">
                                                        <i class="fas fa-map-marker-alt"></i>
                                                    </span>
                                                    <label>
                                                        Contact Address</br>
                                                        <b><?php echo $senders_address ?></b>
                                                    </label>
                                                </div>

                                                </div>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="track-title">
                                                    <label>Shipping quantity</br> <b><?php echo $quantity ?></b></label>
                                                </div>
                                            </div>

                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <div class="track-title">
                                                        <label>Total weight</br> <b>
                                                                <?php echo $weight ?>Kg</b></label>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>

                                        <div class="row">
                                            <div class="col-md-12">
                                                <div class="form-group">
                                                <div class="track-title">
                                                    <span class="align-top" style="font-size: 30px; color: #5a6d90;">
                                                        <i class="fas fa-comment-alt"></i>
                                                    </span>
                                                    <label>
                                                        Description</br>
                                                        <b><?php echo $desc ?></b>
                                                    </label>
                                                </div>

                                                </div>
                                            </div>
                                        </div>

                                    </div>
                                    <!--// General Information -->

                                    <!-- track shipment -->
                                    <div class="payment-wrap">
                                        <div class="row">
                                        <div class="col-md-12">
                                            <div class="track-title">
                                                <h5 class="form_sub" style="background-color: #5a6d90; border-radius: 3px; color:white">
                                                    <i class="fas fa-user" style="margin-right: 8px;"></i> Recipient
                                                </h5>
                                            </div>
                                        </div>

                                        </div>
                                        <div class="row">
                                            <div class="col-md-6">
                                            <div class="track-title">
                                                <span class="align-top" style="font-size: 30px; color: #5a6d90;">
                                                    <i class="fas fa-map-marker-alt"></i>
                                                </span>
                                                <label>
                                                    Delivery location</br>
                                                    <b><?php echo $destination ?></b>
                                                </label>
                                            </div>

                                            </div>
                                            <div class="col-md-6">
                                            <div class="track-title">
                                                <span class="align-top" style="font-size: 30px; color: #5a6d90;">
                                                    <i class="fas fa-map-marker-alt"></i>
                                                </span>
                                                <label>
                                                    Destination</br>
                                                    <b><?php echo $destination ?></b>
                                                </label>
                                            </div>

                                            </div>
                                        </div>
                                        <div class="row">
                                        <div class="col-md-6">
                                            <div class="track-title">
                                                <span class="align-top" style="font-size: 30px; color: #5a6d90;">
                                                    <i class="fas fa-calendar-alt"></i>
                                                </span>
                                                <label>
                                                    Delivery time</br>
                                                    <b><?php echo $delivery_time ?></b>
                                                </label>
                                            </div>
                                        </div>

                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <div class="track-title">
                                                    <span class="align-top" style="font-size: 30px; color: #5a6d90;">
                                                        <i class="fas fa-clock"></i>
                                                    </span>
                                                    <label>
                                                        Estimated delivery date</br>
                                                        <b><?php echo $deliveryy ?></b>
                                                    </label>
                                                </div>
                                            </div>
                                        </div>

                                        </div>
                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="track-title">

                                                    <label>Contact Name</br> <b><?php echo $receivers_name ?></b></label>

                                                </div>
                                            </div>
                                            <div class="col-md-6">
                                            <div class="form-group">
                                                <div class="track-title">
                                                    <span class="align-top" style="font-size: 30px; color: #5a6d90;">
                                                        <i class="fas fa-map-marker-alt"></i>
                                                    </span>
                                                    <label>
                                                        Contact Address</br>
                                                        <b><?php echo $receivers_address ?></b>
                                                    </label>
                                                </div>
                                            </div>
                                        </div>
                                        </div>
                                    </div>
                                </div> <!-- /.user-profile-data -->
                            </div> <!-- /.col- -->


                            <div class="col-lg-5">
                                <br><br><br>
                                <div class="booking-summary_block">
                                    <div class="booking-summary-box">
                                        <h5>Shipping History</h5>
                                        <div class="track-cost">
                                        <?php 
                                        $i = 0;
                                            $tr = mysqli_query($link, "SELECT * FROM track_update WHERE track_num = '$trackId' ");
                                            if (mysqli_num_rows($tr) > 0 ) {
                                                while ($row = mysqli_fetch_assoc($tr)) {
                                                    $i++
                                        ?>
                                            <ul class="timeline a">
                                                <li class="event">
                                                    <div class="row">
                                                        <div class="col-md-7">
                                                            <p class="text-left button5"><?php echo $row['date'] ?></p>
                                                            <h6 class="text-left button4">
                                                                <?php echo $row['status'] ?> <br>
                                                                <br>
                                                                + <?php echo $row['note'] ?>
                                                            </h6>

                                                        </div>
                                                        <div class="col-md-5">
                                                            <p class="text-right button5"><?php echo $row['time'] ?></p>
                                                            <h4></h4>
                                                        </div>
                                                    </div>
                                                </li>
                                                <!--event schedule 1 end-->
                                            </ul>
                                            <?php }} ?>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <?php  
                                if ($show_map == "Yes") {
                            ?>
                            <!--Map Outer-->
                            <div class="row d-flex align-items-stretch">
                                <div class="col-md-12 col-lg-12 col-xl-12 ">
                                    <iframe class="map" src="https://maps.google.com/maps?q=<?php echo $current_location == "" ? $dispatch_l : $current_location ?>&amp;t=k&amp;z=13&amp;ie=UTF8&amp;iwloc=&amp;output=embed" style="border:0; width: 100%; height: 527px;"></iframe>
                                </div>
                            </div>
                            <?php } ?> 
                        </div> <!-- /.row -->
                    </div> <!-- /.checkout-form -->
                </div> <!-- /.container -->
            </div>
        </div>
    </section>


    <!-- ERROR PAGE -->

    <!-- Back to top -->
    <a href="#" class="back-to-top rounded text-center" id="back-to-top">
        <i class="ti-angle-up d-block"> </i>
    </a>
    <!-- Back to top -->


    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <!-- jQuery -->
    <script src="js/jquery.2.2.3.min.js"></script>
    <!-- Popper js -->
    <script src="js/popper.min.js"></script>
    <!-- Bootstrap JS -->
    <script src="js/bootstrap.min.js"></script>
    <!-- menu  -->
    <script src="js/custom.js"></script>
    <!-- js ui -->
    <script src="js/jquery-ui.min.js"></script>
    <script src="js/bootstrap.bundle.min.js"></script>
    <script src="js/jquery.easing.min.js"></script>
    <script src="js/scrollspy.min.js"></script>
    <!-- Main Js -->
    <script src="js/app.js"></script>
    <!-- Theme js -->
    <script src="js/theme.js"></script>

    </div> <!-- /.main-page-wrapper -->

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
</body>

</html>