<?php
//die('test');
include("session.php");
include("connect.php");
global $con;
$pricePlanMode = false;
$isCustomer = false;
//error_reporting(E_ALL);
//ini_set('display_errors',1);
if (isset($_SESSION['isCustomer'])) {
	$isCustomer = $_SESSION['isCustomer'];
}else {
	header("Location: login.php");
	return;
}
$language = "ES";

if ($isCustomer) {
	$customer = new Customer($_SESSION['AccountNumber']);	
	$language = $customer->Language;
} else {
	if (isset($_SESSION['SalesmanID'])) {
		$salesman = new Salesman($_SESSION['SalesmanID']);	
		$language = $salesman->Language;
		$pricePlanMode = $_SESSION['pricePlanMode'];
	}else {
		header("Location: login.php");
		return;
	}
	
}
if(isset($_REQUEST['sku'])){
	if($_REQUEST['sku'] == "" && $_REQUEST['line'] == "" && $_REQUEST['group'] == ""){
		header("Location: index.php");
		return;
	}
}
$_SESSION['LastSearch'] = array(
			"SKU" => "",
			"Line" => "",
			"Group" => "",
			"WC" => "",
			"Page" => ""
);

	if (!$_SESSION['isCustomer']) {
		if ($pricePlanMode) {
			$customer = new Customer($_SESSION['AccountNumber']);
			//echo("Price Plan Mode - <i>" . $customer->AccountNumber . " - " . $customer->Name . "</i>");
		}elseif(isset($_SESSION['setCustomerMode']) && $_SESSION['setCustomerMode']) {
			$customer = new Customer($_SESSION['setCustomer']);
			//echo("<i>" . $customer->AccountNumber . " - " . $customer->Name . "</i>");
		}
	 }

?>
 
 <!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">-->
     <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
	 <meta http-equiv="cache-control" content="max-age=0" />
	 <meta http-equiv="cache-control" content="no-cache" />
	 <meta http-equiv="expires" content="0" />
	 <meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
	 <meta http-equiv="pragma" content="no-cache" />
	 
     <title><?= $config['CompanyName'] ?></title>
 
     <!-- Bootstrap -->
     <link href="css/bootstrap.min.css" rel="stylesheet">
     
     <!-- Icons -->
		<link rel="apple-touch-icon" sizes="57x57" href="img/apple-icon-57x57.png">
		<link rel="apple-touch-icon" sizes="60x60" href="img/apple-icon-60x60.png">
		<link rel="apple-touch-icon" sizes="72x72" href="img/apple-icon-72x72.png">
		<link rel="apple-touch-icon" sizes="76x76" href="img/apple-icon-76x76.png">
		<link rel="apple-touch-icon" sizes="114x114" href="img/apple-icon-114x114.png">
		<link rel="apple-touch-icon" sizes="120x120" href="img/apple-icon-120x120.png">
		<link rel="apple-touch-icon" sizes="144x144" href="img/apple-icon-144x144.png">
		<link rel="apple-touch-icon" sizes="152x152" href="img/apple-icon-152x152.png">
		<link rel="apple-touch-icon" sizes="180x180" href="img/apple-icon-180x180.png">
		<link rel="icon" type="image/png" sizes="192x192"  href="img/android-icon-192x192.png">
		<link rel="icon" type="image/png" sizes="32x32" href="img/favicon-32x32.png">
		<link rel="icon" type="image/png" sizes="96x96" href="img/favicon-96x96.png">
		<link rel="icon" type="image/png" sizes="16x16" href="img/favicon-16x16.png">
		<link rel="manifest" href="img/manifest.json">
		<meta name="msapplication-TileColor" content="#ffffff">
		<meta name="msapplication-TileImage" content="/ms-icon-144x144.png">
		<meta name="theme-color" content="#ffffff">
     
     
     <link rel="stylesheet" href="css/bootstrap-combobox.css?date=2342" />
 
     <!-- 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>
       <script src="js/functions.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?date=13"></script>
       	 <script src="js/bootstrap-combobox.js?date=13"></script>
           <script src="js/select2.full.min.js"></script>
     <![endif]-->
	<link rel="stylesheet" href="css/styles.css"/>
	<link rel="stylesheet" href="css/select2.min.css"/>
	<style>
		.skuInputContainer
{
    position: fixed;
    width: 25%;
    bottom: 10px;
   
}
.buttonBarContainer{
	position: fixed;
    width: 50%;
    bottom: 80px;
}
.headerContainer
{
    width: 100%;
    height: 100px;
}

