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