<?php
ob_start();
session_start();

if (!isset($_SESSION["nombre"]))
{
  header("Location: index.php");
}
else
{
    require '../header.php';

if($_SESSION['finanzas']==1){

      $idcierre=$_GET['idcierre'];
?>




            <div class="content-wrapper">
                <!-- Breadcrumb Section -->
                <section class="content-header">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-sm-12">
                                <nav aria-label="breadcrumb">
                                    <ol class="breadcrumb">
                                        <li class="breadcrumb-item">
                                            <a href="#"><i class="fas fa-home"></i> Panel</a>
                                        </li>
                                        <li class="breadcrumb-item active" aria-current="page">
                                            <a href="cajas_cerrada.php">
                                                <i class="module-icon"></i> Cajas Cerradas
                                            </a>
                                        </li>
                                    </ol>
                                </nav>
                            </div>
                          
                            <div class="col-sm-12" style="margin-top: 20px;">
                                <div class="card">
                                    <div class="card-header bg-primary">
                                        <h3 class="card-title">
                                            <i class="fas fa-search"></i>
                                            Caja Cerrada
                                        </h3>
                                    </div>
                                    <div class="card-body" style="display: block;">
                                        <div class="container-fluid">
                                            <div class="row">
                                                <div class="col-12 col-sm-12 col-md-4">
                                                </div>
                                                <div class="col-12 col-sm-12 col-md-2">
                                                        <div class="form-group">
                                                            <br>
                                                            <input type="hidden" name="idcierre" id="idcierre" value="<?php echo $idcierre ?>" ></input>
                                                               <select class="form-control select2" name="tipopago" id='tipopago' data-placeholder="Seleccione Ingreso"   style="width: 100%;">
                                                                        <option value="">Seleccione Tipo Pago</option> 
                                                                        <option value="2">Efectivo</option> 
                                                                        <option value="3">Deposito</option>                    
                                                                </select>
                                                        </div>
                                                </div>
                                                 <div class="form-group col-lg-3 col-md-3 col-sm-3 col-xs-12">
                                                        <br>
                                                        <button class="btn btn-success btn-flat " style="margin-bottom:-10px" onclick="listar_caja_cerrada(event)"><i class="fas fa-save"></i> Consultar Caja</button>
                                                        <button class="btn btn-primary btn-flat " style="margin-bottom:-10px" onclick="generarExcel()"><i class="fa fa-table"></i> Excel</button>
                                                </div>
                                                <br>
                                                 </div>  
                                               
                                                    <div class="d-flex justify-content-end flex-column align-items-end mb-2">
                                                    <strong class="box-title" id="fecha_apertura">Fecha Apertura</strong>
                                                    <strong class="box-title" id="fecha_cierre">Fecha Cierre Caja</strong>
                                                    <strong class="box-title" id="correlativo_caja">Nro Correlativo Caja</strong>
                                                    </div>
                                                    <h4>Ingresos</h4>
                                                    <div class="text-center font-weight-bold border py-2 mb-2 bg-light" id="nombre_usuario">
                                                        Usuario Responsable
                                                    </div>
                                                    <table class="table table-bordered" id="tabla_ingresos">
                                                    <thead class="thead-light">
                                                        <tr>
                                                        <th>#</th>
                                                        <th>Tipo Pago</th>
                                                        <th>Fecha Pago</th>
                                                        <th>Nombre/Razón Social</th>
                                                        <th>Servicio</th>
                                                        <th>Banco</th>
                                                        <th>Nro Operación</th>
                                                        <th>Nro Comprobante</th>
                                                        <th>Importe (S/)</th>
                                                        </tr>
                                                    </thead>
                                                    <tbody id="tbody_ingresos">
                                                        <!-- filas dinamicas con PHP o JS -->
                                                    </tbody>
                                                    <tfoot>
                                                        <tr>
                                                        <td colspan="8" class="text-right font-weight-bold">Total Ingreso:</td>
                                                        <td class="font-weight-bold" id="total_ingreso">S/ 0.00</td>
                                                        </tr>
                                                    </tfoot>
                                                    </table>

                                                    <!-- EGRESOS -->
                                                    <h4>Egresos</h4>
                                                    <table class="table table-bordered" id="tabla_egresos">
                                                    <thead class="thead-light">
                                                        <tr>
                                                        <th>#</th>
                                                        <th>Tipo Pago</th>
                                                        <th>Fecha Pago</th>
                                                        <th>Tipo Costo</th>
                                                        <th>Clasificador de Gasto</th>
                                                        <th>Detalle Gasto</th>
                                                        <th>Comprobante</th>
                                                        <th>Nro Comprobante</th>
                                                        <th>Importe (S/)</th>
                                                        </tr>
                                                    </thead>
                                                    <tbody id="tbody_egresos">
                                                        <!-- filas dinamicas con PHP o JS -->
                                                    </tbody>
                                                    <tfoot>
                                                        <tr>
                                                        <td colspan="8" class="text-right font-weight-bold">Total Egreso:</td>
                                                        <td class="font-weight-bold" id="total_egreso">S/ 0.00</td>
                                                        </tr>
                                                    </tfoot>
                                                    </table>

                                                    <!-- RESUMEN DE CAJA -->
                                                    <h4>Resumen de Caja</h4>
                                                    <table class="table table-striped table-bordered">
                                                    <tbody>
                                                        <tr>
                                                        <td id="apertura"></td>
                                                        <td class="text-right"><span id="apertura_caja"></span></td>
                                                        </tr>
                                                        <tr>
                                                        <td id="ingreso"></td>
                                                        <td class="text-right"><span id="total_ingresos"></span></td>
                                                        </tr>
                                                        <tr>
                                                        <td id="egreso"></td>
                                                        <td class="text-right"><span id="total_egresos"></span></td>
                                                        </tr>
                                                        <tr>
                                                        <tr class="table-success font-weight-bold">
                                                        <td>TOTAL EFECTIVO</td>
                                                        <td class="text-right"><span id="total_final_efectivo"></span></td>
                                                        </tr>
                                                        <tr class="table-success font-weight-bold">
                                                        <td>TOTAL TRANSFERENCIA</td>
                                                        <td class="text-right"><span id="total_final_transferencia"></span></td>
                                                        </tr>
                                                    </tbody>
                                                    </table>
                                                 
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </section>                
            </div>


               
<?php
}
require '../footer.php';
?>
<script src="https://cdn.jsdelivr.net/npm/exceljs/dist/exceljs.min.js"></script>
<script type="text/javascript" src="../../scripts/finanza.js"></script>

<?php 
}
ob_end_flush();
?>