<?php 
session_start();
 if($_SESSION['usuariogrupo_id']!=1){
	 ?>
<div class="content-header" >
      <div class="container-fluid">
        <div class="row mb-2">
		 <div class="col-sm-6">
			<h1>
			Talonarios
			<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" >General</li>
				<li class="breadcrumb-item active">Talonarios</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">
		    <div class="card">
		        <div class="card-header">
		         <strong>USTED NO TIENE PERMISOS PARA VER ESTA PAGINA</strong>       
		        </div>
		    </div>
		</div>
	</div>
	</div>
</section>

	 <?php 
 }
 else{
?>

<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>
			Talonarios
			<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" >General</li>
				<li class="breadcrumb-item active">Talonarios</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_agregar" onClick="talonario_form('insertar')" class="btn btn-primary">Agregar</button>
		          <button id="btn_actualizar" class="btn btn-default">Actualizar</button>		        
		        </div>
		    </div>
		</div>
	</div>
	</div>
</section>

		
		<!-- Filtro deregistros -->
		<div id="div_talonario_filtro"></div>
		<!-- tabla de registros -->	
		<div id="div_talonario_tabla" ></div>	

		<!-- formulario de registro -->
			<div class="modal fade" id="div_talonario_form_dialog" role="dialog" data-keyboard="false" data-backdrop="static"  tabindex="-1"  style="padding:0px;">
			<div class="modal-dialog modal-lg" style="width: 90% !important;" role="document" >

			<div class="modal-content">

			<div class="modal-body div_talonario_form" >

			</div>
			<br />
			<br />
			</div>
			</div>
			</div>
			
		


<script type="text/javascript">

function talonario_filtro(){	
		$('#div_talonario_filtro').show();
 			$.ajax({						
 				url: "../talonario/talonario_filtro.php",
 				async:true,
 				dataType: "html",                      
 				data: ({
 				}),
 				beforeSend: function() {
 					$('#div_talonario_filtro').addClass("ui-state-disabled");
 				},
 				success: function(html){
 					$('#div_talonario_filtro').html(html);
 				},
 				complete: function(){			
 					$('#div_talonario_filtro').removeClass("ui-state-disabled");
 					
 				}
 			});        
 		}
 		function talonario_tabla()
 		{	
 			$.ajax({
 				type: "POST",
 				url: "../talonario/talonario_tabla.php",
 				async:true,
 				dataType: "html",                      
 				data: $("#for_fil_tal").serialize(),
 				beforeSend: function() {
 					$('#div_talonario_tabla').addClass("ui-state-disabled");
 				},
 				success: function(html){
 					$('#div_talonario_tabla').html(html);
 				},
 				complete: function(){			
 					$('#div_talonario_tabla').removeClass("ui-state-disabled");
 				}
 			});     
 		}
function talonario_form(act,idf){
	$('#div_talonario_form_dialog').modal();
	$.ajax({
		type: "POST",
		url: "../talonario/talonario_form.php",
		async:true,
		dataType: "html",                      
		data: ({
			action: act,
			tal_id:	idf,
			vista:	'talonario_tabla'
		}),
		beforeSend: function() {
			var div = "<center><div class='overlay col-lg-12 col-sm-12 col-xs-12' style='background-color:#fff;padding:0%;font-size:3rem;' >  <i class='fa fa-refresh fa-spin ' ></i> </div>  </center>";	
			$('.div_talonario_form').html(div);	
        },
		success: function(html){
			$('.div_talonario_form').html(html);
	
		}
	});
}

function eliminar_talonario(id)
{      
	if(confirm("Realmente desea eliminar?")){
		$.ajax({
			type: "POST",
			url: "../talonario/talonario_reg.php",
			async:true,
			dataType: "html",
			data: ({
				action: "eliminar",
				id:id
			}),
			beforeSend: function() {
				
			},
			success: function(html){
				toastr["success"](html);	
			},
			complete: function(){
				talonario_tabla();
			}
		});
	}
}

$(function() {
	
	$('#btn_actualizar').click(function() {
		$("#contenido").load("../talonario/talonario_vista.php");
	});
	
	/* $("#div_talonario_form_dialog").on('hidden.bs.modal', function(){
          	$("#content").load("../talonario/talonario_vista.php");
	});
	*/	
	
	talonario_filtro();
		setTitle("TALONARIO - "+nombreEmpresa);
	
});
</script>
 <?php } ?>