blob: 689a59ad0a1c9ba7e1fe3ee8fd4f522ae3e2cf85 [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::ADMIN);
23
24$mdHeaderRowMore = '<div class="mdl-layout-spacer"></div>
25<div class="mdl-textfield mdl-js-textfield mdl-textfield--expandable
26 mdl-textfield--floating-label mdl-textfield--align-right">
27 <label class="mdl-button mdl-js-button mdl-button--icon"
28 for="usuario">
29 <i class="material-icons">search</i>
30 </label>
31 <div class="mdl-textfield__expandable-holder">
32 <input class="mdl-textfield__input" type="text" name="usuario"
33 id="usuario">
34 </div>
35</div>';
36
37listings::buildSelect("workers.php");
38
39$companies = companies::getAll();
40?>
41<!DOCTYPE html>
42<html>
43<head>
44 <title><?php echo $conf["appName"]; ?></title>
45 <?php visual::includeHead(); ?>
46 <link rel="stylesheet" href="css/dashboard.css">
47
48 <style>
49 .filter {
50 position:fixed;
51 bottom: 25px;
52 right: 25px;
53 z-index: 1000;
54 }
55
56 @media (max-width: 655px) {
57 .extra {
58 display: none;
59 }
60 }
61
62 table.has-actions-above {
63 border-top: 0!important;
64 }
65
66 /* Hide datable's search box */
67 .dataTables_wrapper .mdl-grid:first-child {
68 display: none;
69 }
70 .dt-table {
71 padding: 0!important;
72 }
73 .dt-table .mdl-cell {
74 margin: 0!important;
75 }
76 #usuario {
77 position: relative;
78 }
79 </style>
80</head>
81<?php visual::printBodyTag(); ?>
82 <div class="mdl-layout mdl-js-layout mdl-layout--fixed-header mdl-layout--fixed-drawer">
83 <?php visual::includeNav(); ?>
84
85 <button class="filter mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-color--grey-200"><i class="material-icons">filter_list</i></button>
86 <main class="mdl-layout__content">
87 <div class="page-content">
88 <div class="main mdl-shadow--4dp">
89 <div class="actions">
90 <a href="scheduletemplates.php" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect"><i class="material-icons">timelapse</i> Administrar plantillas</a>
91 </div>
92
93 <h2>Trabajadores</h2>
94 <div class="left-actions">
95 <button id="copytemplate" class="mdl-button mdl-js-button mdl-button--icon mdl-js-ripple-effect"><i class="material-icons icon">add_alarm</i></button>
96 <button id="addincidentbulk" class="mdl-button mdl-js-button mdl-button--icon mdl-js-ripple-effect"><i class="material-icons icon">note_add</i></button>
97 <button id="addrecurringincident" class="mdl-button mdl-js-button mdl-button--icon mdl-js-ripple-effect"><i class="material-icons icon">repeat</i></button>
98 </div>
99 <?php
100 visual::addTooltip("copytemplate", "Copiar plantilla de horario a los trabajadores seleccionados");
101 visual::addTooltip("addincidentbulk", "Añadir incidencia a los trabajadores seleccionados");
102 visual::addTooltip("addrecurringincident", "Añadir incidencia recurrente al trabajador seleccionado");
103 ?>
104 <div class="overflow-wrapper overflow-wrapper--for-table">
105 <table class="mdl-data-table mdl-js-data-table mdl-data-table--selectable mdl-shadow--2dp datatable has-actions-above">
106 <thead>
107 <tr>
108 <?php
109 if ($conf["debug"]) {
110 ?>
111 <th class="extra">ID</th>
112 <?php
113 }
114 ?>
115 <th class="mdl-data-table__cell--non-numeric">Nombre</th>
116 <th class="mdl-data-table__cell--non-numeric">Empresa</th>
117 <th class="mdl-data-table__cell--non-numeric extra">Categoría</th>
118 <th class="mdl-data-table__cell--non-numeric"></th>
119 </tr>
120 </thead>
121 <tbody>
122 <?php
123 $workers = people::getAll($select, true);
124 foreach ($workers as $w) {
125 $schedulesStatusDetailed = schedules::getWorkerScheduleStatus($w["workerid"]);
126 $schedulesStatus = $schedulesStatusDetailed["status"];
127 if ($selectedSchedulesStatus !== false && !in_array($schedulesStatus, $selectedSchedulesStatus)) continue;
128 ?>
129 <tr data-worker-id="<?=(int)$w["workerid"]?>"<?=($w["hidden"] == 1 ? "class=\"mdl-color-text--grey-700\"" : "")?>>
130 <?php
131 if ($conf["debug"]) {
132 ?>
133 <td class="extra"><?=(int)$w["workerid"]?></td>
134 <?php
135 }
136 ?>
137 <td class="mdl-data-table__cell--non-numeric"><?=($w["hidden"] == 1 ? "<s>" : "").security::htmlsafe($w["name"]).($w["hidden"] == 1 ? "</s>" : "")?></td>
138 <td class="mdl-data-table__cell--non-numeric"><?=($w["hidden"] == 1 ? "<s>" : "").security::htmlsafe($companies[$w["companyid"]]).($w["hidden"] == 1 ? "</s>" : "")?></td>
139 <td class="mdl-data-table__cell--non-numeric extra"><?=($w["hidden"] == 1 ? "<s>" : "").security::htmlsafe($w["category"]).($w["hidden"] == 1 ? "</s>" : "")?></td>
140 <td class='mdl-data-table__cell--non-numeric'>
141 <a href='<?=($schedulesStatus == schedules::STATUS_NO_ACTIVE_SCHEDULE ? "userschedule" : "workerschedule")?>.php?id=<?=(int)$w['id']?>' title='Ver y gestionar los horarios del trabajador' class='mdl-color-text--<?=security::htmlsafe((schedules::$workerScheduleStatusColors[$schedulesStatus] ?? "black"))?>'><i class='material-icons icon-no-black'>timelapse</i></a>
142 <a href='userincidents.php?id=<?=(int)$w['id']?>' title='Ver y gestionar las incidencias del trabajador'><i class='material-icons icon'>assignment_late</i></a>
143 <a href='userregistry.php?id=<?=(int)$w['id']?>' title='Ver y gestionar los registros del trabajador'><i class='material-icons icon'>list</i></a>
144 <a href='dynamic/workhistory.php?id=<?=(int)$w['workerid']?>' data-dyndialog-href='dynamic/workhistory.php?id=<?=(int)$w['workerid']?>' title='Acceder al historial de altas y bajas'><i class='material-icons icon'>history</i></a>
145 </td>
146 </tr>
147 <?php
148 }
149 ?>
150 </tbody>
151 </table>
152 </div>
153
154 <?php visual::printDebug("people::getAll(\$select, true)", $workers); ?>
155 <?php visual::printDebug("\$select", $select); ?>
156 </div>
157 </div>
158 </main>
159 </div>
160
161 <?php listings::renderFilterDialog("workers.php", $select); ?>
162
163 <?php
164 visual::renderTooltips();
165
166 visual::smartSnackbar([
167 ["unexpected", "Ha ocurrido un error inesperado. Inténtelo de nuevo en unos segundos."],
168 ["copied", "Plantilla copiada correctamente."],
169 ["empty", "Faltaban datos por rellenar en el formulario o ha ocurrido un error inesperado."]
170 ]);
171 ?>
172
173 <script src="js/workers.js"></script>
174 <script src="node_modules/jquery/dist/jquery.min.js"></script>
175 <script src="node_modules/datatables/media/js/jquery.dataTables.min.js"></script>
176 <script src="lib/datatables/dataTables.material.min.js"></script>
177
178 <?php
179 if (isset($_GET["openWorkerHistory"])) {
180 ?>
181 <script>
182 window.addEventListener("load", _ => {
183 dynDialog.load("dynamic/workhistory.php?id=<?=(int)$_GET["openWorkerHistory"]?>");
184 });
185 </script>
186 <?php
187 }
188 ?>
189</body>
190</html>