<?php 
  include("conn.php");
  include('fnc-cajas.php');
?>


    <!-- Modal-Favoritos -->
    <div class="modal fade" id="cajas_modal" tabindex="-1" role="dialog" aria-labelledby="cajas_modalLabel">
      <div class="modal-dialog" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="titulos modal-title" id="intervaloLabel">Seleccionar Cajas</h4>
          </div>


<?php
  $sqlVistaCajas = getVistaCajas($DBSegu);
  $sql = "SELECT DISTINCT B.BASE, B.DESCRI AS DESC_BASE, T.TIPO_CAJA, T.descri as DESC_CAJA
          FROM (SELECT XB.BASE, XB.DESCRI 
               FROM BASES XB 
                    INNER JOIN USUARIOSBASES XUB 
                        INNER JOIN USUARIOS XU ON XUB.ID_USUARIO = XU.ID_USUARIO AND XU.USUARIO = 'PIXO_WEB' 
                    ON XB.BASE = XUB.BASE) B  
                INNER JOIN ".$sqlVistaCajas." T  ON B.BASE = T.BASE
                INNER JOIN USUARIOSBASES UB 
                    INNER JOIN USUARIOS U ON UB.ID_USUARIO = U.ID_USUARIO 
                ON B.BASE = UB.BASE AND UB.ID_USUARIO = ".$_SESSION['CurrentIdUser']." 
          WHERE 1=1 
          ORDER BY B.DESCRI, T.DESCRI ";
  $Rscajas = $DBSegu->Execute($sql);
  if (!$Rscajas) {
    print $DBSegu->ErrorMsg();
  }
?>
          <div class="modal-body">
            <table id="tablaResultado" class="display table table-striped table-bordered sticky-header" style="width:100%;">
              <thead style="background-color: #db5916; color: aliceblue; display: none !important;">
                <tr>
                  <th class="thalign tituloshead"></th>
                  <th class="thalign tituloshead">Unidad de Negocio</th>
                </tr>
              </thead>
              <tbody>
<?php
  while( !$Rscajas->EOF) {  
/*    echo '<tr>
            <td style="text-align: center;">
              <div class="checkbox">
                <label><input type="checkbox" name="chkSelUnidad"  data-base="'.$Rscajas->fields['BASE'].'" data-titular="'.$Rscajas->fields['TITULAR'].'"></label>
                </div> 
            </td>
            <td>'.utf8_encode($Rscajas->fields['DESC_BASE'] . ' - ' . $Rscajas->fields['DESC_TITULAR']).'</td>
          </tr>';*/
    echo '<tr>
            <td style="text-align: center;">data-base="'.$Rscajas->fields['BASE'].'" data-caja="'.$Rscajas->fields['TIPO_CAJA'].'" data-nombre="'.utf8_encode($Rscajas->fields['DESC_BASE'] . ' - ' . $Rscajas->fields['DESC_CAJA']).'"
            </td>
            <td>'.utf8_encode($Rscajas->fields['DESC_BASE'] . ' - ' . $Rscajas->fields['DESC_CAJA']).'</td>
          </tr>';
    $Rscajas->Movenext();
  }
?>
              </tbody>
            </table>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-primary" id='btnAceptarSeleccionCajas'>Aceptar</button>
            <button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
          </div>
        </div>
      </div>
    </div>
