<?php
require_once ("../../config/Cado.php");

require_once ("../cancha/cCancha.php");
$oCancha = new cCancha();

$datos=$oCancha->mostrarUno($_POST['cancha_id']);
$num_rows= mysqli_num_rows($datos);
$dt1 = mysqli_fetch_array($datos);
$can_nom = $dt1['tb_cancha_nom'];

?>

	<div class="col-lg-12 col-sm-12 col-md-12 col-12">
	

	<div class="modal-header">
		<h4 class="modal-title" id="titlemodal">RESERVAS - <strong><?php echo $can_nom.' '; ?></strong> </h4> 
		<span class="btn btn-sm btn-primary " onclick="separarcampo_form('insertar',<?php echo $_POST['cancha_id']; ?>);" style="margin-left:10px;" >Reservar campo</span>
	</div>

	
	<div class="box-body">
		<div  id="contenedor_base_canchaposcalendar" ></div>	
		
	</div>	
	<div class="box-footer  float-right d-none">
		<button type="button" data-dismiss="modal" class="btn btn-default cancel">Cancelar</button>
	</div>
	
	</div>





<script type="text/javascript">

function separarcampo_form(act,idf){
		
	
		$('#div_canchapos_form').modal();
	
		$.ajax({
			type: "POST",
			url: "../canchapos/canchapos_form.php",
			async:true,
			dataType: "html",                      
			data: ({
				action: act,
				cancha_id:	idf
			}),
			beforeSend: function() {
				var div = "<center> <br> <span class='spinner-border spinner-border-lg mr-2'></span> <span style='font-size:1.5rem;'>PROCESANDO PETICIÓN</span></center>";	
					
				$('.div_canchapos_form2').html(div); 
			},
			success: function(html){
				$('.div_canchapos_form2').html(html);	
			},
			complete: function(){
			}
		});
	}

	
function canchapos_form_calendar(cancha_id){
		
				
			$.ajax({
				type: "POST",
				url: "../canchapos/calendar.php",
				async:true,
				dataType: "html",                      
				data: ({
					action : "insertar",
					cancha_id:cancha_id
				}),
				beforeSend: function() {
					//var div = "<center> <br> <span class='spinner-border spinner-border-lg mr-2'></span> <span style='font-size:1.5rem;'>PROCESANDO PETICIÓN</span></center>";	
					//$('#contenedor_base_canchaposcalendar').html(div);
					$('#contenedor_base_canchaposcalendar').addClass("ui-state-disabled");
					
				},
				success: function(html){
					$('#contenedor_base_canchaposcalendar').html(html);				
				},
				complete: function(){			
					$('#contenedor_base_canchaposcalendar').removeClass("ui-state-disabled");
				}
			});
		}
		
		

 $(function () {

setTimeout(function(){
    canchapos_form_calendar('<?php echo $_POST['cancha_id']; ?>');
}, 500);

 // canchapos_form_calendar();

  });

</script>
	