blob: ac0f8ca6c5406769e4b0382af6388c4046f5b035 [file] [log] [blame]
Copybara botbe50d492023-11-30 00:16:42 +01001<?php
2require_once("core.php");
3security::checkType(security::ADMIN);
4
5$mdHeaderRowBefore = visual::backBtn("calendars.php");
6
7if (!security::checkParams("GET", [
8 ["id", security::PARAM_NEMPTY]
9])) {
10 security::go("calendars.php");
11}
12
13$id = (int)$_GET["id"];
14
15$c = calendars::get($id);
16
17if ($c === false) {
18 security::go("calendars.php");
19}
20
21$details = json_decode($c["details"], true);
22
23if (json_last_error() !== JSON_ERROR_NONE) {
24 security::go("calendars.php?msg=unexpected");
25}
26
27$viewOnly = (isset($_GET["view"]) && $_GET["view"] == 1);
28?>
29<!DOCTYPE html>
30<html>
31<head>
32 <title><?php echo $conf["appName"]; ?></title>
33 <?php visual::includeHead(); ?>
34 <link rel="stylesheet" href="css/dashboard.css">
35 <link rel="stylesheet" href="css/calendar.css">
36</head>
37<?php visual::printBodyTag(); ?>
38 <div class="mdl-layout mdl-js-layout mdl-layout--fixed-header mdl-layout--fixed-drawer">
39 <?php visual::includeNav(); ?>
40 <main class="mdl-layout__content">
41 <div class="page-content">
42 <div class="main mdl-shadow--4dp">
43 <h2>Calendario de &ldquo;<?=security::htmlsafe($c["categoryname"])?>&rdquo;</h2>
44 <?php
45 $current = new DateTime();
46 $current->setTimestamp($c["begins"]);
47 $ends = new DateTime();
48 $ends->setTimestamp($c["ends"]);
49 ?>
50 <form action="doeditcalendar.php" method="POST">
51 <input type="hidden" name="id" value="<?=(int)$id?>">
52 <?php
53 calendarsView::renderCalendar($current, $ends, function ($timestamp, $id, $dow, $dom, $extra) {
54 return ($extra[$timestamp] == $id);
55 }, $viewOnly, $details);
56
57 if (!$viewOnly) {
58 ?>
59 <button class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent">Modificar</button>
60 <?php
61 }
62 ?>
63 </form>
64 </div>
65 </div>
66 </main>
67 </div>
68
69 <script src="js/calendar.js"></script>
70
71 <?php
72 visual::smartSnackbar([
73 ["inverted", "La fecha de inicio debe ser anterior a la fecha de fin."],
74 ["overlap", "El calendario que intentabas aƱadir se solapa con uno ya existente."]
75 ]);
76 ?>
77</body>
78</html>