blob: 61235cbdbd2210f1873ef94c141792cc3fc81f7f [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$mdHeaderRowBefore = visual::backBtn("powertools.php");
25
26$gracePeriod = (int)($_GET["gracePeriod"] ?? validations::reminderGracePeriod());
27?>
28<!DOCTYPE html>
29<html>
30<head>
31 <title><?php echo $conf["appName"]; ?></title>
32 <?php visual::includeHead(); ?>
33 <link rel="stylesheet" href="css/dashboard.css">
34</head>
35<?php visual::printBodyTag(); ?>
36 <div class="mdl-layout mdl-js-layout mdl-layout--fixed-header mdl-layout--fixed-drawer">
37 <?php visual::includeNav(); ?>
38 <main class="mdl-layout__content">
39 <div class="page-content">
40 <div class="main mdl-shadow--4dp">
41 <h2>Validaciones pendientes</h2>
42 <form action="pendingvalidations.php" method="GET">
43 <p>Contar elementos que lleven más de <input type="text" name="gracePeriod" value="<?=(int)$gracePeriod?>" size="2"> días pendientes de validar. <button class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent">Generar tabla</button></p>
44 </form>
45 <?php
46 $pending = validations::getPeopleWithPendingValidations($gracePeriod);
47 usort($pending, function($a, $b) {
48 $n =& $a["numPending"];
49 $m =& $b["numPending"];
50 return ($n > $m ? -1 : ($n < $m ? 1 : 0));
51 });
52
53 if (count($pending)) {
54 ?>
55 <div class="overflow-wrapper overflow-wrapper--for-table">
56 <table class="mdl-data-table mdl-js-data-table mdl-shadow--2dp">
57 <thead>
58 <tr>
59 <?php
60 if ($conf["debug"]) {
61 ?>
62 <th class="extra">ID</th>
63 <?php
64 }
65 ?>
66 <th class="mdl-data-table__cell--non-numeric">Nombre</th>
67 <th class="mdl-data-table__cell--non-numeric">Validaciones pendientes</th>
68 <th class="mdl-data-table__cell--non-numeric"></th>
69 </tr>
70 </thead>
71 <tbody>
72 <?php
73 foreach ($pending as $p) {
74 ?>
75 <tr>
76 <?php
77 if ($conf["debug"]) {
78 ?>
79 <td class="extra"><?=(int)$p["person"]["id"]?></td>
80 <?php
81 }
82 ?>
83 <td class="mdl-data-table__cell--non-numeric"><?=security::htmlsafe($p["person"]["name"])?></td>
84 <td class="mdl-data-table__cell--non-numeric"><?=(int)$p["numPending"]?></td>
85 <td class='mdl-data-table__cell--non-numeric'>
86 <a href='userincidents.php?id=<?=(int)$p["person"]["id"]?>' title='Ver y gestionar las incidencias del trabajador'><i class='material-icons icon'>assignment_late</i></a>
87 <a href='userregistry.php?id=<?=(int)$p["person"]["id"]?>' title='Ver y gestionar los registros del trabajador'><i class='material-icons icon'>list</i></a>
88 </td>
89 </tr>
90 <?php
91 }
92 ?>
93 </tbody>
94 </table>
95 </div>
96 <?php
97 } else {
98 ?>
99 <p>Todavía no existe ninguna persona.</p>
100 <?php
101 }
102 ?>
103
104 <?php visual::printDebug("validations::getPeopleWithPendingValidations(".$gracePeriod.")", $pending); ?>
105 </div>
106 </div>
107 </main>
108 </div>
109</body>
110</html>