<?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_mesa_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_mesa_form" >
			</div>
			<br />
			<br />
			</div>
			</div>
			</div>
			
<!-- REGISTROS DEL SALON -->
<div id="div_salon_tabla"></div>
<!-- REGISTROS DE LA MESAS-->
<div id="div_mesa_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_mesa_tabla').hide();
			}
		});  
	}
	
	
	
	function mesa_tabla(idsalon,valor,label)
{	
	$.ajax({
		type: "POST",
		url: "../mesa/mesa_tabla_salon.php",
		async:true,
		dataType: "html", 
		data: ({
				cmb_fil_salon_id: idsalon,
				titulo : label
			}),
		beforeSend: function() {
			$('#div_mesa_tabla').addClass("ui-state-disabled");
        },
		success: function(html){
			$('#div_mesa_tabla').html(html);
		},
		complete: function(){			
			$('#div_mesa_tabla').removeClass("ui-state-disabled");
			if(valor==1){
				$('#div_mesa_tabla').show();
			}			
		}
	});     
}	
	function mesa_form(act,idm,ids)
{
	//alert(idm+'-'+ids);
	$('#div_mesa_form_dialog').modal();
	$.ajax({
		type: "POST",
		url: "../mesa/mesa_form.php",
		async:true,
		dataType: "html",                      
		data: ({
			action: act,
			mesa_id :idm,
			salon_id:ids,
			vista:	'mesa_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_mesa_form').html(div);
        },
		success: function(html){
			$('.div_mesa_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_mesa(id)
{   
	$('#msj_salon').hide();   
	if(confirm("Realmente desea eliminar?")){
		$.ajax({
			type: "POST",
			url: "../mesa/mesa_reg.php",
			async:true,
			dataType: "html",
			data: ({
				action: "eliminar",
				mesa_id:id
			}),
			beforeSend: function() {
				$('#msj_salon').html("Cargando...");
				$('#msj_salon').show(100);
			},
			success: function(html){
				$('#msj_salon').html(html);
			},
			complete: function(){
				mesa_tabla();
			}
		});
	}
}
$(function() {
	$('#div_mesa_tabla').hide();
	piso_tabla();
	//mesa_tabla();
	
	$('#btn_actualizar').click(function() {
		$("#contenido").load("../piso/piso_vista.php");
	});
	
	setTitle("PISOS - "+nombreEmpresa);	
	
});
</script>