<?php 
session_start();
 if($_SESSION["sistema"]!= "1"){ header("location: ../login/index.php"); exit();}

 date_default_timezone_set('America/Lima');
 
 //echo $_SESSION['usuariogrupo_id'];
 if($_SESSION['usuariogrupo_id']==1 || $_SESSION['usuariogrupo_id']==2 ){
	$punven_id = "";
 }else{
	 $punven_id = $_SESSION['puntoventa_id'];
 }
	
?>

<section class="content">
	<div class="container-fluid">
	<div class="row">
	    <div class="col-lg-12 col-md-12 col-sm-12 col-12">
		    <div class="card">
		        <div class="card-header">
					<div class="row">
			
			
						<form action="" id="for_fil_pro">
							
							<div class="row">
							
							<div class="col-lg-3 col-sm-3 col-6">
								<label for="txt_fil_pro_codbar">COD. BAR.:</label>
								<input name="txt_fil_pro_codbar" type="text" id="txt_fil_pro_codbar" class="form-control  input-sm">
							</div>
							
							<div class="col-lg-3 col-sm-3 col-6">
								<label for="txt_fil_pro_dat1">Busqueda:</label>
								<input name="txt_fil_pro_dat1" type="text" id="txt_fil_pro_dat1" class="form-control  input-sm">
							</div>
							
							<div class="col-lg-3 col-sm-3 col-6">
								<label for="txt_fil_pro_dat2">-</label>
								<input name="txt_fil_pro_dat2" type="text" id="txt_fil_pro_dat2" class="form-control  input-sm">
							</div>
							
							<div class="col-lg-3 col-sm-3 col-6">
								<label for="txt_fil_pro_dat3">-</label>
								<input name="txt_fil_pro_dat3" type="text" id="txt_fil_pro_dat3" class="form-control  input-sm">
							</div>
							
							<div class="col-lg-3 col-sm-3 col-6 d-none">
								<label for="txt_fil_pro_dat4">-</label>
								<input name="txt_fil_pro_dat4" type="text" id="txt_fil_pro_dat4" class="form-control  input-sm">
							</div>
							
						
							
							<div class="col-lg-3 col-sm-3 col-6">
								<label for="txt_fil_mar">Marca</label>
								<input name="txt_fil_mar" type="text" id="txt_fil_mar" class="form-control  input-sm">
							</div>
							
							<div class="col-lg-2 col-sm-6 col-sm-3 col-6">				
								<label for="cmb_fil_puntoventa_id">Punto Venta:</label>
								<select name="cmb_fil_puntoventa_id" id="cmb_fil_puntoventa_id" class="form-control input-sm">
								</select>
													
							</div>
							
							<div class="col-lg-1 col-sm-4 col-6">
								<label>N° Filas:</label>
								<select name="cmb_fil_lim" id="cmb_fil_lim" class="form-control input-sm">
									<option value="">-Todos-</option>
									<option value="20">20</option>
									<option value="50" selected="selected">50</option>
									<option value="100">100</option> 
									<option value="500">500</option>
								</select>
							</div>
							<div class="col-lg-1 col-sm-4 col-6" style="display: inline-block; white-space: nowrap;padding-top:30px;">
								<span onClick="preciogestion_tabla()" style="cursor:pointer"  class="btn btn-primary " ><i class="fa fa-search"></i> </span>
								<span onClick="preciogestion_filtro()"  style="cursor:pointer" class="btn btn-default " >Restablecer</span>
							</div>
							
							</div>
						
							
						</form>
						 	
					</div>
				</div>
			</div>
		</div>
	</div>
	</div>
</section>
<script type="text/javascript"> 
	
	
	
	
	
	
	
	
	


function cmb_fil_puntoventa_id(punven){
		$.ajax({
 					type: "POST",
 					url: "../puntoventa/cmb_punven_id.php",
 					async:true,
 					dataType: "html",                      
 					data: ({						
 						emp_id:'',
						punven_id :punven,
 						vista:	''
 					}),
 					beforeSend: function() {
 						$('#cmb_fil_puntoventa_id').html('<option value="">Cargando...</option>');
 					},
 					success: function(html){			
 						$('#cmb_fil_puntoventa_id').html(html);
 					},
 					complete: function(){
 						$('#txt_punven_id').val($('#cmb_fil_puntoventa_id').val());
 							preciogestion_tabla();
 						}
 					});
}
	
	
	
	$(function() {
		
		
	
cmb_fil_puntoventa_id(<?php echo $punven_id; ?>);

		$('input').iCheck({
			checkboxClass: 'icheckbox_square-blue',
			radioClass: 'iradio_square-blue',
      increaseArea: '20%' // optional
  });
  
  $('#cmb_fil_puntoventa_id').change(function(e) {
	///preciogestion_tabla();
	});
  
  	$("#txt_fil_pro_dat1").keydown(function(e){
			if (e.which == 13){
			preciogestion_tabla();
			return false;
			}
		});
		
			$("#txt_fil_pro_dat2").keydown(function(e){
			if (e.which == 13){
			preciogestion_tabla();
			return false;
			}
		});
		
			$("#txt_fil_pro_dat3").keydown(function(e){
			if (e.which == 13){
			preciogestion_tabla();
			return false;
			}
		});
		
			$("#txt_fil_pro_dat4").keydown(function(e){
			if (e.which == 13){
			preciogestion_tabla();
			return false;
			}
		});
		
		$("#txt_fil_pro_codbar").keydown(function(e){
			if (e.which == 13){
			preciogestion_tabla();
			return false;
			}
		});
		
		$( "#txt_fil_mar" ).keydown(function(e){
			if(e.which==13)
			{
				
				preciogestion_tabla();
				e.preventDefault();
			
			}
		});	
		
		$( "#txt_fil_pro_dat1" ).keydown(function(e){
			if(e.which==32)
			{
				
				$( "#txt_fil_pro_dat2" ).focus();
				
				//producto_tabla();
				e.preventDefault();
			}
		});
		$( "#txt_fil_pro_dat2" ).keydown(function(e){
			if(e.which==32)
			{
				$( "#txt_fil_pro_dat3" ).focus();
				//producto_tabla();
				e.preventDefault();
			}
		});
		$( "#txt_fil_pro_dat3" ).keydown(function(e){
			if(e.which==32)
			{
				$( "#txt_fil_pro_dat4" ).focus();
				//producto_tabla();
				e.preventDefault();
			}
		});
		
		
			$("#txt_fil_pro_dat4").keydown(function(e){
			if(e.which==8)
			{
				if($("#txt_fil_pro_dat4").val()==""){
					$("#txt_fil_pro_dat3").focus();
				}	
			//	e.preventDefault();	
			}
		});
		
		
		$("#txt_fil_pro_dat3").keydown(function(e){
			if(e.which==8)
			{
				if($("#txt_fil_pro_dat3").val()==""){
					$("#txt_fil_pro_dat2").focus();
				}	
			//	e.preventDefault();	
			}
		});
		
		
		$("#txt_fil_pro_dat2").keydown(function(e){
			if(e.which==8)
			{
				if($("#txt_fil_pro_dat2").val()==""){
					$("#txt_fil_pro_dat1").focus();
				}	
				//e.preventDefault();	
			}
		});
  
  
		
	});
</script>