<!DOCTYPE html>
<html>
<head>
	<title> Swastik Safe Deposit & Investment Limited. | Tracking </title>

<style>

.btn-warning {
    color: white;
    background-color: yellow;
}

@media print {
  body
        {
            font-family: Arial;
            font-size: 12pt;
        }
    .btn {
        display:none;
    }
    h1 {
        font-size:20px;
    }
} 
    body
        {
            font-family: Arial;
            font-size: 12pt;
            padding:5px;
        } 
    #table2 {
       width:100%;
       padding-left:13%
    }
    
    #table2 td {
        padding:10px;
    }
    
    table td {
        padding:4px;
        margin-left:20%;
    }
    
    #table2{
            border: 1px solid #ccc;
            border-collapse: collapse;
        }
     #table2 th {
        padding:10px;
        background-color:grey;
    }
    h1 {
        color:#458fa0;
        border-bottom: 2px solid #458fa0;
        width:30%;
    }
    h3 {
        color:#458fa0;
    }
    
    .btn {
        padding:10px;
        background-color:#458fa0;
        border:1px solid #458fa0;
        cursor:pointer;
        margin-top:100px;
    }

</style>

</head>

<?php include 'includes/connection.php';


if(isset($_POST['track'])) {

$ferow = mysqli_query($DB_CONN,"SELECT * from shipping WHERE shipping_number='{$_POST['waybill']}'");
$fetch = mysqli_fetch_assoc($ferow);

if(mysqli_num_rows($ferow)) {
    
$rowstattop = mysqli_query($DB_CONN,"SELECT * from statuses WHERE shipping_id='{$fetch['id']}' ORDER by id DESC limit 1");
    $fetchstattop = mysqli_fetch_assoc($rowstattop);
      
?>



<body>
    
 
 
 <table style="width:90%;padding-left:13%">
      
      <center> <img src="images/logo-1.png"> </center>
      
      <tr>
         <td> <?php echo "<img alt='testing' src='includes/barcode.php?codetype=Code39&size=40&text=".$fetch['shipping_number']."&print=true'/>"; ?> </td>
         <td> <h4> Current State :  <span style="background-color:yellow;padding:5px">  <?php echo $fetchstattop['status'] ?>   </span> </h4> </td>
     </tr>
     
     
     <tr>
         <td> <h3> SHIPPER </h3>  </td>
         <td>  <h3> RECEIVER </h3> </td>
     </tr>
     
     <tr>
         <td> <b> Name : </b> <?php echo $fetch['sender_name'] ?>  </td>
         <td> <b> Name : </b> <?php echo $fetch['recipient_name'] ?> </td>
     </tr>
     
     <tr>
         <td> <b> Email : </b> <?php echo $fetch['sender_email'] ?> </td>
         <td> <b> Email : </b> <?php echo $fetch['recipient_email'] ?> </td>
     </tr>
     
     <tr>
         <td> <b> Phone : </b> <?php echo $fetch['sender_phone'] ?> </td>
         <td> <b> Phone : </b> <?php echo $fetch['recipient_phone'] ?> </td>
     </tr>
     
     <tr>
         <td> <b> Address : </b> <?php echo $fetch['sender_address'] ?> </td>
         <td> <b> Address : </b> <?php echo $fetch['recipient_address'] ?> </td>
     </tr>
     
     <tr>
         <td colpan="2"> <h3> SHIPPING DETAILS </h3> </td>
     </tr>
     
     
     <tr>
         <td> <b> Shipping Number : </b> <?php echo $fetch['shipping_number'] ?>  </td>
         <td> <b> Posting Date : </b> <?php echo date("d-m-Y", strtotime($fetch['posting_date'])); ?> </td>
     </tr>
     
     <tr>
         <td> <b> Shipping Date : </b> <?php echo date("d-m-Y", strtotime($fetch['shipping_date'])); ?> </td>
         <td> <b> Estimate Delivery Date : </b> <?php echo date("d-m-Y", strtotime($fetch['estimate_date']));  ?> </td>
     </tr>
     
     <tr>
         <td> <b> Destination : </b> <?php echo $fetch['destination'] ?> </td>
         <td> <b> Country  : </b> <?php echo $fetch['country'] ?> </td>
     </tr>
     
     <tr>
         <td> <b> Content Remark : </b> <?php echo $fetch['content_remark'] ?> </td>
         <td> <b> Content Information  : </b> <?php echo $fetch['content_information'] ?> </td>
     </tr>
     
    <tr>
         <td colpan="2"> <br> <h3> SHIPPING HISTORY </h3> </td>
     </tr>
     
    
     
 </table>
 

 <table id="table2" >
     
     <tr>
         <td> <b> Date </b>  </td>
         <td> <b> Destination </b> </td>
         <td> <b> State </b> </td>
         <td> <b> City </b> </td>
         <td> <b> Status </b> </td>
         <td> <b> Remark </b> </td>
     </tr>
     
  
  
<?php $rowstat = mysqli_query($DB_CONN,"SELECT * from statuses WHERE shipping_id='{$fetch['id']}' ORDER by id DESC");
      while($fetchstat = mysqli_fetch_assoc($rowstat)) { ?>
     
     <tr>
         <td> <?php echo date("H:i:s", strtotime($fetchstat['timestamp'])).' '.date("d-m-Y", strtotime($fetchstat['date'])); ?> </td>
         <td> <?php echo $fetchstat['destination'] ?> </td>
         <td> <?php echo $fetch['state'] ?> </td>
         <td> <?php echo $fetch['city'] ?> </td>
         <td> <?php echo $fetchstat['status'] ?> </td>
         <td> <?php echo $fetchstat['status_remark'] ?> </td>
     </tr>
     
     <?php } ?>
     
 </table>
 
 
 
 <button class="btn btn-warning" onclick="window.print()">Print this page</button>
 
 <?php } } 
 
 if(isset($_POST['check'])) {

$ferow = mysqli_query($DB_CONN,"SELECT * from vault WHERE vaultusername='{$_POST['username']}' AND vaultpasscode='{$_POST['secretecode']}'");

$fetch =  mysqli_fetch_assoc($ferow);
if(mysqli_num_rows($ferow)) {



?>



<body>
    
 
 
 <table style="width:100%;padding-left:13%">
      
     <center> <img src="images/logo-1.png"> </center>
 
    <tr>
        <td> <img style="width:150px" src="admin/images/<?php echo $fetch['vault_ownerimage'] ?>" > </td> <td> </td>
    </tr>
     
     <tr>
         <td> <h3> Vault Owner </h3>  </td>
         <td> <h3> Next of Kin Information </h3> </td>
     </tr>
     
     <tr>
         <td> <b> Name : </b> <?php echo $fetch['vault_ownername'] ?>  </td>
         <td> <b> Name : </b> <?php echo $fetch['v_name'] ?> </td>
     </tr>
     
     <tr>
         <td> <b> Email : </b> <?php echo $fetch['vault_owneremail'] ?> </td>
         <td> <b> Email : </b> <?php echo $fetch['v_email'] ?> </td>
     </tr>
     
     <tr>
         <td> <b> Phone : </b> <?php echo $fetch['vault_ownerphone'] ?> </td>
         <td> <b> Phone : </b> <?php echo $fetch['v_telephone'] ?> </td>
     </tr>
     
     <tr>
         <td> <b> Address : </b> <?php echo $fetch['vault_owneraddress'] ?> </td>
         <td> <b> Address : </b> <?php echo $fetch['v_address'] ?> </td>
     </tr>
     
     <tr>
         <td colpan="2"> <h3> VAULT INFORMATION </h3> </td>
     </tr>

      <tr>
         <td> <b> Vault Username : </b> <?php echo $fetch['vaultusername'] ?> </td>
         <td> <b> Vault Passcode  : </b> <?php echo $fetch['vaultpasscode'] ?> </td>
     </tr>

     <tr>
         <td> <b>  Estimated Value : </b> <?php echo $fetch['declared_estimatedvalue'] ?> </td>
         <td> <b> Quality of Content  : </b> <?php echo $fetch['qualityofcontent'] ?> </td>
     </tr>
     
     <tr>
         <td> <b> Content Remark : </b> <?php echo $fetch['content_remark'] ?> </td>
         <td> <b> Content Information  : </b> <?php echo $fetch['content_information'] ?> </td>
     </tr>
     
     <tr>
         <td colpan="2"> <br><br> </td>
     </tr>
     
 </table>
 
 <table id="table2" >
     <tr>
         <td> <b> Weight </b>  </td>
         <td> <b> Monthly Charges </b> </td>
         <td> <b> Outstanding Charges </b> </td>
         <td> <b> Country </b> </td>
     </tr>
     
     
     <tr>
         <td> <?php echo $fetch['weight'] ?> </td>
         <td> <?php echo $fetch['monthlycharges'] ?> </td>
         <td> <?php echo $fetch['outstandingcharges'] ?> </td>
         <td> <?php echo $fetch['v_country'] ?> </td>
     </tr>
 </table>
 
 <button class="btn btn-warning" onclick="window.print()">Print this page</button>
 
 <?php } }  ?>
 
 
    
</body>
</html>