<?php
session_start();


if (!isset($_SESSION['email'])) {
    echo("<script>location.href = 'login.php';</script>");
}
include 'db.php';
$query = "SELECT * FROM parcel";
$result = mysqli_query($db, $query);
$queryy = "SELECT * FROM track";
$status = mysqli_query($db, $queryy);
?>

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <!-- Bootstrap 3.3.7 -->
  <link rel="stylesheet" href="assects/css/bootstrap.min.css">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="assects/css/font-awesome.min.css">
  <link rel="stylesheet" href="assects/css/font-awesome-animation.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="assects/css/AdminLTE.min.css">
<!-- AdminLTE Skins. Choose a skin from the css/skins
  folder instead of downloading all of them to reduce the load. -->
  <link rel="stylesheet" href="assects/css/_all-skins.min.css">
  <!-- DataTables -->
  <link rel="stylesheet" href="assects/css/dataTables.bootstrap.min.css">
  <script src="https://use.fontawesome.com/2aec379aeb.js"></script>

  <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->

<!-- Google Font -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
</head>
<body class="hold-transition skin-purple sidebar-mini">
  <div class="wrapper">

    <title>Admin Panel | Courier Cargo</title>
    <header class="main-header">
      <!-- Logo -->
      <a href="index.php" class="logo">
        <!-- mini logo for sidebar mini 50x50 pixels -->
        <span class="logo-mini"><b>Admin</b></span>
        <!-- logo for regular state and mobile devices -->
        <span class="logo-lg"><b>Admin</b> Panel</span>
      </a>
      <!-- Header Navbar: style can be found in header.less -->
      <nav class="navbar navbar-static-top">
        <!-- Sidebar toggle button-->
        <a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
          <span class="sr-only">Toggle navigation</span>
        </a>

        <div class="navbar-custom-menu">
          <ul class="nav navbar-nav">
            <li class="dropdown user user-menu">
              <a><span class="hidden-xs">Welcome Admin</span></a>
            </li>
          </ul>
        </div>
      </nav>
    </header>
    <!-- Left side column. contains the logo and sidebar -->
    <aside class="main-sidebar">
      <!-- sidebar: style can be found in sidebar.less -->
      <section class="sidebar">

        <ul class="sidebar-menu" data-widget="tree">
          <li ><a href="index.php"><i class="fa fa-dashboard"></i> <span>Dashboard</span></a></li>
          <li class="treeview active">
            <a href="#">
              <i class="fa fa-truck"></i> <span>Shipment</span>
              <span class="pull-right-container">
                <i class="fa fa-angle-left pull-right"></i>
              </span>
            </a>
            <ul class="treeview-menu">
              <li ><a href="new.php"><i class="fa fa-angle-double-right"></i> Add Shipment</a></li>
              <li class='active'><a href="index.php"><i class="fa fa-angle-double-right"></i> List of Pending Shipment</a></li>
            </ul>
          </li>
 <li><a href="change_password.php"><i class="fa fa-sign-out"></i> <span>Change Password</span></a></li>
          <li><a href="logout.php"><i class="fa fa-sign-out"></i> <span>Logout</span></a></li>
        </ul>
      </section>
      <!-- /.sidebar -->
    </aside>
    <style type="text/css">
      hr { margin:2px !important; }
      h3 { margin-top:5px; }
      #TableTab { width:100% !important; }
    </style>
    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
      <!-- Content Header (Page header) -->
      <section class="content-header">
        <h1>
          List of Pending Shipment
        </h1>
        <ol class="breadcrumb">
          <li><a href="index.php"><i class="fa fa-dashboard"></i> Home</a></li>
          <li class="active">List Pending Shipment</li>
        </ol>
      </section>

      <!-- Main content -->
      <section class="content">
        <!-- Small boxes (Stat box) -->

<?php if (isset($_SESSION['msg-s'])) { ?>
        <div class="alert alert-success alert-dismissible">
                    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                    <h4><i class="icon fa fa-check"></i> Success!</h4> <?php echo $_SESSION['msg-s']; ?>
                </div>
<?php unset($_SESSION['msg-s']); } ?>