.partsList
{
	border: solid 1px;
    width: 100%;
    height: 360px;
    overflow: scroll;
    position: static;
	margin-bottom: 5px;
}

.totalLabelTd{
	width: 100px;

	
}
	</style>
   </head>
   <body>
<?php 
	    
	include("navbar.php");

?>
 
		
        <div class="container headerContainer">
            <div class="row">
                <div class="col-md-4">
                    <h4><span id="customer-name"></span></h4>
					<span id="customer-phone"></span>
					
                </div>
                <div class="col-md-4">
					<span id="customer-address"></span>
				</div>	
                <div class="col-md-4">
                    Balance Due: <span id="customer-balancedue"></span>
					Credit Limit: <span id="customer-creditlimit"></span>
                </div>
            </div>
        </div>
        <div class="container pg-empty-placeholder"></div>
		<div class="row">
			<div class="col-md-12">
				<div class="container partsList">
					<table class="table"> 
						<thead> 
							<tr> 
								<th>#</th>
								<th>Line</th>
								<th>SKU</th> 
								<th>Description</th> 
								<th>Qty</th>
								<th>Price</th>
								<th>Disc</th>
								<th>Extension</th> 
							</tr>                     
						</thead>                 
						<tbody id="posItemsTableBody"> 
										   
						</tbody>
					</table>
				</div>
			</div>
		</div>
		<div class="row">
			<div class="col-md-6">
				<div class="row">
					<div class="col-md-12">
						<div class="col-md-3"><button onclick="openProductLookup()" class="btn btn-block btn-primary">F3 - Product Lookup</button></div>
						<div class="col-md-3"><button onclick="clearCart();" class="btn btn-block btn-danger">F4 - Clear Screen</button></div>
						<div class="col-md-3"><button onclick="deleteCartItem();" class="btn btn-block btn-danger">F5 - Delete Item</button></div>
						<div class="col-md-3"><button onclick="editCartItem();" class="btn btn-block btn-warning">F6 - Edit Item</button></div>
					</div>
				</div>
				<div style="margin-top:10px;" class="row">
					<div class="col-md-12">
						<div class="col-md-3"><button class="btn btn-block btn-primary">F7 - Discount</button></div>
						<div class="col-md-3"><button onclick="openCustomerLookup();" class="btn btn-block btn-primary">F8 - Cust Lookup</button></div>
						<div class="col-md-3"><button class="btn btn-block btn-success">F9 - Checkout</button></div>	
						<div class="col-md-3"><button class="btn btn-block btn-primary">F10 - Blank Line</button></div>
						
					</div>
				</div>
				
			</div>
			<div class="col-md-6">
				<div class="row">
					<div class="col-md-12 pull-right" style="text-align: right;">
						<table class="pull-right" style="margin-right: 120px;">
							<tr>
								<td class="totalLabelTd"><b>Subtotal</b></td>
								<td class="totalLabelTd"><span id="posSubtotalLabel"></span></td>
							</tr>
							<tr>
								<td class="totalLabelTd"><b>Tax 1</b></td>
								<td class="totalLabelTd"><span id="posTax1Label"></span></td>
							</tr>
							<tr>
								<td class="totalLabelTd"><b>Tax 2</b></td>
								<td class="totalLabelTd"><span id="posTax2Label"></span></td>
							</tr>
							<tr>
								<td class="totalLabelTd"><b>Total</b></td>
								<td class="totalLabelTd"><span id="posTotalLabel"></span></td>
							</tr>
						</table>
						
					</div>
				</div>
			</div>
		</div>
		<div class="row">
			
			<div class="col-md-6">
				<div class="container skuInputContainer">
					<br>
					<label class="control-label">Input SKU or UPC:</label>
					<input type="text" class="form-control" id="inputSKU" placeholder="Placeholder text">
				</div>	
			</div>
			<div class="col-md-6">
				<div class="container totalsContainer">
					<div class="row pg-empty-placeholder"></div>
				</div>	
			</div>
			
		</div>
	
	<!-- LINE EDIT MODAL -->
    <div id="posEditModal" class="modal fade">
      <div class="modal-dialog modal-md">
        <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">Edit Line</h4>
            <h5 id="posEditModalTitle"></h5>
          </div>
          <div class="modal-body">
			<div class="form-horizontal" >
				<input type="hidden" id="posEditModalID">
				<div class="form-group">
					
				  <label class="control-label col-sm-2" for="posEditModalSKU">SKU:</label>
				  <div class="col-sm-10">
					<input type="text" class="form-control" id="posEditModalSKU" readonly="readonly" >
				  </div>
				</div>
				<div class="form-group">
				  <label class="control-label col-sm-2" for="posEditModalDescription">Description:</label>
				  <div class="col-sm-10">
					<input type="text" class="form-control" id="posEditModalDescription" placeholder="">
				  </div>
				</div>
				<div class="form-group">
				  <label class="control-label col-sm-2" for="posEditModalPrice">Price:</label>
				  <div class="col-sm-10"> 
					<input type="number" class="form-control" id="posEditModalPrice" >
				  </div>
				</div>
				<div class="form-group">
				  <label class="control-label col-sm-2" for="posEditModalDiscount">Discount:</label>
				  <div class="col-sm-10"> 
					<input type="number" class="form-control" id="posEditModalDiscount" >
				  </div>
				</div>
				<div class="form-group">
				  <label class="control-label col-sm-2" for="posEditModalQty">Qty:</label>
				  <div class="col-sm-10"> 
					<input type="number" class="form-control" id="posEditModalQty" >
				  </div>
				</div>
				<div class="form-group"> 
				  <div class="col-sm-offset-2 col-sm-10">
					<div class="checkbox">
					  <label><input id="posEditModalTaxable1" type="checkbox"> Taxable 1</label>
					</div>
				  </div>
				</div>
				<div class="form-group"> 
				  <div class="col-sm-offset-2 col-sm-10">
					<div class="checkbox">
					  <label><input id="posEditModalTaxable2" type="checkbox"> Taxable 2</label>
					</div>
				  </div>
				</div>
			</div>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
            <button id="posEditModalSave" onclick="saveCartItem();" type="button" class="btn btn-success">Save</button>
          </div>
        </div><!-- /.modal-content -->
      </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
    <!-- END POS EDIT LINE BOX MODAL -->
    
	<!-- Product Lookup Modal -->
	<div class="modal fade" id="productLookupModal" tabindex="-1" role="dialog" aria-hidden="true">
		<div class="modal-dialog modal-lg">
			<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">Product Lookup</h4>
				</div>
				<div class="modal-body">
					<div class="form-group">
						<input type="text" class="form-control" id="productLookupSearchTerm" placeholder="Seach by SKU/Interchange/Description" />
						<div id="productLookupResults">
							
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
				</div>
			</div>
		</div>
		<script type="text/javascript">
			var keyTimerProductSearch = setTimeout(null, 0);
			$('#productLookupSearchTerm').on("keyup", function(e){
				clearTimeout(keyTimerProductSearch);
				if(e.keyCode == 13 || e.keyCode === 0){
					executeProductSearch();
				}
				keyTimerProductSearch = setTimeout(function(){
					executeProductSearch();
				}, 1000);
			});
			function executeProductSearch(){
				clearTimeout(keyTimerProductSearch);
				$.get("mod.php?p=pos&a=functions&f=productLookup",{
					"term" 	: 	$('#productLookupSearchTerm').val(),
					"an"	:	"<?= $customer->AccountNumber ?>"
					},function(data){
						
						$("#productLookupResults").html(data);
					});
				
			}
			function addLookupItem(Line, SKU){
				//$('#inputSKU').val(SKU);
				loadItem(SKU);
				//$('#AddNewItemButton').click();
			}
			$('#productLookupModal').on('shown.bs.modal', function(){
				$('#productLookupSearchTerm').val('');
				$('#productLookupSearchTerm').focus();
			});
		</script>
	</div>
	<!-- Product Lookup Modal End -->
	
	 
	<!-- Customer Lookup Modal -->
	<div class="modal fade" id="customerLookupModal" tabindex="-1" role="dialog" aria-hidden="true">
		<div class="modal-dialog modal-lg">
			<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">Customer Lookup</h4>
				</div>
				<div class="modal-body">
					<div class="form-group">
						<input type="text" class="form-control" id="customerLookupSearchTerm" placeholder="Name / Phone / Account Number" />
						<div id="customerLookupResults">
							
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
				</div>
			</div>
		</div>
		<script type="text/javascript">
			var keyTimerCustomerSearch = setTimeout(null, 0);
			$('#customerLookupSearchTerm').on("keyup", function(e){
				clearTimeout(keyTimerCustomerSearch);
				if(e.keyCode == 13 || e.keyCode === 0){
					executeCustomerSearch();
				}
				keyTimerCustomerSearch = setTimeout(function(){
					executeCustomerSearch();
				}, 1000);
			});
			function executeCustomerSearch(){
				clearTimeout(keyTimerCustomerSearch);
				$.get("mod.php?p=pos&a=functions&f=customerLookup",{
					"term" 	: 	$('#customerLookupSearchTerm').val()
					},function(data){
						
						$("#customerLookupResults").html(data);
					});
				
			}
			
			$('#customerLookupModal').on('shown.bs.modal', function(){
				$('#customerLookupSearchTerm').val('');
				$('#customerLookupSearchTerm').focus();
			});
		</script>
	</div>
	<!-- Customer Lookup Modal End -->
	
	<!-- Delete Line MODAL -->
    <div id="posDeleteModal" class="modal fade">
      <div class="modal-dialog modal-sm">
        <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">Delete Line</h4>
            <h5 id="posDeleteModalTitle"></h5>
          </div>
          <div class="modal-body">
    	      	
				<div class="row">
					<div class="col-xs-12">
						<input class="form-control" id="posDeleteModalLine" type="text" />
					</div>
					
				</div>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
            <button id="posDeleteModalButton" type="button" class="btn btn-primary">Delete</button>
          </div>
        </div><!-- /.modal-content -->
      </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
    <!-- DELETE BOX MODAL -->
	
	<!-- QTY BOX MODAL -->
    <div id="posQtyModal" class="modal fade">
      <div class="modal-dialog modal-sm">
        <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">Enter Quantity</h4>
            <h5 id="posQtyModalTitle"></h5>
          </div>
          <div class="modal-body">
    	      	<input type="number" id="posQtyModalQty" class="form-control" name="Qty" placeholder="Qty">
				<div class="row">
					<div class="col-xs-6">
						On Hand:<span id="posQtyModalOnHand"></span>
					</div>
					<div class="col-xs-6">
						Stock Level:<span id="posQtyModalStockLevel"></span>
					</div>
				</div>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
            <button id="posQtyModalAdd" type="button" class="btn btn-primary">Add</button>
          </div>
        </div><!-- /.modal-content -->
      </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
    <!-- END QTY BOX MODAL -->
     <script>
		var cartIndex = [];
		var cartData = {};
		var cartTax1 = 0;
		var cartTax2 = 0;
		var cartSubtotal = 0;
		function deleteCartItem(){
			$.get('mod.php',{
				"p": "pos",
				"a": "functions",
				"f": "deleteCartItem",
				"id": cartIndex[prompt("Line Number")]
				},function(data){
				if(data == "true"){
					refreshCart();
				}
			});
		}
		function clearCart(){
			if(confirm("Are you sure you want to clear the screen?")){
				$.get('mod.php', {
					"p": "pos",
					"a": "functions",
					"f": "clearCart"
				}, function(data){
					if(data === "true"){
						refreshCart();
					}
				});				
			}
		}
		function saveCartItem(){
			//$('#posEditModalSKU').val();
			$.get("mod.php", {
				"p": "pos",
				"a": "functions",
				"f": "saveCartItem",
				"id" : $('#posEditModalID').val(),
				"desc" : $('#posEditModalDescription').val(),
				"price": $('#posEditModalPrice').val(),
				"discount": $('#posEditModalDiscount').val(),
				"qty": $('#posEditModalQty').val(),
				"taxable1" : $('#posEditModalTaxable1').prop('checked'),
				"taxable2" : $('#posEditModalTaxable2').prop('checked'),
			}, function(data){
				if(data ==="true")	{
					refreshCart();
					$('#posEditModal').modal('hide');	
				}
			});
		}
		function editCartItem(){
			$('#posEditModalSave').unbind("click");
			$('#posEditModalSKU').val('');
			$('#posEditModalID').val('');
			$('#posEditModalDescription').val('');
			$('#posEditModalPrice').val('');
			$('#posEditModalDiscount').val('');
			$('#posEditModalQty').val('');
			$('#posEditModalTaxable1').prop('checked', false);
			$('#posEditModalTaxable2').prop('checked', false);
			var line = prompt("Enter line item to edit:");
			var index = line - 1;
			
			$('#posEditModalSKU').val(cartData[index].Line + " " + cartData[index].SKU);
			$('#posEditModalID').val(cartData[index].id);
			$('#posEditModalDescription').val(cartData[index].Description);
			$('#posEditModalPrice').val(cartData[index].Price);
			$('#posEditModalDiscount').val(cartData[index].Discount);
			$('#posEditModalQty').val(cartData[index].Qty);
			$('#posEditModalTaxable1').prop('checked', cartData[index].Taxable1 === "1");
			$('#posEditModalTaxable2').prop('checked', cartData[index].Taxable2 === "1");
			$('#posEditModal').modal('toggle');
			
		}
		$(window).on("keyup",function(e){
			switch(e.keyCode){
				case 114: //F3
					openProductLookup();
					break;
				case 115: //F4
					clearCart();
					break;
				case 116: //F5
					deleteCartItem();
					break;
				case 117: //F6
					editCartItem();
					break;
				case 118: //F7
					break;
				case 119: //F8
					openCustomerLookup();
					break;
				case 120: //F9
					break;
				case 121: //F10
					break;
				case 122: //F11
					break;
				case 123: //F12
					break;
			}
			
		});
		function openProductLookup(){
			$('#productLookupModal').modal('show');
		}
		function openCustomerLookup(){
			$('#customerLookupModal').modal('show');
		}
		function selectCustomer(an){
			
				$.get("mod.php",{
					"p": "pos",
					"a": "functions",
					"f": "setCustomer",
					"an": an,
					} ,function(data){
						data = JSON.parse(data);
						var name = data.CompanyName!==""?data.CompanyName:"";
						if(data.Name !== ""){
							if(name !== ""){
								name += "<br>";
							}
							name += data.Name;
						}
						var address = data.Address1 + "<br>" + data.Address2 + "<br>" + data.City + ", " + data.State + " " + data.ZipCode;
						$('#customer-name').html(name);
						$('#customer-address').html(address);
						$('#customer-phone').html(data.Phone);
						refreshCart();
						$('#customerLookupModal').modal('hide');
						console.log(data);
					});
				
			
		}
		function askForQty(itemData){
			$('#posQtyModalAdd').unbind('click');
			$('#posQtyModalTitle').text('');
			$('#posQtyModalQty').val('');
			$('#posQtyModalStockLevel').text('');
			$('#posQtyModalOnHand').text('');
			
			$('#posQtyModalTitle').text(itemData.Line + " - " + itemData.SKU + " " + itemData.Description);
			$('#posQtyModalStockLevel').text(itemData.StockLevel);
			$('#posQtyModalOnHand').text(itemData.Qty);
			$('#posQtyModalAdd').on('click', function(){
				$.get("mod.php",{
					"p": "pos",
					"a": "functions",
					"f": "addToCart",
					"line": itemData.Line,
					"sku": itemData.SKU,
					"qty": $('#posQtyModalQty').val()
					} ,function(data){
						refreshCart();
						$('#posQtyModal').modal('toggle');
						console.log("add to cart result : " + data);
					});
				
			});
			$('#posQtyModal').modal('toggle');
			
		}
		$('#posQtyModal').on("shown.bs.modal", function(){
			$('#posQtyModalQty').val(1);
			$('#posQtyModalQty').select();
				$('#posQtyModalQty').focus();
		});
		$('#posQtyModalQty').on("keyup", function(e){
			if(e.keyCode == 13){
				$('#posQtyModalAdd').click();	
			}
			});
		function refreshCart(){
			$.get("mod.php?p=pos&a=functions&f=getCart", function(data){
				data = JSON.parse(data);
				cartData = data;
				cartSubtotal = 0;
				cartTax1 = 0;
				cartTax2 = 0;
				$('#posItemsTableBody').html('');
				for(var i = 0; i<data.length; i++){
					cartIndex[i+1] = data[i].id;
					var html = "<tr>\
					  <td>" + (i+1) + "</td>\
					  <td>" + data[i].Line + "</td>\
					<td>" + data[i].SKU + "</td>\
					<td>" + data[i].Description + "</td>\
					<td>" + data[i].Qty + "</td>\
					<td>" + moneyFormat(data[i].Price) + "</td>\
					<td>" + data[i].Discount + "</td>\
					<td>" + moneyFormat(data[i].Qty*data[i].Price*(1-data[i].Discount)) + "</td>\
					</tr>";
					$('#posItemsTableBody').append(html);
					//console.log(html);
					cartSubtotal += data[i].Qty*data[i].Price*(1-data[i].Discount);
					cartTax1 += data[i].Taxable1 !== "0"?(data[i].Qty*data[i].Price*(1-data[i].Discount))*<?= getSetting('Tax1Percent')['value'] ?>:0;
					cartTax2 += data[i].Taxable2!== "0"?(data[i].Qty*data[i].Price*(1-data[i].Discount))*<?= getSetting('Tax2Percent')['value'] ?>:0;
				}
				$('#posSubtotalLabel').text(moneyFormat(cartSubtotal));
				$('#posTax1Label').text(moneyFormat(cartTax1));
				$('#posTax2Label').text(moneyFormat(cartTax2));
				$('#posTotalLabel').text(moneyFormat(cartSubtotal+cartTax1+cartTax2));
				
				
			});
			$('#inputSKU').focus();
		}
		refreshCart();
		function loadItem(sku){
			$.get("mod.php?p=pos&a=functions&f=getInventoryItem&upc=" + sku, function(data){
					data = JSON.parse(data);
					if(data.Exists){
						askForQty(data);	
					}else{
						alert("Item Not Found!");
					}
					
					$('#inputSKU').val('');
					$('#inputSKU').focus();
					//console.log(data);
					});
			
		}
		$('#inputSKU').on("keyup", function(e){
			if(e.keyCode == "13"){
				loadItem($('#inputSKU').val());
				//$.get("mod.php?p=pos&a=functions&f=addToCart&line=REM&sku=D242&qty=1")
			}
		});
	 </script>
   </body>
 </html>