blob: 1767bc3825fe7679b08d9273e32e08228f18edbe [file] [log] [blame]
Copybara botbe50d492023-11-30 00:16:42 +01001<?php
2class registryView {
3 public static function renderRegistry(&$registry, &$companies, $scrollable = false, $showPersonAndCompany = true, $isForWorker = false, $isForValidationView = false) {
4 global $conf, $renderRegistryAutoIncremental;
5 if (!isset($renderRegistryAutoIncremental)) $renderRegistryAutoIncremental = 0;
6 $menu = "";
7 ?>
8 <div class="mdl-shadow--2dp overflow-wrapper incidents-wrapper<?=($scrollable ? " incidents-wrapper--scrollable" : "")?>">
9 <table class="incidents">
10 <tr>
11 <?php if ($conf["debug"]) { ?><th>ID</th><?php } ?>
12 <th<?=($isForValidationView ? " class=\"has-checkbox\"" : "")?>>
13 <?php if ($isForValidationView) {
14 ?>
15 <label for="checkboxall_r_<?=$renderRegistryAutoIncremental?>" class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" data-check-all="true">
16 <input type="checkbox" id="checkboxall_r_<?=$renderRegistryAutoIncremental?>" class="mdl-checkbox__input" autocomplete="off">
17 </label>
18 <?php
19 }
20 ?>
21 </th>
22 <?php
23 if ($showPersonAndCompany) {
24 ?>
25 <th>Nombre</th>
26 <th>Empresa</th>
27 <?php
28 }
29 ?>
30 <th>Día</th>
31 <th>Jornada laboral</th>
32 <th>Desayuno</th>
33 <th>Comida</th>
34 <th></th>
35 </tr>
36 <?php
37 foreach ($registry as $record) {
38 $id = (int)$record["id"]."_".(int)$renderRegistryAutoIncremental;
39 $breakfastInt = [$record["beginsbreakfast"], $record["endsbreakfast"]];
40 $lunchInt = [$record["beginslunch"], $record["endslunch"]];
41 ?>
42 <tr<?=($record["invalidated"] == 1 ? ' class="mdl-color-text--grey-700 line-through"' : '')?>>
43 <?php if ($conf["debug"]) { ?><td><?=(int)$record["id"]?></td><?php } ?>
44 <td class="icon-cell<?=($isForValidationView ? " has-checkbox" : "")?>">
45 <?php
46 if ($isForValidationView) {
47 ?>
48 <label for="checkbox_r_<?=$id?>" class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect">
49 <input type="checkbox" id="checkbox_r_<?=$id?>" data-record="<?=(int)$record["id"]?>" class="mdl-checkbox__input" autocomplete="off">
50 </label>
51 <?php
52 } else {
53 ?>
54 <i id="state<?=$id?>" class="material-icons <?=security::htmlsafe(registry::$stateIconColors[$record["state"]])?>"><?=security::htmlsafe(registry::$stateIcons[$record["state"]])?></i>
55 <?php
56 visual::addTooltip("state".$id, security::htmlsafe(registry::$stateTooltips[$record["state"]]));
57 }
58 ?>
59 </td>
60 <?php
61 if ($showPersonAndCompany) {
62 ?>
63 <td class="can-strike"><span<?=($isForWorker ? '' : ' data-dyndialog-href="dynamic/user.php?id='.(int)$record["personid"].'"')?>><?=security::htmlsafe($record["workername"])?></span></td>
64 <td class="can-strike"><?=security::htmlsafe($companies[$record["companyid"]])?></td>
65 <?php
66 }
67 ?>
68 <td class="can-strike"><?=strftime("%d %b %Y", $record["day"])?></td>
69 <td class="centered can-strike"><?=schedules::sec2time($record["beginswork"])." - ".schedules::sec2time($record["endswork"])?></td>
70 <td class="centered can-strike"><?=(intervals::measure($breakfastInt) == 0 ? "-" : ($isForWorker ? export::sec2hours(intervals::measure($breakfastInt)) : schedules::sec2time($record["beginsbreakfast"])." - ".schedules::sec2time($record["endsbreakfast"])))?></td>
71 <td class="centered can-strike"><?=(intervals::measure($lunchInt) == 0 ? "-" : ($isForWorker ? export::sec2hours(intervals::measure($lunchInt)) : schedules::sec2time($record["beginslunch"])." - ".schedules::sec2time($record["endslunch"])))?></td>
72 <td><button id="actions<?=$id?>" class="mdl-button mdl-js-button mdl-button--icon mdl-js-ripple-effect custom-actions-btn"><i class="material-icons icon">more_vert</i></button></td>
73 </tr>
74 <?php
75 $menu .= '<ul class="mdl-menu mdl-menu--unaligned mdl-js-menu mdl-js-ripple-effect" for="actions'.$id.'">';
76
77 if (!$isForWorker && $record["invalidated"] == 0) {
78 $menu .= '<a href="dynamic/invalidaterecord.php?id='.(int)$record["id"].'" data-dyndialog-href="dynamic/invalidaterecord.php?id='.(int)$record["id"].'"><li class="mdl-menu__item">Invalidar</li></a>';
79 }
80
81 $menu .= '<a href="dynamic/authorsrecord.php?id='.(int)$record["id"].'" data-dyndialog-href="dynamic/authorsrecord.php?id='.(int)$record["id"].'"><li class="mdl-menu__item">Autoría</li></a></ul>';
82
83 $renderRegistryAutoIncremental++;
84 }
85 ?>
86 </table>
87 <?php echo $menu; ?>
88 </div>
89 <?php
90 }
91}