<?php

	//Appears only in admin section
  if(stripos($_SERVER['SCRIPT_NAME'],"/admin/")===false?false:true){
		
?>
	
<?php

	//appears only in customer section both salesman and customer
  }else{
		
		//var_dump($_SESSION);
?>
	<div class="row" id="productNotFoundDiv">
		<div class="col-md-6 col-md-offset-3">
				<h4>¿No encuentras lo que buscas? ¡D&eacute;janos saber!</h4>
	<table class="table">
		<thead>
			<tr>
				<th>Part Number</th>
				<th>Descripcion</th>
				<th>Cantidad</th>
				<th></th>
			</tr>
		</thead>
		<tbody>
			<tr>
				<td>
					<input type="text" class="form-control" id="lostSaleSKU" placeholder="SKU" value="<?= isset($_REQUEST['sku'])?$_REQUEST['sku']:'' ?>">		
				</td>
				<td>
					<input type="text" class="form-control" style="width: 300px;" id="lostSaleDescription" placeholder="Description">
				</td>
				<td>
					<input type="text" class="form-control" style="width: 50px;" id="lostSaleQty" placeholder="Qty">
				</td>
				
				<td>
					<button class="btn btn-success" id="lostSaleSubmit" onclick="submitLostSale()">Enviar</button>
				</td>
			</tr>
		</tbody>
	</table>
		</div>
	</div>
	<script>
		$('#lostSaleSKU').on('keyup', function(e){
			//$(this).val($(this).val().toUpperCase());
			if(e.keyCode == 13){
				
				e.preventDefault();
				$('#lostSaleDescription').focus();
			}
		});
		$('#lostSaleDescription').on('keyup', function(e){
			//$(this).val($(this).val().toUpperCase());
			
			if(e.keyCode == 13){
				e.preventDefault();
				$('#lostSaleQty').focus();
			}
		});
		$('#lostSaleQty').on('keyup', function(e){
			if(e.keyCode == 13){
				if($('#lostSaleQty').val() == ""){
					$('#lostSaleQty').val("1");
					//$('#lostSaleSubmit').click();
				}
				e.preventDefault();
				$('#lostSaleSubmit').focus();
			}
		});
		$(document).ready(function(){
			setTimeout(function(){
					if($('#lostSaleDescription').length > 0){
						$('#lostSaleDescription').focus();	
					}
					
				}, 100);
				
			
			});
		
		function submitLostSale(){
			var sku = $('#lostSaleSKU').val();
			var description = $('#lostSaleDescription').val();
			var qty = $('#lostSaleQty').val();
			if (qty == ""){
				qty = 1;
			}
			$.post('mod.php?p=lostsale&a=functions&f=saveLostSale',
						 { 	"sku" : sku.toUpperCase(),
								"description" : description.toUpperCase(),
								"qty": qty,
								"reason": "Product Not Found"
							})
			.done(function(data){
					$('#productNotFoundDiv').html('<center><h3>¡Gracias por su cooperacion!</h3></center>');	
				});
			
		}
	</script>
	
<?php
	
  }

	
	/*
	 *
	 *<td>
					<input type="text" class="form-control" style="width: 90px;" id="lostSaleCompetitorPrice" placeholder="Price">
				</td>
				<td>
					<select class="form-control" id="lostSaleCompetitor" >
						<option>--Seleccione Suplidor--</option>
						<option>CAP Clutch Manufacturing</option>
						<option>Caribe Automotive Distributors</option>
						<option>CYM Auto Parts Distributors</option>
						<option>Hi-Tec Brakes</option>
						<option>Ignition and Fuel Systems</option>
						<option>JapaKorean Parts</option>
						<option>Overseas Import Corp.</option>
						<option>Roberto Gandia Distributors</option>
						<option>Otro</option>
						
					</select>
				</td>
	 *
	 *
	 *
	 */
?>