<?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 name="for_fil_con" id="for_fil_con" method="POST" > 

						<div class="row">
						
						<div class="col-lg-1 col-sm-4 col-xs-6">
							<label>TOP:</label>
							<select name="cmb_fil_lim" id="cmb_fil_lim" style="cursor:pointer;" class="form-control">
								<option value="5" selected="selected">5</option>
								<option value="10">10</option> 
								<option value="20">20</option>
							</select>
						</div>
						
						<div class="col-lg-3 col-sm-4 col-xs-6">
							<label>Sucursal:</label>
							<select name="cmb_fil_punven" id="cmb_fil_punven" style="cursor:pointer;" class="form-control">
								
							</select>
						</div>
									
				<div class=" col-lg-2 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_con_fec1" type="text" id="txt_fil_con_fec1" value="<?php echo $fec1?>" class="form-control" >
                  </div>
                </div>
				
				
				
				<div class=" col-lg-2 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_con_fec2" type="text" id="txt_fil_con_fec2" value="<?php echo $fec2?>" class="form-control" >
                  </div>
                </div>
				
                           <div class="col-lg-2 col-xs-6">
								<label>Cliente:</label>
								<input type="hidden" id="hdd_fil_cli_id" name="hdd_fil_cli_id" />
								<input type="text" id="txt_fil_cli" name="txt_fil_cli" class="form-control" /> 
							</div>
							
							<div class="col-lg-2 col-xs-6" style="padding-top:30px;"> 
								<span onClick="consulta_cst_tabla()"  style="cursor:pointer" class="btn btn-primary" ><i class="fas fa-search"></i></span>
								<span onClick="consulta_cst_filtro()"  style="cursor:pointer" class="btn btn-default" >Restablecer</span>
							</div>
						
							</div>

						</form>
						
						
					</div>
				</div>
			</div>
		</div>
	</div>
	</div>
</section>

<script type="text/javascript">

  function cmb_fil_punven(idf)
{	
	$.ajax({
		type: "POST",
		url: "../puntoventa/cmb_punven_id.php",
		async:false,
		dataType: "html",                      
		data: ({
			punven_id: idf
		}),
		beforeSend: function() {
			$('#cmb_fil_punven').html('<option value="">Cargando...</option>');
        },
		success: function(html){
			$('#cmb_fil_punven').html(html);
		},
		complete: function(){
			//venta_tabla();
		}
	});
}


 

	$(function() {
	
	cmb_fil_punven();
	
	$('#txt_fil_con_fec1, #txt_fil_con_fec2').datepicker({
			format: 'dd-mm-yyyy',
			autoclose:true
		}).on('changeDate', function(e){
			
		}); 
	
	$("#txt_fil_cli" ).autocomplete({
	minLength: 1,
	source: "../cliente/cliente_complete_nom.php",
	select: function(event, ui){
		$("#hdd_fil_cli_id").val(ui.item.id);		
		consulta_cst_tabla();		
	}
	});

	$("#txt_fil_cli").change(function(){
	var cli=$("#txt_fil_cli").val();
	if(cli=="")$("#hdd_fil_cli_id").val('');
	});

		consulta_cst_tabla();

	});
</script>   