<?php
session_start();
date_default_timezone_set('America/Lima');
$y=date('Y');
$m=date('m');
$d=date('d');

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

?>




<section class="content">
	<div class="container-fluid">
	<div class="row">
	    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
		    <div class="card">
		        <div class="card-header">
    		<div class="row">
			
						<form id="for_fil_ven" action="POST">
							
							<div class="row">
							
					
							<div class=" col-lg-2 col-sm-3 col-xs-6 form-group">
								<label>Fecha 1:</label>

								<div class="input-group">
									<div class="input-group-prepend">
									<span class="input-group-text"><i class="far fa-calendar-alt"></i></span>
								</div>
									<input name="txt_fil_ven_fec1" type="text" id="txt_fil_ven_fec1" value="<?php echo $fec1?>"  class="form-control input-sm"> 
								</div>
							</div>
							
							<div class=" col-lg-2 col-sm-3 col-xs-6 form-group">
								<label>Fecha 2:</label>

								<div class="input-group">
									<div class="input-group-prepend">
									<span class="input-group-text"><i class="far fa-calendar-alt"></i></span>
								</div>
									<input name="txt_fil_ven_fec2" type="text" id="txt_fil_ven_fec2" value="<?php echo $fec2 ?>"  class="form-control input-sm"> 
								</div>
							</div>
							
						
							<div class="col-lg-2 col-sm-3 col-xs-6">
								<label for="cmb_fil_empresa_id">Empresa:</label>
								<select name="cmb_fil_empresa_id" id="cmb_fil_empresa_id" class="form-control  input-sm"></select>
							</div>
														
							<div class="col-lg-2 col-sm-3 col-xs-6">
								<label>Serie/Numero:</label>
								<input type="text" id="txt_fil_docnum" name="txt_fil_docnum" class="form-control  input-sm" /> 
							</div>
							
							<div class="col-lg-4 col-sm-3 col-xs-6">
								<label>Receptor Doc:</label>
								<input type="hidden" id="hdd_fil_cli_id" name="hdd_fil_cli_id" />
								<input type="text" id="txt_fil_recdoc" name="txt_fil_recdoc" class="form-control  input-sm" /> 
							</div>

							

							<div  class="col-lg-3 col-sm-4 col-xs-6">
									<br />							
									<span onClick="guiaremision_tabla()" style="cursor:pointer" class="btn btn-primary"><i class="fas fa-search"></i></span>									
									<span onClick="guiaremision_filtro()" style="cursor:pointer" class="btn btn-default">RESTABLECER</span>																
							</div>
							
							</div> 
							
						</form>	
						
					</div>
				</div>
			</div>
		</div>
	</div>
	</div>
</section>

<script type="text/javascript">


cmb_empresa_id('');

	 function cmb_empresa_id(empid){
	
	  	$.ajax({
			type: "POST",
			url: "../empresa/cmb_emp_id.php",
			async:true,
			dataType: "html",                      
			data: ({
				emp_id:empid
			}),
			beforeSend: function() {
				$('#cmb_fil_empresa_id').html('<option value="">Cargando...</option>');
			},
			success: function(html){	
			
				$('#cmb_fil_empresa_id').html(html);
				
				
			}
		});		
  
  }



	function cmb_fil_doc_id()
	{	
		$.ajax({
			type: "POST",
			url: "../documento/cmb_doc_id.php",
			async:true,
			dataType: "html",                      
			data: ({
				mod_id:	'3',
				nosel_def : true,
				vista:	'<?php echo $_POST['action']?>'
			}),
			beforeSend: function() {
				$('#cmb_fil_doc_id').html('<option value="">Cargando...</option>');
			},
			success: function(html){			
				$('#cmb_fil_doc_id').html(html);
			}
		});
	}


	$(function(){

	/* 	$('input').iCheck({
		checkboxClass: 'icheckbox_square-blue',
		radioClass: 'iradio_square-blue',
		increaseArea: '20%' 
		}); */
		
	$('#txt_fil_ven_fec1, #txt_fil_ven_fec2').datepicker({
			format: 'dd-mm-yyyy',
			autoclose:true
		}).on('changeDate', function(e){
			
		}); 
		

	//cargarMozos(<?php echo $_SESSION['puntoventa_id']; ?>);
	cmb_fil_doc_id();


	$("#txt_fil_cli" ).autocomplete({
	minLength: 1,
	source: "../cliente/cliente_complete_nom.php",
	select: function(event, ui){
		$("#hdd_fil_cli_id").val(ui.item.id);		
	guiaremision_tabla();		
	}
	});

	$("#txt_fil_recdoc").change(function(){
		var cli=$("#txt_fil_recdoc").val();
		if(cli=="")$("#hdd_fil_cli_id").val('');
	});
	
	$('#cmb_fil_doc_id, #cmb_fil_moz_id ,#cmb_fil_mon_id , #txt_fil_docnum, #txt_fil_recdoc').change(function(e) {
	guiaremision_tabla();
	});
	
	$('#cmb_fil_ven_est').change(function(e) {
	guiaremision_tabla();
	});

	$('#cmb_fil_empresa_id').change(function(e) {
	cmb_punven_id($('#cmb_fil_empresa_id').val());
	});

	$('#cmb_fil_punven_id').change(function(e) {
	guiaremision_tabla();
	});
	
	guiaremision_tabla();



});	
</script>
