blob: 808070e2c46613c4a3cc633d36df1df3b6d88401 [file] [log] [blame]
Copybara botbe50d492023-11-30 00:16:42 +01001<?php
2require_once(__DIR__."/../core.php");
3security::checkType(security::WORKER, security::METHOD_NOTFOUND);
4security::checkWorkerUIEnabled();
5
6if (!isset($_GET["id"])) {
7 security::notFound();
8}
9
10$id = (int)$_GET["id"];
11
12$incident = incidents::get($id, true);
13if ($incident === false) security::notFound();
14
15$isAdmin = security::isAdminView();
16$status = incidents::getStatus($incident);
17
18if (($isAdmin && in_array($status, incidents::$cannotEditStates)) || (!$isAdmin && !in_array($status, incidents::$workerCanEditStates))) security::notFound();
19if (!$isAdmin) incidents::checkIncidentIsFromPerson($incident["id"]);
20?>
21
22<dynscript>
23document.getElementById("edit_allday").addEventListener("change", e => {
24 var partialtime = document.getElementById("edit_partialtime");
25 if (e.target.checked) {
26 partialtime.classList.add("notvisible");
27 } else {
28 partialtime.classList.remove("notvisible");
29 }
30});
31</dynscript>
32
33<form action="doeditincident.php" method="POST" autocomplete="off">
34 <input type="hidden" name="id" value="<?=(int)$id?>">
35 <?php visual::addContinueInput(); ?>
36 <h4 class="mdl-dialog__title">Editar incidencia</h4>
37 <div class="mdl-dialog__content">
38 <div class="mdlext-selectfield mdlext-js-selectfield mdlext-selectfield--floating-label">
39 <select name="type" id="edit_type" class="mdlext-selectfield__select" data-required>
40 <option></option>
41 <?php
42 foreach (incidents::getTypesForm() as $i) {
43 echo '<option value="'.(int)$i["id"].'"'.($i["id"] == $incident["type"] ? " selected" : "").'>'.security::htmlsafe($i["name"]).'</option>';
44 }
45 ?>
46 </select>
47 <label for="edit_type" class="mdlext-selectfield__label">Tipo</label>
48 </div>
49
50 <h5>Afectación</h5>
51 <div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
52 <input class="mdl-textfield__input" type="date" name="day" id="edit_day" autocomplete="off" value="<?=security::htmlsafe(date("Y-m-d", $incident["day"]))?>" data-required>
53 <label class="mdl-textfield__label always-focused" for="edit_day">Día</label>
54 </div>
55 <br>
56 <p>
57 <label class="mdl-switch mdl-js-switch mdl-js-ripple-effect" for="edit_allday">
58 <input type="checkbox" id="edit_allday" name="allday" value="1" class="mdl-switch__input"<?=($incident["allday"] ? " checked" : "")?>>
59 <span class="mdl-switch__label">Día entero</span>
60 </label>
61 </p>
62 <div id="edit_partialtime"<?=($incident["allday"] ? ' class="notvisible"' : '')?>>De <input type="time" name="begins"<?=($incident["allday"] ? '' : ' value="'.schedules::sec2time($incident["begins"]).'"')?>> a <input type="time" name="ends"<?=($incident["allday"] ? '' : ' value="'.schedules::sec2time($incident["ends"]).'"')?>></div>
63 </div>
64 <div class="mdl-dialog__actions">
65 <button type="submit" class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--accent">Editar</button>
66 <button data-dyndialog-close class="mdl-button mdl-js-button mdl-js-ripple-effect cancel">Cancelar</button>
67 </div>
68</form>