<?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";
?>
 
 <style type="text/css">
.ui-autocomplete
{
    z-index: 99999; 
}

</style>

<div class="modal-header">
        <h5 class="modal-title">BUSQUE Y SELECCIONE UNA NOTA DE CREDITO </h5>
		<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
      </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">
		    <div class="card">
		        <div class="card-header">
					<div class="row">
						
						
						<form id="for_fil_notcre" action="POST">
								
							<div class="row">
								
							<div class=" col-lg-2 col-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_notcre_fec1" type="text" id="txt_fil_notcre_fec1" value="<?php echo $fec1?>" class="form-control" >
							</div>
							</div>	
							
							<div class=" col-lg-2 col-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_notcre_fec2" type="text" id="txt_fil_notcre_fec2" value="<?php echo $fec2?>" class="form-control" >
							</div>
							</div>
									
							<div class="col-lg-3 col-6">
								<label>Cliente:</label>
								<input type="hidden" id="hdd_fil_cli_id" name="hdd_fil_cli_id" value="<?php echo $_POST['cli_id']?>" />
								<input type="text" id="txt_fil_cli" name="txt_fil_cli" readonly class="form-control  input-sm" value="<?php echo $_POST['cli_nom']?>" /> 
							</div>

												
							<div class="col-lg-3 col-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-2 col-md-4 col-6" style="display: inline-block; white-space: nowrap;padding-top:30px;">						
									<span onClick="notacredito_tabla_seleccion()" style="cursor:pointer" class="btn btn-primary"><i class="fas fa-search"></i></span>											
							</div>
							
							</div>
							
						</form>	
						
					</div>
				</div>
			</div>
		</div>
	</div>
	</div>
</section>


<div id="div_notacredito_tabla"></div>






<script type="text/javascript">


function notacredito_tabla_seleccion(){
			$('#div_mensaje_dialog').modal('show');
			$.ajax({
				type: "POST",
				url: "../notacredito/notacredito_tabla_seleccion.php",
				dataType: "html",
				data:  $("#for_fil_notcre").serialize(),
				beforeSend: function() {
					var divmen = "<center> <br> <span class='spinner-border spinner-border-lg mr-2'></span> <span style='font-size:1.5rem;'>PROCESANDO PETICIÓN</span></center>";	
							
					$('.div_mensaje').html(divmen);
					$('#div_notacredito_tabla').addClass("ui-state-disabled");
				},
				success: function(html){
					$('#div_notacredito_tabla').html(html);
				},
				complete: function(){					
					$('#div_mensaje_dialog').modal('hide');				
					
					$('#div_notacredito_tabla').removeClass("ui-state-disabled");
				}
			}); 
		}
		


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

	
	$("#txt_fil_cli").change(function(){
	var cli=$("#txt_fil_cli").val();
	if(cli=="")$("#hdd_fil_cli_id").val('');
	});
	
	$('#txt_fil_notcre_fec1, #txt_fil_notcre_fec2').datepicker({
			format: 'dd-mm-yyyy',
			autoclose:true
		}).on('changeDate', function(e){
			// notacredito_tabla();
		}); 
		
	$('#txt_fil_docnum').change(function(e) {
	notacredito_tabla_seleccion();
	});	
	 
	notacredito_tabla_seleccion();
});	
</script>
