<?php
session_start();
if(isset($_SESSION['uid'])){
 
 
  include '../../config/database.php';
  include '../../config/config.php';
  include 'header.php';
  $msg = "";

}
else{

    header("location:../pages/login.php");
}



if(isset($_POST['confirm'])){
    
    $pi = $_POST['pid'];
    
    $sql = "UPDATE  track SET status = 'confirm' WHERE pid = '$pi'";
    
       if(mysqli_query($link, $sql)){
           
           $msg = "package corfirmed";
           
       }else{
           
           $msg = "package not corfirmed"; 
       }
      

    
}





if(isset($_POST['processing'])){
    
    $pi = $_POST['pid'];
    
    $sql = "UPDATE  track SET status = 'process' WHERE pid = '$pi'";
    
       if(mysqli_query($link, $sql)){
           
           $msg = "package processing";
           
       }else{
           
           $msg = "package not processed"; 
       }
      

    
}





if(isset($_POST['quality'])){
    
    $pi = $_POST['pid'];
    
    $sql = "UPDATE  track SET status = 'quality' WHERE pid = '$pi'";
    
       if(mysqli_query($link, $sql)){
           
           $msg = "package checked";
           
       }else{
           
           $msg = "package not checked"; 
       }
      

    
}




if(isset($_POST['dispatch'])){
    
    $pi = $_POST['pid'];
    
    $sql = "UPDATE  track SET status = 'dispatch' WHERE pid = '$pi'";
    
       if(mysqli_query($link, $sql)){
           
           $msg = "package Dispatched";
           
       }else{
           
           $msg = "package not Dispatched"; 
       }
      

    
}





if(isset($_POST['delivered'])){
    
    $pi = $_POST['pid'];
    
    $sql = "UPDATE  track SET status = 'deliver' WHERE pid = '$pi'";
    
       if(mysqli_query($link, $sql)){
           
           $msg = "package delivered";
           
       }else{
           
           $msg = "package not delivered"; 
       }
      

    
}



if(isset($_POST['withheld'])){
    
    $pi = $_POST['pid'];
    
    $sql = "UPDATE  track SET status = 'withheld' WHERE pid = '$pi'";
    
       if(mysqli_query($link, $sql)){
           
           $msg = "package withheld";
           
       }else{
           
           $msg = "package not withheld"; 
       }
      

    
}

?>

  <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.css">
  
  

  <link rel="stylesheet" href=" https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
  <link rel="stylesheet" href=" https://cdn.datatables.net/1.10.19/css/dataTables.jqueryui.min.css">
  <link rel="stylesheet" href=" https://cdn.datatables.net/buttons/1.5.6/css/buttons.jqueryui.min.css">



  

  <link rel="stylesheet" href=" https://cdn.datatables.net/1.10.19/css/dataTables.bootstrap.min.css">
  <link rel="stylesheet" href=" https://cdn.datatables.net/buttons/1.5.6/css/buttons.bootstrap.min.css">
  <link rel="stylesheet" href="">
 
  
    
    



  <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.js"></script>
 

  <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
  <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.19/js/dataTables.jqueryui.min.js"></script>
  <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/buttons/1.5.6/js/dataTables.buttons.min.js"></script>

  <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/buttons/1.5.6/js/buttons.jqueryui.min.js"></script>
   
  <script type="text/javascript" charset="utf8" src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
  <script type="text/javascript" charset="utf8" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script>
  <script type="text/javascript" charset="utf8" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script>
  <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/buttons/1.5.6/js/buttons.html5.min.js"></script>
  <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/buttons/1.5.6/js/buttons.print.min.js"></script>
  <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/buttons/1.5.6/js/buttons.colVis.min.js"></script>
  
  
  <script type="text/javascript" charset="utf8" src=""></script>
  <script type="text/javascript" charset="utf8" src=""></script>

 
  



    
    
 
    
    
    
    
    
    

   
   



<style>
.table-responsive {
overflow-x: hidden;
}
@media (max-width: 8000px) {
.table-responsive {
overflow-x: auto;
}
</style>
</head>
<body>






  <!-- Main Content -->
      <div class="main-content">

        <section class="section">

          <div class="section-header">
            <h1><i class="fa fa-users" style="font-size:30px"></i> PACKAGE PROGRESS CONTROL</h1>
            <div class="section-header-breadcrumb">
              <div class="breadcrumb-item active"><a href=""><?php echo $name;?></a></div>
                 <div class="breadcrumb-item"></div>
            </div>
          </div>

<?php 

$pids = $_GET['pid'];
?>





	<?php 
			
			$sql= "SELECT * FROM track WHERE pid = '$pids'";
			  $result = mysqli_query($link,$sql);
			  if(mysqli_num_rows($result) > 0){
				$row = mysqli_fetch_assoc($result); 
              
				$row['status'];
				
				
				if(isset($row['status']) && $row['status'] == "confirm" ){

				$confirm = 'Package Confirmed';
				
				}else{
				    
				    	$confirm = 'Confirm';
				    
				}
				
				
				
	if(isset($row['status']) && $row['status'] == "processing" ){

				$process = 'Package Processed';
			
				}else{
				    
				    	$process = 'Processing';
				    
				}
				
				
				if(isset($row['status']) && $row['status'] == "dispatch" ){

				$dispatch = 'Package Dispatched';
			
				}else{
				    
				    	$dispatch = 'Dispatch';
				    
				}
				
				
				
			if(isset($row['status']) && $row['status'] == "quality" ){

				$quality = 'Package In Transit';
			
				}else{
				    
				    	$quality = 'In Transit';
				    
				}
				
				
				
				if(isset($row['status']) && $row['status'] == "delivered" ){

				$deliver = 'Package Delivered';
			
				}else{
				    
				    	$deliver = 'Deliver';
				    
				}
				
				
				if(isset($row['status']) && $row['status'] == "withheld" ){

				$withheld = 'Package On Hold';
			
				}else{
				    
				    	$withheld = 'On Hold';
				    
				}
				
				  
			  }
				  
				  ?>
	



<div class="container">
    
     <?php if($msg != "") echo "<div style='padding:20px;background-color:#dce8f7;color:black'> $msg</div class='btn btn-success'>" ."</br></br>";  ?>
    
    
    <form action="ocontrol.php?pid=<?php echo $pids;?>" method="POST">

<input name="pid" type="hidden" value="<?php echo $pids;?>">

  <button  name="processing" type="submit" class="btn btn-primary"><?php echo $process;?></button>
  <button  name="quality" type="submit" class="btn btn-info"><?php echo $quality;?></button>
  <button name="withheld" type="submit" class="btn btn-danger"><?php echo $withheld;?></button>
  <button name="dispatch" type="submit" class="btn btn-info"><?php echo $dispatch;?></button>
  <button name="delivered" type="submit" class="btn btn-success"><?php echo $deliver;?></button>
  

  
       </form>
</div>

</body>
</html>
