<?php
include('session.php');
  include("inc/header.php")
  
  ?>
        <!-- ============================================================== -->
        <!-- End Topbar header -->
        <!-- ============================================================== -->
        <!-- ============================================================== -->
        <!-- Left Sidebar - style you can find in sidebar.scss  -->
        <!-- ============================================================== -->
       
       
       
       
       <?php include("inc/sidebar.php") ?>
       
       
        <div class="page-wrapper">
            <!-- ============================================================== -->
            <!-- Bread crumb and right sidebar toggle -->
            <!-- ============================================================== -->
            <div class="page-breadcrumb bg-white">
                <div class="row align-items-center">
                    <div class="col-lg-3 col-md-4 col-sm-4 col-xs-12">
                        <h4 class="page-title">Dashboard</h4>
                    </div>
                    <div class="col-lg-3"></div><div class="col-lg-3"></div><div class="col-lg-2"></div>
                     <div class="col-lg-1">
                         <div class="pl-5 ml-5 text-right">
                             <form enctype="multipart/form-data" method="post">
                                    <input type="submit" class="btn btn-danger text-white" value="LogOut" name="logout"/>
                             </form>
                             
                             <?
                                if(isset($_POST['logout'])){
                                $url = 'logout.php';   
                        
                                echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
                                }
                                ?>
                         </div>
                         
                    </div>
                </div>
                <!-- /.col-lg-12 -->
            </div>
     
            <div class="container-fluid">
                 
                <div class="row">
                    <!-- .col -->
                    <div class="col-md-12 col-lg-8 col-sm-12">
                        <div class="card white-box p-0">
                            <div class="card-body">
                                <h3 class="box-title mb-0">CREATE A NEW SHIPPING NUMBER</h3>
                            </div>
                             <div>
                                 <form enctype="multipart/form-data" method="post" action="" class="p-4">
                                  <div class="mb-3">
                                    <label for="" class="form-label">Enter a Username for the Shipping Customer :</label>
                                    <input type="text" class="form-control"   name="username">
                                     <label for="" class="form-label">Enter New Shipping number below :</label>
                                    <input type="text" class="form-control"   name="chipnumber">
                                     
                                  </div>
                                  
                                  <button type="submit" class="btn btn-primary" name="sub">Submit</button>
                                </form>
                                
                                 <?php
                                    if(isset($_POST['sub'])){
                                                        $newName=$_POST['username'];
                                                        $newNumb=$_POST['chipnumber']; 
                                                        
                                                        $query3="insert into  `shipping`(`shippingID`, `user`) values ('$newNumb','$newName')";
                                                        $ressu=mysqli_query($conn, $query3);
                                                        if($ressu){
                                                            echo 'Record successfully updated';
                                                            $url = 'main.php';   
                                    
                                                            echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
                                                        }else{
                                                            echo 'Problem updating records';
                                                        }
                                                        
                                                        
                                                    }
                    
                    
            
  
  ?>
  
                                
                                
                                
                             </div>
                        </div>
                        
                        <div class="card white-box p-0">
                            <div class="card-body">
                                <h1 class="box-title mb-0" style="font-weight:bold !important; text-decoration:underline;">ORIGINATION</h1>
                                <h5 class=" mb-0">ATTACH DETAILS TO EXISTING SHIPPING NUMBER</h5>
                            </div>
                             <div>
                                 <form enctype="multipart/form-data" class="p-4 " action="#" method="post">
                                  <div class="mb-3">
                                      
                                      
   
                                      
                                    <label for="exampleInputEmail1" class="form-label">Select your shipping Number Below :</label>
                                    <select class="form-select" aria-label="Default select example" name="shipmentnumber"> 
                                    <option value=" ">Select</option>
                                    <?php
                                     $que="SELECT * FROM shipping";
                                     $row=mysqli_query($conn,$que);
                                     
                                     while(($rw=mysqli_fetch_array($row))>0){
                                         
                                         $shipNumber=$rw['shippingID'];
                                     ?>
                                          <option value="<?php echo $shipNumber; ?>"><?php echo $shipNumber; ?></option>
                                             <?php } ?>
                                        </select>
                                        <br>
                                        <label for="exampleInputEmail1" class="form-label">Enter Country of Origin:</label>
                                    <input type="text" class="form-control" name="origincountry"  >
                                    <br>
                                    <label for="exampleInputEmail1" class="form-label">Enter City of Origin:</label>
                                    <input type="text" class="form-control" name="origincity"  >
                                    <br>
                                    <label for="exampleInputEmail1" class="form-label">Weight of Package (kg):</label>
                                    <input type="text" class="form-control"  name="weight" >
                                    <br>
                                    <label for="exampleInputEmail1" class="form-label">Date of Registration</label>
                                    <input type="date" class="form-control"  name="dater" >
                                    <br>
                                    <hr>
                                    <h1 class="box-title mb-0" style="font-weight:bold !important; text-decoration:underline;">DESTINATION</h1>
                                    <hr>
                                    <br>
                                    <label for="exampleInputEmail1" class="form-label">Enter COUNTRY of Destination:</label>
                                    <input type="text" class="form-control" name="destinationcountry"  >
                                    <br>
                                    <label for="exampleInputEmail1" class="form-label">Enter CITY of Destination:</label>
                                    <input type="text" class="form-control"  name="destinationcity" >
                                    <br>
                                    <label for="exampleInputEmail1" class="form-label">Date of Shippment Delivery</label>
                                    <input type="date" class="form-control"  name="deliverydate" >
                                    <br>
                                  </div>
                                  
                                  <button type="submit" class="btn btn-primary" name="subb">Submit</button>
                                </form>
                                
                                <?php
                                    if(isset($_POST['subb'])){
                                                        
                                                        $shipmentNumber=$_POST['shipmentnumber']; 
                                                        $origincountry=$_POST['origincountry']; 
                                                        $origincity=$_POST['origincity']; 
                                                        $weight=$_POST['weight']; 
                                                        $dater=$_POST['dater']; 
                                                        $destinationcountry=$_POST['destinationcountry']; 
                                                        $destinationcity=$_POST['destinationcity']; 
                                                        $deliveryd=$_POST['deliverydate']; 
                                                        $autoStatus="Created";
                                                        $Statusid=0;
                                                        
                                                        
                                                        
                                                        $query3="insert into shippingDetails(shippingID,originCountry, originCity, weight, date, destinationCountry, destinationCity, deliveryDate) 
                                                        values ('$shipmentNumber',
                                                                '$origincountry',
                                                                '$origincity',
                                                                '$weight',
                                                                '$dater',
                                                                '$destinationcountry',
                                                                '$destinationcity',
                                                                '$deliveryd')";
                                                                
                                                       
                                                                
                                                        $ressu=mysqli_query($conn, $query3);
                                                        if($ressu){
                                                            echo 'Record successfully updated';
                                                            $url = 'main.php';   
                                    
                                                            echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
                                                        }else{
                                                            echo 'Problem updating records';
                                                        }
                                                        
                                                        
                                                    }
                    
                    
            
  
                                        ?>
                                        <?php
                                            if(isset($_POST['subb'])){
                                                                
                                                                $goldNumber=$_POST['shipmentnumber'];  
                                                                $autoStatus="Created";
                                                                $Statusid=0;
                                                                
                                                             
                                                                        
                                                                $query4="insert into shippingStatus(shippingID, status) 
                                                                values ('$goldNumber',
                                                                        '$autoStatus' )";
                                                                        
                                                                $ressu=mysqli_query($conn,  $query4);
                                                                if($ressu){
                                                                    echo 'Record successfully updated';
                                                                    $url = 'main.php';   
                                            
                                                                    echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
                                                                }else{
                                                                    echo 'Problem updating records';
                                                                }
                                                                
                                                                
                                                            }
                            
                            
                    
          
                                        ?>
                                        
                                        <?php
                                            if(isset($_POST['subb'])){
                                                                
                                                                $goldNumber=$_POST['shipmentnumber'];  
                                                                $dater=$_POST['dater'];   
                                                                
                                                             
                                                                        
                                                                $query4="insert into timeCategory(shippingID, timeID) 
                                                                values ('$goldNumber',
                                                                        '$dater' )";
                                                                        
                                                                $ressu=mysqli_query($conn,  $query4);
                                                                if($ressu){
                                                                    echo 'Record successfully updated';
                                                                    $url = 'main.php';   
                                            
                                                                    echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
                                                                }else{
                                                                    echo 'Problem updating records';
                                                                }
                                                                
                                                                
                                                            }
                            
                            
                    
          
                                        ?>
                                
                             </div>
                        </div>
                        
                        <div class="card white-box p-0">
                            <div class="card-body">
                                <h3 class="box-title mb-0">UPDATE SHIPPING STATUS FOR A PARTICULAR SHIPPMENT</h3>
                            </div>
                             <div>
                                 <form enctype="multipart/form-data" method="post" actio="#" class="p-4">
                                  <div class="mb-3">
                                    <label for="exampleInputEmail1" class="form-label">Select your shipping number below :</label>
                                    <select class="form-select" name="shippment"> 
                                        <option value=" ">Select</option>
                                    <?php
                                     $que="SELECT * FROM shipping";
                                     $row=mysqli_query($conn,$que);
                                     
                                     while(($rw=mysqli_fetch_array($row))>0){
                                         
                                         $shipNumber=$rw['shippingID'];
                                     ?>
                                          <option value="<?php echo $shipNumber; ?>"><?php echo $shipNumber; ?></option>
                                             <?php } ?>
                                        </select>
                                        
                                        <br>
                                        <label for="exampleInputEmail1" class="form-label">Apply one of the status to shippment :</label>
                                    <select class="form-select" name="statuses"> 
                                          <option value="Created">Created</option>
                                          <option value="Pickedup">Picked up</option>
                                          <option value="InTransit">In Transit</option>
                                          <option value="Delivered">Delivered</option>
                                        </select>
                                  </div>
                                  
                                  <button type="submit" class="btn btn-primary" name="subbb">Submit</button>
                                </form>
                                
                                
                                <?php
                                
                                                                     
                                    if(isset($_POST['subbb'])){
                                            $newStatus=$_POST['statuses'];
                                             $shipmnt=$_POST['shippment'];
                                            
                                            $query2="UPDATE shippingStatus SET status='$newStatus'
                                            WHERE shippingID='$shipmnt'";
                                            $resu=mysqli_query($conn, $query2);
                                            if($resu){
                                                
                                                echo 'Record successfully updated';
                                                $url = 'main.php';   
                        
                                            echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
                                            }else{
                                                echo 'Problem updating records';
                                            }
                                        }
                                
                                
                                
                                
                                ?>
                                
                                
                                
                                
                                
                             </div>
                        </div>
                        
                        <div class="card white-box p-0">
                            <div class="card-body">
                                <h3 class="box-title mb-0">APPLYING HISTORY TO ANY OF YOUR CURRENT SHIPPMENT</h3>
                            </div>
                             <div>
                                 <form enctype="multipart/form-data" method="post" action="" class="p-4">
                                  <div class="mb-3">
                                    <label for="exampleInputEmail1" class="form-label">Select your shipping number below :</label>
                                    <select class="form-select"  name="stat"> 
                                        <option value=" ">Select</option>
                                          <?php
                                     $que="SELECT * FROM shipping";
                                     $row=mysqli_query($conn,$que);
                                     
                                     while(($rw=mysqli_fetch_array($row))>0){
                                         
                                         $shipNumber=$rw['shippingID'];
                                     ?>
                                     
                                        <option value="<?php echo $shipNumber; ?>"><?php echo $shipNumber; ?></option>
                                             <?php } ?>
                                     
                                     
                                        </select>
                                        <br>
                                    <label for="exampleInputEmail1" class="form-label">Attach current DATE for this new history report:</label>
                                    <input type="date" class="form-control" name="cur-date">
                                    <br>    
                                    <label for="exampleInputEmail1" class="form-label">Enter current COUNTRY DESTINATION as of NOW:</label>
                                    <input type="text" class="form-control"  name="cur-destination" >
                                    <br>
                                    <label for="exampleInputEmail1" class="form-label">Enter current CITY DESTINATION as of NOW:</label>
                                    <input type="text" class="form-control"  name="cur-city" >
                                    <br>
                                    <div class="form-floating">
                                      <textarea class="form-control" placeholder="Leave a comment here" name="cur-description"></textarea>
                                      <label for="floatingTextarea">Description</label>
                                    </div>
                                  </div>
                                  
                                  <button type="submit" class="btn btn-primary" name="subbbe">Submit</button>
                                </form>
                                
                                <?php
                                            if(isset($_POST['subbbe'])){
                                                                
                                                                
                                                                $goldNumberr=$_POST['stat']; 
                                                                $golddate=$_POST['cur-date']; 
                                                                $goldcountry=$_POST['cur-destination']; 
                                                                $goldcity=$_POST['cur-city']; 
                                                                $golddescription=$_POST['cur-description']; 
                                                                  $historyID=0;
                                                             
                                                                        
                                                                $query4="insert into shippingHistory(shippingID, date, currentCountry, currentCity, description) 
                                                                values ('$goldNumberr',
                                                                        '$golddate',
                                                                        '$goldcountry',
                                                                        '$goldcity',
                                                                        '$golddescription'
                                                                        )";
                                                                        
                                                                $ressu=mysqli_query($conn,  $query4);
                                                                if($ressu){
                                                                    echo 'Record successfully updated';
                                                                    $url = 'main.php';   
                                            
                                                                    echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
                                                                }else{
                                                                    echo 'Problem updating records';
                                                                }
                                                                
                                                                
                                                            }
                            
                            
                    
          
                                        ?>
                                
                                <?php
                                
                                                                     
                                    if(isset($_POST['subbbe'])){
                                             $goldNumberr=$_POST['stat']; 
                                             
                                             $golddate=$_POST['cur-date']; 
                                             
                                            
                                            $query2="UPDATE timeCategory SET timeID='$golddate'
                                            WHERE shippingID='$goldNumberr'";
                                            $resu=mysqli_query($conn, $query2);
                                            if($resu){
                                                
                                                echo 'Record successfully updated';
                                                $url = 'main.php';   
                        
                                            echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
                                            }else{
                                                echo 'Problem updating records';
                                            }
                                        }
                                
                                
                                
                                
                                ?>
                                
                             </div>
                        </div>
                        
                        
                    </div>
                    <div class="col-lg-4 col-md-12 col-sm-12">
                        <div class="card white-box p-0">
                            <div class="card-heading">
                                <h3 class="box-title mb-0">Shipping Numbers Available</h3>
                            </div>
                            <div class="card-body">
                                <div class="table-responsive">          
                                      <table class="table">
                                        <thead>
                                          <tr>
                                             
                                            <th>Shipping Number</th>
                                            <th>Action</th>
                                          </tr>
                                        </thead>
                                        
                                         <?php
                                             $que="SELECT shippingID FROM shipping";
                                             $row=mysqli_query($conn,$que);
                                             
                                             while(($rw=mysqli_fetch_array($row))>0){
                                                 
                                                 $shipNumber=$rw['shippingID'];
                                             ?>
                                        <tbody>
                                          <tr>
                                            <td><?php echo $shipNumber; ?></td>
                                            <td>
                                                <form method="POST" action="main.php">
                                                    <button type="submit" name="affirm" class="btn btn-danger btn-sm text-white">DELETE</button>
                                                </form>
                                            </td>
                                             
                                          </tr>
                                          <?php } ?>
                                          
                                          
                                          
                                          
                                          
                                          
                                          <?php
                                          
                                            if(isset($_POST["affirm"])){
                                            	    $dell="DELETE FROM shipping where shippingID='$shipNumber'";
                                            	    $que=mysqli_query($conn, $dell);
                                            	    if($que){
                                            	        echo 'Record deleted';
                                            	        $url = 'main.php';   
                                                
                                                        echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
                                            	    }else{
                                            	        echo 'Operation unsuccessful';
                                            	    }
                                            	}
                                          
                                          ?>
                                          
                                           <?php
                                          
                                            if(isset($_POST["affirm"])){
                                            	    $delle="DELETE FROM shippingDetails where shippingID='$shipNumber'";
                                            	    $quer=mysqli_query($conn, $delle);
                                            	    if($quer){
                                            	        echo 'Record deleted';
                                            	        $url = 'main.php';   
                                                
                                                        echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
                                            	    }else{
                                            	        echo 'Operation unsuccessful';
                                            	    }
                                            	}
                                          
                                          ?>
                                            <?php
                                          
                                            if(isset($_POST["affirm"])){
                                            	    $deller="DELETE FROM shippingHistory where shippingID='$shipNumber'";
                                            	    $querr=mysqli_query($conn, $deller);
                                            	    if($querr){
                                            	        echo 'Record deleted';
                                            	        $url = 'main.php';   
                                                
                                                        echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
                                            	    }else{
                                            	        echo 'Operation unsuccessful';
                                            	    }
                                            	}
                                          
                                          ?>
                                          
                                          <?php
                                          
                                            if(isset($_POST["affirm"])){
                                            	    $dellerr="DELETE FROM shippingStatus where shippingID='$shipNumber'";
                                            	    $querrye=mysqli_query($conn, $dellerr);
                                            	    if($querrye){
                                            	        echo 'Record deleted';
                                            	        $url = 'main.php';   
                                                
                                                        echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
                                            	    }else{
                                            	        echo 'Operation unsuccessful';
                                            	    }
                                            	}
                                          
                                          ?>
                                          
                                          <?php
                                          
                                            if(isset($_POST["affirm"])){
                                            	    $dellerre="DELETE FROM timeCategory where shippingID='$shipNumber'";
                                            	    $querryee=mysqli_query($conn, $dellerre);
                                            	    if($querryee){
                                            	        echo 'Record deleted';
                                            	        $url = 'main.php';   
                                                
                                                        echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
                                            	    }else{
                                            	        echo 'Operation unsuccessful';
                                            	    }
                                            	}
                                          
                                          ?>
                                          
                                          
                                          
                                        </tbody>
                                      </table>
                                      </div>
                            </div>
                        </div>
                    </div>
                    <!-- /.col -->
                </div>
            </div>
            <!-- ============================================================== -->
            <!-- End Container fluid  -->
            <!-- ============================================================== -->
            <!-- ============================================================== -->
            <!-- footer -->
            <!-- ============================================================== -->
            <footer class="footer text-center"> 2021 © Ample Admin brought to you by <a
                    href="https://www.wrappixel.com/">wrappixel.com</a>
            </footer>
            <!-- ============================================================== -->
            <!-- End footer -->
            <!-- ============================================================== -->
        </div>
        <!-- ============================================================== -->
        <!-- End Page wrapper  -->
        <!-- ============================================================== -->
    </div>
    <!-- ============================================================== -->
    <!-- End Wrapper -->
    <!-- ============================================================== -->
    <!-- ============================================================== -->
    <!-- All Jquery -->
    <!-- ============================================================== -->
    <script src="plugins/bower_components/jquery/dist/jquery.min.js"></script>
    <!-- Bootstrap tether Core JavaScript -->
    <script src="bootstrap/dist/js/bootstrap.bundle.min.js"></script>
    <script src="js/app-style-switcher.js"></script>
    <script src="plugins/bower_components/jquery-sparkline/jquery.sparkline.min.js"></script>
    <!--Wave Effects -->
    <script src="js/waves.js"></script>
    <!--Menu sidebar -->
    <script src="js/sidebarmenu.js"></script>
    <!--Custom JavaScript -->
    <script src="js/custom.js"></script>
    <!--This page JavaScript -->
    <!--chartis chart-->
    <script src="plugins/bower_components/chartist/dist/chartist.min.js"></script>
    <script src="plugins/bower_components/chartist-plugin-tooltips/dist/chartist-plugin-tooltip.min.js"></script>
    <script src="js/pages/dashboards/dashboard1.js"></script>
</body>

</html>