
<?php


if(isset($_REQUEST['pickup'])){
	$pickup = new Pickup($_REQUEST['pickup']);
}
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;}
		}
		body{
			font-size: 2em;
		}
	</style>
   </head>
   <body  onload="window.print();">
   
       <?php
		$queryRejected = "SELECT PICKUP_DETAIL.*, CONCAT(INVENTORY.Description, ' ',INVENTORY.Notes) Description ,  GROUP_CONCAT('<span class=\"glyphicon glyphicon-arrow-right\"></span>', PICKUP_VERIFICATION_STATUS.StatusReason SEPARATOR '<br>') as StatusReason FROM PICKUP_DETAIL LEFT JOIN PICKUP_VERIFICATION_STATUS ON(PickupDetailID = PICKUP_DETAIL.id), INVENTORY WHERE INVENTORY.SKU = PICKUP_DETAIL.SKU AND INVENTORY.Line = PICKUP_DETAIL.Line AND PICKUP_DETAIL.PickupID = " . $pickup->PickupID . " AND Approved = FALSE GROUP BY PICKUP_DETAIL.id ";
		//echo $query;
		$result = mysqli_query($con, $queryRejected);
		if(mysqli_num_rows($result)>0){
	   ?>     
	
   <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="row">
			<div style="font-size: large;" class="col-md-6 pull-left">
				<span><b>Customer:</b> <?= ($pickup->Customer->AccountNumber) ?> - <?= ($pickup->Customer->Name) ?></span><br />
				<span><b>City:</b> <?= ($pickup->Customer->City) ?></span><br />
				<span><b>Phone:</b> <?= ($pickup->Customer->Phone) ?></span>
			</div>
			
			<div style="font-size: large;" class="col-md-3 pull-right">
				<span><b>Pickup ID:</b> <?= ($pickup->PickupID) ?></span><br />
				<span><b>Pickup Date:</b> <?= date("m/d/Y h:i a", strtotime($pickup->PickupDate)) ?></span><br />
				<span><b>Salesman:</b> <?= ($pickup->Salesman->Name) ?></span><br />
				
			</div>
			
		</div>
		<div class="container">
			<div class="row">
				<center><h3>RETURN ITEM REJECTED REPORT</h3></center>
			</div>
			<div class="row">
				<h4>
				<!--<div class="col-md-3">Verification User: <?= $pickup->StatusUser ?></div>-->
				<div class="col-md-3 pull-left">Print User: <?= $_SESSION['Username'] ?></div>
				<div class="col-md-4 pull-right">Print Date/Time: <?= date("m/d/Y h:i a", time()+(2*60*60)) ?></div>
				</h4>
			</div>
			<div class="row">
				
				<table class="table table-bordered table-striped table-condensed table-responsive">
					<thead>
						<tr>
							<tr>
							<th style="width: 5%;">
								Line
							</th>
							<th style="width: 10%;">
								SKU
							</th>
							<th style="width: 25%;">
								Description
							</th>
							<th style="width: 5%;">
								Qty
							</th>
							<th style="width: 5%;">
								OrderID
							</th>
							<th style="width: 8%;">
								Invoice Number
							</th>
							<th style="width: 15%;">
								Return Reason
							</th>
							<th style="width: 15%;">
								Rejection Reason
							</th>
							
						</tr>
					</thead>
					<tbody>
					<?php
						
						while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
						
					?>
						<tr>
							<td>
								<?= $row['Line'] ?>
							</td>
							<td>
								<?= $row['SKU'] ?>
							</td>
							<td>
								<?= $row['Description'] ?>
							</td>
							<td>
								<?= $row['Qty'] ?>
							</td>
							<td>
								<?= ($row['OrderID'])?>
							</td>
							<td>
								<?= $row['InvoiceNumber'] ?>
							</td>
							<td>
								<?= getReasonText($row['Reason']) ?>
							</td>
							<td>
								<?= $row['StatusReason'] ?>
							</td>
						</tr>
						
					<?php
						}
					?>
					
					</tbody>
				</table>
				
			</div>
			<div class="row">
				<div class="col-md-3 col-md-offset-8 pull-right" style="border: solid 4px; width: 500px;">
						<br>
						Fecha:________/____________/________<br>
						<b>Recibido por:</b><br>
						<br>
						Letra de Molde:__________________________<br>
						<br>
						Firma: __________________________________
						
				</div>
				
			</div>
		</div>
			
	</div>
	<div class="breakBefore"></div>
	
	<?php
		}
	$query = "SELECT PICKUP_DETAIL.*, CONCAT(INVENTORY.Description, ' ',INVENTORY.Notes) Description   FROM PICKUP_DETAIL, INVENTORY WHERE INVENTORY.SKU = PICKUP_DETAIL.SKU AND INVENTORY.Line = PICKUP_DETAIL.Line AND PickupID = " . $pickup->PickupID . " AND Approved = TRUE";
	$result = mysqli_query($con, $query);
	if(mysqli_num_rows($result)>0){
						
	
	?>
	
	
	
	
	 <!-- 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="row">
			<div style="font-size: large;" class="col-md-6 pull-left">
				<span><b>Customer:</b> <?= ($pickup->Customer->AccountNumber) ?> - <?= ($pickup->Customer->Name) ?></span><br />
				<span><b>City:</b> <?= ($pickup->Customer->City) ?></span><br />
				<span><b>Phone:</b> <?= ($pickup->Customer->Phone) ?></span>
			</div>
			
			<div style="font-size: large;" class="col-md-3 pull-right">
				<span><b>Pickup ID:</b> <?= ($pickup->PickupID) ?></span><br />
				<span><b>Pickup Date:</b> <?= date("m/d/Y h:i a", strtotime($pickup->PickupDate)) ?></span><br />
				<span><b>Salesman:</b> <?= ($pickup->Salesman->Name) ?></span><br />
				
			</div>
			
		</div>
		<div class="container">
			<div class="row">
				<center><h3>RETURN ITEM APPROVED REPORT</h3></center>
			</div>
			<div class="row">
				<h4>
				<!--<div class="col-md-3">Verification User: <?= $pickup->StatusUser ?></div>-->
				<div class="col-md-3 pull-left">Print User: <?= $_SESSION['Username'] ?></div>
				<div class="col-md-4 pull-right">Print Date/Time: <?= date("m/d/Y h:i a", time()+(2*60*60)) ?></div>
				</h4>
			</div>
			<div class="row">
				
				<table class="table table-bordered table-striped table-condensed table-responsive">
					<thead>
						<tr>
							<th style="width: 5%;">
								Line
							</th>
							<th style="width: 10%;">
								SKU
							</th>
							<th style="width: 25%;">
								Description
							</th>
							<th style="width: 5%;">
								Qty
							</th>
							<th style="width: 10%;">
								OrderID
							</th>
							<th style="width: 10%;">
								Invoice Number
							</th>
							<th style="width: 15%;">
								Return Reason
							</th>
						</tr>
					</thead>
					<tbody>
					<?php
						
						while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
						
					?>
						<tr>
							<td>
								<?= $row['Line'] ?>
							</td>
							<td>
								<?= $row['SKU'] ?>
							</td>
							<td>
								<?= $row['Description'] ?>
							</td>
							<td>
								<?= $row['Qty'] ?>
							</td>
							<td>
								<?= ($row['OrderID'])?>
							</td>
							<td>
								<?= $row['InvoiceNumber'] ?>
							</td>
							<td>
								<?= getReasonText($row['Reason']) ?>
							</td>
						</tr>
						
					<?php
						}
					?>
					
					</tbody>
				</table>
				
			</div>
			<div class="row">
				<br>
				<h4>
				
				</h4>
			</div>
		</div>
			
	</div>
	<div class="breakBefore"></div>
	<?php
	}
		//$query = "SELECT PICKUP_DETAIL.*, CONCAT(INVENTORY.Description, ' ',INVENTORY.Notes) Description   FROM PICKUP_DETAIL, INVENTORY WHERE INVENTORY.SKU = PICKUP_DETAIL.SKU AND INVENTORY.Line = PICKUP_DETAIL.Line AND PickupID = " . $pickup->PickupID . " AND Approved = FALSE";
		$result = mysqli_query($con, $queryRejected);
		$meses = array("", "enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre");
		while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
	?>
			<div class="container " style="margin-top: -50px; width: 100%;">
				<div class="row">
					<center>
					<img src="/img/logo_ej.png" style="height: 75px;" /><br />
					<span>PO BOX 191538</span><br />
					<span>SAN JUAN, PR 00919-1538</span><br />
					<span>Phone: (787) 760-7295</span><br />
					</center>
				</div>
				<div class="row">
					<p>
						<b>Fecha:</b> <?= date("m/d/Y h:m a", strtotime($row['StatusDate'])) ?><br /><br />
						<b># Cuenta:</b> <?= ($pickup->Customer->AccountNumber)  ?></b><br />
						<b>A:</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?= $pickup->Customer->Name . " - " . $pickup->Customer->City ?><br />
						<!--<b>Direccion:</b>&nbsp;&nbsp;<?= $pickup->Customer->Address ?><br />-->
						<br />
						<b>Asunto: </b> Notificaci&oacute;n de Devoluci&oacute;n Denegada <br /><br />
						Estimado cliente, el <?= date('d \d\e ', strtotime($pickup->PickupDate)) . $meses[(int) date('m', strtotime($pickup->PickupDate))] . " de " . date('Y', strtotime($pickup->PickupDate)) ?> <?= ucwords(strtolower($pickup->RequestedBy)) ?> solicit&oacute; la devoluci&oacute;n de <?= $row['Qty'] ?> <?= $row['Qty']>1?"unidades":"unidad" ?> del art&iacute;culo n&uacute;mero:
						<b><?= "(" . $row['Line'] . ") " . $row['SKU'] ?></b> - <i><?= $row['Description'] ?></i>
						en el <b>Pickup #<?= $pickup->PickupID ?></b>. 
						&Eacute;sta ha sido denegada por la siguiente razón:<br>
						<pre><big><big><big><?= $row['StatusReason'] ?></big></big></big></pre>
						<br />
						Para mas informaci&oacute;n, favor de contactar su vendedor.
						<br />
						<br />
						Gracias<br />
							
					
						
						
						
						
					</p>
				</div>
			</div>
			<div class="breakBefore"></div>
	
	<?php
		}
	?>
   </body>
   
 </html>
 
 <!--
			
		-->