Project import generated by Copybara.

GitOrigin-RevId: 63746295f1a5ab5a619056791995793d65529e62
diff --git a/src/dynamic/workhistory.php b/src/dynamic/workhistory.php
new file mode 100644
index 0000000..4c74000
--- /dev/null
+++ b/src/dynamic/workhistory.php
@@ -0,0 +1,91 @@
+<?php
+require_once(__DIR__."/../core.php");
+security::checkType(security::ADMIN, security::METHOD_NOTFOUND);
+
+if (!isset($_GET["id"])) {
+  security::notFound();
+}
+
+$id = (int)$_GET["id"];
+
+$worker = workers::get($id);
+if ($worker === false) security::notFound();
+?>
+
+<dynscript>
+document.getElementById("additem").addEventListener("click", e => {
+  dynDialog.load("dynamic/addworkhistoryitem.php?id="+parseInt(document.getElementById("additem").getAttribute("worker-id")));
+});
+
+document.querySelectorAll(".edititem").forEach(el => {
+  el.addEventListener("click", e => {
+    dynDialog.load("dynamic/editworkhistoryitem.php?id="+parseInt(el.getAttribute("data-id")));
+  });
+});
+
+document.querySelectorAll(".deleteitem").forEach(el => {
+  el.addEventListener("click", e => {
+    dynDialog.load("dynamic/deleteworkhistoryitem.php?id="+parseInt(el.getAttribute("data-id")));
+  });
+});
+</dynscript>
+
+<style>
+#dynDialog {
+  max-width: 380px;
+  width: auto;
+}
+
+#dynDialog .mdl-list {
+  margin-top: 0;
+  padding-top: 0;
+}
+
+.float-right {
+  float: right;
+}
+</style>
+
+<h4 class="mdl-dialog__title">Historial de altas y bajas</h4>
+<div class="mdl-dialog__content">
+  <p><b>Persona:</b> <?=security::htmlsafe($worker["name"])?><br>
+  <b>Empresa:</b> <?=security::htmlsafe($worker["companyname"])?></p>
+
+  <div class="float-right"><button id="additem" class="mdl-button mdl-js-button mdl-js-ripple-effect" worker-id="<?=(int)$worker["id"]?>"><i class="material-icons">add</i> Añadir alta/baja</button></div>
+  <div style="clear: both;"></div>
+
+  <?php
+  $items = workers::getWorkHistory($id);
+
+  if ($items === false) {
+    echo "<p>Ha ocurrido un problema cargando los elementos del historial.</p>";
+  } elseif (!count($items)) {
+    echo "<p>No hay ningún elmento en el historial, así que el aplicativo está considerando que el trabajador está de baja.</p>";
+  } else {
+    echo '<ul class="mdl-list">';
+    foreach ($items as $item) {
+      $icon = security::htmlsafe(workers::affiliationStatusIcon($item["status"]) ?? "indeterminate_check_box");
+      $helper = workers::affiliationStatusHelper($item["status"]);
+      $day = date("d/m/Y", $item["day"]);
+      $isAutomatic = workers::isAutomaticAffiliation($item["status"]);
+      echo '<li class="mdl-list__item '.($isAutomatic ? 'mdl-list__item--two-line' : '').'">
+        <span class="mdl-list__item-primary-content">
+          <i class="material-icons mdl-list__item-icon">'.security::htmlsafe($icon).'</i>
+          <span>'.security::htmlsafe($helper).' ('.security::htmlsafe($day).')</span>
+          '.($isAutomatic ? '<span class="mdl-list__item-sub-title">Registro automático</span>' : '').'
+        </span>
+        <button class="mdl-list__item-secondar-action mdl-button mdl-js-button mdl-button--icon mdl-js-ripple-effect edititem" data-id="'.(int)$item["id"].'">
+          <i class="material-icons">edit</i>
+        </button>
+        <button class="mdl-list__item-secondar-action mdl-button mdl-js-button mdl-button--icon mdl-js-ripple-effect deleteitem" data-id="'.(int)$item["id"].'">
+          <i class="material-icons">delete</i>
+        </button>
+      </li>';
+    }
+    echo "</ul>";
+  }
+  ?>
+</div>
+<div class="mdl-dialog__actions">
+  <button data-dyndialog-close class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--accent">Cerrar</button>
+</div>