blob: 6239a5f203c08c7728de047ae6fcadaa69984e66 [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$companies = companies::getAll();
25
26$date = new DateTime();
27$interval = new DateInterval("P1D");
28$date->sub($interval);
29$yesterday = date("Y-m-d", $date->getTimestamp());
30?>
31<!DOCTYPE html>
32<html>
33<head>
34 <title><?php echo $conf["appName"]; ?></title>
35 <?php visual::includeHead(); ?>
36 <link rel="stylesheet" href="css/dashboard.css">
37
38 <style>
39 .categories-select {
40 float: right;
41 border-left: 1px solid #ccc;
42 padding: 0 32px 16px 16px;
43 user-select: none;
44 }
45
46 .categories-select .select-all {
47 color: blue;
48 text-decoration: underline;
49 cursor: pointer;
50 }
51
52 @media (max-width: 500px) {
53 .categories-select {
54 float: none;
55 border-left: none;
56 border-top: 1px solid #ddd;
57 border-bottom: 1px solid #ddd;
58 padding: 0 0 16px 0;
59 margin-bottom: 16px;
60 }
61 }
62 </style>
63</head>
64<?php visual::printBodyTag(); ?>
65 <div class="mdl-layout mdl-js-layout mdl-layout--fixed-header mdl-layout--fixed-drawer">
66 <?php visual::includeNav(); ?>
67 <main class="mdl-layout__content">
68 <div class="page-content">
69 <div class="main mdl-shadow--4dp">
70 <h2>Exportar registro</h2>
71 <p>Aquí puedes configurar cómo quieres exportar los datos del registro:</p>
72 <form action="doexport.php" method="GET">
73 <h5>Periodo</h5>
74 <p>Del <input type="date" name="begins" max="<?=security::htmlsafe($yesterday)?>" required> al <input type="date" name="ends" max="<?=security::htmlsafe($yesterday)?>" required></p>
75
76 <h5>Empresas</h5>
77 <div class="mdlext-selectfield mdlext-js-selectfield mdlext-selectfield--floating-label">
78 <div id="companies" class="mdlext-selectfield__select mdl-custom-selectfield__select" tabindex="0">-</div>
79 <ul class="mdl-menu mdl-menu--bottom mdl-js-menu mdl-custom-multiselect mdl-custom-multiselect-js" for="companies">
80 <?php
81 foreach (companies::getAll() as $id => $company) {
82 if ($id == calendars::TYPE_FESTIU) continue;
83 ?>
84 <li class="mdl-menu__item mdl-custom-multiselect__item">
85 <label class="mdl-checkbox mdl-js-checkbox" for="company-<?=(int)$id?>">
86 <input type="checkbox" id="company-<?=(int)$id?>" name="companies[]" value="<?=(int)$id?>" data-value="<?=(int)$id?>" class="mdl-checkbox__input">
87 <span class="mdl-checkbox__label"><?=security::htmlsafe($company)?></span>
88 </label>
89 </li>
90 <?php
91 }
92 ?>
93 </ul>
94 <label for="companies" class="mdlext-selectfield__label always-focused mdl-color-text--primary">Empresas</label>
95 </div>
96
97 <h5>Trabajadores</h5>
98 <div class="categories-select">
99 <h6>Seleccionar:</h6>
100 <?php
101 $categories = categories::getAllWithWorkers();
102 foreach ($categories as $c) {
103 if (!count($c["workers"])) continue;
104 echo "<span class=\"select-all\" data-workers=\"".security::htmlsafe(implode(",", $c["workers"]))."\">".security::htmlsafe($c["name"])."</span><br>";
105 }
106 ?>
107 </div>
108 <div class="overflow-wrapper overflow-wrapper--for-table">
109 <table class="mdl-data-table mdl-js-data-table mdl-data-table--selectable mdl-shadow--2dp">
110 <thead>
111 <tr>
112 <?php
113 if ($conf["debug"]) {
114 ?>
115 <th class="extra">ID</th>
116 <?php
117 }
118 ?>
119 <th class="mdl-data-table__cell--non-numeric">Nombre</th>
120 <th class="mdl-data-table__cell--non-numeric">Empresa</th>
121 <th class="mdl-data-table__cell--non-numeric extra">Categoría</th>
122 </tr>
123 </thead>
124 <tbody>
125 <?php
126 $workers = people::getAll(false, true);
127 foreach ($workers as $w) {
128 ?>
129 <tr data-worker-id="<?=(int)$w["workerid"]?>" data-company-id="<?=(int)$w["companyid"]?>">
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"><?=security::htmlsafe($w["name"])?></td>
138 <td class="mdl-data-table__cell--non-numeric"><?=security::htmlsafe($companies[$w["companyid"]])?></td>
139 <td class="mdl-data-table__cell--non-numeric extra"><?=security::htmlsafe($w["category"])?></td>
140 </tr>
141 <?php
142 }
143 ?>
144 </tbody>
145 </table>
146 </div>
147
148 <div style="clear: both;"></div>
149
150 <h5>Formato</h5>
151 <div class="mdlext-selectfield mdlext-js-selectfield mdlext-selectfield--floating-label">
152 <select name="format" id="format" class="mdlext-selectfield__select">
153 <?php
154 foreach (export::$formats as $i => $format) {
155 echo '<option value="'.(int)$i.'">'.security::htmlsafe($format).'</option>';
156 }
157 ?>
158 </select>
159 <label for="format" class="mdlext-selectfield__label">Formato</label>
160 </div>
161
162 <div id="pdf">
163 <h5>Opciones para PDF</h5>
164 <p>
165 <label class="mdl-switch mdl-js-switch mdl-js-ripple-effect" for="ignoreempty">
166 <input type="checkbox" id="ignoreempty" name="ignoreempty" value="1" class="mdl-switch__input" checked>
167 <span class="mdl-switch__label">No incluir trabajadores que no tengan ningún registro ni incidencia</span>
168 </label>
169 </p>
170 <p>
171 <label class="mdl-switch mdl-js-switch mdl-js-ripple-effect" for="labelinvalid">
172 <input type="checkbox" id="labelinvalid" name="labelinvalid" value="1" class="mdl-switch__input" checked>
173 <span class="mdl-switch__label">Marcar en rojo incidencias/registros no validados</span>
174 </label>
175 </p>
176 <p style="font-weight: bold;">
177 Mostrar registros/incidencias que estén:
178 </p>
179 <p>
180 <label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="showvalidated">
181 <input type="checkbox" id="showvalidated" name="showvalidated" value="1" class="mdl-checkbox__input" checked>
182 <span class="mdl-checkbox__label">Validados</span>
183 </label>
184 <br>
185 <label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="shownotvalidated">
186 <input type="checkbox" id="shownotvalidated" name="shownotvalidated" value="1" class="mdl-checkbox__input" checked>
187 <span class="mdl-checkbox__label">No validados</span>
188 </label>
189 </p>
190 </div>
191 <br>
192 <button class="mdl-button mdl-js-button mdl-button--raised mdl-button--accent mdl-js-ripple-effect">Exportar</button>
193 </form>
194
195 <?php visual::printDebug("categories::getAllWithWorkers()", $categories); ?>
196 </div>
197 </div>
198 </main>
199 </div>
200
201 <?php
202 visual::smartSnackbar([
203 ["empty", "Faltan datos por introducir en el formulario."],
204 ["unexpected", "Ha ocurrido un error inesperado. Inténtelo de nuevo en unos segundos."],
205 ["inverted", "La fecha de inicio debe ser anterior a la de fin."],
206 ["forecastingthefutureisimpossible", "La fecha de fin debe ser anterior al día de hoy."]
207 ]);
208 ?>
209
210 <script src="js/export.js"></script>
211</body>
212</html>