blob: c38bca8db38c97884376e6c17d70cda1c4b4ed66 [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("calendars.php");
25
26if (!security::checkParams("GET", [
27 ["id", security::PARAM_NEMPTY]
28])) {
29 security::go("calendars.php");
30}
31
32$id = (int)$_GET["id"];
33
34$c = calendars::get($id);
35
36if ($c === false) {
37 security::go("calendars.php");
38}
39
40$details = json_decode($c["details"], true);
41
42if (json_last_error() !== JSON_ERROR_NONE) {
43 security::go("calendars.php?msg=unexpected");
44}
45
46$viewOnly = (isset($_GET["view"]) && $_GET["view"] == 1);
47?>
48<!DOCTYPE html>
49<html>
50<head>
51 <title><?php echo $conf["appName"]; ?></title>
52 <?php visual::includeHead(); ?>
53 <link rel="stylesheet" href="css/dashboard.css">
54 <link rel="stylesheet" href="css/calendar.css">
55</head>
56<?php visual::printBodyTag(); ?>
57 <div class="mdl-layout mdl-js-layout mdl-layout--fixed-header mdl-layout--fixed-drawer">
58 <?php visual::includeNav(); ?>
59 <main class="mdl-layout__content">
60 <div class="page-content">
61 <div class="main mdl-shadow--4dp">
62 <h2>Calendario de &ldquo;<?=security::htmlsafe($c["categoryname"])?>&rdquo;</h2>
63 <?php
64 $current = new DateTime();
65 $current->setTimestamp($c["begins"]);
66 $ends = new DateTime();
67 $ends->setTimestamp($c["ends"]);
68 ?>
69 <form action="doeditcalendar.php" method="POST">
70 <input type="hidden" name="id" value="<?=(int)$id?>">
71 <?php
72 calendarsView::renderCalendar($current, $ends, function ($timestamp, $id, $dow, $dom, $extra) {
73 return ($extra[$timestamp] == $id);
74 }, $viewOnly, $details);
75
76 if (!$viewOnly) {
77 ?>
78 <button class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent">Modificar</button>
79 <?php
80 }
81 ?>
82 </form>
83 </div>
84 </div>
85 </main>
86 </div>
87
88 <script src="js/calendar.js"></script>
89
90 <?php
91 visual::smartSnackbar([
92 ["inverted", "La fecha de inicio debe ser anterior a la fecha de fin."],
93 ["overlap", "El calendario que intentabas añadir se solapa con uno ya existente."]
94 ]);
95 ?>
96</body>
97</html>