Copybara bot | be50d49 | 2023-11-30 00:16:42 +0100 | [diff] [blame] | 1 | <?php |
Adrià Vilanova Martínez | 5af8651 | 2023-12-02 20:44:16 +0100 | [diff] [blame^] | 2 | /* |
| 3 | * hores |
| 4 | * Copyright (c) 2023 Adrià Vilanova Martínez |
| 5 | * |
| 6 | * This program is free software: you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU Affero General Public License as |
| 8 | * published by the Free Software Foundation, either version 3 of the |
| 9 | * License, or (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU Affero General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Affero General Public |
| 17 | * License along with this program. |
| 18 | * If not, see http://www.gnu.org/licenses/. |
| 19 | */ |
| 20 | |
Copybara bot | be50d49 | 2023-11-30 00:16:42 +0100 | [diff] [blame] | 21 | require_once("core.php"); |
| 22 | security::checkType(security::ADMIN); |
| 23 | |
| 24 | $mdHeaderRowBefore = visual::backBtn("settings.php"); |
| 25 | ?> |
| 26 | <!DOCTYPE html> |
| 27 | <html> |
| 28 | <head> |
| 29 | <title><?php echo $conf["appName"]; ?></title> |
| 30 | <?php visual::includeHead(); ?> |
| 31 | <link rel="stylesheet" href="css/dashboard.css"> |
| 32 | |
| 33 | <style> |
| 34 | .addcategory { |
| 35 | position: fixed; |
| 36 | bottom: 16px; |
| 37 | right: 16px; |
| 38 | z-index: 1000; |
| 39 | } |
| 40 | |
| 41 | @media (max-width: 655px) { |
| 42 | .extra { |
| 43 | display: none; |
| 44 | } |
| 45 | } |
| 46 | </style> |
| 47 | </head> |
| 48 | <?php visual::printBodyTag(); ?> |
| 49 | <div class="mdl-layout mdl-js-layout mdl-layout--fixed-header mdl-layout--fixed-drawer"> |
| 50 | <?php visual::includeNav(); ?> |
| 51 | <button class="addcategory mdl-button md-js-button mdl-button--fab mdl-js-ripple-effect mdl-button--accent"><i class="material-icons">add</i><span class="mdl-ripple"></span></button> |
| 52 | <main class="mdl-layout__content"> |
| 53 | <div class="page-content"> |
| 54 | <div class="main mdl-shadow--4dp"> |
| 55 | <h2>Categorías</h2> |
| 56 | <?php |
| 57 | $categories = categories::getAll(false); |
| 58 | if (count($categories)) { |
| 59 | ?> |
| 60 | <div class="overflow-wrapper overflow-wrapper--for-table"> |
| 61 | <table class="mdl-data-table mdl-js-data-table mdl-shadow--2dp"> |
| 62 | <thead> |
| 63 | <tr> |
| 64 | <th class="extra">ID</th> |
| 65 | <th class="mdl-data-table__cell--non-numeric">Categoría</th> |
| 66 | <th class="mdl-data-table__cell--non-numeric extra">Emails responsables <i id="tt_emails" class="material-icons help">help</i></th> |
| 67 | <th class="mdl-data-table__cell--non-numeric"></th> |
| 68 | </tr> |
| 69 | </thead> |
| 70 | <tbody> |
| 71 | <?php |
| 72 | foreach ($categories as $c) { |
| 73 | $emails = categories::readableEmails($c["emails"]); |
| 74 | ?> |
| 75 | <tr> |
| 76 | <td class="extra"><?=(int)$c["id"]?></td> |
| 77 | <td class="mdl-data-table__cell--non-numeric"><?=security::htmlsafe($c["name"]).($c["parent"] == 0 ? "" : "<br><span class='mdl-color-text--grey-600'>Padre: ".security::htmlsafe($c["parentname"])."</span>")?></td> |
| 78 | <td class="mdl-data-table__cell--non-numeric extra"><?=security::htmlsafe((empty($emails) ? "-" : $emails))?></td> |
| 79 | <td class='mdl-data-table__cell--non-numeric'><a href='dynamic/editcategory.php?id=<?=(int)$c["id"]?>' data-dyndialog-href='dynamic/editcategory.php?id=<?=(int)$c["id"]?>' title='Editar categoría'><i class='material-icons icon'>edit</i></a></td> |
| 80 | </tr> |
| 81 | <?php |
| 82 | } |
| 83 | ?> |
| 84 | </tbody> |
| 85 | </table> |
| 86 | </div> |
| 87 | <?php visual::addTooltip("tt_emails", "Cuando un tipo de incidencia tenga activada las notificaciones a los responsables de categoría, se notificará de las incidencias nuevas a estos correos."); ?> |
| 88 | <?php |
| 89 | } else { |
| 90 | ?> |
| 91 | <p>Todavía no hay definida ninguna categoría para los trabajadores.</p> |
| 92 | <p>Puedes añadir una haciendo clic en el botón de la esquina inferior derecha de la página.</p> |
| 93 | <?php |
| 94 | } |
| 95 | ?> |
| 96 | |
| 97 | <?php visual::printDebug("categories::getAll()", $categories); ?> |
| 98 | </div> |
| 99 | </div> |
| 100 | </main> |
| 101 | </div> |
| 102 | |
| 103 | <dialog class="mdl-dialog" id="addcategory"> |
| 104 | <form action="doaddcategory.php" method="POST" autocomplete="off"> |
| 105 | <h4 class="mdl-dialog__title">Añade una categoría</h4> |
| 106 | <div class="mdl-dialog__content"> |
| 107 | <div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label"> |
| 108 | <input class="mdl-textfield__input" type="text" name="name" id="name" autocomplete="off" data-required> |
| 109 | <label class="mdl-textfield__label" for="name">Nombre de la categoría</label> |
| 110 | </div> |
| 111 | <br> |
| 112 | <div class="mdlext-selectfield mdlext-js-selectfield mdlext-selectfield--floating-label"> |
| 113 | <select name="parent" id="parent" class="mdlext-selectfield__select"> |
| 114 | <option value="0"></option> |
| 115 | <?php |
| 116 | foreach ($categories as $category) { |
| 117 | if ($category["parent"] == 0) echo '<option value="'.$category["id"].'">'.$category["name"].'</option>'; |
| 118 | } |
| 119 | ?> |
| 120 | </select> |
| 121 | <label for="parent" class="mdlext-selectfield__label">Categoría padre</label> |
| 122 | </div> |
| 123 | <br> |
| 124 | <div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label"> |
| 125 | <textarea class="mdl-textfield__input" name="emails" id="emails"></textarea> |
| 126 | <label class="mdl-textfield__label" for="emails">Correos electrónicos de los responsables</label> |
| 127 | </div> |
| 128 | <span style="font-size: 12px;">Introduce los correos separados por comas.</span> |
| 129 | </div> |
| 130 | <div class="mdl-dialog__actions"> |
| 131 | <button type="submit" class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--accent">Añadir</button> |
| 132 | <button onclick="event.preventDefault(); document.querySelector('#addcategory').close();" class="mdl-button mdl-js-button mdl-js-ripple-effect cancel">Cancelar</button> |
| 133 | </div> |
| 134 | </form> |
| 135 | </dialog> |
| 136 | |
| 137 | <?php |
| 138 | visual::renderTooltips(); |
| 139 | |
| 140 | visual::smartSnackbar([ |
| 141 | ["added", "Se ha añadido la categoría correctamente."], |
| 142 | ["modified", "Se ha modificado la categoría correctamente."], |
| 143 | ["empty", "Faltan datos por introducir en el formulario."], |
| 144 | ["unexpected", "Ha ocurrido un error inesperado. Inténtelo de nuevo en unos segundos."] |
| 145 | ]); |
| 146 | ?> |
| 147 | |
| 148 | <script src="js/categories.js"></script> |
| 149 | </body> |
| 150 | </html> |