blob: 17bb29e0f3e94c07b8749573823facadf32225cf [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$mainURL = (security::isAdminView() ? "workers.php" : "workerhome.php");
9
10if (!security::checkParams("GET", [
11 ["id", security::PARAM_ISINT]
12])) {
13 security::go($mainURL);
14}
15
16$id = (int)$_GET["id"];
17
18if (!$isAdmin && people::userData("id") != $id) {
19 security::notFound();
20}
21
22$p = people::get($id);
23
24if ($p === false) {
25 security::go($mainURL);
26}
27
28$workers = workers::getPersonWorkers((int)$p["id"]);
29$companies = companies::getAll();
30
31if ($workers === false || $companies === false) {
32 security::go($mainURL."?msg=unexpected");
33}
34
35$numRows = registry::numRowsUser($p["id"]);
36
37if (security::isAdminView()) $mdHeaderRowBefore = visual::backBtn("workers.php");
38?>
39<!DOCTYPE html>
40<html>
41<head>
42 <title><?php echo $conf["appName"]; ?></title>
43 <?php visual::includeHead(); ?>
44 <link rel="stylesheet" href="css/dashboard.css">
45 <link rel="stylesheet" href="css/incidents.css">
46 <style>
47 @media (max-width: 400px) {
48 #exportbtn {
49 display: none;
50 }
51 }
52 </style>
53</head>
54<?php visual::printBodyTag(); ?>
55 <div class="mdl-layout mdl-js-layout mdl-layout--fixed-header mdl-layout--fixed-drawer">
56 <?php
57 visual::includeNav();
58 ?>
59 <main class="mdl-layout__content">
60 <div class="page-content">
61 <div class="main mdl-shadow--4dp">
62 <?php
63 if (!security::isAdminView()) {
64 ?>
65 <div class="actions">
66 <a href="export4worker.php?id=<?=(int)$_SESSION["id"]?>" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" id="exportbtn"><i class="material-icons">cloud_download</i> Exportar registro e incidencias</a>
67 <?php helpView::renderHelpButton(help::PLACE_REGISTRY_PAGE); ?>
68 </div>
69 <?php
70 }
71 ?>
72
73 <?php
74 $title = "Registro".(security::isAdminView() ? " de &ldquo;".security::htmlsafe($p["name"])."&rdquo;" : "");
75 ?>
76 <h2><?=$title?></h2>
77
78 <p>Total: <?=(int)$numRows?> registros</p>
79
80 <?php
81 $page = (isset($_GET["page"]) ? (int)$_GET["page"] - 1 : null);
82
83 $registry = registry::getRecords($p["id"], false, false, true, true, true, $page, registry::REGISTRY_PAGINATION_LIMIT, true);
84 if (count($registry)) {
85 registryView::renderRegistry($registry, $companies, false, true, !security::isAdminView());
86 }
87 ?>
88
89 <?php
90 visual::renderPagination($numRows, "userregistry.php?id=".(int)$p["id"], incidents::PAGINATION_LIMIT, false, true);
91 visual::printDebug("registry::getRecords(".(int)$p["id"].", false, false, true, true, true, ".(int)$page.", registry::REGISTRY_PAGINATION_LIMIT, true)", $registry);
92 ?>
93 </div>
94 </div>
95 </main>
96 </div>
97
98 <?php
99 visual::renderTooltips();
100
101 visual::smartSnackbar([
102 ["unexpected", "Ha ocurrido un error inesperado. Inténtelo de nuevo en unos segundos."]
103 ]);
104 ?>
105
106 <script src="js/userincidents.js"></script>
107 <script src="js/incidentsgeneric.js"></script>
108</body>
109</html>