blob: 9ff412a6646f9bc1c05e9a0451e5cbafb19c9e68 [file] [log] [blame]
Copybara botbe50d492023-11-30 00:16:42 +01001<?php
2require_once("core.php");
3security::checkType(security::ADMIN);
4
5if (!security::checkParams("POST", [
6 ["template", security::PARAM_ISINT],
7 ["workers", security::PARAM_ISARRAY]
8])) {
9 security::go("workers.php?msg=unexpected");
10}
11
12$template = (int)$_POST["template"];
13$active = ((isset($_POST["active"]) && $_POST["active"] == 1) ? 1 : 0);
14
15$mdHeaderRowBefore = visual::backBtn("workers.php");
16?>
17<!DOCTYPE html>
18<html>
19<head>
20 <title><?php echo $conf["appName"]; ?></title>
21 <?php visual::includeHead(); ?>
22 <link rel="stylesheet" href="css/dashboard.css">
23</head>
24<?php visual::printBodyTag(); ?>
25 <div class="mdl-layout mdl-js-layout mdl-layout--fixed-header mdl-layout--fixed-drawer">
26 <?php visual::includeNav(); ?>
27
28 <main class="mdl-layout__content">
29 <div class="page-content">
30 <div class="main mdl-shadow--4dp">
31 <h2>Resultado de la copia de plantilla</h2>
32
33 <?php
34 foreach ($_POST["workers"] as $workerid) {
35 $worker = workers::get($workerid);
36 if ($worker === false) continue;
37
38 $status = schedules::copyTemplate($template, $worker["id"], $active);
39 $person = "&ldquo;".security::htmlsafe($worker["name"])."&rdquo; (".security::htmlsafe($worker["companyname"]).")";
40
41 switch ($status) {
42 case 0:
43 echo "<p class='mdl-color-text--green'>Plantilla copiada correctamente a $person.";
44 break;
45
46 case 2:
47 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.";
48 break;
49
50 case 1:
51 echo "<p class='mdl-color-text--red'>No se ha podido copiar la plantilla a $person porque la plantilla no existe.";
52 break;
53
54 case -1:
55 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.";
56 break;
57
58 default:
59 echo "<p class='mdl-color-text--red'>Ha ocurrido un error inesperado copiando la plantilla a $person.";
60 }
61 echo "</p>";
62 }
63 ?>
64 </div>
65 </div>
66 </main>
67 </div>
68</body>
69</html>