blob: 45633d6df4d7e5489143f79080e578bc62248aa6 [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(__DIR__."/../core.php");
22security::checkType(security::ADMIN, security::METHOD_NOTFOUND);
23
24if (!isset($_GET["id"])) {
25 security::notFound();
26}
27
28$id = (int)$_GET["id"];
29
30$day = schedules::getDay($id);
31
32if ($day === false) {
33 security::notFound();
34}
35
36$empty = [];
37
38foreach (schedules::$allEvents as $date) {
39 $empty[$date] = (intervals::measure([$day["begins".$date], $day["ends".$date]]) == 0);
40}
41?>
42
43<form action="doeditdayschedule.php" method="POST" autocomplete="off">
44 <input type="hidden" name="id" value="<?=(int)$day["id"]?>">
45 <h4 class="mdl-dialog__title">Modificar horario</h4>
46 <div class="mdl-dialog__content">
47 <h5>Día</h5>
48 <div class="mdlext-selectfield mdlext-js-selectfield mdlext-selectfield--floating-label">
49 <select id="edit_day" class="mdlext-selectfield__select" disabled>
50 <?php
51 foreach (calendars::$days as $id => $tday) {
52 echo '<option value="'.(int)$id.'"'.($day["day"] == $id ? " selected" : "").'>'.security::htmlsafe($tday).'</option>';
53 }
54 ?>
55 </select>
56 <label for="edit_day" class="mdlext-selectfield__label">Día de la semana</label>
57 </div>
58 <br>
59 <div class="mdlext-selectfield mdlext-js-selectfield mdlext-selectfield--floating-label">
60 <select id="edit_type" class="mdlext-selectfield__select" disabled>
61 <?php
62 foreach (calendars::$types as $id => $type) {
63 if ($id == calendars::TYPE_FESTIU) continue;
64 echo '<option value="'.(int)$id.'"'.($day["typeday"] == $id ? " selected" : "").'>'.security::htmlsafe($type).'</option>';
65 }
66 ?>
67 </select>
68 <label for="edit_type" class="mdlext-selectfield__label">Tipo de día</label>
69 </div>
70
71 <h5>Jornada laboral</h5>
72 <p>De <input type="time" name="beginswork" <?=(!$empty["work"] ? " value='".schedules::sec2time($day["beginswork"])."'" : "")?> required> a <input type="time" name="endswork" <?=(!$empty["work"] ? " value='".schedules::sec2time($day["endswork"])."'" : "")?> required></p>
73
74 <h5>Desayuno</h5>
75 <p>De <input type="time" name="beginsbreakfast" <?=(!$empty["breakfast"] ? " value='".schedules::sec2time($day["beginsbreakfast"])."'" : "")?>> a <input type="time" name="endsbreakfast" <?=(!$empty["breakfast"] ? " value='".schedules::sec2time($day["endsbreakfast"])."'" : "")?>></p>
76
77 <h5>Comida</h5>
78 <p>De <input type="time" name="beginslunch" <?=(!$empty["lunch"] ? " value='".schedules::sec2time($day["beginslunch"])."'" : "")?>> a <input type="time" name="endslunch" <?=(!$empty["lunch"] ? " value='".schedules::sec2time($day["endslunch"])."'" : "")?>></p>
79 </div>
80 <div class="mdl-dialog__actions">
81 <button type="submit" class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--primary">Modificar</button>
82 <button data-dyndialog-close class="mdl-button mdl-js-button mdl-js-ripple-effect cancel">Cancelar</button>
83 </div>
84</form>