<div class="content-header" >
      <div class="container-fluid">
        <div class="row mb-2">
		 <div class="col-sm-6">
			<h1>
			Caja
			<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" >Caja</li>
				<li class="breadcrumb-item active">Caja</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="caja_form('insertar')" class="btn btn-primary">Agregar</button>
		          <button id="btn_actualizar" class="btn btn-default">Actualizar</button>		        
		        </div>
		    </div>
		</div>
	</div>
	</div>
</section>
<!-- formulario de registro -->
			<div class="modal fade" id="div_caja_form_dialog" role="dialog" data-keyboard="false" data-backdrop="static" tabindex="-1"  style="padding:0px;">
			<div class="modal-dialog "  role="document" >
			<div class="modal-content">
			<div class="modal-body div_caja_form" >
			</div>
			<br />
			<br />
			</div>
			</div>
			</div>
			
		<!-- tabla de registros -->	
<div id="div_caja_filtro"></div>
<div id="div_caja_tabla"></div>
<script type="text/javascript">


function caja_filtro(){			
	$.ajax({						
		url: "../caja/caja_filtro.php",
		async:true,
		dataType: "html",                      
		data: ({
		}),
		beforeSend: function() {
			$('#div_caja_filtro').addClass("ui-state-disabled");
        },
		success: function(html){
			$('#div_caja_filtro').html(html);
		},
		complete: function(){			
			$('#div_caja_filtro').removeClass("ui-state-disabled");
			//cliente_tabla();
		}
	});        
}


function caja_tabla()
{	
	$.ajax({
		type: "POST",
		url: "../caja/caja_tabla.php",
		async:true,
		dataType: "html",                      
		data: ({
			punven_id:	$('#cmb_fil_puntoventa_id').val()
		}),
		beforeSend: function() {
			$('#div_caja_tabla').addClass("ui-state-disabled");
        },
		success: function(html){
			$('#div_caja_tabla').html(html);
		},
		complete: function(){			
			$('#div_caja_tabla').removeClass("ui-state-disabled");
		}
	});     
}
function caja_form(act,idf){
	$('#div_caja_form_dialog').modal();
	$.ajax({
		type: "POST",
		url: "../caja/caja_form.php",
		async:true,
		dataType: "html",                      
		data: ({
			action: act,
			caj_id:	idf,
			vista:	'caja_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_caja_form').html(div);	
        },
		success: function(html){
			$('.div_caja_form').html(html);		
		}
	});
}
function eliminar_caja(id)
{   
	$('#msj_caja').hide();   
	if(confirm("Realmente desea eliminar?")){
		$.ajax({
			type: "POST",
			url: "../caja/caja_reg.php",
			async:true,
			dataType: "html",
			data: ({
				action: "eliminar",
				caj_id:		id
			}),
			beforeSend: function() {
				
			},
			success: function(html){
				toastr["success"](html);
			},
			complete: function(){
				caja_tabla();
			}
		});
	}
}
$(function() {
	
	$('#btn_actualizar').click(function() {
		$("#contenido").load("../caja/caja_vista.php");
	});
	caja_filtro();
	setTitle("CAJA - "+nombreEmpresa);
	
});
</script>