blob: 09150484cb5000391e54559b3188869d00b9dc9a [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::WORKER);
23security::checkWorkerUIEnabled();
24
25$id = (int)people::userData("id");
26
27$p = people::get($id);
28
29if ($p === false) {
30 security::go((security::isAdminView() ? "workers.php" : "workerhome.php"));
31}
32
33$cal = calendars::getCurrentCalendarByCategory($p["categoryid"]);
34if ($cal === false) security::go("workerhome.php?msg=unexpected");
35
36$mdHeaderRowBefore = visual::backBtn("workerschedule.php");
37?>
38<!DOCTYPE html>
39<html>
40<head>
41 <title><?php echo $conf["appName"]; ?></title>
42 <?php visual::includeHead(); ?>
43 <link rel="stylesheet" href="css/dashboard.css">
44 <link rel="stylesheet" href="css/calendar.css">
45</head>
46<?php visual::printBodyTag(); ?>
47 <div class="mdl-layout mdl-js-layout mdl-layout--fixed-header mdl-layout--fixed-drawer">
48 <?php visual::includeNav(); ?>
49 <main class="mdl-layout__content">
50 <div class="page-content">
51 <div class="main mdl-shadow--4dp">
52 <h2>Calendario laboral</h2>
53
54 <?php
55 if ($cal === calendars::NO_CALENDAR_APPLICABLE) {
56 echo "<p>Actualmente no tienes asignado ningún calendario laboral.</p>";
57 } else {
58 $current = new DateTime();
59 $current->setTimestamp($cal["begins"]);
60 $ends = new DateTime();
61 $ends->setTimestamp($cal["ends"]);
62
63 calendarsView::renderCalendar($current, $ends, function ($timestamp, $id, $dow, $dom, $extra) {
64 return ($extra[$timestamp] == $id);
65 }, true, $cal["details"]);
66 }
67 ?>
68
69 <?php visual::printDebug("calendars::getCurrentCalendarByCategory(".(int)$p["categoryid"].")", $cal); ?>
70 </div>
71 </div>
72 </main>
73 </div>
74
75 <script src="js/calendar.js"></script>
76
77 <?php
78 visual::smartSnackbar([
79 ["unexpected", "Ha ocurrido un error inesperado. Inténtelo de nuevo en unos segundos."]
80 ]);
81 ?>
82</body>
83</html>