<?php
session_start();
date_default_timezone_set('America/Lima');
	$y=date('Y');
	$m=date('m');
	$d=date('d');
	if($_SESSION['usuariogrupo_id']==1 || $_SESSION['usuariogrupo_id']==2){
		
	}
	else{
 	$punven_id = $_SESSION['puntoventa_id'];
 	}
	
	$fec="$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">
			
			<?php // echo $_SESSION['usuario_ser'];?>
			<form id="for_fil_cot" action="POST">
			    <input type="hidden" id="hdd_fil_cli_id" name="hdd_fil_cli_id" />
	          
			<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_cot_fec1" type="text" id="txt_fil_cot_fec1" value="<?php echo $fec?>" class="form-control" >
                  </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_cot_fec2" type="text" id="txt_fil_cot_fec2" value="<?php echo $fec?>" class="form-control" >
                  </div>
                </div>
				
			
			
			<div class="col-lg-3  col-sm-3 col-xs-6">
					<label for="cmb_fil_mon_id">Moneda:</label>
					<select name="cmb_fil_mon_id" id="cmb_fil_mon_id" class="form-control">
					</select>    
			</div>
							
			<div class="col-lg-3  col-sm-3 col-xs-6">
					<label>Estado:</label>
					<select name="cmb_fil_ven_est" id="cmb_fil_ven_est" style="cursor:pointer;" class="form-control">
						<option value="" selected>TODAS COTIZACIONES</option>
						<option value="1">COTIZADA</option>
						<option value="2">ACEPTADA</option>
						<option value="3">RECHAZADA</option>
					</select>
			</div>
			<div class="col-lg-2  col-sm-3 col-xs-6">				
				<label for="cmb_fil_puntoventa_id">Punto Venta:</label>
				<select name="cmb_fil_puntoventa_id" id="cmb_fil_puntoventa_id" class="form-control ">
				</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" /> 
			</div>
				
                <div class="col-lg-3  col-sm-3 col-xs-6">
				    <label>Cliente:</label>
				    <input type="text" id="txt_fil_cli_nom" name="txt_fil_cli_nom" class="form-control" />
                </div>
				<div class="col-lg-2  col-sm-3 col-xs-6">
				    <label>Taller/Mec.:</label>
				    <input type="text" id="txt_fil_mec_nom" name="txt_fil_mec_nom" class="form-control" />
                </div>
							
			
							
									
                 <div class="col-lg-3  col-sm-3 col-xs-6" style="padding-top: 30px;" >
				    <span  onClick="cotizacion_tabla()"  style="cursor:pointer"  class="btn btn-primary"><i class="fas fa-search"></i></span>
					<span  onClick="cotizacion_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_fil_puntoventa_id(<?php echo $punven_id; ?>);
function cmb_fil_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_fil_puntoventa_id').html('<option value="">Cargando...</option>');
 					},
 					success: function(html){			
 						$('#cmb_fil_puntoventa_id').html(html);
 					},
 					complete: function(){
 						$('#txt_punven_id').val($('#cmb_fil_puntoventa_id').val());
 						}
 					});
}
		function cmb_fil_mon_id(moneid)
	{	
		$.ajax({
			type: "POST",
			url: "../moneda/cmb_mon_id.php",
			async:true,
			dataType: "html",                      
			data: ({
				mon_id: moneid
			}),
			beforeSend: function(){
				$('#cmb_fil_mon_id').html('<option value="">Cargando...</option>');
			},
			success: function(html){
				$('#cmb_fil_mon_id').html(html);
				cotizacion_tabla();
			}
		});
	}
	
$("#txt_fil_cli_nom").focus();
cmb_fil_mon_id('');
	$('#txt_fil_cot_fec1, #txt_fil_cot_fec2').datepicker({
			format: 'dd-mm-yyyy',
			autoclose:true
		}).on('changeDate', function(e){
			
		}); 
	
	$('#txt_fil_docnum, #cmb_fil_mon_id, #cmb_fil_ven_est').change(function(){
		cotizacion_tabla();
	}); 
	
	
	$( "#txt_fil_mec_nom" ).autocomplete({
		minLength: 1,
		source: "../mecanico/mecanico_complete_nom.php",
		select: function(event, ui){			
			$("#hdd_fil_mec_id").val(ui.item.id);							
		}
	});
	
	
	$( "#txt_fil_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_cli_doc").val(ui.item.documento);
			$("#txt_fil_cli_dir").val(ui.item.direccion);
			cotizacion_tabla();
		}
	});
	
	$( "#txt_fil_cli_doc" ).autocomplete({
		minLength: 1,
		source: "../cliente/cliente_complete_doc.php",
		select: function(event, ui){			
			$("#hdd_fil_cli_id").val(ui.item.id);							
			$("#txt_fil_cli_nom").val(ui.item.nombre);
			$("#txt_fil_cli_dir").val(ui.item.direccion);		
			cotizacion_tabla();
		}
	});
cotizacion_tabla();	
</script>