<?php 
/*
 *HAY UN QUERY CON VARIABLE QUE CAMBIA SEGUN ALMACEN
 */
$fromDate = $_REQUEST['fromDate'];
$toDate = $_REQUEST['toDate'];
 ?>
 
 <!DOCTYPE html>
 <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 src="../js/functions.js"></script>
           <script type="text/javascript">
             $(document).ready(function(){
       //        $('.grpline').css("width", "100px");
             });
           </script>

     <![endif]-->
	<link rel="stylesheet" href="../css/styles.css"/>
   </head>
   <body>
   
       <?php include("navbar.php"); ?>     

   
   <!-- Stack the columns on mobile by making one full-width and the other half-width -->
<div class="container " style="padding-top: 10px;" >
	<h3>Picking Incentives - From: <?= date('m/d/Y', strtotime($fromDate)) ?> To: <?= date('m/d/Y', strtotime($toDate)) ?></h3>
</div>
<div class="container " style="padding-top: 10px;" >
	<div class="panel panel-default col-md-5" >
	  <div class="panel-heading form-inline">
	  <a class="btn btn-success hidden-print" role="button" style="float: right;" href="#" download="Picking Incentive Despachadores<?= $fromDate . "_" . $toDate ?>.xls" href="#" onclick="return ExcellentExport.excel(this, 'pickingincentive-despachadores', 'Picking Incentives-Despachadores');" data-toggle="tooltip" data-placement="left" title="Does not work with Internet Explorer">Export To Excel</a>
	  <h3 class="panel-title">Despachadores</h3><br />
	  </div>
	  <div class="panel-body">
	  	<table class="table table-hover table-condensed" id="pickingincentive-despachadores">
	  		<thead>
	  			<tr>
	  				<th>Items</th>
						<th>Code</th>
	  				<th>User</th>
						<th>Job Done</th>
	  			</tr>
	  		</thead>
	    <?php 
	    $query = "SELECT SUM(Units) as `Items`, 
									IF(LENGTH(`PO`) <= 2,
										SUBSTRING(`PO`,1,1),
										IF(LOCATE('/', PO) = 0,
											'',
											SUBSTRING(`PO`,1,1)
										)
									) AS `User`, 'Despachador' as `Job`
								FROM `PICKING_INCENTIVE` WHERE TransactionDate BETWEEN '$fromDate' AND '$toDate' AND ST LIKE '3'
								GROUP BY `User`
								ORDER BY User, Job";
		$result = mysqli_query($con, $query);
		while($row = mysqli_fetch_array($result)){
		?>
		<tr>
			<td><?= $row['Items'] ?></td>
			<td><?= $row['User'] ?></td>
			<td><?= getPickerName($row['User']) ?></td>
			<td><?= $row['Job'] ?></td>
		</tr>
		<?php
		}
		?>
	     </table>
	  </div>
	  <div class="panel-footer" style="height: 100px;" >
	  </div>
	</div>
	<div class="panel panel-default col-md-5 col-md-offset-2">
	  <div class="panel-heading form-inline">
			<a class="btn btn-success hidden-print" role="button" style="float: right;" href="#" download="Picking Incentive Verificadores<?= $fromDate . "_" . $toDate ?>.xls" href="#" onclick="return ExcellentExport.excel(this, 'pickingincentive-verificadores', 'Picking Incentives-Verificadores');" data-toggle="tooltip" data-placement="left" title="Does not work with Internet Explorer">Export To Excel</a>
			<h3 class="panel-title">Verificadores</h3><br />
	  </div>
	  <div class="panel-body">
	  	<table class="table table-hover table-condensed" id="pickingincentive-verificadores">
	  		<thead>
	  			<tr>
	  				<th>Items</th>
						<th>Code</th>
	  				<th>User</th>
						<th>Job Done</th>
	  			</tr>
	  		</thead>
	    <?php 
	    $query = "SELECT SUM(Units) as `Items`, 
									IF(LENGTH(`PO`) <= 2,
										SUBSTRING(`PO`,2,1),
										IF(LOCATE('/', PO) = 0,
											'',
											SUBSTRING(`PO`,2,1)
										)
									) AS `User`, 'Verificador' as `Job`
								FROM `PICKING_INCENTIVE` WHERE TransactionDate BETWEEN '$fromDate' AND '$toDate'
								GROUP BY `User` ORDER BY User, Job";
		$result = mysqli_query($con, $query);
		while($row = mysqli_fetch_array($result)){
		?>
		<tr>
			<td><?= $row['Items'] ?></td>
			<td><?= $row['User'] ?></td>
			<td><?= getPickerName($row['User']) ?></td>
			<td><?= $row['Job'] ?></td>
		</tr>
		<?php
		}
		?>
	     </table>
	  </div>
	  <div class="panel-footer" style="height: 100px;" >
	  </div>
	
	</div>
</div>       
<script type="text/javascript">
</script>

   </body>
   
 </html>