<?php
include("../connect.php");
include("../session.php");
//error_reporting(E_ALL);

$isAdmin = $_SESSION['isAdmin'];
if (!$isAdmin) {
	header("Location: logout.php");
}
if(isset($_REQUEST['id'])){
		$po = new PurchaseOrder($_REQUEST['id']);
}else{
	$po = new PurchaseOrder(1);
}

//error_reporting(E_ALL);
//DIE('ELI');

 ?>
 <!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'] ?> - Create New Purchase Order</title>

      <!-- Bootstrap -->
      <link href="<?= $root ?>css/bootstrap.min.css" rel="stylesheet">
      <link rel="stylesheet" href="<?= $root ?>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://code.jquery.com/jquery-3.3.1.min.js"></script>
            <!-- Include all compiled plugins (below), or include individual files as needed -->
            <script src="<?= $root ?>js/bootstrap.min.js"></script>

			<script type="text/javascript" src="../js/functions.js"></script>

			<script type="text/javascript" src="../js/jquery.jeditable.js"></script>
			<script type="text/javascript" src="../js/jquery.jeditable.autogrow.js"></script>
			<script type="text/javascript" src="../js/jquery.jeditable.charcounter.js"></script>
			<script type="text/javascript" src="../js/jquery.jeditable.checkbox.js"></script>
			<script type="text/javascript" src="../js/jquery.jeditable.datepicker.js"></script>
			<script type="text/javascript" src="../js/fixHeader.js"></script>
			<script type="text/javascript" src="../js/jquery.jeditable.masked.js"></script>
			<script type="text/javascript" src="../js/jquery.jeditable.time.js"></script>
        	 <script src="<?= $root ?>js/bootstrap-combobox.js"></script>
			 <script src="../js/gridviewscroll.js"></script>
			 <script type="text/javascript" src="../js/fileinput.js"></script>
            <script type="text/javascript">
				var indexHash = new HashTable({});
              $(document).ready(function(){
				$('.edit').on('change', function(){
					$.post("mod.php?p=purchasing&a=functions&f=saveReviewField&po=<?= $po->PurchaseOrderID ?>",
						   { id: $(this).attr('id'), value: $(this).val() }, function(data){
								$(this).val(data);
								recalculateOrder();

						   });
				});
				$('.editItem').on('change', function(){
					$.post("mod.php?p=purchasing&a=functions&f=saveReviewFieldItem&id=<?= $po->PurchaseOrderID ?>",
						   { id: $(this).attr('id'), value: $(this).val() }, function(data){
								$(this).val(data);

								recalculateOrder();
						   });
				});
                //$('.combobox').bscombobox();
        //        $('.grpline').css("width", "100px");

			  });

            </script>

      <![endif]-->
 	<link rel="stylesheet" href="<?= $root ?>css/styles.css"/>
	<link rel="stylesheet" href="../css/fileinput.min.css"/>
	<style>
		.cloned_header{
			background-color: white;
		}
	</style>
    </head>
    <body>

    <!-- Stack the columns on mobile by making one full-width and the other half-width -->
 <div class="container-fluid" style="margin-top: -50px;">
	<img class="img-responsive" style="width: 120px;" src="<?= $root ?>img/<?= $config['Logo'] ?>" alt="" />
 	<div class="row">
 	  <div class="col-xs-4">

 	  	<p>
			<div class="pull-left" style="width: 50px; height: 100px;"><b>Vendor: </b></div>
 	  		<div style="margin-left: 60px;">
				<select class="form-control edit" id="VendorID" name="VendorID">

					<option value="">---Select a Vendor---</option>
					<?php
					$query ="SELECT * FROM VENDOR ORDER BY `Name` ASC";
					$result = mysqli_query($con, $query);
					while($row = mysqli_fetch_array($result)){
					?>
					<option <?= $row['VendorID'] == $po->VendorID?"selected":"" ?> value="<?= $row['VendorID'] ?>"><?= $row['Name'] ?></option>
					<?php
					}

					?>
				</select>

			</div>
 	  </p>

 	  </div>
  	  <div class="col-xs-4">
		<p>
			<div class="pull-left" style="width: 60px; height: 100px;"><b>Ship To: </b></div>
 	  		<div>
				<?= $po->ShipToName; ?><br />
				<?= $po->ShipToAddress1 ?><br />
				<?= $po->ShipToAddress2 ?><br />
				<?= $po->ShipToCity ?>, <?= $po->ShipToState ?> <?=  $po->ShipToZip ?>

			</div>
		</p>

	  </div>
 	  <div class="col-xs-4" style="margin-top: -20px;">
 		  <h3>Create Purchase Order</h3>
 		  <p>
 		  	<b>Purchase Order ID: </b><span style="font-style: italic;"><?= $po->PurchaseOrderID==1?"NEW":$po->PurchaseOrderID ?></span><br>
 		  <b>PO Date: </b><?= date("m/d/Y",strtotime($po->PODate)) . " "  . date("g:i a",strtotime($po->PODate)) ?><br>

 		  </p>
 	  </div>
	  <table class="table table-condensed centered">
		<thead>
			<tr class="centered">
				<th style="width: 20%;" class="centered">Account Number #</th>
				<th style="width: 20%;" class="centered"></th>
				<th style="width: 15%;" class="centered"></th>


				<th></th>
			</tr>
		</thead>
		<tbody>
			<tr class="centered">
				<td id="OurAccountNumber"><?= $po->Vendor->OurAccountNumber ?></td>

				<td><button onclick="$('#LoadItemsModal').modal('show');" class="btn btn-primary">Load Items</button>
				</td>

				<td>
					<button onclick="$('#UploadSupplierListModal').modal('show');" class="btn btn-primary">Upload Supplier List</button>
				</td>
				<td>
					<button onclick="cleanPO();" class="btn btn-primary">Clean PO</button>
				</td>

			</tr>
		</tbody>
	  </table>

 	  <table id="poReviewTable" class="table table-condensed fix_header_table">
 	    <thead>
 	      <tr class="GridViewScrollHeader" style="background-color: #E0E0E0;">
 	        <th style="width: 100px;">Line Group</th>
 	        <th style="width: 180px;">Item</th>
			<th style="width: 450px;">Description</th>
			<th style="width: 150px;">SupplierQty</th>
			<th style="width: 150px;">Committed Qty</th>
			<th style="background-color: #89cff0; width: 150px; ">Recommended</th>
			<th style="width: 150px;">Sold Last 6 months</th>
			<th style="width: 150px;">On Hand</th>
			<th style="width: 150px;" class="centered">Order</th>

			<th style="width: 150px; text-align: right;">Cost</th>


 	        <th style="width: 150px; text-align: right;">Extension</th>
			<?php
			if(!$po->Sent){
			?>
			<th style="width: 150px;"></th>
			<?php
			}
			?>
 	      </tr>
 	    </thead>
 	  	<tbody id="poReviewTableBody">
 	  	<?php

 	  		$index = 0;
			$totalItems = 0;
			$invoiceTotal = 0;
			function compareQty($a, $b){
				return strcmp($a->Qty, $b->Qty);

			}
			//usort($po->Items, "compareQty");
			foreach($po->Items as $key => $item){
			//DIE('ELI');
				$item = new PurchaseOrderItem($item->id);
				$invItem = $item->InventoryItem;
				$committedQty = $invItem->getCommittedQty();
				//var_dump($invItem);
					$effectiveQty = $invItem->ConfirmedQty+$item->InventoryItem->Qty;
					if($effectiveQty > $item->SoldQty){
					// 	$flagAlreadyInStock = true;
					}else{
					//	$flagAlreadyInStock = false;
					}
					$flagAlreadyInStock = false;
					$potentialRevenue += $invItem->PriceA * $item->OrderQty;

 	  	?>
 	  		<tr style="<?= $flagAlreadyInStock?"background-color: #ffc107;\"":"\"" ?> data-id="<?= $item->id ?>" class="<?= ($item->SupplierItem->Discontinued?"danger":"") ?> GridViewScrollItem">
					<script type="text/javascript">
						indexHash.setItem("<?= $item->SKU ?>", "<?= $item->id ?>");
					</script>
 	    			<td>
 	        			<span id="<?= $item->id ?>-Line" class="itemInfo"><?= $item->Line ?></span>
 	        			<span id="<?= $item->id ?>-Group" class="itemInfo"><?= $item->Group ?></span>
 	        		</td>
 	        		<td style="text-overflow: ellipsis;" >
 	        			<span id="<?= $item->id ?>-SKU" class="itemInfo"><b><?= $item->SKU ?></b></span><?= (hasImage($item->Line, $item->SKU, true))?("<a href=\"" . $invItem->getImage(true)  . "\" target=\"_blank\"><img style=\"width: 28px;\" src=\"../img/icon-camera-32.png\" /></a>"):"" ?>
					</td>
					<td>
 	        			<span class="itemInfo"><?= $item->Description . " " . $item->Notes ?>
						</span>

					</td>
					<td>
						<span class="itemInfo"><?= ($item->SupplierItem->QtyAvailable) ?></span>
					</td>
					<td>
						<span class="itemInfo"><?= $committedQty ?></span>
					</td>
					<td style="background-color: #89cff0;">
						<span class="itemInfo"><?= ceil(($committedQty+($item->SoldQty/6))-$item->InventoryItem->Qty) ?></span>
					</td>

					<td>
						<span class="itemInfo"><?= $item->SoldQty ?></span>
					</td>
					<td>
						<span class="itemInfo"><?=  $item->InventoryItem->Qty ?></span>
					</td>
					<td class="centered">
						<input <?= $po->Sent?"readonly":"" ?> name="<?= $item->id ?>-OrderQty" class="editItem centered form-control input-sm" type="text" id="<?= $item->id ?>-OrderQty" value="<?= $item->OrderQty ?>"/>

					</td>

					<td style="text-align: right;">

						<input name="<?= $item->id ?>-Cost" class="editItem centered form-control input-sm" type="text" id="<?= $item->id ?>-Cost" value="<?= $item->Cost ?>"/>

					</td>


 	        		<td style="text-align: right;" id="<?= $item->id ?>-Extension" >
						<?php

								echo moneyFormat($item->Cost*$item->OrderQty);
							$poTotal+= ($item->Cost*$item->OrderQty);


						?>
 	        		</td>
				<?php
				if(!$po->Sent){
				?>
					<td><a onclick="deletePOItem(<?= $item->id ?>); return false;" class="btn btn-sm btn-danger"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
					</a></td>
				<?php
				}
				?>
 	      	</tr>
 	      	<?php

 	      	$index++;
 	      	}?>

		</tbody>
		<tfoot>
 	      	<tr>
				<td style="text-align: right;">Add New Item:</td>
				<td colspan="1"><input type="text" name="newItemSKU" id="newItemSKU" placeholder="SKU" /></td>
				<td><a id="AddNewItemButton" class="btn btn-primary btn-sm">Add</a></td>
 	      		<td colspan="<?= ($po->Received)?"9":($po->Sent)?"8":"7" ?>" style="text-align: right;"><span style="font-weight: bold; text-align: right;">Subtotal</span></td>
				<td id="POSubtotal" style="text-align: right;"><?= moneyFormat($po->getSubtotal()); ?></td>
				<script type="text/javascript">
					$('#AddNewItemButton').on("click", function(){
						$.get('mod.php?p=purchasing&a=functions&f=addNewItem&po=<?= $po->PurchaseOrderID ?>&sku=' + $('#newItemSKU').val(), function(data){
							if(data == "true"){
								location.reload();
							}else{
								alert("Error, maybe SKU does not exist.");
							}
							});
					});
					$('#newItemSKU').on("keyup", function(e){
						if(e.keyCode == 13){
							$('#AddNewItemButton').click();
						}
					});

				</script>
 	      	</tr>
			<tr class="borderless">

 	      		<td colspan="<?= ($po->Received)?"10":($po->Sent)?"9":"8" ?>" class="borderless" style="text-align: right;"><span style="font-weight: bold;">Freight:</span></td>
				<td colspan="2" style="text-align: left;"><input id="Freight" type="text" class="edit form-control input-sm" name="Freight" value="<?= ($po->Freight); ?>" /></td>
				<td style="text-align: right;" id="FreightLabel"><?= moneyFormat($po->Freight); ?></td>
 	      	</tr>
			<tr class="borderless">

 	      		<td colspan="<?= ($po->Received)?"10":($po->Sent)?"9":"8" ?>" class="borderless" style="text-align: right;"><span style="font-weight: bold;">Other Charges:</span></td>
				<td colspan="2" style="text-align: left;"><input type="number"  id="MiscCharges" class="edit form-control input-sm" name="MiscCharges" value="<?= ($po->MiscCharges) ?>" /></td>
				<td style="text-align: right;" id="MiscChargesLabel"><?= moneyFormat($po->MiscCharges); ?></td>
 	      	</tr>
			<tr class="borderless">

 	      		<td colspan="<?= ($po->Received)?"12":($po->Sent)?"11":"10" ?>" class="borderless" style="text-align: right;"><span style="font-weight: bold;">Total</span></td>
				<td style="text-align: right;" id="POTotal"><?= moneyFormat($po->getTotal()); ?></td>
 	      	</tr>
			<tr class="borderless">

 	      		<td colspan="<?= ($po->Received)?"12":($po->Sent)?"11":"10" ?>" class="borderless" style="text-align: right;"><span style="font-weight: bold;">Invoice Total</span></td>
				<td style="text-align: right;" id="POTotal"><?= moneyFormat($po->getConfirmedTotal()); ?></td>
 	      	</tr>
 	      </tr>
				<tr class="bordeless">
					<td colspan="<?= ($po->Received)?"12":($po->Sent)?"11":"10" ?>" class="borderless" style="text-align: right;"><span style="font-weight: bold;">Projected Revenue</span></td>
					<td style="text-align: right;" id="ProjectedRevenue"><?= moneyFormat($potentialRevenue); ?></td>

				</tr>
				<tr class="bordeless">
					<td colspan="<?= ($po->Received)?"12":($po->Sent)?"11":"10" ?>" class="borderless" style="text-align: right;"><span style="font-weight: bold;">Projected Profit</span></td>
					<td style="text-align: right;" id="ProjectedProfit"><?= moneyFormat(($potentialRevenue-$po->getTotal())); ?></td>

				</tr>
 	    </tfoot>
 	  </table>
 	</div>

	<div class="modal fade" id="LoadItemsModal" tabindex="-1" role="dialog">
		<div class="modal-dialog modal-sm" role="document">
		  <div class="modal-content">
			<div class="modal-header">
			  <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
			  <h4 class="modal-title">Load Items</h4>
			</div>
			<div class="modal-body">
				<span>Please select the filters for the parts to be loaded.</span>
				<div class="form-group">
					<label for="LoadItemsLine">Select Line:</label>
					<select class="form-control" name="LoadItemsLine" id="LoadItemsLine">
						<option value="%">ALL</option>
						<?php
						$query ="SELECT DISTINCT(Line) Line, Name FROM INVENTORY LEFT JOIN `LINE` ON(INVENTORY.Line = `LINE`.Code)  WHERE Line NOT LIKE '' ORDER BY Line";
						$result = mysqli_query($con, $query);
						while($row = mysqli_fetch_array($result)){
						?>
						<option value="<?= $row['Line'] ?>"><?= $row['Line'] . " - " .$row['Name'] ?></option>
						<?php
						}
						?>
					</select>
				</div>
				<div class="form-group">
					<label for="LoadItemsGroup">Select Group:</label>
					<select class="form-control" name="LoadItemsGroup" id="LoadItemsGroup">
						<option value="%">ALL</option>
						<?php
						$query ="SELECT DISTINCT(`Group`) `Group`, Name FROM INVENTORY LEFT JOIN `GROUP` ON(INVENTORY.Group = `GROUP`.Code)  WHERE `Group` NOT LIKE '' ORDER BY `Group`";
						$result = mysqli_query($con, $query);
						while($row = mysqli_fetch_array($result)){
						?>
						<option value="<?= $row['Group'] ?>"><?= $row['Group'] . " - " .$row['Name'] ?></option>
						<?php
						}
						?>
					</select>
				</div>
				<div class="form-group">
					<label for="LoadItemsVendor">Select Vendor:</label>
					<select class="form-control" name="LoadItemsVendor" id="LoadItemsVendor">
						<option value="%">ALL</option>
						<?php
						$query ="SELECT DISTINCT(VendorID) VendorID, Name FROM INVENTORY LEFT JOIN `VENDOR` USING(VendorID)  WHERE VendorID NOT LIKE '' ORDER BY Name";
						$result = mysqli_query($con, $query);
						while($row = mysqli_fetch_array($result)){
						?>
						<option value="<?= $row['VendorID'] ?>"><?= $row['VendorID'] . " - " .$row['Name'] ?></option>
						<?php
						}
						?>
					</select>
				</div>

			</div>


			<div class="modal-footer">
				<button type="button" onclick="loadItems();" name="" class="btn btn-primary">Add</button>
			  <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>

			</div>
			<script type="text/javascript">
				function loadItems(){
					var Line = $('#LoadItemsLine').val();
					var Group = $('#LoadItemsGroup').val();
					var Vendor = $('#LoadItemsVendor').val();
					$.get('mod.php', {
						"p"	:	"purchasing",
						"a"	:	"functions",
						"f"	:	"addNewPOItems",
						"Line"	: Line,
						"Group"	: Group,
						"VendorID"	: Vendor

						}, function(data){
						if(data == "true"){
							location.reload();
						}

					});
				}
			</script>
		  </div><!-- /.modal-content -->
		</div><!-- /.modal-dialog -->

	</div><!-- /.modal -->

 	<div class="modal fade" id="AddReferenceModal" tabindex="-1" role="dialog">
		<div class="modal-dialog" role="document">
		  <div class="modal-content">
			<div class="modal-header">
			  <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
			  <h4 class="modal-title">Add Reference</h4>
			</div>
			<div class="modal-body">
			  <p>
				<input type="hidden" id="AddReferenceID" />
				<input type="hidden" id="AddReferenceLine" />
				<input type="hidden" id="AddReferenceSKU" />

				<select class="form-control" name="AddReferenceType" id="AddReferenceType">
					<option value="-1">Select Reference Type</option>
					<option value="OriginalInvoice">Originally from other Invoice</option>
					<option value="Substitute">Substitute for another item</option>
					<option value="Custom">Custom Message</option>
				</select>
				<div id="AddReferenceDataDiv">

				</div>
			  </p>
			</div>
			<div class="modal-footer">
			  <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
			  <button type="button" class="btn btn-primary">Save changes</button>
			</div>
			<script type="text/javascript">

			</script>
		  </div><!-- /.modal-content -->
		</div><!-- /.modal-dialog -->

	</div><!-- /.modal -->
 <style>
	.borderless {
		border: hidden;
		border-top: hidden;
		border-left-style: none;
		border-right-style: none;
		border-bottom-style: none;
	}
 </style>
 <style type="text/css" media="print">
	body { margin: 0; background-image: none; font-size: 1em }


 </style>
 </div>
        <div class="panel panel-default">
          <div class="panel-body">
			<div class="row">

			</div>
			<br>
            <span><b>Purchase Order Notes:</b></span><br />
           <textarea id="Notes" class="form-control edit"><?= $po->Notes ?></textarea>
          </div>
        </div>
        <div style="float: right;" >
			<?php
			if($po->Received){
			?>
			<button id="uploadPO" class="btn btn-success">Upload</button>
			<?php
			}elseif($po->Sent){
			?>
			<button id="confrimPO" class="btn btn-success">Confirm Purchase Order</button>
			<?php
			}else{
			?>
			<button id="createPO" class="btn btn-success">Create Purchase Order</button>

			<?php
			}
			?>

			<button class="btn btn-primary" onclick="window.close();">Save & Close</button>
			<script>
				$('#createPO').on('click', function(){
					if(confirm("Are you sure you want to create a new PO with this information?")){
						$('#createPO').prop("disabled", true);
						$.get('mod.php?p=purchasing&a=functions&f=createNewPO', function(data){
							data = JSON.parse(data);
						if(data.Result){
							window.location = "mod.php?p=purchasing&a=manage";
						}else{
							alert("Error: \n" + data.Error);
						}

					});
					}else{
						return;
					}
				});
				$('#uploadPO').on('click', function(){
					if(confirm("Are you sure you want to upload and set this order as complete?")){
						$('#uploadPO').prop("disabled", true);
						$.get('mod.php?p=purchasing&a=functions&f=setPOComplete&po=<?= $po->PurchaseOrderID ?>', function(data){
						window.close();
					});
					}else{
						return;
					}

				});
				$('#confrimPO').on('click', function(){
					if(confirm("Are you sure you want to confirm this order?")){
						$.get('mod.php?p=purchasing&a=functions&f=setPOFinalize&po=<?= $po->PurchaseOrderID ?>', function(data){
						window.close();
					});
					}else{
						return;
					}

				});
				function refreshReviewTable(){
					recalculateOrder();
				}
				function cleanPO(){
					if(confirm("Are you sure you want to clean this PO (remove blank items)?")){
						$.get('mod.php?p=purchasing&a=functions&f=cleanNewPO', function(data){
							if(data == "true"){
								location.reload();
							}else{
								alert("Error");
							}
						});
					}

				}
				function deletePOItem(id){
					if(confirm("Are you sure you want to delete this item?")){
						$.get('mod.php?p=purchasing&a=functions&f=deletePOItem&id=' + id, function(data){
							if(data == "true"){
								$('#' + id + '-SKU').parent().parent().remove();
								recalculateOrder();
							}else{
								alert("Error");
							}
						});
					}

				}
				function recalculateOrder(){
					var poTotal = 0;
					$('#poReviewTableBody tr').each(function(){

						var id = $(this).attr('data-id');
						var OrderQty = $("#" + id + "-OrderQty").val();
						if(isNaN(OrderQty)){
							OrderQty = 0;
						}

						var cost = $("#" + id + "-Cost").val();

							$('#' + id + '-Extension').text(moneyFormat(OrderQty*cost));
							poTotal += OrderQty*cost;


					});
					$("#POSubtotal").text(moneyFormat(poTotal));
					poTotal += parseFloat($('#Freight').val());
					poTotal += parseFloat($('#MiscCharges').val());

					$('#FreightLabel').text(moneyFormat($('#Freight').val()));
					$('#MiscChargesLabel').text(moneyFormat($('#MiscCharges').val()));
					$('#POTotal').text(moneyFormat(poTotal));
				}
			</script>
		</div>
		<div style="float: right;" >

		</div>

		<div class="modal fade" id="UploadSupplierListModal" tabindex="-1" role="dialog">
			<div class="modal-dialog modal-md" role="document">
			  <div class="modal-content">
				<div class="modal-header">
				  <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
				  <h4 class="modal-title">Load Items</h4>
				</div>
				<div class="modal-body">
					<div id="uploadSupplierError" style="display:none;">
					<p class="bg-danger" id="uploadSupplierError"></p>
					</div>
					<span>Please select the CSV file.</span>
					<p>The file must contain the following columns:<br>
					"SKU", "QtyAvailable", "AdditionalDate", "Volume", "Price", "AdditionalQty", "Discontinued" <br><br>
					In that specific order. Column names must be present but do not have to match, just the order has to match.</p>
					<div class="form-group">

						<input id="supplierFile" type="file" name="csv" class="file" data-show-preview="false">
					</div>
				</div>


				<div class="modal-footer">

				  <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>

				</div>
				<script type="text/javascript">
					$("#supplierFile").fileinput({
		     		'showUpload':true,
		     		'uploadUrl':"mod.php?p=purchasing&a=upload_csv&vendor=<?= $po->VendorID; ?>",
		     		'fileTypeSettings':'text',
		     		'elErrorContainer':'#uploadSupplierError',
		     	});
					 $('#supplierFile').on('filebatchuploadsuccess', function(event, data, previewId, index) {
							response = data.response;
							console.log(data);
							if(response.fileuploaded == true){
								alert("File uploaded successfully");
								location.reload();

							}

					});
					$('#supplierFile').on('fileuploaded', function(event, data, previewId, index) {
							response = data.response;
							if(data.response.fileuploaded == true){
								alert("File uploaded successfully");
								location.reload();
							}

					});
					var freezeTable = null;

					var options = new GridViewScrollOptions();
					options.elementID = "poReviewTable";
					options.width = 450;
					options.height = 300;
					options.freezeColumn = true;
					options.freezeColumnCssClass = "GridViewScrollItemFreeze";
					options.freezeFooterCssClass = "GridViewScrollFooterFreeze";
					options.freezeColumnCount = 1;

					freezeTable = new GridViewScroll(options);
				</script>
			  </div><!-- /.modal-content -->
			</div><!-- /.modal-dialog -->

		</div><!-- /.modal -->



    </body>
  </html>
