blob: 9ba43e6097c19d60fe50552bc9a218a25c4e9e72 [file] [log] [blame]
Copybara botbe50d492023-11-30 00:16:42 +01001<?php
2require_once("core.php");
3security::checkType(security::WORKER);
4security::checkWorkerUIEnabled();
5
6$isAdmin = security::isAllowed(security::ADMIN);
7
8$id = $_GET["id"] ?? people::userData("id");
9$id = (int)$id;
10
11if (!$isAdmin && people::userData("id") != $id) {
12 security::notFound();
13}
14
15$p = people::get($id);
16
17if ($p === false) {
18 security::go((security::isAdminView() ? "workers.php" : "workerhome.php"));
19}
20
21if (security::isAdminView()) $mdHeaderRowBefore = visual::backBtn("workers.php");
22
23$plaintext = isset($_GET["plaintext"]) && $_GET["plaintext"] == "1";
24$companies = companies::getAll();
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 <link rel="stylesheet" href="css/schedule.css">
33</head>
34<?php visual::printBodyTag(); ?>
35 <div class="mdl-layout mdl-js-layout mdl-layout--fixed-header mdl-layout--fixed-drawer">
36 <?php visual::includeNav(); ?>
37 <main class="mdl-layout__content">
38 <div class="page-content">
39 <div class="main mdl-shadow--4dp">
40 <div class="actions">
41 <?php
42 if (!security::isAdminView()) {
43 ?>
44 <a href="workercalendar.php" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect"><i class="material-icons">today</i> Calendario laboral</a>
45 <?php
46 }
47 ?>
48 <a href="userschedule.php?id=<?=(int)$id?>" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect"><i class="material-icons">timelapse</i> <?=(security::isAdminView() ? "Administrar los horarios" : "Todos los horarios")?></a>
49 </div>
50
51 <h2>Horario actual<?=(security::isAdminView() ? " de &ldquo;".security::htmlsafe($p["name"])."&rdquo;" : "")?></h2>
52
53 <?php
54 $schedules = schedules::getCurrent($id);
55
56 if (!count($schedules)) {
57 echo "<p>Actualmente no tienes asignado ningún horario.</p>";
58 } else {
59 foreach ($schedules as $i => $schedule) {
60 $worker = workers::get($schedule["worker"]);
61
62 if (security::isAdminView()) {
63 ?>
64 <a href="schedule.php?id=<?=(int)$schedule["id"]?>" class="mdl-button mdl-js-button mdl-button--icon mdl-js-ripple-effect" style="float: right;"><i class="material-icons">edit</i><span class="mdl-ripple"></span></a>
65 <?php
66 }
67 ?>
68 <p>
69 <b>Empresa:</b> <?=$companies[$worker["company"]]?><br>
70 <b>Validez:</b> del <?=security::htmlsafe(date("d/m/Y", $schedule["begins"]))?> al <?=security::htmlsafe(date("d/m/Y", $schedule["ends"]))?>
71 </p>
72 <?php
73 if ($plaintext) {
74 $flag = false;
75 foreach ($schedule["days"] as $typeday) {
76 schedulesView::renderPlainSchedule($typeday, false, null, null, $flag);
77 }
78
79 if (!$flag) {
80 echo "<p>Tu horario todavía no está configurado.</p>";
81 }
82 } else {
83 foreach (calendars::$types as $tdid => $type) {
84 if ($tdid == calendars::TYPE_FESTIU) continue;
85
86 $tdisset = isset($schedule["days"][$tdid]);
87
88 echo "<h4>".security::htmlsafe(calendars::$types[$tdid])."</h4>";
89
90 if ($tdisset) {
91 schedulesView::renderSchedule($schedule["days"][$tdid], false, null, null);
92 } else {
93 echo "<p>Todavía no hay configurado ningún horario en días del tipo \"".security::htmlsafe(calendars::$types[$tdid])."\".</p>";
94 }
95 }
96 }
97
98 if ($i + 1 != count($schedules)) echo "<hr>";
99 }
100 }
101 ?>
102
103 <?php visual::printDebug("schedules::getCurrent()", $schedules); ?>
104 </div>
105 </div>
106 </main>
107 </div>
108
109 <?php
110 visual::smartSnackbar([
111 ["unexpected", "Ha ocurrido un error inesperado. Inténtelo de nuevo en unos segundos."]
112 ]);
113 ?>
114</body>
115</html>