<?php
    $sql = "SELECT DISTINCT B.BASE, B.DESCRI, B.NOMBRE_BASE  
            FROM (SELECT XB.BASE, XB.DESCRI, XB.NOMBRE_BASE  
                  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 USUARIOSBASES UB 
                            INNER JOIN USUARIOS U 
                            ON UB.ID_USUARIO = U.ID_USUARIO 
                        ON B.BASE = UB.BASE  
            ORDER BY B.DESCRI ";
    $RsBases = $DBSegu->Execute($sql);
    if (!$RsBases) {
      print $DBSegu->ErrorMsg();
    }
    if ($RsBases->RecordCount() < 80) { 
?>
                <div class="box box-light">
                  <div class="box-header with-border">
                    <h3 class="titulos-gris box-title">Base de Datos</h3>
                    <div class="box-tools pull-right">
                      <button type="button" class="btn btn-default" id='btnLimpiarBases' title="Eliminar Todas"><i class="fa fa-eraser"></i></button>
                      <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
                    </div>
                  </div>
                  <div class="box-body no-padding" style="">
                    <div class="zero col-sm-12">
                      <div style="margin-top: 15px;" class="form-group">
                        <select data-clear='1' data-tipo='0' id='listaBases' class="form-control select2 select2-hidden-accessible"  data-placeholder="Introduzca base de datos" style="width: 100%;" tabindex="-1" aria-hidden="true">
<?php
        while (!$RsBases->EOF) {
            echo "<option value='".$RsBases->fields['BASE']."'>".utf8_encode($RsBases->fields['DESCRI']) ."</option>";
            $RsBases->MoveNext();
        }
 ?>
                        </select>
                      </div>
                    </div>
                  </div>
                </div>

<?php
    }
    else {
?>
                <div class="box box-light">
                  <div class="box-header with-border">
                    <h3 class="titulos-gris box-title">Bases de Dato</h3>
                    <div class="box-tools pull-right">
                      <div class="btn-group" style="display: none;">
                        <button type="button" class="btn btn-default" id="btnTodosBases"><i class="fa fa-plus-square"></i><i class="fa fa-plus-square"></i></button>
                      </div>
                      <button type="button" class="btn btn-default" id='btnLimpiarBases' title="Eliminar Todas"><i class="fa fa-eraser"></i></button>
                      <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
                    </div>
                  </div>
                  <div class="box-body no-padding" style="">
                    <div class="zero col-sm-12">
                      <div style="margin-right: 10px; margin-top: 15px; margin-left: 10px;" class="form-group">
                        <input data-clear='2' data-tipo='1' placeholder="Introduzca base de datos"  type="text" value="" id="listaBases" data-role="tagsinput" />
                      </div>
                    </div>
                  </div>
                </div>

<?php
    }
?>

