<?php
session_start();
if($_SESSION["sistema"]!= "1"){ header("location: ../../index.php"); exit();}
require_once ("../../config/Cado.php");
?>
<style type="text/css">
select{
	cursor:pointer;
}
</style>
<div class="content-header" >
      <div class="container-fluid">
        <div class="row mb-2">
		 <div class="col-sm-6">
			<h1>
			Pisos
			<small>modulo</small>
			</h1>
		</div>	
		
		<div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
				<li class="breadcrumb-item" >Inicio</li>
				<li class="breadcrumb-item" >Mantenimiento</li>
				<li class="breadcrumb-item" >Sucursal</li>
				<li class="breadcrumb-item active">Piso</li>
            </ol>
          </div>
		</div>
	</div>
</div>
<section class="content">
	<div class="container-fluid">
	<div class="row">
	    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" style="padding:0px;" >
		    <div class="card">
		        <div class="card-header">
		          <button id="btn_actualizar" class="btn btn-default">Actualizar</button>		        
		        </div>
		    </div>
		</div>
	</div>
	</div>
</section>
			<!-- formulario de registro salon-->
			<div class="modal fade" id="div_salon_form_dialog" role="dialog" data-keyboard="true" tabindex="-1"  style="padding:0px;">
			<div class="modal-dialog modal-lg"  role="document" >
			<div class="modal-content">
			<div class="modal-body div_salon_form" >
			</div>
			<br />
			<br />
			</div>
			</div>
			</div>
			
			<!-- formulario de registro salon-->
			<div class="modal fade" id="div_cancha_form_dialog" role="dialog" data-keyboard="true" tabindex="-1"  style="padding:0px;">
			<div class="modal-dialog "  role="document" >
			<div class="modal-content">
			<div class="modal-body div_cancha_form" >
			</div>
			<br />
			<br />
			</div>
			</div>
			</div>
			
<!-- REGISTROS DEL SALON -->
<div id="div_salon_tabla"></div>
<!-- REGISTROS DE LA canchaS-->
<div id="div_cancha_tabla"></div>
<script type="text/javascript">
function piso_tabla()
	{	
		$.ajax({
			type: "POST",
			url: "../piso/piso_tabla.php",
			async:true,
			dataType: "html",                      
			data: ({
			//pro_est:	$('#cmb_fil_pro_est').val()
		}),
			beforeSend: function() {
				$('#div_salon_tabla').addClass("ui-state-disabled");
			},
			success: function(html){
				$('#div_salon_tabla').html(html);
			},
			complete: function(){			
				$('#div_salon_tabla').removeClass("ui-state-disabled");
				$('#div_cancha_tabla').hide();
			}
		});  
	}
	
	
	
	function cancha_tabla(idsalon,valor,label)
{	
	$.ajax({
		type: "POST",
		url: "../cancha/cancha_tabla_salon.php",
		async:true,
		dataType: "html", 
		data: ({
				pis_id: idsalon,
				titulo : label
			}),
		beforeSend: function() {
			$('#div_cancha_tabla').addClass("ui-state-disabled");
        },
		success: function(html){
			$('#div_cancha_tabla').html(html);
		},
		complete: function(){			
			$('#div_cancha_tabla').removeClass("ui-state-disabled");
			if(valor==1){
				$('#div_cancha_tabla').show();
			}			
		}
	});     
}	
	function cancha_form(act,idm,ids)
{
	//alert(idm+'-'+ids);
	$('#div_cancha_form_dialog').modal();
	$.ajax({
		type: "POST",
		url: "../cancha/cancha_form.php",
		async:true,
		dataType: "html",                      
		data: ({
			action: act,
			cancha_id :idm,
			salon_id:ids,
			vista:	'cancha_tabla'
		}),
		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_cancha_form').html(div);
        },
		success: function(html){
			$('.div_cancha_form').html(html);			
		}
	});
}
	
	function piso_form(act,idf)
	{
		
		$('#div_salon_form_dialog').modal();
		$.ajax({
			type: "POST",
			url: "../piso/piso_form.php",
			async:true,
			dataType: "html",                      
			data: ({
				action: act,
				salon_id:	idf,
				vista:	'salon_tabla'
			}),
			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_salon_form').html(div);
			},
			success: function(html){
				$('.div_salon_form').html(html);	
						
			}
		});
	}
	
		function eliminar_piso(id)
	{   
		$('#msj_salon').hide();   
		if(confirm("Realmente desea eliminar?")){
			$.ajax({
				type: "POST",
				url: "../piso/piso_reg.php",
				async:true,
				dataType: "html",
				data: ({
					action: "eliminar",
					piso_id:id
				}),
				beforeSend: function() {
					
				},
				success: function(html){
					toastr["success"](html);
				},
				complete: function(){
					salon_tabla();
				}
			});
		}
	}
	
	
		function eliminar_cancha(id,pis_id)
{   
	$('#msj_salon').hide();   
	if(confirm("Realmente desea eliminar?")){
		$.ajax({
			type: "POST",
			url: "../cancha/cancha_reg.php",
			async:true,
			dataType: "html",
			data: ({
				action: "eliminar",
				cancha_id:id
			}),
			beforeSend: function() {
				$('#msj_salon').html("Cargando...");
				$('#msj_salon').show(100);
			},
			success: function(html){
				$('#msj_salon').html(html);
			},
			complete: function(){
				cancha_tabla(pis_id);
			}
		});
	}
}
$(function() {
	$('#div_cancha_tabla').hide();
	piso_tabla();
	//cancha_tabla();
	
	$('#btn_actualizar').click(function() {
		$("#contenido").load("../piso/piso_vista.php");
	});
	
	setTitle("PISOS - "+nombreEmpresa);	
	
});
</script>