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