1 | <?php |
2 | |
3 | require_once __DIR__ . "/../lib/php/ejecutaServicio.php"; |
4 | require_once __DIR__ . "/../lib/php/fetchAll.php"; |
5 | require_once __DIR__ . "/../lib/php/devuelveJson.php"; |
6 | require_once __DIR__ . "/Bd.php"; |
7 | require_once __DIR__ . "/TABLA_USUARIO.php"; |
8 | |
9 | ejecutaServicio(function () { |
10 | |
11 | $lista = fetchAll(Bd::pdo()->query( |
12 | "SELECT |
13 | U.USU_ID, |
14 | U.USU_CUE, |
15 | GROUP_CONCAT(UR.ROL_ID, ', ') AS roles |
16 | FROM USUARIO U |
17 | LEFT JOIN USU_ROL UR |
18 | ON U.USU_ID = UR.USU_ID |
19 | GROUP BY U.USU_CUE |
20 | ORDER BY U.USU_CUE" |
21 | )); |
22 | |
23 | $render = ""; |
24 | foreach ($lista as $modelo) { |
25 | $encodeUsuId = urlencode($modelo[USU_ID]); |
26 | $usuId = htmlentities($encodeUsuId); |
27 | $usuCue = htmlentities($modelo[USU_CUE]); |
28 | $roles = $modelo["roles"] === null || $modelo["roles"] === "" |
29 | ? "<em>-- Sin roles --</em>" |
30 | : htmlentities($modelo["roles"]); |
31 | $render .= |
32 | "<dt><a href='modifica.html?id=$usuId'>$usuCue</a></dt> |
33 | <dd><a href='modifica.html?id=$usuId'>$roles</a></dd>"; |
34 | } |
35 | |
36 | devuelveJson(["lista" => ["innerHTML" => $render]]); |
37 | }); |
38 | |