<?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>
                             
                             <?php
                                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 '<script type="text/javascript"> alert("record inserted successfuly"); document.location="main.php"; </script>';
                                                                    
                                                            
                                                            
                                                                    
                                                                    
                                                                    
                                                                    
                                                                    
                                                                 
                                                            
                                                              
                                                            
                                                            
                                                            
                                                            
                                                            
                                                            
                                                        }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">Estimated Delivery:</label>
                                    <input type="text" class="form-control" name="estdel"  >
                                    <br>
                                    <label for="exampleInputEmail1" class="form-label">From:</label>
                                    <input type="text" class="form-control" name="from"  >
                                    <br>
                                    <label for="exampleInputEmail1" class="form-label">To:</label>
                                    <input type="text" class="form-control" name="to"  >
                                    <br>
                                    <label for="exampleInputEmail1" class="form-label">Origin:</label>
                                    <input type="text" class="form-control"  name="origin" >
                                    <br>
                                    <label for="exampleInputEmail1" class="form-label">Destination:</label>
                                    <input type="text" class="form-control"  name="dest" >
                                    <br>
                                    <label for="exampleInputEmail1" class="form-label">Package Description:</label>
                                    <input type="text" class="form-control"  name="desc" >
                                    <br>
                                    
                                  </div>
                                  
                                  <button type="submit" class="btn btn-primary" name="subb">Submit</button>
                                </form>
                                
                                <?php
                                    if(isset($_POST['subb'])){
                                                        
                                                        $shipmentNumber=$_POST['shipmentnumber']; 
                                                        
                                                        $estdel=$_POST['estdel'];
                                                        $from = $_POST['from'];
                                                        $to=$_POST['to']; 
                                                        $origin=$_POST['origin']; 
                                                        $dest=$_POST['dest']; 
                                                        $desc=$_POST['desc'];
                                                        
                                                        
                                                        
                                                        
                                                        $query3="insert into shippingDetails(shippingid,estimated,from_where,to_where,origin,dest,descriptn) 
                                                        values ('$shipmentNumber',
                                                                '$estdel',
                                                                '$from',
                                                                '$to',
                                                                '$origin',
                                                                '$dest',
                                                                '$desc'
                                                                )";
                                                                
                                                       
                                                                
                                                        $ressu=mysqli_query($conn, $query3);
                                                        if($ressu){
                                                            echo 'Record successfully added';
                                                            $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/TIMESTAMP TO ANY OF YOUR CURRENT SHIPPMENT</h3>
                            </div>
                             <div>
                                 <form enctype="multipart/form-data" method="post" action="history.php" 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="text" class="form-control" name="cur-date">
                                    <br>    
                                    <label for="exampleInputEmail1" class="form-label">Enter timestamp:</label>
                                    <input type="text" class="form-control"  name="cur-time" >
                                    <br>
                                    <label for="exampleInputEmail1" class="form-label">Enter Main Heading:</label>
                                    <input type="text" class="form-control"  name="cur-head" >
                                    <br>
                                    <label for="exampleInputEmail1" class="form-label">Enter Sub Heading:</label>
                                    <input type="text" class="form-control"  name="cur-sub" >
                                    <br>
                                    <label for="exampleInputEmail1" class="form-label">Enter Type:</label>
                                    <input type="text" class="form-control"  name="cur-type" >
                                    <br>
                                    
                                  </div>
                                  
                                  <button type="submit" class="btn btn-primary" name="subbbe">Submit</button>
                                </form>
                                
                                
                                
                                
                             </div>
                        </div>
                        
                        <div class="card white-box p-0">
                            <div class="card-body">
                                <h3 class="box-title mb-0">DELETE HISTORY</h3>
                            </div>
                             <div>
                                 <form enctype="multipart/form-data" method="post" action="" class="p-4">
                                  <div class="table-responsive">
                                      <table class="table align-middle">
    <thead>
      <tr>
        <th>Shipping ID</th>
        <th>Main Head</th>
        <th>Sub Head</th>
        <th>Date</th>
        <th>Action</th>
      </tr>
    </thead>
    <tbody>
        <?php
            $get_hist = "SELECT * FROM shippingHistory  ORDER BY hist_id DESC LIMIT 50";
            $result_gethist = mysqli_query($conn, $get_hist);
            while($fetch_gethist = mysqli_fetch_array($result_gethist)){
                $shi_id = $fetch_gethist['shippingid'];
                $h_id = $fetch_gethist['hist_id'];
                $da = $fetch_gethist['date'];
                $m_head = $fetch_gethist['main_head'];
                $s_head = $fetch_gethist['sub_head'];
                
                
        ?>
      <tr class>
        <td><?php echo $shi_id 
        ?></td>
        <td><?php echo $m_head; ?></td>
        <td><?php echo $s_head; ?></td>
        <td><?php echo $da; ?></td>
        <td><button><a href="deletehistory.php?id=<?php echo $h_id; ?>"> Delete</a></button></td>
      </tr>
      
      <?php
            }
      ?>
    </tbody>
  </table></div>
                                  
                                  
                                </form>
                                
                                <?php
                                            if(isset($_POST['subbbe'])){
                                                                
                                                                
                                                                $goldNumberr=$_POST['stat']; 
                                                                $golddate=$_POST['cur-date']; 
                                                                $goldtime=$_POST['cur-time']; 
                                                                $goldhead=$_POST['cur-head']; 
                                                                $goldsub=$_POST['cur-sub']; 
                                                                $goldtype=$_POST['cur-type']; 
                                                                  
                                                             
                                                                        
                                                                $query4="insert into shippingHistory(shippingId, date, time, main_head, sub_head,type) 
                                                                values ('$goldNumberr',
                                                                        '$golddate',
                                                                        '$goldtime',
                                                                        '$goldhead',
                                                                        '$goldsub', '$goldtype'
                                                                        )";
                                                                        
                                                                $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>
                    <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';
                                            	    }
                                            	}
                                          
                                          ?>
                                          
                                          
                                
                                          
                                          
                                          
                                        </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>