/**
  * Listado de usuarios imetos
  * @param type $is_admin is boolean
  * @param type $userid is number
  */
 public static function users_list($is_admin = false, $userid = 0)
 {
     //$enum_tipos_usuarios=getEnumOptions('usuarios', 'usertype');
     if ($users = User::getAll($is_admin)) {
         echo "\n                <h1>Listado de usuarios iMetos</h1>\n                <table class=\"table table-striped table-hover table-bordered table-condensed\">\n                    <tr>    \n                        <th>&nbsp;</th>\n                        <th>Usuario</th>\n                        <th>Mails</th>\n                    </tr>";
         foreach ($users as $user) {
             echo "\n                    <tr>\n                        <td align=\"center\">\n                            <a class=\"link-tabla\" href=\"javascript:borrar_usuario('{$user->getId()}');\">\n                                <i class=\"fa fa-trash\"></i>\n                            </a>&nbsp;";
             if ($user->getEnableFTP()) {
                 echo "  <a class=\"link-tabla\" href=\"javascript:realizar_informe('{$user->getUserFTP()}');\" title=\"Revisar sondas detenidas\">\n                                <i class=\"fa fa-terminal\"></i>\n                            </a>&nbsp;&nbsp;";
             }
             echo "      <a class=\"link-tabla\" href=\"javascript:mostrar_ocultar('conf_usuario_{$user->getId()}');\" title=\"Configuraci&oacute;n de usuario\">\n                                <i class=\"fa fa-user\"></i>\n                            </a>&nbsp;&nbsp;";
             echo "      <a class=\"link-tabla\" href=\"javascript:mostrar_ocultar('conf_exporta_{$user->getId()}');\" title=\"Configuraci&oacute;n de estaciones\">\n                                <i class=\"fa fa-pencil\"></i>\n                            </a>";
             echo "  </td>\n                        <td>{$user->getUsername()}</td>\n                        <td>{$user->getEmails()}</td>\n                    </tr>\n                    <tr>\n                        <td colspan=\"6\">\n                            <div id=\"conf_usuario_{$user->getId()}\" style=\"display:none\">\n                                <form name=\"user_edit\" method=\"post\" action=\"/users/edit/{$user->getId()}\">";
             User::formulario_editar_usuario($user);
             echo "              <div class=\"panel-body\" style=\"text-align:right\">\n                                        <div class=\"form-group\">\n                                            <button type=\"submit\" name=\"save_user\" class=\"btn btn-default\"><i class=\"fa fa-floppy-o\" aria-hidden=\"true\"></i>&nbsp;Guardar usuario</button>&nbsp;\n                                            <button type=\"button\" name=\"close\" class=\"btn btn-default\" onClick=\"javascript:mostrar_ocultar('conf_usuario_{$user->getId()}');\"><i class=\"fa fa-times\" aria-hidden=\"true\"></i>&nbsp;Cerrar</button>&nbsp;\n                                        </div>\n                                    </div>\n                                </form>";
             echo "      </div>\n                            <div class=\"conf_exporta\" id=\"conf_exporta_{$user->getId()}\" style=\"display:none\">";
             // si esta habilitado muestra info de estaciones
             if ($user->getEnableMySQL()) {
                 $BD = new IMETOS($user->getIdMySQL(), $user->getServerMySQL(), $user->getDatabaseMySQL(), $user->getUserMySQL(), $user->getPasswMySQL());
                 if ($stations = Station::getAll($BD, $user->getId())) {
                     Station::listAll($BD, $stations, $user);
                 }
             }
             echo "      </div> <!-- cierre de div conf_exporta -->\n                        </td>\n                    </tr>";
         }
         echo "</table>";
     } else {
         echo "No se pudo cargar los usuarios<br>";
     }
 }
<?php

require '../config.php';
require '../lib/class_imetos.php';
require '../lib/class_users.php';
require '../lib/class_station.php';
require '../lib/class_sensor.php';
require '../lib/class_config.php';
// busco los usuarios para expotar datos
if ($users = User::getAll(true)) {
    foreach ($users as $user) {
        if ($user->getEnableMySQL()) {
            $BD = new IMETOS($user->getIdMySQL(), $user->getServerMySQL(), $user->getDatabaseMySQL(), $user->getUserMySQL(), $user->getPasswMySQL());
            if ($stations = Station::getAll($BD)) {
                foreach ($stations as $station) {
                    $station->loadSensors($BD);
                    $stationSensorsList = $station->getAvailableSensors();
                    $q_config = $station->getConfig();
                    //
                    echo "<br>-------------------------------------------------------<br>";
                    echo "UserId--------->{$user->getId()}<br>";
                    echo "station-code--->{$station->getStationCode()}<br>";
                    echo "enable--------->{$q_config->getEnable()}<br>";
                    echo "periodo-------->{$q_config->getPeriodo()}<br>";
                    //
                    $datas = array();
                    $enca1 = "";
                    $enca2 = "FECHA";
                    list($querys, $enca1, $enca2) = $q_config->runQuery($BD, $station);
                    if (!empty($querys)) {
                        foreach ($querys as $key_query => $query) {