<?php include_once('function/__data_app_db.php');?>
<!DOCTYPE html>

<html class="loading" lang="en" data-textdirection="ltr">
  <!-- BEGIN: Head-->
<?php include_once('head.php');?>
  <!-- END: Head-->

  <!-- BEGIN: Body-->
  <body class="vertical-layout 1-column  navbar-sticky footer-static pace-done blank-page" data-open="click" data-menu="vertical-menu-modern" data-col="1-column">

    <!-- BEGIN: Content-->
    <div class="app-content content">
      <div class="content-overlay"></div>
      <div class="content-wrapper">
        <div class="content-header row"></div>
        <div class="content-body">
            <div class="row p-2">
                <div class="col-md-4 offset-md-4 text-center">
                   <a href="index"> <center> <img style="width: 80%" src="../full_logo.png" class="mb-5"></center></a>

                    <h4>TRACK YOUR SHIPMENT</h4>
                </div>
                <!-- invoice view page -->
                <?php
                $quotation_number_err ='';
                if(isset($_GET['inq'])){
                    $quotation_number_er = show_jsnj_data($_GET['inq']);
                    $quotation_number_err = "<strong class='text-danger'>#$quotation_number_er</strong>";
                };
                $errorPage ='
     <div class="col-md-6 offset-md-3">
     <div class="card bg-white p-4">
              <div id="page-head">
                   <div class="text-center cls-content">
                       <h1 class="error-code text-info">Oops!</h1>
                   </div>
                </div>
                <div id="page-content">
					<!-- CONTENT -->
					<!--===================================================-->
					<div class="text-center cls-content">
					    <p class="h4 text-uppercase text-bold">Shipment '.$quotation_number_err.' Not Found!</p>
					    <div class="pad-btm">
					        Sorry, but the shipment '.$quotation_number_err.' you are looking for has not been found on our server.
					    </div>
					    <hr class="new-section-sm bord-no">
					    <div class="pad-top"><a class="btn btn-primary" href="index">Return To Track Shipment</a></div>
					</div>
                </div>
                </div>
                </div>';
                if(isset($_GET['inq'])){
                    $t_status = $lr_number='';
                    $quotation_number = $inq_number = show_jsnj_data($_GET['inq']);
                    $query_inq = mysqli_query($_conn_db,"select * from tbl_courier as tc inner join tbl_courier_track as tct on tc.doc_no = tct.doc_no where tc.doc_no='$quotation_number' and tc.action='1' order by tct.tracking_id asc");
                    $query_inq_tc = mysqli_query($_conn_db,"select * from tbl_courier as tc  where tc.doc_no='$quotation_number' and tc.action='1' order by tc.cid asc limit 1");
                    if(mysqli_num_rows($query_inq)>0){ ?>

                        <div class="col-md-6">
                            <div class="card pb-2">
                                <div class="card-header">
                                    <h4 class="card-title">Tracking Details <strong class="text-success"># <?php echo $inq_number;?></strong> <br><small>Your tracking detail is below. </small></h4>
                                </div>
                                <hr>
                                <div class="card-content">
                                    <div class="card-body">
                                        <div class="table-responsive">
                                            <table class="table table-bordered">
                                                <?php while($data_inq_tc = mysqli_fetch_array($query_inq_tc)){ ?>
                                                    <tr>
                                                        <th>Customer/Company Name</th>
                                                        <td><?php echo show_jsnj_data($data_inq_tc['company_name']);?></td>
                                                    </tr>
                                                    <tr>
                                                        <th>Courier Type</th>
                                                        <td><?php echo show_jsnj_data($data_inq_tc['type']);?></td>
                                                    </tr>
                                                    <tr>
                                                        <th>Weight</th>
                                                        <td><?php echo show_jsnj_data($data_inq_tc['weight']);?></td>
                                                    </tr>
                                                    <tr>
                                                        <th>Invoice No</th>
                                                        <td><?php echo show_jsnj_data($data_inq_tc['invice_no']);?></td>
                                                    </tr>
                                                    <tr>
                                                        <th>Quantity</th>
                                                        <td><?php echo show_jsnj_data($data_inq_tc['qty']);?></td>
                                                    </tr>
                                                    <tr>
                                                        <th>Booking Date</th>
                                                        <td><?php echo jsnj_date_dmy($data_inq_tc['book_date']);?></td>
                                                    </tr>
                                                    <tr>
                                                        <th>Ship From Name/Phone</th>
                                                        <td><?php echo show_jsnj_data($data_inq_tc['ship_name']);?> / <?php echo show_jsnj_data($data_inq_tc['phone']);?></td>
                                                    </tr>
                                                    <tr>
                                                        <th>Ship From Address</th>
                                                        <td><?php echo show_jsnj_data($data_inq_tc['s_add']);?>/
                                                       <?php echo show_jsnj_data($data_inq_tc['s_country']);?>/<?php echo show_jsnj_data($data_inq_tc['s_state']);?>/<?php echo show_jsnj_data($data_inq_tc['s_city']);?>/<?php echo show_jsnj_data($data_inq_tc['s_pincode']);?></td>
                                                    </tr>
                                                    <tr>
                                                        <th>Ship To Name / Phone</th>
                                                        <td><?php echo show_jsnj_data($data_inq_tc['rev_name']);?> / <?php echo show_jsnj_data($data_inq_tc['r_phone']);?></td>
                                                    </tr>
                                                    <tr>
                                                        <th>Ship To Address</th>
                                                        <td><?php echo show_jsnj_data($data_inq_tc['r_add']);?>/<?php echo show_jsnj_data($data_inq_tc['r_country']);?>/<?php echo show_jsnj_data($data_inq_tc['r_state']);?>/<?php echo show_jsnj_data($data_inq_tc['r_city']);?>/<?php echo show_jsnj_data($data_inq_tc['r_pincode']);?></td>
                                                    </tr>

                                                <?php };?>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="col-xl-6 col-md-6 col-12">
                            <div class="card">
                                <div class="card-content">
                                    <div class="card-body pb-0 mx-25 p-1">
                                        <!-- header section -->
                                        <div class="row">
                                            <div class="col-xl-12 col-md-12">
                                                <div class="row">
                                                    <div class="col-xl-12 col-md-12 text-right pr-2">

                                                        <h3 class="text-uppercase text-thin mar-no text-primary mt-1"><small class="text-warning">Track Order</small> <a href="view-quote?inq=<?php echo $quotation_number;?>" class="text-success">#<?php echo $quotation_number;?></a></h3>
                                                    </div>
                                                </div>

                                                <hr>
                                            </div>
                                        </div>
                                        <!-- logo and title -->

                                        <ul class="widget-timeline mb-0">
                                            <?php  while($data_inq = mysqli_fetch_array($query_inq)){
                                                $status_q = show_jsnj_data($data_inq['status']);
                                                if($status_q == 1){
                                                    $t_status = "<small class=\"timeline-time text-white badge badge-pill badge-warning\">Pending</small>";
                                                } elseif($status_q == 2){
                                                    $t_status = "<small class=\"timeline-time text-white badge badge-pill badge-info\">On The Way</small>";
                                                }elseif($status_q == 3){
                                                    $t_status = "<small class=\"timeline-time text-white badge badge-pill badge-glow\">Dispatch</small>";
                                                }elseif($status_q == 4){
                                                    $t_status = "<small class=\"timeline-time text-white badge badge-pill badge-success\">Delivered</small>";
                                                }elseif($status_q == 5){
                                                    $t_status = "<small class=\"timeline-time text-white badge badge-pill badge-danger\">Opps</small>";
                                                }
                                                $action = show_jsnj_data($data_inq['action']);
                                                $t_from = show_jsnj_data($data_inq['t_from']);
                                                $remark = show_jsnj_data($data_inq['remark']);
                                                $t_type = show_jsnj_data($data_inq['t_type']);
                                                if(!empty($remark)){
                                                    $remark = "<div class=\"timeline-content\">$remark</div>";
                                                } else {
                                                    $remark = "";
                                                }
                                                $time_t_date_time = jsnj_time_show($data_inq['t_date_time']);
                                                $t_date_time = jsnj_date_dmy($data_inq['t_date_time']);

                                                ?>
                                                <li class="timeline-items timeline-icon-primary active">
                                                    <?php echo $t_status;?>
                                                    <h6 class="timeline-title"><?php echo "$t_type $t_from";?></h6>
                                                    <div class="timeline-text"><?php echo $t_date_time;?></div>

                                                    <?php echo $remark;?>
                                                </li>
                                            <?php } ?></ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                    <?php }else { echo $errorPage;} } else { echo $errorPage; }; ?>


            </div>
            <!-- forgot password ends -->
        </div>
      </div>


        </div>
    <!-- END: Content-->

    <!-- BEGIN: Footer-->
    <?php include_once('footer.php');?>
    <!-- END: Footer-->

    <?php include_once('foot.php');?>

  </body>
  <!-- END: Body-->
</html>