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

<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_tra" id="for_fil_tra" > 
						
						<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_tra_fec1" type="text" id="txt_fil_tra_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_tra_fec2" type="text" id="txt_fil_tra_fec2" value="<?php echo $fec2?>" class="form-control" >
								</div>
						</div>
						
						<div class="col-lg-3 col-xs-6">
								<label for="cmb_fil_caj_id_ori">Origen:</label>
								<select name="cmb_fil_caj_id_ori" id="cmb_fil_caj_id_ori" class="form-control input-sm"></select>
						</div>
						
						<div class="col-lg-3 col-xs-6">
							<label for="cmb_fil_caj_id_des">Destino:</label>
							<select name="cmb_fil_caj_id_des" id="cmb_fil_caj_id_des" class="form-control input-sm"> </select> 
						</div>
						
						<div class="col-lg-2 col-xs-12" style="padding-top:30px;"> 
							<span onClick="transferencia_tabla()" class="btn btn-primary"><i class="fas fa-search"></i></span>
							<span onClick="transferencia_filtro()" class="btn btn-default">Restablecer</span>
						</div>
						
					</div>
						
						
					</form>
					
					
					
					
				</div>
			</div>
		</div>
	</div>
</div>
</div>
</section>


<script type="text/javascript">
	function cmb_fil_caj_id_ori(ids)
	{	
		$.ajax({
			type: "POST",
			url: "../caja/cmb_caj_id.php",
			async:true,
			dataType: "html",                      
			data: ({
				caj_id: ids
			}),
			beforeSend: function() {
				$('#cmb_fil_caj_id_ori').html('<option value="">Cargando...</option>');
			},
			success: function(html){
				$('#cmb_fil_caj_id_ori').html(html);
			}
		});
	}	
	function cmb_fil_caj_id_des(ids)
	{	
		$.ajax({
			type: "POST",
			url: "../caja/cmb_caj_id_tra.php",
			async:true,
			dataType: "html",                      
			data: ({
				caj_id: ids,
				caj_id_ori: $('#cmb_fil_caj_id_ori').val()
			}),
			beforeSend: function() {
				$('#cmb_fil_caj_id_des').html('<option value="">Cargando...</option>');
			},
			success: function(html){
				$('#cmb_fil_caj_id_des').html(html);
			}
		});
	}
	$(function() {
		cmb_fil_caj_id_ori();
		$('#cmb_fil_caj_id_ori').change(function(){
			cmb_fil_caj_id_des(<?php echo $caj_id_des?>);
		});
		$('#txt_fil_tra_fec1, #txt_fil_tra_fec2').datepicker({
			format: 'dd-mm-yyyy',
			autoclose:true
		}).on('changeDate', function(e){
			transferencia_tabla();
		}); 
		
		$("#cmb_fil_caj_id_ori, #cmb_fil_caj_id_des").change(function()
		{
			transferencia_tabla();
		});
		transferencia_tabla();
	});
</script> 