Copybara bot | be50d49 | 2023-11-30 00:16:42 +0100 | [diff] [blame] | 1 | <?php |
| 2 | require_once("core.php"); |
| 3 | security::checkType(security::ADMIN); |
| 4 | |
| 5 | $mdHeaderRowBefore = visual::backBtn("settings.php"); |
| 6 | ?> |
| 7 | <!DOCTYPE html> |
| 8 | <html> |
| 9 | <head> |
| 10 | <title><?php echo $conf["appName"]; ?></title> |
| 11 | <?php visual::includeHead(); ?> |
| 12 | <link rel="stylesheet" href="css/dashboard.css"> |
| 13 | |
| 14 | <style> |
| 15 | .addcategory { |
| 16 | position: fixed; |
| 17 | bottom: 16px; |
| 18 | right: 16px; |
| 19 | z-index: 1000; |
| 20 | } |
| 21 | |
| 22 | @media (max-width: 655px) { |
| 23 | .extra { |
| 24 | display: none; |
| 25 | } |
| 26 | } |
| 27 | </style> |
| 28 | </head> |
| 29 | <?php visual::printBodyTag(); ?> |
| 30 | <div class="mdl-layout mdl-js-layout mdl-layout--fixed-header mdl-layout--fixed-drawer"> |
| 31 | <?php visual::includeNav(); ?> |
| 32 | <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> |
| 33 | <main class="mdl-layout__content"> |
| 34 | <div class="page-content"> |
| 35 | <div class="main mdl-shadow--4dp"> |
| 36 | <h2>Categorías</h2> |
| 37 | <?php |
| 38 | $categories = categories::getAll(false); |
| 39 | if (count($categories)) { |
| 40 | ?> |
| 41 | <div class="overflow-wrapper overflow-wrapper--for-table"> |
| 42 | <table class="mdl-data-table mdl-js-data-table mdl-shadow--2dp"> |
| 43 | <thead> |
| 44 | <tr> |
| 45 | <th class="extra">ID</th> |
| 46 | <th class="mdl-data-table__cell--non-numeric">Categoría</th> |
| 47 | <th class="mdl-data-table__cell--non-numeric extra">Emails responsables <i id="tt_emails" class="material-icons help">help</i></th> |
| 48 | <th class="mdl-data-table__cell--non-numeric"></th> |
| 49 | </tr> |
| 50 | </thead> |
| 51 | <tbody> |
| 52 | <?php |
| 53 | foreach ($categories as $c) { |
| 54 | $emails = categories::readableEmails($c["emails"]); |
| 55 | ?> |
| 56 | <tr> |
| 57 | <td class="extra"><?=(int)$c["id"]?></td> |
| 58 | <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> |
| 59 | <td class="mdl-data-table__cell--non-numeric extra"><?=security::htmlsafe((empty($emails) ? "-" : $emails))?></td> |
| 60 | <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> |
| 61 | </tr> |
| 62 | <?php |
| 63 | } |
| 64 | ?> |
| 65 | </tbody> |
| 66 | </table> |
| 67 | </div> |
| 68 | <?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."); ?> |
| 69 | <?php |
| 70 | } else { |
| 71 | ?> |
| 72 | <p>Todavía no hay definida ninguna categoría para los trabajadores.</p> |
| 73 | <p>Puedes añadir una haciendo clic en el botón de la esquina inferior derecha de la página.</p> |
| 74 | <?php |
| 75 | } |
| 76 | ?> |
| 77 | |
| 78 | <?php visual::printDebug("categories::getAll()", $categories); ?> |
| 79 | </div> |
| 80 | </div> |
| 81 | </main> |
| 82 | </div> |
| 83 | |
| 84 | <dialog class="mdl-dialog" id="addcategory"> |
| 85 | <form action="doaddcategory.php" method="POST" autocomplete="off"> |
| 86 | <h4 class="mdl-dialog__title">Añade una categoría</h4> |
| 87 | <div class="mdl-dialog__content"> |
| 88 | <div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label"> |
| 89 | <input class="mdl-textfield__input" type="text" name="name" id="name" autocomplete="off" data-required> |
| 90 | <label class="mdl-textfield__label" for="name">Nombre de la categoría</label> |
| 91 | </div> |
| 92 | <br> |
| 93 | <div class="mdlext-selectfield mdlext-js-selectfield mdlext-selectfield--floating-label"> |
| 94 | <select name="parent" id="parent" class="mdlext-selectfield__select"> |
| 95 | <option value="0"></option> |
| 96 | <?php |
| 97 | foreach ($categories as $category) { |
| 98 | if ($category["parent"] == 0) echo '<option value="'.$category["id"].'">'.$category["name"].'</option>'; |
| 99 | } |
| 100 | ?> |
| 101 | </select> |
| 102 | <label for="parent" class="mdlext-selectfield__label">Categoría padre</label> |
| 103 | </div> |
| 104 | <br> |
| 105 | <div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label"> |
| 106 | <textarea class="mdl-textfield__input" name="emails" id="emails"></textarea> |
| 107 | <label class="mdl-textfield__label" for="emails">Correos electrónicos de los responsables</label> |
| 108 | </div> |
| 109 | <span style="font-size: 12px;">Introduce los correos separados por comas.</span> |
| 110 | </div> |
| 111 | <div class="mdl-dialog__actions"> |
| 112 | <button type="submit" class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--accent">Añadir</button> |
| 113 | <button onclick="event.preventDefault(); document.querySelector('#addcategory').close();" class="mdl-button mdl-js-button mdl-js-ripple-effect cancel">Cancelar</button> |
| 114 | </div> |
| 115 | </form> |
| 116 | </dialog> |
| 117 | |
| 118 | <?php |
| 119 | visual::renderTooltips(); |
| 120 | |
| 121 | visual::smartSnackbar([ |
| 122 | ["added", "Se ha añadido la categoría correctamente."], |
| 123 | ["modified", "Se ha modificado la categoría correctamente."], |
| 124 | ["empty", "Faltan datos por introducir en el formulario."], |
| 125 | ["unexpected", "Ha ocurrido un error inesperado. Inténtelo de nuevo en unos segundos."] |
| 126 | ]); |
| 127 | ?> |
| 128 | |
| 129 | <script src="js/categories.js"></script> |
| 130 | </body> |
| 131 | </html> |