<?php
session_start();
date_default_timezone_set('America/Lima');
	$y = $anio=date('Y');
	$m=date('m');
	$d=date('d');
	if($_SESSION['usuariogrupo_id']==1 || $_SESSION['usuariogrupo_id']==2){
		
	}
	else{
 	$punven_id = $_SESSION['cancha_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-12">
		    <div class="card">
		        <div class="card-header">
    		
			<?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-2 col-6">
													<label for="cmb_fil_mes">Mes:</label>
												
													<select name="cmb_fil_mes" id="cmb_fil_mes" class="form-control">
												
												
														<option value="01" <?php if($mes=="01") echo"selected";  ?> >Enero</option>
													    <option value="02" <?php if($mes=="02") echo"selected";  ?> >Febrero</option>
														<option value="03" <?php if($mes=="03") echo"selected";  ?> >Marzo</option>
														<option value="04" <?php if($mes=="04") echo"selected";  ?> >Abril</option>
													    <option value="05" <?php if($mes=="05") echo"selected";  ?> >Mayo</option>
														<option value="06" <?php if($mes=="06") echo"selected";  ?> >Junio</option>
														<option value="07" <?php if($mes=="07") echo"selected";  ?> >Julio</option>
													    <option value="08" <?php if($mes=="08") echo"selected";  ?> >Agosto</option>
														<option value="09" <?php if($mes=="09") echo"selected";  ?> >Septiembre</option>
														<option value="10" <?php if($mes=="10") echo"selected";  ?> >Octubre</option>
													    <option value="11" <?php if($mes=="11") echo"selected";  ?> >Noviembre</option>
														<option value="12" <?php if($mes=="12") echo"selected";  ?> >Diciembre</option>
																
													</select>
																									
							</div>
							
							
							<div class="col-lg-2 col-sm-2 col-6">
								<label for="cmb_fil_anio">Año:</label>
												
								<select name="cmb_fil_anio" id="cmb_fil_anio" class="form-control">
																			<?php  
										for($i=2022;$i<= $anio+2 ;$i++){				
										?>
									<option value="<?php echo $i;?>"  <?php if($i==$anio) echo 'selected'; ?> ><?php echo $i;?></option>
										<?php
										}
										?>
								</select>
												
						</div>	
			
			
			<div class="col-lg-3 col-sm-2 col-6">				
				<label for="cmb_fil_cancha_id">Campo:</label>
				<select name="cmb_fil_cancha_id" id="cmb_fil_cancha_id" class="form-control ">
				</select>
													
			</div>
							
                 <div class="col-lg-2 col-sm-2 col-6" style="padding-top: 30px;display: inline-block; white-space: nowrap;" >
				    <span  onClick="reserva_tabla()"  style="cursor:pointer"  class="btn btn-primary"><i class="fas fa-search"></i></span>
					<span  onClick="reserva_filtro()" style="cursor:pointer" class="btn btn-default">Restablecer</span>
				</div>
				
				<div class="col-lg-2 col-sm-3 col-6" style="display: inline-block; white-space: nowrap;padding-top:30px;" >
						<span class="btn btn-sm btn-success" id="btn_excel"> <i class="fas fa-file-excel"></i> DESCARGAR EXCEL </span>
				</div>
						
						
				
				</div>
				
				</form>
           
		   
        </div>
      </div>
    </div>
  </div>
  </div>
</section> 
<script type="text/javascript">


function abrirEnPestana(url) {
		var a = document.createElement("a");
		a.target = "_blank";
		a.href = url;
		a.click();
}


$("#btn_excel").click(function(){
		mes = $('#cmb_fil_mes').val();
		anio = $('#cmb_fil_anio').val();
		can_id = $('#cmb_fil_cancha_id').val();
	abrirEnPestana('../../files/reserva/reserva_excel.php?mes='+mes+'&anio='+anio+'&can_id='+can_id);
});


	cmb_fil_cancha_id(<?php echo $can_id; ?>);
	
function cmb_fil_cancha_id(can_id){
		$.ajax({
 					type: "POST",
 					url: "../cancha/cmb_cancha_id.php",
 					async:true,
 					dataType: "html",                      
 					data: ({						
 						emp_id:'',
						can_id :can_id,
 						vista:	''
 					}),
 					beforeSend: function() {
 						$('#cmb_fil_cancha_id').html('<option value="">Cargando...</option>');
 					},
 					success: function(html){			
 						$('#cmb_fil_cancha_id').html(html);
 					},
 					complete: function(){
 						reserva_tabla();
 						}
 					});
}


</script>