Project import generated by Copybara.

GitOrigin-RevId: 63746295f1a5ab5a619056791995793d65529e62
diff --git a/src/dynamic/editincident.php b/src/dynamic/editincident.php
new file mode 100644
index 0000000..808070e
--- /dev/null
+++ b/src/dynamic/editincident.php
@@ -0,0 +1,68 @@
+<?php
+require_once(__DIR__."/../core.php");
+security::checkType(security::WORKER, security::METHOD_NOTFOUND);
+security::checkWorkerUIEnabled();
+
+if (!isset($_GET["id"])) {
+  security::notFound();
+}
+
+$id = (int)$_GET["id"];
+
+$incident = incidents::get($id, true);
+if ($incident === false) security::notFound();
+
+$isAdmin = security::isAdminView();
+$status = incidents::getStatus($incident);
+
+if (($isAdmin && in_array($status, incidents::$cannotEditStates)) || (!$isAdmin && !in_array($status, incidents::$workerCanEditStates))) security::notFound();
+if (!$isAdmin) incidents::checkIncidentIsFromPerson($incident["id"]);
+?>
+
+<dynscript>
+document.getElementById("edit_allday").addEventListener("change", e => {
+  var partialtime = document.getElementById("edit_partialtime");
+  if (e.target.checked) {
+    partialtime.classList.add("notvisible");
+  } else {
+    partialtime.classList.remove("notvisible");
+  }
+});
+</dynscript>
+
+<form action="doeditincident.php" method="POST" autocomplete="off">
+  <input type="hidden" name="id" value="<?=(int)$id?>">
+  <?php visual::addContinueInput(); ?>
+  <h4 class="mdl-dialog__title">Editar incidencia</h4>
+  <div class="mdl-dialog__content">
+    <div class="mdlext-selectfield mdlext-js-selectfield mdlext-selectfield--floating-label">
+      <select name="type" id="edit_type" class="mdlext-selectfield__select" data-required>
+        <option></option>
+        <?php
+        foreach (incidents::getTypesForm() as $i) {
+          echo '<option value="'.(int)$i["id"].'"'.($i["id"] == $incident["type"] ? " selected" : "").'>'.security::htmlsafe($i["name"]).'</option>';
+        }
+        ?>
+      </select>
+      <label for="edit_type" class="mdlext-selectfield__label">Tipo</label>
+    </div>
+
+    <h5>Afectación</h5>
+    <div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
+      <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>
+      <label class="mdl-textfield__label always-focused" for="edit_day">Día</label>
+    </div>
+    <br>
+    <p>
+      <label class="mdl-switch mdl-js-switch mdl-js-ripple-effect" for="edit_allday">
+        <input type="checkbox" id="edit_allday" name="allday" value="1" class="mdl-switch__input"<?=($incident["allday"] ? " checked" : "")?>>
+        <span class="mdl-switch__label">Día entero</span>
+      </label>
+    </p>
+    <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>
+  </div>
+  <div class="mdl-dialog__actions">
+    <button type="submit" class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--accent">Editar</button>
+    <button data-dyndialog-close class="mdl-button mdl-js-button mdl-js-ripple-effect cancel">Cancelar</button>
+  </div>
+</form>