<?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";

	

	$punven_id=$_SESSION['puntoventa_id'];

	$id_usuario = $_SESSION['usuariogrupo_id'];

?>

<script type="text/javascript">

	

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 cmb_fil_ven_id(){

	$.ajax({

		type: "POST",

		url: "../usuario/cmb_usu_id.php",

		async:true,

		dataType: "html",                      

		data:({}),

		beforeSend: function() {

			$('#cmb_fil_ven_id').html('<option value="">Cargando...</option>');

		},

		success: function(html){			

			$('#cmb_fil_ven_id').html(html);

		}

	});

}



function cmb_fil_punven_id(idf)

{	

	$.ajax({

		type: "POST",

		url: "../puntoventa/cmb_punven_id.php",

		async:false,

		dataType: "html",                      

		data: ({

			punven_id: idf

		}),

		beforeSend: function() {

			$('#cmb_fil_punven_id').html('<option value="">Cargando...</option>');

        },

		success: function(html){

			$('#cmb_fil_punven_id').html(html);

		},

		complete: function(){

			//venta_tabla();

		}

	});

}



$(function() {

	

	cmb_fil_doc_id();

	cmb_fil_ven_id();

	cmb_fil_punven_id(<?php echo $punven_id?>);



	$('#txt_fil_ven_fec1, #txt_fil_ven_fec2').datepicker({

			format: 'dd-mm-yyyy',

			autoclose:true

		}).on('changeDate', function(e){

			venta_tabla();

		}); 



	

	$( "#txt_fil_cli" ).autocomplete({

   		minLength: 1,

   		source: "../cliente/cliente_complete_nom.php",

		select: function(event, ui){

			$("#hdd_fil_cli_id").val(ui.item.id);

			venta_tabla();

		}

    });

	

	$("#txt_fil_cli").change(function(){

		var cli=$("#txt_fil_cli").val();

		if(cli=="")$("#hdd_fil_cli_id").val('');

	});

	

	$('#cmb_fil_punven_id, #cmb_fil_ven_est, #cmb_fil_ven_id, #chk_ven_anu').change(function(e) {

        venta_tabla();

    });

	

});

</script>





<section class="content" id="filter" style="min-height:0px;padding-bottom:0px;margin-bottom:-30px;">

	<div class="row">

		<div class="col-xs-12">

			<div class="box">

				<div class="box-body">

					<div class="row">

					

	<form name="for_fil_ven" id="for_fil_ven" target="_blank" action="" method="post">

	<input name="hdd_modo" id="hdd_modo" type="hidden" value="../venta_cst/venta_tabla.php">

	

	<div class="col-lg-2 col-xs-4">

    <label for="txt_fil_ven_fec1">Fecha 1:</label>

    <input name="txt_fil_ven_fec1" type="text" class="form-control" id="txt_fil_ven_fec1" value="<?php echo $fec1?>" >

	</div>

	<div class="col-lg-2 col-xs-4">

	<label for="txt_fil_ven_fec2">Fecha 2:</label>

    <input name="txt_fil_ven_fec2" type="text" class="form-control" id="txt_fil_ven_fec2" value="<?php echo $fec2?>" >

    </div>

	  

	  

    <input type="hidden" id="hdd_fil_cli_id" class="form-control" name="hdd_fil_cli_id" />

    <div class="col-lg-5 col-xs-4">

    <label for="txt_fil_cli_id">Cliente:</label>

    <input type="text" id="txt_fil_cli" class="form-control" name="txt_fil_cli" size="40" />

	</div>

	

	<div class="col-lg-3 col-xs-4">

    <label for="cmb_fil_ven_id">Vendedor:</label><br />

	<select name="cmb_fil_ven_id" class="form-control input-sm" id="cmb_fil_ven_id"></select>

	</div>



	<div class="col-lg-4 col-xs-4">

    <label for="cmb_fil_punven_id">Punto Venta:</label><br />

    <select name="cmb_fil_punven_id" class="form-control input-sm" id="cmb_fil_punven_id">

    </select>

	</div>

	

	<div class="col-lg-4 col-xs-4">

    <label for="cmb_fil_ven_est">Estado:</label>

		<select name="cmb_fil_ven_est" id="cmb_fil_ven_est" class="form-control input-sm" >

			<option value="">-</option>

			<option value="1" selected>REGISTRADA</option>

			<option value="2">ANULADA</option>

		</select>

		</div>

		

	<div class="col-lg-4 col-xs-4">

	<br />	

  	<span onClick="venta_tabla()" class=" btn btn-primary glyphicon glyphicon-search"></span>

    <span onClick="venta_filtro()" class="btn btn-default">Restablecer</span>

	</div>

		

	</form>



					</div>

				</div>

			</div>

		</div>

	</div>

</section>