blob: 4afc6b22e8287ec6810d51f68891595758f50fa8 [file] [log] [blame]
Copybara botbe50d492023-11-30 00:16:42 +01001<?php
Adrià Vilanova Martínez5af86512023-12-02 20:44:16 +01002/*
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 botbe50d492023-11-30 00:16:42 +010021require_once("core.php");
22security::checkType(security::ADMIN);
23
24$mdHeaderRowBefore = visual::backBtn("workers.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 .addtemplate {
35 position: fixed;
36 bottom: 16px;
37 right: 16px;
38 z-index: 1000;
39 }
40 </style>
41</head>
42<?php visual::printBodyTag(); ?>
43 <div class="mdl-layout mdl-js-layout mdl-layout--fixed-header mdl-layout--fixed-drawer">
44 <?php visual::includeNav(); ?>
45 <button class="addtemplate 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>
46 <main class="mdl-layout__content">
47 <div class="page-content">
48 <div class="main mdl-shadow--4dp">
49 <h2>Plantillas de horarios</h2>
50 <?php
51 $templates = schedules::getTemplates();
52 if (count($templates)) {
53 foreach ($templates as $t) {
54 ?>
55 <a href="scheduletemplate.php?id=<?=(int)$t["id"]?>" class="clicky-container">
56 <div class="clicky mdl-js-ripple-effect">
57 <div class="text">
58 <span class="title"><?=security::htmlsafe($t["name"])?></span><br>
59 <span class="description"><?=security::htmlsafe(date("d/m/Y", $t["begins"]))?> - <?=security::htmlsafe(date("d/m/Y", $t["ends"]))?></span>
60 </div>
61 <div class="mdl-ripple"></div>
62 </div>
63 </a>
64 <?php
65 }
66 } else {
67 ?>
68 <p>Todavía no has creado ninguna plantilla.</p>
69 <p>Puedes añadir una haciendo clic en el botón de la esquina inferior derecha de la página.</p>
70 <?php
71 }
72 ?>
73
74 <?php visual::printDebug("schedules::getTemplates()", $templates); ?>
75 </div>
76 </div>
77 </main>
78 </div>
79
80 <dialog class="mdl-dialog" id="addtemplate">
81 <form action="doaddscheduletemplate.php" method="POST" autocomplete="off">
82 <h4 class="mdl-dialog__title">Crea una nueva plantilla</h4>
83 <div class="mdl-dialog__content">
84 <div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
85 <input class="mdl-textfield__input" type="text" name="name" id="name" autocomplete="off" data-required>
86 <label class="mdl-textfield__label" for="name">Nombre de la plantilla</label>
87 </div>
88 <br>
89 <div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
90 <input class="mdl-textfield__input" type="date" name="begins" id="begins" autocomplete="off" data-required>
91 <label class="mdl-textfield__label always-focused" for="begins">Fecha inicio de validez del horario</label>
92 </div>
93 <br>
94 <div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
95 <input class="mdl-textfield__input" type="date" name="ends" id="ends" autocomplete="off" data-required>
96 <label class="mdl-textfield__label always-focused" for="ends">Fecha fin de validez del horario</label>
97 </div>
98 </div>
99 <div class="mdl-dialog__actions">
100 <button type="submit" class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--accent">Crear</button>
101 <button onclick="event.preventDefault(); document.querySelector('#addtemplate').close();" class="mdl-button mdl-js-button mdl-js-ripple-effect cancel">Cancelar</button>
102 </div>
103 </form>
104 </dialog>
105
106 <?php
107 visual::smartSnackbar([
108 ["added", "Se ha añadido la plantilla correctamente."],
109 ["deleted", "Se ha eliminado la plantilla correctamente."],
110 ["empty", "Faltan datos por introducir en el formulario."],
111 ["unexpected", "Ha ocurrido un error inesperado. Inténtelo de nuevo en unos segundos."],
112 ["order", "La fecha de inicio debe ser anterior a la fecha de fin."]
113 ]);
114 ?>
115
116 <script src="js/scheduletemplates.js"></script>
117</body>
118</html>