blob: f1c96740417700fbc3ba5e2a9fde81081b9d4d23 [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);
23
24if (!security::checkParams("GET", [
25 ["id", security::PARAM_ISINT]
26])) {
27 security::go("workerhome.php?msg=empty");
28}
29
30$isAdmin = security::isAllowed(security::ADMIN);
31
32if (!$isAdmin && people::userData("id") != $_GET["id"]) {
33 security::notFound();
34}
35
36$workers = workers::getPersonWorkers((int)$_GET["id"]);
37if ($workers === false) security::go("workerhome.php?msg=unexpected");
38
39$companies = companies::getAll();
40
41$date = new DateTime();
42$interval = new DateInterval("P1D");
43$date->sub($interval);
44$yesterday = date("Y-m-d", $date->getTimestamp());
45?>
46<!DOCTYPE html>
47<html>
48<head>
49 <title><?php echo $conf["appName"]; ?></title>
50 <?php visual::includeHead(); ?>
51 <link rel="stylesheet" href="css/dashboard.css">
52</head>
53<?php visual::printBodyTag(); ?>
54 <div class="mdl-layout mdl-js-layout mdl-layout--fixed-header mdl-layout--fixed-drawer">
55 <?php visual::includeNav(); ?>
56 <main class="mdl-layout__content">
57 <div class="page-content">
58 <div class="main mdl-shadow--4dp">
59 <?php helpView::renderHelpButton(help::PLACE_EXPORT_REGISTRY_PAGE, true); ?>
60 <h2>Exportar registro</h2>
61 <?php
62 if (count($workers)) {
63 ?>
64 <form action="doexport.php" method="GET">
65 <?php
66 foreach ($workers as $w) {
67 echo '<input type="hidden" name="workers[]" value="'.(int)$w["id"].'">';
68 }
69 ?>
70
71 <h5>Periodo</h5>
72 <p>Del <input type="date" name="begins" max="<?=security::htmlsafe($yesterday)?>" required> al <input type="date" name="ends" max="<?=security::htmlsafe($yesterday)?>" required></p>
73
74 <h5>Formato</h5>
75 <div class="mdlext-selectfield mdlext-js-selectfield mdlext-selectfield--floating-label">
76 <select name="format" id="format" class="mdlext-selectfield__select">
77 <?php
78 foreach (export::$formats as $i => $format) {
79 if (!in_array($i, export::$workerFormats)) continue;
80 echo '<option value="'.(int)$i.'">'.security::htmlsafe($format).'</option>';
81 }
82 ?>
83 </select>
84 <label for="format" class="mdlext-selectfield__label">Formato</label>
85 </div>
86
87 <div id="pdf">
88 <h5>Opciones para PDF</h5>
89 <p>
90 <label class="mdl-switch mdl-js-switch mdl-js-ripple-effect" for="labelinvalid">
91 <input type="checkbox" id="labelinvalid" name="labelinvalid" value="1" class="mdl-switch__input" checked>
92 <span class="mdl-switch__label">Marcar en rojo incidencias/registros no validados</span>
93 </label>
94 </p>
95 <p style="font-weight: bold;">
96 Mostrar registros/incidencias que estén:
97 </p>
98 <p>
99 <label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="showvalidated">
100 <input type="checkbox" id="showvalidated" name="showvalidated" value="1" class="mdl-checkbox__input" checked>
101 <span class="mdl-checkbox__label">Validados</span>
102 </label>
103 <br>
104 <label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="shownotvalidated">
105 <input type="checkbox" id="shownotvalidated" name="shownotvalidated" value="1" class="mdl-checkbox__input" checked>
106 <span class="mdl-checkbox__label">No validados</span>
107 </label>
108 </p>
109 </div>
110 <br>
111 <button class="mdl-button mdl-js-button mdl-button--raised mdl-button--accent mdl-js-ripple-effect">Exportar</button>
112 </form>
113 <?php
114 } else {
115 echo "<p>No puedes exportar el registro porque todavía no se te ha asignado ninguna empresa.</p>";
116 }
117 ?>
118 </div>
119 </div>
120 </main>
121 </div>
122
123 <?php
124 visual::smartSnackbar([
125 ["empty", "Faltan datos por introducir en el formulario."],
126 ["unexpected", "Ha ocurrido un error inesperado. Inténtelo de nuevo en unos segundos."],
127 ["inverted", "La fecha de inicio debe ser anterior a la de fin."],
128 ["forecastingthefutureisimpossible", "La fecha de fin debe ser anterior al día de hoy."]
129 ]);
130 ?>
131
132 <script src="js/export.js"></script>
133</body>
134</html>