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 | if (!security::checkParams("POST", [ |
| 25 | ["template", security::PARAM_ISINT], |
| 26 | ["workers", security::PARAM_ISARRAY] |
| 27 | ])) { |
| 28 | security::go("workers.php?msg=unexpected"); |
| 29 | } |
| 30 | |
| 31 | $template = (int)$_POST["template"]; |
| 32 | $active = ((isset($_POST["active"]) && $_POST["active"] == 1) ? 1 : 0); |
| 33 | |
| 34 | $mdHeaderRowBefore = visual::backBtn("workers.php"); |
| 35 | ?> |
| 36 | <!DOCTYPE html> |
| 37 | <html> |
| 38 | <head> |
| 39 | <title><?php echo $conf["appName"]; ?></title> |
| 40 | <?php visual::includeHead(); ?> |
| 41 | <link rel="stylesheet" href="css/dashboard.css"> |
| 42 | </head> |
| 43 | <?php visual::printBodyTag(); ?> |
| 44 | <div class="mdl-layout mdl-js-layout mdl-layout--fixed-header mdl-layout--fixed-drawer"> |
| 45 | <?php visual::includeNav(); ?> |
| 46 | |
| 47 | <main class="mdl-layout__content"> |
| 48 | <div class="page-content"> |
| 49 | <div class="main mdl-shadow--4dp"> |
| 50 | <h2>Resultado de la copia de plantilla</h2> |
| 51 | |
| 52 | <?php |
| 53 | foreach ($_POST["workers"] as $workerid) { |
| 54 | $worker = workers::get($workerid); |
| 55 | if ($worker === false) continue; |
| 56 | |
| 57 | $status = schedules::copyTemplate($template, $worker["id"], $active); |
| 58 | $person = "“".security::htmlsafe($worker["name"])."” (".security::htmlsafe($worker["companyname"]).")"; |
| 59 | |
| 60 | switch ($status) { |
| 61 | case 0: |
| 62 | echo "<p class='mdl-color-text--green'>Plantilla copiada correctamente a $person."; |
| 63 | break; |
| 64 | |
| 65 | case 2: |
| 66 | echo "<p class='mdl-color-text--orange'>El horario de la plantilla se solapa con uno de los horarios de $person, así que no se ha copiado al trabajador."; |
| 67 | break; |
| 68 | |
| 69 | case 1: |
| 70 | echo "<p class='mdl-color-text--red'>No se ha podido copiar la plantilla a $person porque la plantilla no existe."; |
| 71 | break; |
| 72 | |
| 73 | case -1: |
| 74 | echo "<p class='mdl-color-text--red'>Se ha empezado a copiar la plantilla a $person pero no se han podido copiar todos los horarios de cada día correctamente por algún error desconocido."; |
| 75 | break; |
| 76 | |
| 77 | default: |
| 78 | echo "<p class='mdl-color-text--red'>Ha ocurrido un error inesperado copiando la plantilla a $person."; |
| 79 | } |
| 80 | echo "</p>"; |
| 81 | } |
| 82 | ?> |
| 83 | </div> |
| 84 | </div> |
| 85 | </main> |
| 86 | </div> |
| 87 | </body> |
| 88 | </html> |