<?php
ob_start();
session_start();

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

if($_SESSION['ingreso']==1 and $_SESSION['nombrecargo']=='Administrador'){

?>

            <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="list.php">
                                                <i class="module-icon"></i> Egresos
                                            </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>
                                            Listado de Egresos
                                        </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-3">
                                                <br>
                                                <button  type="button" class="btn btn-danger  btn-flat" data-toggle="modal" data-target="#modalEgreso">
                                                <span class="fa fa-plus"></span>&nbsp;&nbsp;Registro Egreso
                                                </button>  
                                                </div>
                                                <div class="col-12 col-sm-12 col-md-2">
                                                    <div class="form-group">
                                                        <br>
                                                        <input name="fecha_inicial" id="fecha_inicial" class="form-control" type="date" required>
                                                    </div>
                                                </div>
                                                <div class="col-12 col-sm-12 col-md-2">
                                                    <div class="form-group">
                                                        <br>
                                                        <input name="fecha_final" id="fecha_final" class="form-control" type="date" required>
                                                    </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()"> <i class="fa-solid fa-magnifying-glass"></i> Consultar Pagos</button>
                                                </div>
                                                <div class="card-body" style="display: block;">
                                                    <div class="container-fluid">
                                                        <table style="width:100%;" class="table table-bordered" id="egreso">
                                                            <thead>
                                                            <tr>
                                                            <th>Tipo Egreso</th>
                                                            <th>Concepto</th>
                                                            <th>Monto</th>
                                                            <th>Banco</th>                            
                                                            <th>Nro Operacion</th>
                                                            <th>Descripcion</th>
                                                            <th>Comprobante</th>
                                                            <th>Nro Recibo</th>
                                                            <th>Fecha Pago</th>
                                                            </tr>
                                                            </thead>
                                                            <tbody>
                                                            </tbody>
                                                        </table>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </section>                
                    </div>
               
            <?php
}else if (($_SESSION['ingreso']==1 or $_SESSION['averia']==1) and $_SESSION['nombrecargo']!=='Administrador' ){
    ?>

    <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="list.php">
                                                <i class="module-icon"></i> Egresos
                                            </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>
                                            Listado de Egresos
                                        </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-3">
                                                <br>
                                                <button  type="button" class="btn btn-danger  btn-flat" data-toggle="modal" data-target="#modalEgreso">
                                                <span class="fa fa-plus"></span>&nbsp;&nbsp;Registro Egreso
                                                </button>  
                                                </div>
                                                <div class="col-12 col-sm-12 col-md-2">
                                                    <div class="form-group">
                                                        <br>
                                                        <input name="fecha_inicial" id="fecha_inicial" class="form-control" type="date" required>
                                                    </div>
                                                </div>
                                                <div class="col-12 col-sm-12 col-md-2">
                                                    <div class="form-group">
                                                        <br>
                                                        <input name="fecha_final" id="fecha_final" class="form-control" type="date" required>
                                                    </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_por_usuario()"> <i class="fa-solid fa-magnifying-glass"></i> Consultar Pagos</button>
                                                </div>
                                                <div class="card-body" style="display: block;">
                                                    <div class="container-fluid">
                                                        <table style="width:100%;" class="table table-bordered" id="egreso_usuario">
                                                            <thead>
                                                            <tr>
                                                            <th>Tipo Egreso</th>
                                                            <th>Responsable</th>
                                                            <th>Concepto</th>
                                                            <th>Monto</th>
                                                            <th>Banco</th>                            
                                                            <th>Nro Operacion</th>
                                                            <th>Descripcion</th>
                                                            <th>Comprobante</th>
                                                            <th>Nro Recibo</th>
                                                            <th>Fecha Pago</th>
                                                            </tr>
                                                            </thead>
                                                            <tbody>
                                                            </tbody>
                                                        </table>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </section>                
                    </div>

<?php
}
require '../footer.php';
?>
<script type="text/javascript" src="../../scripts/control_egreso.js"></script>
<?php 
}
ob_end_flush();
?>