<?php
session_start(); 
require_once ("../../config/Cado.php");
$anio=date('Y');
$caj_id=1;
?>
<style type="text/css">
	.ui-autocomplete {
		z-index: 5000;
	}
	select{
		cursor:pointer;
	}
</style>
<div class="content-header" >
      <div class="container-fluid">
        <div class="row mb-2">
		 <div class="col-sm-6">
			<h1>
			Flujo de 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" >Caja</li>
				<li class="breadcrumb-item active">Flujo de 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">
				
					<span onClick="ingreso_form('insertar')" style="cursor:pointer" class="btn btn-primary" title="Registrar nuevo ingreso" > INGRESO</span>
					<span onClick="egreso_form('insertar')" style="cursor:pointer" class="btn btn-danger " title="Registrar nuevo egreso" > EGRESO</span>
					<!--
					<span onClick="transferencia_form('insertar')" style="cursor:pointer" class="btn btn-success "> TRANSFERENCIA</span>	
					-->
					<span id="btn_actualizar" style="cursor:pointer" class="btn btn-default  float-right">Actualizar</span>
					        
		        </div>
		    </div>
		</div>
	</div>
	</div>
</section>

<a id="" href="#" class="back-to-top" style="z-index:9999;" role="button" aria-label="Scroll to top">
    <input id="chkcajre" type="checkbox" checked data-toggle="toggle" style=""
           data-on="REGISTRO"
           data-off="RESUMEN" data-onstyle="warning" data-offstyle="primary" data-size="normal" >
</a>


<div class="container-fluid">
    <div class="row">

        <div class="col-lg-12 col-sm-12 col-xs-12" id="contenedor_caja_registro" ></div>
        <div class="col-lg-12 col-sm-12 col-xs-12" id="contenedor_caja_resumen" ></div>

    </div>
</div>


	<div class="modal fade" id="div_egreso_form_dialog2" role="dialog" data-keyboard="false" data-backdrop="static" tabindex="-1"  style="padding:0px;">
			<div class="modal-dialog modal-md"  role="document" >
			<div class="modal-content">
			<div class="modal-body div_egreso_form2" style="padding:0%;" >
			</div>
			<br />
			<br />
			</div>
			</div>
			</div>
			
			<!-- formulario de ingresos -->
			<div class="modal fade" id="div_ingreso_form_dialog2" role="dialog" data-keyboard="false" data-backdrop="static" tabindex="-1"  style="padding:0px;">
			<div class="modal-dialog modal-md"  role="document" >
			<div class="modal-content">
			<div class="modal-body div_ingreso_form2" style="padding:0%;" >
			</div>
			<br />
			<br />
			</div>
			</div>
			</div>
			


			

<script type="text/javascript">

	function flujocaja_registro()
	{
		$.ajax({
			type: "POST",
			url: "../flujocaja/flujocaja_registro.php",
			async:true,
			dataType: "html",                      
			data: ({
			}),
			beforeSend: function() {
				
			},
			success: function(html){
				$('#contenedor_caja_registro').html(html);
			},
			complete: function(){
				
			}
		});
	}
	
	
	function flujocaja_resumen()
	{
		$.ajax({
			type: "POST",
			url: "../flujocaja/flujocaja_resumen.php",
			async:true,
			dataType: "html",                      
			data: ({
			}),
			beforeSend: function() {
				
			},
			success: function(html){
				$('#contenedor_caja_resumen').html(html);
			},
			complete: function(){
				
			}
		});
	}	
	
	
	
	function egreso_form(act,idf)
	{
		$('#div_egreso_form_dialog2').modal(); 
		$.ajax({
			type: "POST",
			url: "../egreso/egreso_form.php",
			async:true,
			dataType: "html",                      
			data: ({
				action: act,
				egr_id:	idf,
				vista: 'egreso_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_egreso_form2').html(div); 
				
			},
			success: function(html){
				$('.div_egreso_form2').html(html);				
			}
		});
	}
	
	function ingreso_form(act,idf)
	{
		$('#div_ingreso_form_dialog2').modal(); 
		$.ajax({
			type: "POST",
			url: "../ingreso/ingreso_form.php",
			async:true,
			dataType: "html",                      
			data: ({
				action: act,
				ing_id:	idf,
				vista: 'ingreso_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_ingreso_form2').html(div);
			},
			success: function(html){
			$('.div_ingreso_form2').html(html);				
			}
		});
	}
	
	
	
	
	$(function() {


        $('#chkcajre').bootstrapToggle();


        $('#chkcajre').change(function() {
            if($(this).prop('checked')==true){

                $('#contenedor_caja_registro').show('fade');
                $('#contenedor_caja_resumen').hide('fade');
				flujocaja_registro();

            }else if($(this).prop('checked')==false){

                $('#contenedor_caja_registro').hide('fade');
                $('#contenedor_caja_resumen').show('fade');
                flujocaja_resumen();

            }
        });

flujocaja_registro();


        $('#btn_actualizar').click(function() {
			$("#contenido").load("../flujocaja/flujocaja_vista.php");
		});
		setTitle("FLUJO DE CAJA - "+nombreEmpresa);	
		
	});
</script> 