 <?php
date_default_timezone_set('America/Lima');
session_start();

$y=date('Y');
$m=date('m');
$d=date('d');

$fec1="$d-$m-$y";
$fec2="$d-$m-$y";


require_once("../formatos/formato.php");

?>

 <section class="content" id="filter" style="min-height:0px;padding-bottom:0px;margin-bottom:-30px;">
	<div class="row">
		<div class="col-xs-12">
			<div class="box">
				<div class="box-body">
					<div class="row"> 
						<form name="for_fil_cuenta" id="for_fil_cuenta" method="POST" > 

							<div class="col-lg-2  col-sm-3 col-xs-6">
								<label for="cmb_fil_tip">TIPO:</label>
								<select name="cmb_fil_tip" id="cmb_fil_tip" class="form-control">
								<option value="-">-- SELECCIONAR --</option>
								<option value="1">COMPROBANTES</option>
								<option value="2">LETRAS</option>
								</select>
							</div>
						
							<div class="col-lg-2  col-sm-3 col-xs-6"  id="div_por">
								<label for="cmb_fil_por">POR:</label>
								<select name="cmb_fil_por" id="cmb_fil_por" class="form-control">
								<option value="1">EMISION</option>
								<option value="2">VENCIMIENTO</option>
								</select>
							</div>
							
							<div class="col-lg-2 col-xs-6" id="div_fec1">
								<label for="txt_fil_fec1">Desde:</label>
								<div class="input-group date">
									<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
									<input name="txt_fil_fec1" type="text" id="txt_fil_fec1" value="<?php echo $fec1?>" autocomplete="off" class="form-control"> 
								</div>
							</div>
							<div class="col-lg-2 col-xs-6" id="div_fec2">
								<label for="txt_fil_fec2">Hasta:</label>
								<div class="input-group date">
									<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
									<input name="txt_fil_fec2" type="text" id="txt_fil_fec2" value="<?php echo $fec2 ?>" autocomplete="off" class="form-control"> 
								</div>								 
							</div>
							
							<div class="col-lg-2  col-sm-3 col-xs-6" id="div_orden">
								<label for="cmb_fil_orden">ORDEN:</label>
								<select name="cmb_fil_orden" id="cmb_fil_orden" class="form-control">
								<option value="1">ASCENDENTE</option>
								<option value="2">DESCENDENTE</option>
								</select>
							</div>		 
							
							<div style="display: inline-block; white-space: nowrap;padding-top: 23px;" id="div_btn"  class="col-lg-2 col-sm-3 col-xs-6">		
								<span onClick="cuentapagarconsolidadasfecha_cst_tabla()" id="btn_filtrar" class="btn btn-primary glyphicon glyphicon-search"></span>
								<span onClick="cuentapagarconsolidadasfecha_cst_filtro()" id="btn_resfil"  class="btn btn-default ">Restablecer</span>
							</div> 				
							
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
</section>

<script type="text/javascript">

	$("#div_por").hide();
	$("#div_fec1").hide();
	$("#div_fec2").hide();
	$("#div_btn").hide();
	$("#div_orden").hide();

 
	function abrirEnPestana(url) {
		var a = document.createElement("a");
		a.target = "_blank";
		a.href = url;
		a.click();
	}

	
	function activar(){
		
		if($('#cmb_fil_empresa_id').val()>0 && $("#hdd_fil_pro_id").val()>0){
			$("#btn_pdf_cuentasgeneral").attr('onClick','pdf_general()');
			
		}else{
			$("#btn_pdf_cuentasgeneral").attr('onClick','');
		}
	}
	
	function pdf_general(){
		
		pro_id = $("#hdd_fil_pro_id").val();
		emp_id = $("#cmb_fil_empresa_id").val();
		mon_id = $("#cmb_fil_mon_id").val();
		fec1 = $("#txt_fil_fec1").val();
		fec2 = $("#txt_fil_fec2").val();
			
		abrirEnPestana('../../files/cuentapagar/cuentapagar_general_impcpe_doc.php?pro_id='+pro_id+'&emp_id='+emp_id+'&mon_id='+mon_id+'&doctod='+doctod+'&letr='+letr+'&fac='+fac+'&nd='+nd+'&nc='+nc+'&esttod='+esttod+'&pen='+pen+'&canj='+canj+'&pag='+pag+'&fec1='+fec1+'&fec2='+fec2);
	}
	

		
	activar();
	
		$('#txt_fil_fec1, #txt_fil_fec2').datepicker({
		format: 'dd-mm-yyyy',
			autoclose:true
		}).on('changeDate', function(e){
			//compra_tabla();
		}); 

		$("#cmb_fil_tip").change(function(){
			
			if($("#cmb_fil_tip").val()>0){
			$("#div_por").show(100);
			$("#div_fec1").show(100);
			$("#div_fec2").show(100);
			$("#div_orden").show(100);
			$("#div_btn").show(100);
			}else{
				
			$("#div_por").hide(100);
			$("#div_fec1").hide(100);
			$("#div_fec2").hide(100);
			$("#div_orden").hide(100);
			$("#div_btn").hide(100);
	
			}
			
			//activar();
		});
	
</script>   