 <?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_pro" id="for_fil_pro" method="POST" >							
				<div class="col-lg-12 col-xs-12" style="height:15px;" >
				</div>
				
				
				<div class="col-lg-4 col-xs-12" >			
				
				<table>
				<tr>
				<td nowrap >
				<div class="col-lg-12 col-xs-12">
				<label class="text-red" >
					<input  name="chk_comp" id="chk_comp"  type="checkbox"> COMPROBANTES
				</label> 
				</div>
				</td>
				</tr>
				
				<tr id="tr_tipcom" >				
				<td nowrap >
				<div class="col-lg-12 col-xs-12" >
				<label class="text-red" >
					<input name="chk_comope" id="chk_comope" type="checkbox"> OPERACION
				</label>
				</div>
				</td>
				
				<td nowrap >
				<div class="col-lg-12 col-xs-12">
				<label class="text-red" >
					<input name="chk_comven" id="chk_comven" type="checkbox"> VENCIMIENTO
				</label>
				</div>
				</td>
				</tr>
				
				<tr id="tr_feccom">					
				<td nowrap >
						<div class="col-lg-12 col-xs-12">
								<label for="txt_com_fec1">Desde:</label>
								<div class="input-group date">
									<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
									<input name="txt_com_fec1" type="text" id="txt_com_fec1" value="<?php echo $fec1?>" autocomplete="off" class="form-control"> 
								</div>
						</div>
				</td>
				
				<td nowrap >
						<div class="col-lg-12 col-xs-12">
								<label for="txt_com_fec2">Hasta:</label>
								<div class="input-group date">
									<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
									<input name="txt_com_fec2" type="text" id="txt_com_fec2" value="<?php echo $fec2 ?>" autocomplete="off" class="form-control"> 
								</div>								 
						</div>
				</td>
				</tr>
				
				<tr id="tr_ordcom">				
				<td nowrap >
				<div class="col-lg-12 col-xs-12">
				<label class="text-red" >
					<input name="chk_comasc" id="chk_comasc" type="checkbox"> ASCENDENTE
				</label>
				</div>
				</td>
				
				<td nowrap >
				<div class="col-lg-12 col-xs-12">
				<label class="text-red" >
					<input name="chk_comdesc" id="chk_comdesc" type="checkbox"> DESCENDENTE
				</label>
				</div>
				</td>
				</tr>
				
				</table>
			</div>	

			
				<div class="col-lg-4 col-xs-12" >			
				
				<table>
				<tr>
				<td nowrap >
				<div class="col-lg-12 col-xs-12">
				<label class="text-red" >
					<input  name="chk_let" id="chk_let"  type="checkbox"> LETRAS
				</label> 
				</div>
				</td>
				</tr>
				
				<tr id="tr_tiplet">				
				<td nowrap >
				<div class="col-lg-12 col-xs-12">
				<label class="text-red" >
					<input name="chk_letope" id="chk_letope" type="checkbox"> OPERACION
				</label>
				</div>
				</td>
				
				<td nowrap >
				<div class="col-lg-12 col-xs-12">
				<label class="text-red" >
					<input name="chk_letven" id="chk_letven" type="checkbox"> VENCIMIENTO
				</label>
				</div>
				</td>
				</tr>
				
				<tr id="tr_feclet">					
				<td nowrap >
						<div class="col-lg-12 col-xs-12">
								<label for="txt_let_fec1">Desde:</label>
								<div class="input-group date">
									<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
									<input name="txt_let_fec1" type="text" id="txt_let_fec1" value="<?php echo $fec1?>" autocomplete="off" class="form-control"> 
								</div>
						</div>
				</td>
				
				<td nowrap >
						<div class="col-lg-12 col-xs-12">
								<label for="txt_let_fec2">Hasta:</label>
								<div class="input-group date">
									<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
									<input name="txt_let_fec2" type="text" id="txt_let_fec2" value="<?php echo $fec2 ?>" autocomplete="off" class="form-control"> 
								</div>								 
						</div>
				</td>
				</tr>
				
				<tr id="tr_ordlet">				
				<td nowrap >
				<div class="col-lg-12 col-xs-12">
				<label class="text-red" >
					<input name="chk_letasc" id="chk_letasc" type="checkbox"> ASCENDENTE
				</label>
				</div>
				</td>
				
				<td nowrap >
				<div class="col-lg-12 col-xs-12">
				<label class="text-red" >
					<input name="chk_letdesc" id="chk_letdesc" type="checkbox"> DESCENDENTE
				</label>
				</div>
				</td>
				</tr>
				
				</table>
			</div>	
							
					
				<div style="display: inline-block; white-space: nowrap;" id="div_btn"  class="col-lg-4 col-sm-3 col-xs-6">		
								<span onClick="cuentapagadaconsolidadasfecha_cst_tabla()" id="btn_filtrar" class="btn btn-primary btn-lg glyphicon glyphicon-search"></span>
								<span onClick="cuentapagadaconsolidadasfecha_cst_filtro()" id="btn_resfil"  class="btn btn-default btn-lg ">Restablecer</span>
				</div> 				
							
							
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
</section>

