<?php

session_start();
date_default_timezone_set('America/Lima');
require_once ("../../config/Cado.php");

$y=date('Y');
$m=date('m');
$d=date('d');

$fec1="$d-$m-$y";
$fec2="$d-$m-$y";

$caj_id='1'; //$_SESSION['caja_id'];
?>

<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_caj" action="POST">

				<div class="row">
				
				<div class="col-lg-3 col-sm-3 col-xs-6">
                  <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_caj_fec1" type="text" id="txt_fil_caj_fec1" value="<?php echo $fec1?>" class="form-control" >
                  </div>
				</div>
				
				<div class=" col-lg-3 col-sm-3 col-xs-6">
                  <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_caj_fec2" type="text" id="txt_fil_caj_fec2" value="<?php echo $fec2?>" class="form-control" >
                  </div>
				</div>
	
	
	

							<div class="col-lg-3 col-sm-3 col-xs-6">
								<label for="cmb_fil_caj_id">Caja:</label>
								<select name="cmb_fil_caj_id" id="cmb_fil_caj_id" class="form-control">
								</select>							 
							</div>
							
							<div class="col-lg-3 col-sm-3 col-xs-6" style="padding-top: 30px;"> 
								<span onClick="flujocaja_tabla()" style="cursor:pointer" class="btn btn-primary"><i class="fas fa-search"></i></span>
								<span onClick="flujocaja_filtro()" style="cursor:pointer" class="btn btn-default ">Restablecer</span>
							</div>
							
							</div>
							<!--
							<div class="col-lg-2 col-md-4 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>
							-->
					<!--		
						<a  target="_blank" href="../../app/egreso/egreso_actu.php">ver y actuaizar</a>
                        -->
						</form>
						
						
					</div>
				</div>
			</div>
		</div>
	</div>
</section>

<script type="text/javascript">

	function cmb_fil_caj_id(ids,punven)
	{	
		$.ajax({
			type: "POST",
			url: "../caja/cmb_caj_id.php",
			async:false,
			dataType: "html",                      
			data: ({
				caj_id: ids,
				punvenid :punven  
			}),
			beforeSend: function() {
				$('#cmb_fil_caj_id').html('<option value="">Cargando...</option>');
			},
			success: function(html){
				$('#cmb_fil_caj_id').html(html);
			}
		});
	}
	
	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);
				flujocaja_tabla();
			}
		});
	}
	
	$(function(){		
		$('#btn_actualizar').click(function() {
			$("#content").load("../flujocaja/flujocaja_vista.php");
		});
		
		$('#txt_fil_caj_fec1, #txt_fil_caj_fec2').datepicker({
			format: 'dd-mm-yyyy',
			autoclose:true
		}).on('changeDate', function(e){
			//flujocaja_tabla();
		}); 
		
	<?php if ($_SESSION['usuariogrupo_id']=='6'){?>	
	
	cmb_fil_caj_id(<?php echo $caj_id?>,<?php echo $_SESSION['puntoventa_id']?>);
	<?php }else{
	?>
	cmb_fil_caj_id(<?php echo $caj_id?>);
	<?php 
	}?>
	
	$("#cmb_fil_caj_id , #cmb_fil_mon_id").change(function(){
	flujocaja_tabla();
	});	
	
	cmb_fil_mon_id('1');
	
	


});	
</script> 