<?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> Ingresos
                                            </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 Pagos
                                        </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="#modalIngreso">
                                                <span class="fa fa-plus"></span>&nbsp;&nbsp;Registro Ingreso
                                                </button>  
                                            </div>
                                                <div class="col-12 col-sm-12 col-md-2">
                                                    <div class="form-group">
                                                        <br>
                                                        <input name="fecha_inicio" id="fecha_inicio" 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_fin" id="fecha_fin" 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_administrador()"> <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="producto">
                                                            <thead>
                                                            <tr>
                                                            <th>Tipo Ingreso</th>
                                                            <th>Responsable</th>
                                                            <th>Cliente</th>
                                                            <th>Monto Pagado</th>                            
                                                            <th>Nro Recibo</th>
                                                            <th>Nro Operacion</th>
                                                            <th>Descripcion</th>
                                                            <th>Fecha Pago</th>
                                                            </tr>
                                                            </thead>
                                                            <tbody>
                                                            </tbody>
                                                        </table>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </section>                
                    </div>
  <div class="modal fade" id="modalIngreso" tabindex="-1" role="dialog" aria-labelledby="modalLabel" aria-hidden="true">
                <div class="modal-dialog modal-xl" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h5 class="modal-title" id="modalLabel">Regitro Ingreso</h5>
                            <button type="button" class="close" data-dismiss="modal" aria-label="Cerrar">
                                <span >&times;</span>
                            </button>
                        </div>
                        <form id="formRegistroIngreso">
                            <div class="modal-body">
                                <!-- Campo para mostrar el dato -->
                                 <input type="hidden" name="idingreso" id="idingreso">
                                 <div class="row">
                                    <div class="col-12 col-sm-12 col-md-4">
                                        <div class="form-group">
                                        <label >Seleccione Ingreso:</label>
                                        <select class="form-control select" name="idcategoria_ingreso" id="idcategoria_ingreso" required>                                        
                                        </select>
                                        </div>
                                    </div>
                                    <div class="col-12 col-sm-12 col-md-4">
                                        <div class="form-group">
                                        <label >Tipo Trabajo:</label>
                                        <select class="form-control select" name="idconcepto_ingreso" id="idconcepto_ingreso" required>  
                                            <option value="">Seleccione una Concepto</option>                                      
                                        </select>
                                        </div>
                                    </div>
                                    <div class="col-12 col-sm-12 col-md-4">
                                        <div class="form-group">
                                        <label >Seleccione Cliente:</label>
                                        <select class="form-control select" name="idpersona" id="idpersona" required>                                        
                                        </select>
                                        </div>
                                    </div>
                                    <div class="col-12 col-sm-12 col-md-3">
                                    </div> 
                                    <div class="col-12 col-sm-12 col-md-6">
                                        <br>
                                        <div class="form-group">
                                        <label>Forma de Pago:</label>&nbsp;&nbsp;&nbsp;
                                        <input  type="radio" checked  name="tipopago" id="radioEfectivo" onclick="mostrarOcultarCampos()" value="2"><label>&nbsp;EFECTIVO</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;             
                                        <input  type="radio"  name="tipopago" id="radioDeposito" onclick="mostrarOcultarCampos()" value="3"><label>&nbsp;DEPOSITO</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                        </div> 
                                    </div> 
                                    <div class="col-12 col-sm-12 col-md-6" id="campoBanco" style="display: none;">
                                        <div class="form-group">
                                            <label>Banco:</label>
                                            <select name="idbanco" id="idbanco" class="form-control select2" data-live-search="true" data-style="btn-default" >
                                            </select>
                                        </div>
                                    </div>
                                    <div class="col-12 col-sm-6 col-md-6" id="campoOperacion" style="display: none;">
                                        <div class="form-group">
                                            <label>Numero Operacion:</label>
                                            <input type="text" class="form-control" name="nro_operacion" id="nro_operacion" placeholder="Nro Operacion">
                                        </div>
                                    </div>
                                    <div class="col-12 col-sm-6 col-md-6">
                                        <div class="form-group">
                                            <label>Hora:</label>
                                            <input  type="time" name="hora" id="hora" class="form-control" value="<?php echo date("H:i")?>" > </input> 
                                        </div>
                                    </div>
                                    <div class="col-12 col-sm-6 col-md-6">
                                        <div class="form-group">
                                            <label>Fecha Pago:</label>
                                            <input  type="date" name="fechapago" id="fechapago" class="form-control" value="<?php echo date("Y-m-d")?>" > </input> 
                                        </div>
                                    </div>
                                    <div class="col-12 col-sm-6 col-md-6">
                                        <div class="form-group">
                                            <label>Monto:</label>
                                            <input type="number" step="0.01" class="form-control" name="monto" id="monto"  placeholder="Monto" >
                                        </div>
                                    </div>
                                    <div class="col-12 col-sm-6 col-md-6">
                                        <div class="form-group">
                                            <label>Comprobante:</label>
                                            <select class="form-control" name="comprobante" id="comprobante">
                                                <option value="">Seleccione Comprobante</option>
                                                <option value="1">Recibo Egreso </option>
                                                <option value="2">Boleta </option>
                                                <option value="3">Factura </option>
                                            </select> 
                                        </div>
                                    </div>
                                    <div class="col-12 col-sm-6 col-md-12">
                                        <div class="form-group">
                                            <label>Nro Recibo:</label>
                                            <input  type="text" name="nrorecibo" id="nrorecibo" class="form-control" placeholder="Nro recibo"> </input> 
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-danger btn-flat" data-dismiss="modal" id="btnGuardar"> <i class="fas fa-times"></i> Cancelar</button>
                                <button type="submit" id="btn_Ingreso" class="btn btn-primary btn-flat"> <i class="fas fa-save"></i> Guardar Ingreso</button>
                            </div>
                        </form>
                    </div>
                </div>
            </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> Ingresos
                                            </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 Pagos
                                        </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="#modalIngreso">
                                                <span class="fa fa-plus"></span>&nbsp;&nbsp;Registro Ingreso
                                                </button>  
                                            </div>
                                                <div class="col-12 col-sm-12 col-md-2">
                                                    <div class="form-group">
                                                        <br>
                                                        <input name="fecha_inicio" id="fecha_inicio" 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_fin" id="fecha_fin" 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_fecha_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="ingreso_usuario">
                                                            <thead>
                                                            <tr>
                                                            <th>Tipo Ingreso</th>
                                                            <th>Responsable</th>
                                                            <th>Cliente</th>
                                                            <th>Monto Pagado</th>                            
                                                            <th>Nro Recibo</th>
                                                            <th>Nro Operacion</th>
                                                            <th>Descripcion</th>
                                                            <th>Fecha Pago</th>
                                                            </tr>
                                                            </thead>
                                                            <tbody>
                                                            </tbody>
                                                        </table>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </section>                
                    </div>



            <div class="modal fade" id="modalIngreso" tabindex="-1" role="dialog" aria-labelledby="modalLabel" aria-hidden="true">
                <div class="modal-dialog modal-xl" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h5 class="modal-title" id="modalLabel">Regitro Ingreso</h5>
                            <button type="button" class="close" data-dismiss="modal" aria-label="Cerrar">
                                <span >&times;</span>
                            </button>
                        </div>
                        <form id="formRegistroIngreso">
                            <div class="modal-body">
                                <!-- Campo para mostrar el dato -->
                                 <input type="hidden" name="idingreso" id="idingreso">
                                 <div class="row">
                                    <div class="col-12 col-sm-12 col-md-4">
                                        <div class="form-group">
                                        <label >Seleccione Ingreso:</label>
                                        <select class="form-control select" name="idcategoria_ingreso" id="idcategoria_ingreso" required>                                        
                                        </select>
                                        </div>
                                    </div>
                                    <div class="col-12 col-sm-12 col-md-4">
                                        <div class="form-group">
                                        <label >Tipo Trabajo:</label>
                                        <select class="form-control select" name="idconcepto_ingreso" id="idconcepto_ingreso" required>  
                                            <option value="">Seleccione una Concepto</option>                                      
                                        </select>
                                        </div>
                                    </div>
                                    <div class="col-12 col-sm-12 col-md-4">
                                        <div class="form-group">
                                        <label >Seleccione Cliente:</label>
                                        <select class="form-control select" name="idpersona" id="idpersona" required>                                        
                                        </select>
                                        </div>
                                    </div>
                                    <div class="col-12 col-sm-12 col-md-3">
                                    </div> 
                                    <div class="col-12 col-sm-12 col-md-6">
                                        <br>
                                        <div class="form-group">
                                        <label>Forma de Pago:</label>&nbsp;&nbsp;&nbsp;
                                        <input  type="radio" checked  name="tipopago" id="radioEfectivo" onclick="mostrarOcultarCampos()" value="2"><label>&nbsp;EFECTIVO</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;             
                                        <input  type="radio"  name="tipopago" id="radioDeposito" onclick="mostrarOcultarCampos()" value="3"><label>&nbsp;DEPOSITO</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                        </div> 
                                    </div> 
                                    <div class="col-12 col-sm-12 col-md-6" id="campoBanco" style="display: none;">
                                        <div class="form-group">
                                            <label>Banco:</label>
                                            <select name="idbanco" id="idbanco" class="form-control select2" data-live-search="true" data-style="btn-default" >
                                            </select>
                                        </div>
                                    </div>
                                    <div class="col-12 col-sm-6 col-md-6" id="campoOperacion" style="display: none;">
                                        <div class="form-group">
                                            <label>Numero Operacion:</label>
                                            <input type="text" class="form-control" name="nro_operacion" id="nro_operacion" placeholder="Nro Operacion">
                                        </div>
                                    </div>
                                    <div class="col-12 col-sm-6 col-md-6">
                                        <div class="form-group">
                                            <label>Hora:</label>
                                            <input  type="time" name="hora" id="hora" class="form-control" value="<?php echo date("H:i")?>" > </input> 
                                        </div>
                                    </div>
                                    <div class="col-12 col-sm-6 col-md-6">
                                        <div class="form-group">
                                            <label>Fecha Pago:</label>
                                            <input  type="date" name="fechapago" id="fechapago" class="form-control" value="<?php echo date("Y-m-d")?>" > </input> 
                                        </div>
                                    </div>
                                    <div class="col-12 col-sm-6 col-md-6">
                                        <div class="form-group">
                                            <label>Monto:</label>
                                            <input type="number" step="0.01" class="form-control" name="monto" id="monto"  placeholder="Monto" >
                                        </div>
                                    </div>
                                    <div class="col-12 col-sm-6 col-md-6">
                                        <div class="form-group">
                                            <label>Comprobante:</label>
                                            <select class="form-control" name="comprobante" id="comprobante">
                                                <option value="">Seleccione Comprobante</option>
                                                <option value="1">Recibo Egreso </option>
                                                <option value="2">Boleta </option>
                                                <option value="3">Factura </option>
                                            </select> 
                                        </div>
                                    </div>
                                    <div class="col-12 col-sm-6 col-md-12">
                                        <div class="form-group">
                                            <label>Nro Recibo:</label>
                                            <input  type="text" name="nrorecibo" id="nrorecibo" class="form-control" placeholder="Nro recibo"> </input> 
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-danger btn-flat" data-dismiss="modal" id="btnGuardar"> <i class="fas fa-times"></i> Cancelar</button>
                                <button type="submit" id="btn_Ingreso" class="btn btn-primary btn-flat"> <i class="fas fa-save"></i> Guardar Ingreso</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
               
<?php
}
require '../footer.php';
?>
<script type="text/javascript" src="../../scripts/control_ingreso.js"></script>
<?php 
}
ob_end_flush();
?>