blob: d6d944a1873d34bdb58341da24342302cdfd44e4 [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("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 .add-calendar, .category {
35 vertical-align: middle;
36 }
37 </style>
38</head>
39<?php visual::printBodyTag(); ?>
40 <div class="mdl-layout mdl-js-layout mdl-layout--fixed-header mdl-layout--fixed-drawer">
41 <?php visual::includeNav(); ?>
42 <main class="mdl-layout__content">
43 <div class="page-content">
44 <div class="main mdl-shadow--4dp">
45 <h2>Calendarios</h2>
46 <?php
47 $calendars_response = calendars::getAll();
48
49 foreach ($calendars_response as $ccs) {
50 ?>
51 <h4><span class="category"><?=security::htmlsafe($ccs["category"])?></span> <a href="addcalendar.php?id=<?=(int)$ccs["categoryid"]?>" class="mdl-button mdl-js-button mdl-button--icon mdl-button--accent add-calendar" id="cat<?=(int)$ccs["categoryid"]?>"><i class="material-icons">add</i></a></h4>
52 <?php visual::addTooltip("cat".(int)$ccs["categoryid"], "Añadir un calendario a esta categoría"); ?>
53 <?php
54 if (count($ccs["calendars"])) {
55 ?>
56 <div class="overflow-wrapper overflow-wrapper--for-table">
57 <table class="mdl-data-table mdl-js-data-table mdl-shadow--2dp datatable">
58 <thead>
59 <tr>
60 <?php
61 if ($conf["debug"]) {
62 ?>
63 <th class="extra">ID</th>
64 <?php
65 }
66 ?>
67 <th class="mdl-data-table__cell--non-numeric">Fecha inicio</th>
68 <th class="mdl-data-table__cell--non-numeric">Fecha fin</th>
69 <th class="mdl-data-table__cell--non-numeric"></th>
70 </tr>
71 </thead>
72 <tbody>
73 <?php
74 foreach ($ccs["calendars"] as $c) {
75 ?>
76 <tr>
77 <?php
78 if ($conf["debug"]) {
79 ?>
80 <td class="extra"><?=(int)$c["id"]?></td>
81 <?php
82 }
83 ?>
84 <td class="mdl-data-table__cell--non-numeric"><?=security::htmlsafe(date("d/m/Y", $c["begins"]))?></td>
85 <td class="mdl-data-table__cell--non-numeric"><?=security::htmlsafe(date("d/m/Y", $c["ends"]))?></td>
86 <td class='mdl-data-table__cell--non-numeric'>
87 <a href='editcalendar.php?id=<?=(int)$c['id']?>&view=1' title='Ver calendario'><i class='material-icons icon'>open_in_new</i></a>
88 <a href='editcalendar.php?id=<?=(int)$c['id']?>' title='Editar calendario'><i class='material-icons icon'>edit</i></a>
89 <a href='dynamic/deletecalendar.php?id=<?=(int)$c['id']?>' data-dyndialog-href='dynamic/deletecalendar.php?id=<?=(int)$c['id']?>' title='Eliminar calendario'><i class='material-icons icon'>delete</i></a>
90 <a href='dynamic/exportcalendar.php?id=<?=(int)$c['id']?>' data-dyndialog-href='dynamic/exportcalendar.php?id=<?=(int)$c['id']?>' title='Exportar calendario'><i class='material-icons icon'>code</i></a>
91 </td>
92 </tr>
93 <?php
94 }
95 ?>
96 </tbody>
97 </table>
98 </div>
99 <?php
100 } else {
101 echo "<p>No se ha configurado ningún calendario todavía.</p>";
102 }
103 }
104 ?>
105
106 <?php visual::printDebug("calendars::getAll()", $calendars_response); ?>
107 </div>
108 </div>
109 </main>
110 </div>
111
112 <div class="mdl-snackbar mdl-js-snackbar">
113 <div class="mdl-snackbar__text"></div>
114 <button type="button" class="mdl-snackbar__action"></button>
115 </div>
116
117 <?php
118 visual::renderTooltips();
119
120 visual::smartSnackbar([
121 ["added", "Se ha añadido el calendario correctamente."],
122 ["modified", "Se ha modificado el calendario correctamente."],
123 ["deleted", "Se ha eliminado el calendario correctamente."],
124 ["empty", "Faltan datos por introducir en el formulario o el correo electrónico es incorrecto."],
125 ["unexpected", "Ha ocurrido un error inesperado. Inténtelo de nuevo en unos segundos."],
126 ["overlap", "El calendario que intentabas añadir se solapa con uno ya existente, así que no se ha añadido."]
127 ], 10000, false);
128 ?>
129</body>
130</html>