<div class="content-wrapper">

  <section class="content-header">

    <h1>

      Movimiento Caja

    </h1>

    <ol class="breadcrumb">

      <li><a href="inicio"><i class="fa fa-dashboard"></i> Inicio</a></li>

      <li class="active">Movimiento caja</li>

    </ol>

  </section>

<section class="content">

<div class="box">

<div class="box-header with-border">

    <button class="btn btn-success reporteCajaPDF2" >

        Descargar reporte en .pdf <i class="fa fa-file-pdf-o"></i>
        <input type="hidden" id="idCaja" value="<?= base64_encode($_SESSION['id']) ?>">

    </button>
    <button type="button" class="btn btn-primary" id="actualizar-tabla2">Actualizar Tabla</button>
    <div class="row" style="margin-top: 10px;">
      <div class="col-12 col-md-6 col-lg-6">
        <form class="" action="" method="post">
          <div class="row">
            <div class="col-md-4">
              <input type="date" class="form-control" name="fecha1" id="fecha1" value="<?= (isset($_POST['fecha1'])) ? $_POST['fecha1'] : '' ?>">
            </div>
            <div class="col-md-4">
              <input type="date" class="form-control" name="fecha2" id="fecha2" value="<?= (isset($_POST['fecha2'])) ? $_POST['fecha2'] : '' ?>">
            </div>

            <div class="col-md-4">
              <input type="submit" class="btn btn-primary" name="consultar-caja" value="Consultar">
            </div>

          </div>
        </form>
      </div>
    </div>
<!--
    <div class="form-row">

        <div class="form-group col-md-3">
            <div class="input-group">




            </div>
        </div>

    </div>
-->
</div>

      <div class="box-body">

       <table class="table table-bordered table-striped dt-responsive tablas serviConti">

        <thead>

         <tr>

            <th>#</th>
            <th>Nombres</th>
            <th>Fecha registro</th>
           <th>Tipo caja</th>
           <th>Concepto</th>
           <th>N° Documento</th>          
           <th>importe</th>
           <th>Tipo de pago</th> 
           <th></th>

         </tr>

        </thead>

        <tbody id="serviCont">
        <?php
            $idUsuario = $_SESSION['id'];   
            if(isset($_POST['consultar-caja'])){
                if($_SESSION["perfil"] == "Administrador")
                    $detalleCaja = ControladorCaja::ctrMostrarDetalleCajaMovimiento(null, $_POST['fecha1'], $_POST['fecha2']);
                else
                    $detalleCaja = ControladorCaja::ctrMostrarDetalleCajaMovimiento($idUsuario, $_POST['fecha1'], $_POST['fecha2']);
            } else {
                if($_SESSION["perfil"] == "Administrador")
                    $detalleCaja = ControladorCaja::ctrMostrarDetalleCajaMovimiento(null);
                else
                    $detalleCaja = ControladorCaja::ctrMostrarDetalleCajaMovimiento($idUsuario);
            }
        ?>
            <?php 
              $totalCaja = 0;
              foreach ($detalleCaja as $key => $value) {
                $totalCaja += $value["importeCaja"];
                echo '<tr id="fila">
                        <td>'.($key+1).'</td>
                        <td>'.$value["nombre"].'</td>
                        <td>'.$value["fechaRegistro"].'</td>
                        <td>'.$value["tipoCaja"].'</td>
                        <td>'.$value["concepto"].'</td>
                        <td>'.$value["numeroDocumento"].'</td>                        
                        <td>'.number_format($value["importeCaja"],2,'.',',').'</td>
                        <td>'.$value["tipoPago"].'</td>
                        <td><span class="badge bg-green">Pagado</span></td>';
                        

                 echo '</tr>';
              }

            
            ?>

        </tbody>

       </table>

      </div>

    </div>

  </section>

</div>



<div id="modalEditarContrato" class="modal fade" role="dialog">

<div class="modal-dialog modal-lg">
    <div class="modal-content">

      <form role="form" method="post">

        <!--=====================================
        CABEZA DEL MODAL
        ======================================-->

        <div class="modal-header" style="background:#3c8dbc; color:white">

          <button type="button" class="close" data-dismiss="modal">&times;</button>

          <h4 class="modal-title">Cronograma de Pagos</h4>

        </div>

        <!--=====================================
        CUERPO DEL MODAL
        ======================================-->

        <div class="modal-body">

          <div class="box-body">

            <table class="table table-bordered table-striped dt-responsive tablas tablaContratos" width="100%">


        <thead>

         <tr>

           <th style="width:10px">#</th>
           <th>Fechas de pagos</th>
           <th>Monto</th>
           <th>Estado</th>

         </tr>

        </thead>

        <tbody id="tablebody1">


        </tbody>

       </table>


          </div>

        </div>



        <!--=====================================
        PIE DEL MODAL
        ======================================-->

        <div class="modal-footer">

          <button type="button" class="btn btn-danger pull-right" data-dismiss="modal">Close</button>


        </div>

      </form>

      </div>

  </div>

</div>
