<style type="text/css">
select{
	cursor:pointer;
}
</style>
<div class="content-header" >
      <div class="container-fluid">
        <div class="row mb-2">
		 <div class="col-sm-6">
			<h1>
			Gestion stock
			<small>modulo</small>
			</h1>
		</div>	
		
		<div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
				<li class="breadcrumb-item" >Inicio</li>
				<li class="breadcrumb-item" >Almacen</li>
				<li class="breadcrumb-item active">Gestion stock</li>
            </ol>
          </div>
		</div>
	</div>
</div>
<section class="content">
	<div class="container-fluid">
	<div class="row">
	    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" style="padding:0px;" >
		    <div class="card">
		        <div class="card-header">
		          <button id="btn_actualizar" class="btn btn-default">Actualizar</button>
		          
		          <span style="cursor:pointer" id="btn_excel" class="btn btn-success float-right"> <i class="fas fa-file-excel"></i> DESCARGAR EXCEL</span>
		
		        </div>
		    </div>
		</div>
	</div>
	</div>
</section>
	<!-- busqueda de registros -->
	<div id="div_gestionstock_filtro"></div>
	<!-- listado de registros -->
	<div id="div_gestionstock_tabla"></div>
	
<script type="text/javascript">
	function gestionstock_filtro()
	{
		$.ajax({
			type: "POST",
			url: "../gestionstock/gestionstock_filtro.php",
			async:true,
			dataType: "html",                      
		data: ({
		}),
		beforeSend: function() {
			var div = "<center> <br> <span class='spinner-border spinner-border-lg mr-2'></span> <span style='font-size:1.5rem;'>PROCESANDO PETICIÓN</span></center>";	
				$('#div_gestionstock_filtro').html(div);
		},
		success: function(html){
			$('#div_gestionstock_filtro').html(html);
		},
		complete: function(){
		}
	});
	}
	
	function gestionstock_tabla()
	{
		$.ajax({
			type: "POST",
			url: "../gestionstock/gestionstock_tabla.php",
			async:true,
			dataType: "html", 
			data: $("#for_fil_pro").serialize(),                    
			beforeSend: function() {		
				$('#div_gestionstock_tabla').addClass("ui-state-disabled");
			},
			success: function(html){
				$('#div_gestionstock_tabla').html(html);
			},
			complete: function(){			
				$('#div_gestionstock_tabla').removeClass("ui-state-disabled");
			}
		});     
	}
	
	
function abrirEnPestana(url) {
		var a = document.createElement("a");
		a.target = "_blank";
		a.href = url;
		a.click();
}
	
$(function() {
	
	
	
$("#btn_excel").click(function(){
			dat1 = $("#txt_fil_pro_dat1").val();
			dat2 = $("#txt_fil_pro_dat2").val();
			dat3 =$("#txt_fil_pro_dat3").val();
			dat4 = $("#txt_fil_pro_dat4").val();
			lit = $("#cmb_fil_lim").val();
			mar = $("#txt_fil_mar").val();	
			acc = $("#txt_fil_pro_acc").val();	
			cat_id = $("#cmb_fil_cat_id").val();	
			
			
			
			abrirEnPestana('../../files/gestionstock/gestionstock_excel.php?dat1='+dat1+'&dat2='+dat2+'&dat3='+dat3+'&dat4='+dat4+'&mar='+mar+'&lit='+lit+'&cat_id='+cat_id);
});
	
	
	$('#btn_actualizar').click(function() {
		$("#contenido").load("../gestionstock/gestionstock_vista.php");
	});
	 
	gestionstock_filtro();	
	setTitle("GESTION STOCK - "+nombreEmpresa);	
	
});
</script>