Copybara bot | be50d49 | 2023-11-30 00:16:42 +0100 | [diff] [blame] | 1 | <?php |
Adrià Vilanova Martínez | 5af8651 | 2023-12-02 20:44:16 +0100 | [diff] [blame] | 2 | /* |
| 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 bot | be50d49 | 2023-11-30 00:16:42 +0100 | [diff] [blame] | 21 | class registryView { |
| 22 | public static function renderRegistry(&$registry, &$companies, $scrollable = false, $showPersonAndCompany = true, $isForWorker = false, $isForValidationView = false) { |
| 23 | global $conf, $renderRegistryAutoIncremental; |
| 24 | if (!isset($renderRegistryAutoIncremental)) $renderRegistryAutoIncremental = 0; |
| 25 | $menu = ""; |
| 26 | ?> |
| 27 | <div class="mdl-shadow--2dp overflow-wrapper incidents-wrapper<?=($scrollable ? " incidents-wrapper--scrollable" : "")?>"> |
| 28 | <table class="incidents"> |
| 29 | <tr> |
| 30 | <?php if ($conf["debug"]) { ?><th>ID</th><?php } ?> |
| 31 | <th<?=($isForValidationView ? " class=\"has-checkbox\"" : "")?>> |
| 32 | <?php if ($isForValidationView) { |
| 33 | ?> |
| 34 | <label for="checkboxall_r_<?=$renderRegistryAutoIncremental?>" class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" data-check-all="true"> |
| 35 | <input type="checkbox" id="checkboxall_r_<?=$renderRegistryAutoIncremental?>" class="mdl-checkbox__input" autocomplete="off"> |
| 36 | </label> |
| 37 | <?php |
| 38 | } |
| 39 | ?> |
| 40 | </th> |
| 41 | <?php |
| 42 | if ($showPersonAndCompany) { |
| 43 | ?> |
| 44 | <th>Nombre</th> |
| 45 | <th>Empresa</th> |
| 46 | <?php |
| 47 | } |
| 48 | ?> |
| 49 | <th>Día</th> |
| 50 | <th>Jornada laboral</th> |
| 51 | <th>Desayuno</th> |
| 52 | <th>Comida</th> |
| 53 | <th></th> |
| 54 | </tr> |
| 55 | <?php |
| 56 | foreach ($registry as $record) { |
| 57 | $id = (int)$record["id"]."_".(int)$renderRegistryAutoIncremental; |
| 58 | $breakfastInt = [$record["beginsbreakfast"], $record["endsbreakfast"]]; |
| 59 | $lunchInt = [$record["beginslunch"], $record["endslunch"]]; |
| 60 | ?> |
| 61 | <tr<?=($record["invalidated"] == 1 ? ' class="mdl-color-text--grey-700 line-through"' : '')?>> |
| 62 | <?php if ($conf["debug"]) { ?><td><?=(int)$record["id"]?></td><?php } ?> |
| 63 | <td class="icon-cell<?=($isForValidationView ? " has-checkbox" : "")?>"> |
| 64 | <?php |
| 65 | if ($isForValidationView) { |
| 66 | ?> |
| 67 | <label for="checkbox_r_<?=$id?>" class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect"> |
| 68 | <input type="checkbox" id="checkbox_r_<?=$id?>" data-record="<?=(int)$record["id"]?>" class="mdl-checkbox__input" autocomplete="off"> |
| 69 | </label> |
| 70 | <?php |
| 71 | } else { |
| 72 | ?> |
| 73 | <i id="state<?=$id?>" class="material-icons <?=security::htmlsafe(registry::$stateIconColors[$record["state"]])?>"><?=security::htmlsafe(registry::$stateIcons[$record["state"]])?></i> |
| 74 | <?php |
| 75 | visual::addTooltip("state".$id, security::htmlsafe(registry::$stateTooltips[$record["state"]])); |
| 76 | } |
| 77 | ?> |
| 78 | </td> |
| 79 | <?php |
| 80 | if ($showPersonAndCompany) { |
| 81 | ?> |
| 82 | <td class="can-strike"><span<?=($isForWorker ? '' : ' data-dyndialog-href="dynamic/user.php?id='.(int)$record["personid"].'"')?>><?=security::htmlsafe($record["workername"])?></span></td> |
| 83 | <td class="can-strike"><?=security::htmlsafe($companies[$record["companyid"]])?></td> |
| 84 | <?php |
| 85 | } |
| 86 | ?> |
Adrià Vilanova Martínez | eaee4a9 | 2023-12-03 21:07:21 +0100 | [diff] [blame^] | 87 | <td class="can-strike"><?=date::getShortDate($record["day"])?></td> |
Copybara bot | be50d49 | 2023-11-30 00:16:42 +0100 | [diff] [blame] | 88 | <td class="centered can-strike"><?=schedules::sec2time($record["beginswork"])." - ".schedules::sec2time($record["endswork"])?></td> |
| 89 | <td class="centered can-strike"><?=(intervals::measure($breakfastInt) == 0 ? "-" : ($isForWorker ? export::sec2hours(intervals::measure($breakfastInt)) : schedules::sec2time($record["beginsbreakfast"])." - ".schedules::sec2time($record["endsbreakfast"])))?></td> |
| 90 | <td class="centered can-strike"><?=(intervals::measure($lunchInt) == 0 ? "-" : ($isForWorker ? export::sec2hours(intervals::measure($lunchInt)) : schedules::sec2time($record["beginslunch"])." - ".schedules::sec2time($record["endslunch"])))?></td> |
| 91 | <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> |
| 92 | </tr> |
| 93 | <?php |
| 94 | $menu .= '<ul class="mdl-menu mdl-menu--unaligned mdl-js-menu mdl-js-ripple-effect" for="actions'.$id.'">'; |
| 95 | |
| 96 | if (!$isForWorker && $record["invalidated"] == 0) { |
| 97 | $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>'; |
| 98 | } |
| 99 | |
| 100 | $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>'; |
| 101 | |
| 102 | $renderRegistryAutoIncremental++; |
| 103 | } |
| 104 | ?> |
| 105 | </table> |
| 106 | <?php echo $menu; ?> |
| 107 | </div> |
| 108 | <?php |
| 109 | } |
| 110 | } |