<script type="text/javascript">


var com='';
var comope='';
var comven='';
var comasc='';
var comdesc='';

var letra='';
var letraope='';
var letraven='';
var letraasc='';
var letradesc='';

$("#tr_tipcom").hide();
$("#tr_feccom").hide();
$("#tr_ordcom").hide();
$("#tr_tiplet").hide();
$("#tr_feclet").hide();
$("#tr_ordlet").hide();
$("#div_btn").hide();

function cuentapagadaconsolidadasfecha_cst_tabla()
{
			$('#div_mensaje_dialog').modal('show');
			$.ajax({
				type: "POST",
				url: "../cuentapagadaconsolidadasfecha_cst/cuentapagadaconsolidadasfecha_cst_tabla.php",
				async:true,
				dataType: "html",                      
				data: ({
					com :com,
					comope :comope,
					comven :comven,
					comfec1 :$("#txt_com_fec1").val(),
					comfec2 :$("#txt_com_fec2").val(),
					comasc :comasc,
					comdesc :comdesc,
					letra:letra,
					letraope:letraope,
					letraven:letraven,
					letrafec1:$("#txt_let_fec1").val(),
					letrafec2:$("#txt_let_fec2").val(),
					letraasc:letraasc,
					letradesc:letradesc
				}), 
				beforeSend: function() {
						var divmen = "<center><div class='overlay col-lg-12 col-sm-12 col-xs-12' style='background-color:#fff;padding:0%;font-size:3rem;' >  <i class='fa fa-refresh fa-spin ' ></i> PROCESANDO PETICIÓN</div>  </center>";	
				$('.div_mensaje').html(divmen);
					$('#div_cuentapagar_tabla').addClass("ui-state-disabled");
				},
				success: function(html){
					$('#div_cuentapagar_tabla').html(html);
				},
				complete: function(){			
					$('#div_cuentapagar_tabla').removeClass("ui-state-disabled");
					$('#div_mensaje_dialog').modal('hide');
				}
			});     
}







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

	function activar(){
		ok = 0;
	
		
		if(com==1){
			
			if(comope > 0 || comven > 0){
				if(comasc > 0 || comdesc > 0){
				ok = 1;
				}
			}else{
				ok = 0;
			}
			
			if(comasc > 0 || comdesc > 0){
				if(comope > 0 || comven > 0){
				ok = 1;
				}
			}else{
				ok = 0;
			}
			
		}
		
		if(letra==1){
			
			if(letraope > 0 || letraven > 0){
				if(letraasc > 0 || letradesc > 0){
				ok = 1;
				}
			}else{
				ok = 0;
			}
			
			if(letraasc > 0 || letradesc > 0){
				if(letraope > 0 || letraven > 0){
				ok = 1;
				}
			}else{
				ok = 0;
			}
			
		}
		
		if(ok==1){
			$("#div_btn").show(100);
		}else{
			$("#div_btn").hide(100);
		}
		
	}
	
	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);
	}
	
	
	$('input').iCheck({
		checkboxClass: 'icheckbox_square-blue',
		radioClass: 'iradio_square-blue',
      increaseArea: '20%' // optional
  });

  
		$('#txt_let_fec1,#txt_let_fec2,#txt_com_fec1,#txt_com_fec2').datepicker({
			format: 'dd-mm-yyyy',
			autoclose:true
		}).on('changeDate', function(e){
			//compra_tabla();
		}); 

		