<?php if (isset($_SESSION['msg-e'])) { ?>
        <div class="alert alert-error alert-dismissible">
                    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                    <h4><i class="icon fa fa-check"></i> Error!</h4> <?php echo $_SESSION['msg-e']; ?>
                </div>
<?php unset($_SESSION['msg-e']); } ?>

        <div class="row">
          <div class="col-md-12">
            <div class="box">
              <!-- /.box-header -->
              <div class="box-body">
                <table id="TableTab" class="table table-bordered table-striped no-more-tables">
                  <thead>
                    <tr>
                      <th>Consign. No.</th>
                      <th>Origin</th>
                      <th>Destination</th>
                      <th>PickupDate</th>
                      <th>Status</th>
                      <th>Postby</th>
                      <th style="display:none;">hidepickupdate</th>
                      <th>Action</th>
                    </tr>
                  </thead>
                  <tbody>
                    <?php while($row = mysqli_fetch_assoc($result)) { ?>
                      <tr>
                        <td data-title="Consign. No.">
                          <?php echo $row['cno']; ?>
                        </td>
                        <td data-title="Origin"><?php echo $row['origin']; ?></td>
                        <td data-title="Destination"><?php echo $row['destination']; ?></td>
                        <td data-title="PickupDate"><?php echo $row['expdelivdate']; ?></td>
                        <td data-title="Status">
                          <button type="button" class="btn bg-purple btn-flat btn-sm"><?php echo $row['status']; ?></button>
                        </td>
                        <td data-title="Postby">Customer Service</td>
                        <td data-title="hidepickupdate" style="display:none;"><?php echo $row['pdate']; ?></td>
                        <td data-title="Action"> 

                          <form method="post" action="process.php" style="display:inline;">
                            <input type="hidden" name="id" id="id" value="<?php echo $row['id']; ?>" />
                            <button class="btn btn-flat btn-xs btn-info" name="update"><i class="fa fa-edit"></i></button>
                          </form>&nbsp; | 

                          <form method="post" action="process.php" style="display:inline;">
                            <input type="hidden" name="delid" id="delid" value="<?php echo $row['id']; ?>" />
                            <button class="btn btn-flat btn-xs btn-danger" name="delete"><i class="fa fa-trash"></i></button>
                          </form>


                          <style type="text/css">
                            .divhead {
                              /* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#ffffff+0,e0e0e0+63,f3f3f3+63,e0e0e0+63,ffffff+100 */
                              background: rgb(255,255,255); /* Old browsers */
                              background: -moz-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(224,224,224,1) 63%, rgba(243,243,243,1) 63%, rgba(224,224,224,1) 63%, rgba(255,255,255,1) 100%); /* FF3.6-15 */
                              background: -webkit-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(224,224,224,1) 63%,rgba(243,243,243,1) 63%,rgba(224,224,224,1) 63%,rgba(255,255,255,1) 100%); /* Chrome10-25,Safari5.1-6 */
                              background: linear-gradient(to bottom, rgba(255,255,255,1) 0%,rgba(224,224,224,1) 63%,rgba(243,243,243,1) 63%,rgba(224,224,224,1) 63%,rgba(255,255,255,1) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
                              filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#ffffff',GradientType=0 ); /* IE6-9 */
                            }

                            @media print {
                              body * { visibility: hidden; }
                              .content-wrapper { min-height:100vh !important; }
                              .printcontent * { visibility: visible; }
                              .printcontent {  min-height:100vh !important;  max-height:100vh !important; height:100vh !important; }
                              .modal-footer, .close { display:none !important; }
                            }
                          </style>
                          <div class="modal fade printcontent" id="View<?php echo $row['id']; ?>" role="dialog">
                            <div class="modal-dialog modal-lg">
                              <div class="modal-content">                                      
                                <div class="modal-header">
                                  <button type="button" class="close" data-dismiss="modal">&times;</button>
                                  <h4 class="modal-title">Consignment No. : <strong><?php echo $row['cno']; ?></strong><span class="pull-right"><button type="button" class="btn bg-purple btn-flat btn-sm"><?php echo $row['status']; ?></button> &nbsp;  &nbsp; </span></h4>
                                </div>

                                <div class="modal-body">
                                  <div class="row">
                                    <div class="col-md-6 col-sm-6 col-xs-6">
                                      <h4 style="font-weight:bold;">Shipper Details</h4>
                                      <div style="border: solid 1px #ddd; border-radius:4px; padding-left:5px; line-height:24px;">
                                        <?php echo $row['sname']; ?><br />
                                        <?php echo $row['saddress']; ?><br />
                                        <?php echo $row['sphone']; ?><br>
                                        <?php echo $row['semail']; ?><br>
                                      </div>
                                    </div>
                                    <div class="col-md-6 col-sm-6 col-xs-6">
                                      <h4 style="font-weight:bold;">Receiver Details</h4>
                                      <div style="border: solid 1px #ddd; border-radius:4px; padding-left:5px; line-height:24px;">
                                        <?php echo $row['rname']; ?><br />
                                        <?php echo $row['raddress']; ?><br />
                                        <?php echo $row['rphone']; ?><br>
                                        <?php echo $row['remail']; ?><br>
                                      </div>
                                    </div>

                                    <div class="clearfix"></div><br />

                                    <div class="col-md-6 col-sm-6 col-xs-6">
                                      <ul class="list-group list-group-bordered col-md-12">
                                        <li class="list-group-item">
                                          <b>Carrier No.</b> <a class="pull-right"><?php echo $row['carrier']; ?> <a href="" target="_blank"><?php echo $row['reference']; ?></a></a>
                                        </li>
                                        <li class="list-group-item">
                                          <b><?php echo $row['total']; ?></b> <a class="pull-right">4</a>
                                        </li>
                                        <li class="list-group-item">
                                          <b>Origin</b> <a class="pull-right"><?php echo $row['origin']; ?></a>
                                        </li>
                                        <li class="list-group-item">
                                          <b>Pickup Date/Time</b> <a class="pull-right"><?php echo $row['pdate']; ?> - <?php echo $row['ptime']; ?></a>
                                        </li>
                                        <li class="list-group-item">
                                          <b>Postby</b> <a class="pull-right">Customer Care</a>
                                        </li>
                                      </ul>
                                    </div>

                                    <div class="col-md-6 col-sm-6 col-xs-6">
                                      <ul class="list-group list-group-bordered col-md-12">
                                        <li class="list-group-item">
                                          <b>Payment Mode</b> <a class="pull-right"><?php echo $row['payment']; ?></a>
                                        </li>
                                        <li class="list-group-item">
                                          <b>Mode</b> <a class="pull-right"><?php echo $row['mode']; ?></a>
                                        </li>
                                        <li class="list-group-item">
                                          <b>Destination</b> <a class="pull-right"><?php echo $row['destination']; ?></a>
                                        </li>
                                        <li class="list-group-item">
                                          <b>Comments</b> <a class="pull-right"></a>
                                        </li>
                                      </ul>
                                    </div>

                                    <div class="clearfix"></div>
                                    
                                      <div class="row upship" style="line-height:24px;">
                                        <div class="col-md-2 col-sm-2 col-xs-2 col-md-offset-1 divhead"><strong>Date</strong></div>
                                        <div class="col-md-2 col-sm-2 col-xs-2 divhead"><strong>Time</strong></div>
                                        <div class="col-md-2 col-sm-2 col-xs-2 divhead"><strong>Location</strong></div>
                                        <div class="col-md-2 col-sm-2 col-xs-2 divhead"><strong>Status</strong></div>
                                        <div class="col-md-2 col-sm-2 col-xs-2 divhead"><strong>Remarks</strong></div>
                                        <div class="clearfix"></div>
                                        <div class="col-md-10 col-md-offset-1"><hr /></div>
                                        <?php  while($rowz = mysqli_fetch_assoc($status)) { ?>
                                        <div class="clearfix"></div>
                                        <div class="col-md-2 col-sm-2 col-xs-2 col-md-offset-1"><?php echo $rowz['udate']; ?></div>
                                        <div class="col-md-2 col-sm-2 col-xs-2"><?php echo $rowz['utime']; ?></div>
                                        <div class="col-md-2 col-sm-2 col-xs-2"><?php echo $rowz['location']; ?></div>
                                        <div class="col-md-2 col-sm-2 col-xs-2"><?php echo $rowz['status']; ?></div>
                                        <div class="col-md-2 col-sm-2 col-xs-2"><?php echo $rowz['remark']; ?></div>
                                        <div class="clearfix"></div>
                                        
                                    <?php } ?>
                                      </div>
 
                                  </div>
                                </div> 
                                <div class="modal-footer">
                                  <button class="btn btn-xs btn-primary print" onclick="window.print()"><i class="fa fa-print"></i> Print</button>
                                </div>                                        
                              </div>
                            </div>
                          </div>                                        
                        </td>
                      </tr>
                    <?php } ?>
                  </tbody>
                </table>
              </div>
              <!-- /.box-body -->
            </div>
          </div>

        </div>
        <!-- /.row -->

      </section>
      <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->
    <footer class="main-footer">
      <strong>Copyright &copy; 2022.</strong> All rights reserved.
    </footer>
  </div>
  <!-- ./wrapper -->

  <!-- jQuery 3 -->
  <script src="assects/js/jquery.min.js"></script>
  <!-- jQuery UI 1.11.4 -->
  <script src="assects/js/jquery-ui.min.js"></script>
  <!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
  <script>
    $.widget.bridge('uibutton', $.ui.button);
  </script>
  <!-- Bootstrap 3.3.7 -->
  <script src="assects/js/bootstrap.min.js"></script>
  <!-- DataTables -->
  <script src="assects/js/jquery.dataTables.min.js"></script>
  <script src="assects/js/dataTables.bootstrap.min.js"></script>
  <!-- AdminLTE App -->
  <script src="assects/js/adminlte.min.js"></script>
  <!-- AdminLTE for demo purposes -->
  <script src="assects/js/demo.js"></script>
</body>
</html>
<script>
  $(function () {
    $('#TableTab').DataTable( {
      "order": [[ 6, "desc" ]],
      "columnDefs": [ {
        "targets": 7,
        "orderable": false
      } ]
    })
  })
</script>