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

$webTitle = "Truck Loading Report";
$wid = mysqli_real_escape_string($con,$_REQUEST['wid']);
 ?>

 <!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'] ?> - <?= $webTitle ?></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(){
       //        $('.grpline').css("width", "100px");
             });
           </script>

     <![endif]-->
	<link rel="stylesheet" href="../css/styles.css"/>
	<style>
		.truncate {
			width: 150px;
			max-width: 2.5in;
			white-space: nowrap;
			overflow: hidden;
			text-overflow: ellipsis;
		}
	</style>
   </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;">
	<div class="panel panel-default">
	  <div class="panel-heading form-inline">



	  		    <h3 class="panel-title">Truck Inventory Report</h3><br />
						<div class="">
							<?php
							$warehouse = new Warehouse($wid);
							//error_reporting(E_ALL);
							echo "<b>" . ($warehouse->WarehouseName) . "</b><br>";

              //var_dump($warehouse->Items);
							?>

						<a href="mod.php?p=truckinventory&a=addToTruck&wid=<?= $wid ?>" class="hidden-print btn btn-primary">
							Go Back
						</a>
						<button onclick="window.print();" class="hidden-print btn btn-primary">
							Print
						</button>

					</div>
	  </div>
	  <div class="panel-body">
	  	<table class="table table-hover table-condensed" id="receiveReportTable">
	  		<thead>
	  			<tr>
						<th>SKU</th>
						<th>Description</th>
						<th>Qty</th>
						<th>Normal Stock</th>
						<th>Manual Count</th>

	  			</tr>

	  		</thead>
			<tbody>
	    <?php
		//$query = "SELECT id FROM PURCHASE_ORDER_HEADER JOIN PURCHASE_ORDER_DETAIL USING(PurchaseOrderID) WHERE PurchaseOrderID = $poid";
		//echo $query;
		//$result = mysqli_query($con,$query);
		//while($row = mysqli_fetch_array($result)){

    $warehouse->getWarehouseItems();
    foreach ($warehouse->Items as $key => $item) {
      // code...
      //var_dump($item);
			//$invoice = new Invoice(322);
			$item = new WarehouseItem($item['id']);
      var_dump();
			// $poItemObj = new Item($poItem->Group, $poItem->Line, $poItem->SKU);
			// $rowClass = $poItem->ReceivedQty==$poItem->ConfirmedQty?"success":"danger";
		?>
				<tr class="" >
					<td>
					<?= $item->SKU ?></td>
					<td class="truncate">
					<?= $item->InventoryItem->Description; ?></td>
					<td><?php
            echo $item->Qty;
          ?></td>
					<td><?php
            echo $item->StockLevel;
          ?></td>

					<td valign="bottom">
						__________
					</td>
		<?php
		}
		?>
			</tbody>
	     </table>
	  </div>
	  <div class="panel-footer" >
			<div class="pull-left">


			</div>
	  	<div class="pull-right">

			</div>
			<br>
				<br>
	  </div>
	</div>

</div>
	<script type="text/javascript">

	$('[name=filter]').on('keypress', function(e) {
		if (e.which == 13) {
			filter();
		}

	});
	function clearFilter() {
		$('[name=filter]').val("");
		$('#clearButton').css('display', 'none');
		$('tr').css('display', '');

	}
	function filter() {
		var	name = $('[name=filter]').val();
		filterByName(name);
	}
	function filterByName(name) {
		$('#clearButton').css('display', '');
		var cols = $('#paymenthistory th').length;
		for (var i = 0; i < $('#paymenthistory td').length; i=i+cols) {

			var text = $($('td')[i]).text();

			var result = text.toUpperCase().indexOf(name.toUpperCase());
			if (text != name) {
				$($('tr')[i/cols+1]).css('display', 'none');
			}else {
				$($('tr')[i/cols+1]).css('display', '');
			}

		}
	}
	</script>

   </body>

 </html>