$('#chk_comp').on('ifChecked', function(event){
 
	
	$("#tr_tipcom").show(100);
	$("#tr_feccom").show(100);
	$("#tr_ordcom").show(100);
	activar();
	com='1';

});

$('#chk_comp').on('ifUnchecked', function(event){
 
	$('#chk_comope').iCheck('uncheck');
	$('#chk_comven').iCheck('uncheck');
	$('#chk_comasc').iCheck('uncheck');
	$('#chk_comdesc').iCheck('uncheck');

	com='';
	comope='';
	comven='';
	comasc='';
	comdesc='';
	
	
	$("#tr_tipcom").hide(100);
	$("#tr_feccom").hide(100);
	$("#tr_ordcom").hide(100);
	activar();
	
});

$('#chk_comope').on('ifChecked', function(event){
	$('#chk_comven').iCheck('uncheck');
	comope='1';
	comven='';
	activar();
});
$('#chk_comope').on('ifUnchecked', function(event){
 	comope='';
	comven='';
	activar();
});

$('#chk_comven').on('ifChecked', function(event){
	$('#chk_comope').iCheck('uncheck');
	comope='';
	comven='1';
	activar();
});
$('#chk_comven').on('ifUnchecked', function(event){
 	comope='';
	comven='';
	activar();
});


$('#chk_comasc').on('ifChecked', function(event){
	$('#chk_comdesc').iCheck('uncheck');
	comasc='1';
	comdesc='';
	activar();
});
$('#chk_comasc').on('ifUnchecked', function(event){
 	comasc='';
	comdesc='';
	activar();
});

$('#chk_comdesc').on('ifChecked', function(event){
	$('#chk_comasc').iCheck('uncheck');
	comasc='';
	comdesc='1';
	activar();
});
$('#chk_comdesc').on('ifUnchecked', function(event){
 	comasc='';
	comdesc='';
	activar();
});




		
$('#chk_let').on('ifChecked', function(event){
 
	$("#tr_tiplet").show(100);
	$("#tr_feclet").show(100);
	$("#tr_ordlet").show(100);
	activar();
	letra='1';
});

$('#chk_let').on('ifUnchecked', function(event){
 
	$('#chk_letope').iCheck('uncheck');
	$('#chk_letven').iCheck('uncheck');
	$('#chk_letasc').iCheck('uncheck');
	$('#chk_letdesc').iCheck('uncheck');

	letra='';
	letraope='';
	letraven='';
	letasc='';
	letdesc='';
	activar();
	
	$("#tr_tiplet").hide(100);
	$("#tr_feclet").hide(100);
	$("#tr_ordlet").hide(100);

});

$('#chk_letope').on('ifChecked', function(event){
	$('#chk_letven').iCheck('uncheck');
	letraope='1';
	letraven='';
	activar();
});
$('#chk_letope').on('ifUnchecked', function(event){
 	letraope='';
	letraven='';
	activar();
});

$('#chk_letven').on('ifChecked', function(event){
	$('#chk_letope').iCheck('uncheck');
	letraope='';
	letraven='1';
	activar();
});
$('#chk_letven').on('ifUnchecked', function(event){
 	letraope='';
	letraven='';
	activar();
});


$('#chk_letasc').on('ifChecked', function(event){
	$('#chk_letdesc').iCheck('uncheck');
	letraasc='1';
	letradesc='';
	activar();
});
$('#chk_letasc').on('ifUnchecked', function(event){
 	letraasc='';
	letradesc='';
	activar();
});

$('#chk_letdesc').on('ifChecked', function(event){
	$('#chk_letasc').iCheck('uncheck');
	letraasc='';
	letradesc='1';
	activar();
});
$('#chk_letdesc').on('ifUnchecked', function(event){
 	letraasc='';
	letradesc='';
	activar();
});


</script>   