
<?php


include_once("../connect.php");
include_once("../session.php");

?>

 <html lang="en">
   <head>
     <meta charset="utf-8">
     <meta http-equiv="X-UA-Compatible" content="IE=edge">
     <meta name="viewport" content="width=device-width, initial-scale=1">
     <title><?= $config['CompanyName'] ?></title>
 
     <!-- Bootstrap -->
     <link href="../css/bootstrap.min.css" rel="stylesheet">
     <link rel="stylesheet" href="../css/bootstrap-combobox.css" />
 
     <!-- HTML5 shim and Respond.js for 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.2/html5shiv.min.js"></script>
       <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
       <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
           <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
           <!-- Include all compiled plugins (below), or include individual files as needed -->
           <script src="../js/bootstrap.min.js"></script>
       	 <script src="../js/bootstrap-combobox.js"></script>
       	 <script src="../js/excellentexport.js"></script>
           <script type="text/javascript">
             $(document).ready(function(){
              // $('.combobox').combobox();
       //        $('.grpline').css("width", "100px");
             });
           </script>

     <![endif]-->
	<link rel="stylesheet" href="../css/styles.css"/>
	<style>
		.listPanel {
			height: 500px;
			background-color: #eee;
			
		}
		@media print {
			.breakBefore {page-break-before: always;}
		}
	</style>
   </head>
   <body  onload="">
   
       <?php include("navbar.php"); ?>     

   <br />
   <!-- Stack the columns on mobile by making one full-width and the other half-width -->
	<div class="container " style="margin-top: -50px; width: 100%;">
		<div class="row">
			<center>
			<img src="/img/logo_ej.png" style="height: 75px;" />
			</center>
			
		</div>
		<div class="container">
			<div class="row">
				<center><h3>Package Pickup Pending Report</h3></center>
			</div>
			<div class="row">
				<h4>
				<div class="col-md-3">User: <?= $_SESSION['Username'] ?></div>
				<div class="col-md-2"></div>
				<div class="col-md-4">Print Date/Time: <?= date("m/d/Y h:i a", time()-(4*60*60)) ?></div>
				<div class="col-md-3" style="text-align: right;">
					<a class="btn btn-success" role="button"  href="#" download="WaitingPickups<?= "(" . date("m.d.Y") . ")" ?>.xls" href="#" onclick="return ExcellentExport.excel(this, 'waitingpickups', 'Pickups Waiting to be picked up');" data-toggle="tooltip" data-placement="left" title="Does not work with Internet Explorer">Export To Excel</a>
				</div>
				</h4>
			</div>
			<div class="row">
				
				<table id="waitingpickups" class="table table-bordered table-striped table-condensed table-responsive">
					<thead>
						<tr>
							<th>
								Pickup ID
							</th>
							<th>
								Pickup Date
							</th>
							<th>
								Customer
							</th>
							<th>
								Packages
							</th>
							<th>
								Via	
							</th>
							<th>
								Sent To Pickup
							</th>
							<th>
								Days Waiting
							</th>
							<th>
								User
							</th>
						</tr>
					</thead>
					<tbody>
					<?php
						$query = "SELECT PickupID, AccountNumber, PickupDate, Salesman, Packages, Via, ToPickup, ToPickupUser, (TIMESTAMPDIFF(DAY, ToPickup, NOW())) AS DaysWaiting FROM PICKUP_HEAD WHERE ToPickup != \"0000-00-00 00:00:00\" AND AtWarehouse = '0000-00-00 00:00:00' AND PickupID > 1000 AND Void = False";
						$result = mysqli_query($con, $query);
						$lastNumber = "";
						$totalRows = mysqli_num_rows($result);
						$totalPackages = 0;
						while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
							$customer = new Customer($row['AccountNumber']);
							$totalPackages = $totalPackages + $row['Packages'] ;
					?>
						<tr>
							<td>
								<?= $row['PickupID'] ?>
							</td>
							<td>
								<?= date("m/d/Y h:i a", strtotime($row['PickupDate'])) ?>
							</td>
							<td>
								<?= $customer->AccountNumber . " - " . $customer->Name ?>
							</td>
							<td style="text-align: center;">
								<?= $row['Packages'] ?>
							</td>
							<td>
								<?= $row['Via'] ?>
							</td>
							<td>
								<?= date("m/d/Y", strtotime($row['ToPickup'])) ?>
							</td>
							<td style="text-align: center;">
								<?= $row['DaysWaiting'] ?>
							</td>
							<td>
								<?= $row['ToPickupUser'] ?>
							</td>
						</tr>
						
					<?php
						}
					?>
					<tr>
						<td>
						</td>
						<td>
						</td>
						<td>
							<b>Total Pickups:</b> <?= $totalRows ?>
						</td>
						<td>
							<b>Total:</b> <?= $totalPackages ?>
						</td>
						<td>
							
						</td>
						<td>
							
						</td>
						<td>
							
						</td>
					</tr>
					</tbody>
				</table>
				
			</div>
			<div class="row">
				
			</div>
		</div>
			
	</div>
	<div class="breakBefore"></div>
	
	<?php
		
		
		
	?>
	<script type="text/javascript">
		$(document).ready(function(){
			$('.pickupReceipt').css('font-size', '2vw');
			$('.pickupReceipt table').css('font-size', '2vw');
			$('.pickupReceipt h4').css('font-size', '2vw');
			$('.pickupReceipt h4').css('margin-top', '100px');
			$('.pickupReceipt h4').css('padding-top', '100px');
			
		});
	</script>
   </body>
   
 </html>
 
 <!--
			
		-->