<?php
session_start();
 if($_SESSION['usuariogrupo_id']==1 || $_SESSION['usuariogrupo_id']==2){
		
	}
	else{
	
		$punven_id = $_SESSION['puntoventa_id'];
	}
	

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_pro" id="for_fil_pro" method="POST" > 

						<div class="row">
						
						
				<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_dev_fec1" type="text" id="txt_fil_dev_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_dev_fec2" type="text" id="txt_fil_dev_fec2" value="<?php echo $fec2?>" class="form-control" >
                  </div>
                </div>
							
						
							
							<div class="col-lg-4 col-sm-3 col-xs-6">
									<label for="cmb_puntoventa_id">Punto Venta:</label>
									<select name="cmb_puntoventa_id" id="cmb_puntoventa_id" class="form-control input-sm">
									</select>
								<input name="txt_punven_id" type="hidden" value="" id="txt_punven_id">	
							</div>
							
							<div class="col-lg-3 col-xs-6">
								<input type="hidden" id="hdd_fil_cli_id" name="hdd_fil_cli_id"/>
								<label for="txt_dev_cli_nom">Cliente:</label>
								<input name="txt_dev_cli_nom" type="text" id="txt_dev_cli_nom" class="form-control input-sm"> 
							</div> 

                            <div class="col-lg-2 col-xs-6">
								<label for="txt_dev_numdocfil">Numero Doc:</label>
								<input name="txt_dev_numdocfil" type="text" id="txt_dev_numdocfil" class="form-control input-sm">   
							</div>
							
							
							<div class="col-lg-3 col-xs-6" style="padding-top: 30px;"> 
								<span onClick="devolucion_tabla()" style="cursor:pointer" class="btn btn-primary" ><i class="fas fa-search"></i></span>
								<span onClick="devolucion_filtro()"  style="cursor:pointer" class="btn btn-default" >Restabecer</span>
							</div>
						
							</div>

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

<script type="text/javascript">

 
function cmb_puntoventa_id(punven){
		$.ajax({
 					type: "POST",
 					url: "../puntoventa/cmb_punven_id.php",
 					async:true,
 					dataType: "html",                      
 					data: ({						
 						emp_id:'',
						punven_id :punven,
 						vista:	''
 					}),
 					beforeSend: function() {
 						$('#cmb_puntoventa_id').html('<option value="">Cargando...</option>');
 					},
 					success: function(html){			
 						$('#cmb_puntoventa_id').html(html);
 					},
 					complete: function(){
 						$('#txt_punven_id').val($('#cmb_puntoventa_id').val());
 						}
 					});
}
		
	

  

	$(function() {

	cmb_puntoventa_id('<?php echo $punven_id;?>');
	
		$( "#txt_dev_cli_nom" ).autocomplete({
			minLength: 1,
			source: "../cliente/cliente_complete_nom.php",
			select: function(event, ui){			
				$("#hdd_fil_cli_id").val(ui.item.id);							
			}
		});
		
		$('#txt_fil_dev_fec1, #txt_fil_dev_fec2').datepicker({
			format: 'dd-mm-yyyy',
			autoclose:true
		}).on('changeDate', function(e){
			
		}); 
		

	
	$("#txt_dev_numdocfil").keydown(function(e){
			if (e.which == 13){
				devolucion_tabla();
			return false;
			}
		});
		
		$("#txt_dev_pro_nom").keydown(function(e){
			if (e.which == 13){
					
			return false;
			}
		});

	
		
		devolucion_tabla();
		
	});
</script>   