<?php
session_start();
date_default_timezone_set('America/Lima');
require_once("../almacen/cAlmacen.php");
$oAlmacen = new cAlmacen();
require_once ("../../config/Cado.php");

if($_SESSION['usuariogrupo_id']==1 || $_SESSION['usuariogrupo_id']==2){
	$alm_id = '';
}else{
	
			$dts1=$oAlmacen->mostrarAlmCajEmp($_SESSION['puntoventa_id']);
			$dt1 = mysqli_fetch_array($dts1);
 			$alm_id = $dt1['tb_almacen_id'];
			mysqli_free_result($dts1);
}

//echo $alm_id ;

?>

<script type="text/javascript">
	 
	function cmb_fil_alm_id()
	{	
		$.ajax({
			type: "POST",
			url: "../almacen/cmb_alm_id_user.php",
			async:false,
			dataType: "html",                      
			data: ({
				alm_id: '<?php echo $alm_id?>'
			}),
			beforeSend: function() {
			//$('#cmb_fil_pro_alm').html('<option value="">Cargando...</option>');
		},
		success: function(html){
			$('#cmb_fil_alm_id').html(html);
		},
		complete: function(){
		    inventarioinicial_tabla();
		}
	});
	}
	
	
		 $( "#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_letlab" ).keydown(function(e){
			if(e.which==13)
			{
				
				inventarioinicial_tabla();
				e.preventDefault();
			
			}
		});	
		
		$( "#txt_fil_mar" ).keydown(function(e){
			if(e.which==13)
			{
				
				inventarioinicial_tabla();
				e.preventDefault();
			
			}
		});	
		
		
		$( "#txt_fil_pro_dat1" ).keydown(function(e){
			if(e.which==13)
			{
				
				inventarioinicial_tabla();
				e.preventDefault();
			
			}
		});
		
			$( "#txt_fil_pro_dat2" ).keydown(function(e){
			if(e.which==13)
			{
				
				inventarioinicial_tabla();
				e.preventDefault();
			
			}
		});
		
		
			$( "#txt_fil_pro_dat3" ).keydown(function(e){
			if(e.which==13)
			{
				
				inventarioinicial_tabla();
				e.preventDefault();
			
			}
		});
		
		$( "#txt_fil_pro_dat4" ).keydown(function(e){
			if(e.which==13)
			{
				
				inventarioinicial_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();
				}	
					
			}
		});
		
		
		$("#txt_fil_pro_dat3").keydown(function(e){
			if(e.which==8)
			{
				if($("#txt_fil_pro_dat3").val()==""){
					$("#txt_fil_pro_dat2").focus();
				}	
					
			}
		});
		
		
		$("#txt_fil_pro_dat2").keydown(function(e){
			if(e.which==8)
			{
				if($("#txt_fil_pro_dat2").val()==""){
					$("#txt_fil_pro_dat1").focus();
				}	
					
			}
		});
		
	
	
	$(function() {
		
		
		cmb_fil_alm_id();
		
	//	inventarioinicial_tabla();
		
		
		$( "#chk_fil_stockvacio" ).click(function(event) {
			inventarioinicial_tabla();
		});
		$('#cmb_fil_alm_id, #cmb_fil_lim,#txt_fil_pro_acc').change(function(){
			inventarioinicial_tabla();
		});
	});
</script>
<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_invini">
						
							<div class="row">
							
							<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" autocomplete="off" 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" autocomplete="off" 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" autocomplete="off" class="form-control  input-sm">
							</div>
							
							<div class="col-lg-3 col-sm-3 col-6">
								<label for="txt_fil_pro_dat4">-</label>
								<input name="txt_fil_pro_dat4" type="text" id="txt_fil_pro_dat4" autocomplete="off" class="form-control  input-sm">
							</div>							
							
							<div class="col-lg-3 col-sm-3 col-6">
								<label for="txt_fil_mar">Laboratorio</label>
								<input name="txt_fil_mar" type="text" id="txt_fil_mar" autocomplete="off" class="form-control  input-sm">
							</div>
							
							<div class="col-lg-3 col-sm-3 col-6">
								<label for="txt_fil_letlab">Letra Lab.:</label>
								<input name="txt_fil_letlab" type="text" id="txt_fil_letlab" autocomplete="off" class="form-control  input-sm">
							</div>
							
							<div class="col-lg-3 col-sm-3 col-6 d-none">
								<label for="txt_fil_pro_acc">Accion:</label>
								<input name="txt_fil_pro_acc" type="text" id="txt_fil_pro_acc" autocomplete="off" class="form-control  input-sm">
							</div>
							
						<div class="col-lg-2 col-sm-4 col-6">
							<label>Almacen:</label>
							<select name="cmb_fil_alm_id" id="cmb_fil_alm_id" style="cursor:pointer;" class="form-control">
							</select>
						</div>
						
						
						<div class="col-lg-2 col-sm-4 col-6">
							<label>N° Filas:</label>
							<select name="cmb_fil_lim" id="cmb_fil_lim" style="cursor:pointer;" class="form-control">
								<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-2 col-sm-4 col-6" style="display: inline-block; white-space: nowrap;padding-top:30px;">
							<span onClick="inventarioinicial_tabla()"  style="cursor:pointer"  class="btn btn-primary"><i class="fas fa-search" ></i></span>
							<span onClick="inventarioinicial_filtro()" style="cursor:pointer" class="btn btn-default">Restablecer</span>
                         </div>
						
						</div>
                     </form>
                         
						 
						
                   
						</div>
					</div>
				 </div>
			</div>
		</div>
	</div>
</section>