Copybara bot | be50d49 | 2023-11-30 00:16:42 +0100 | [diff] [blame] | 1 | <?php |
| 2 | require_once("core.php"); |
| 3 | security::checkType(security::ADMIN); |
| 4 | |
| 5 | incidentsView::handleIncidentShortcuts(); |
| 6 | |
| 7 | incidentsView::buildSelect(); |
| 8 | |
| 9 | $numRows = incidents::numRows($select); |
| 10 | $companies = companies::getAll(); |
| 11 | ?> |
| 12 | <!DOCTYPE html> |
| 13 | <html> |
| 14 | <head> |
| 15 | <title><?php echo $conf["appName"]; ?></title> |
| 16 | <?php visual::includeHead(); ?> |
| 17 | <link rel="stylesheet" href="css/dashboard.css"> |
| 18 | <link rel="stylesheet" href="css/incidents.css"> |
| 19 | |
| 20 | <style> |
| 21 | .addincident, .addrecurringincident, .filter { |
| 22 | z-index: 1000; |
| 23 | } |
| 24 | |
| 25 | .addincident { |
| 26 | position: fixed; |
| 27 | bottom: 16px; |
| 28 | right: 16px; |
| 29 | } |
| 30 | |
| 31 | .addrecurringincident { |
| 32 | position: fixed; |
| 33 | bottom: 80px; |
| 34 | right: 25px; |
| 35 | } |
| 36 | |
| 37 | .filter { |
| 38 | position: fixed; |
| 39 | bottom: 126px; |
| 40 | right: 25px; |
| 41 | } |
| 42 | |
| 43 | .helper-bellow-incidents-list { |
| 44 | text-align: center; |
| 45 | font-size: 13px; |
| 46 | } |
| 47 | |
| 48 | @media (max-width: 655px) { |
| 49 | .extra { |
| 50 | display: none; |
| 51 | } |
| 52 | } |
| 53 | </style> |
| 54 | </head> |
| 55 | <?php visual::printBodyTag(); ?> |
| 56 | <div class="mdl-layout mdl-js-layout mdl-layout--fixed-header mdl-layout--fixed-drawer"> |
| 57 | <?php visual::includeNav(); ?> |
| 58 | <button class="addincident mdl-button md-js-button mdl-button--fab mdl-js-ripple-effect mdl-button--accent"><i class="material-icons">add</i><span class="mdl-ripple"></span></button> |
| 59 | <button class="addrecurringincident mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-color--grey-200"><i class="material-icons">repeat</i><span class="mdl-ripple"></span></button> |
| 60 | <button class="filter mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-color--grey-200"><i class="material-icons">filter_list</i></button> |
| 61 | <main class="mdl-layout__content"> |
| 62 | <div class="page-content"> |
| 63 | <div class="main mdl-shadow--4dp"> |
| 64 | <h2>Incidencias</h2> |
| 65 | |
| 66 | <?php |
| 67 | if ($select["showPendingQueue"]) { |
| 68 | $numRowsPending = incidents::numPending(); |
| 69 | ?> |
| 70 | <h4>Cola de revisión (<?=$numRowsPending?>)<?=($select["isAnyEnabled"] ? ' <i id="tt_filtersarenotapplied" class="material-icons help">info</i>' : '')?></h4> |
| 71 | <?php |
| 72 | if ($select["isAnyEnabled"]) { |
| 73 | visual::addTooltip("tt_filtersarenotapplied", "Los filtros no se han aplicado a la cola de revisión."); |
| 74 | } |
| 75 | |
| 76 | $incidentsPending = incidents::getAll(true); |
| 77 | if (count($incidentsPending)) { |
| 78 | incidentsView::renderIncidents($incidentsPending, $companies); |
| 79 | } else { |
| 80 | echo "Todas las incidencias ya han sido revisadas."; |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | |
| 85 | $page = ($select["showResultsPaginated"] ? (isset($_GET["page"]) ? (int)$_GET["page"] - 1 : null) : 0); |
| 86 | |
| 87 | if ($select["showResultsPaginated"]) { |
| 88 | $limit = (int)($_GET["limit"] ?? incidents::PAGINATION_LIMIT); |
| 89 | if ($limit <= 0 || $limit > 100) $limit = incidents::PAGINATION_LIMIT; |
| 90 | } else $limit = 0; |
| 91 | |
| 92 | $incidents = incidents::getAll(null, $page, $limit, "ALL", null, null, false, $select); |
| 93 | |
| 94 | if (!$select["showResultsPaginated"]) $numRows = count($incidents); |
| 95 | ?> |
| 96 | |
| 97 | <h4><?=($select["isAnyEnabled"] ? "Incidencias filtradas" : "Todas las incidencias")?> (<?=(int)$numRows?>)</h4> |
| 98 | |
| 99 | <?php |
| 100 | if (count($incidents)) { |
| 101 | incidentsView::renderIncidents($incidents, $companies, false, true, false, false, true); |
| 102 | /*if (!$select["showResultsPaginated"]) { |
| 103 | echo "<p class=\"helper-bellow-incidents-list mdl-color-text--grey-600\">Se está truncando la lista de incidencias a un máximo de resultados, así que es posible que algunas incidencias no se muestren en la lista.<br>Puedes encontrar más incidencias cambiando el selector de fecha final de la sección de filtros a la fecha de la última incidencia de la lista.</p>"; |
| 104 | }*/ |
| 105 | } else if ($select["isAnyEnabled"]) { |
| 106 | echo "No se ha encontrado ninguna incidencia con los filtros seleccionados."; |
| 107 | } else { |
| 108 | echo "Todavía no existe ninguna incidencia. Puedes añadir una haciendo clic en el botón de la esquina inferior derecha."; |
| 109 | } |
| 110 | ?> |
| 111 | |
| 112 | <?php |
| 113 | if ($select["showResultsPaginated"]) visual::renderPagination($numRows, $select["pageUrl"], $limit, ($limit == incidents::PAGINATION_LIMIT ? false : true), $select["pageUrlHasParameters"], [ |
| 114 | "elementName" => "incidencias", |
| 115 | "options" => incidentsView::$limitOptions |
| 116 | ], incidents::todayPage($limit)); |
| 117 | if ($select["showPendingQueue"]) visual::printDebug("incidents::getAll(true)", $incidentsPending); |
| 118 | visual::printDebug("incidents::getAll(null, ".(int)$page.", ".(int)$limit.", \"ALL\", null, null, false, \$select)", $incidents); |
| 119 | visual::printDebug("\$select", $select); |
| 120 | ?> |
| 121 | </div> |
| 122 | </div> |
| 123 | </main> |
| 124 | </div> |
| 125 | |
| 126 | <?php |
| 127 | $workers = people::getAll(false, true); |
| 128 | incidentsView::renderIncidentForm($workers, function(&$worker) { |
| 129 | return (int)$worker["workerid"]; |
| 130 | }, function (&$worker, &$companies) { |
| 131 | return $worker["name"].' ('.$companies[$worker["companyid"]].')'; |
| 132 | }, $companies, false, false, "incidents.php"); |
| 133 | |
| 134 | incidentsView::renderIncidentForm($workers, function(&$worker) { |
| 135 | return (int)$worker["workerid"]; |
| 136 | }, function (&$worker, &$companies) { |
| 137 | return $worker["name"].' ('.$companies[$worker["companyid"]].')'; |
| 138 | }, $companies, false, true, "incidents.php"); |
| 139 | |
| 140 | if (isset($_GET["openRecurringFormWorker"])) { |
| 141 | $openWorker = (int)$_GET["openRecurringFormWorker"]; |
| 142 | ?> |
| 143 | <script> |
| 144 | document.getElementById("recurringworker").value = "<?=security::htmlsafe($openWorker)?>"; |
| 145 | document.getElementById("addrecurringincident").showModal(); |
| 146 | </script> |
| 147 | <?php |
| 148 | } |
| 149 | |
| 150 | incidentsView::renderFilterDialog($select); |
| 151 | |
| 152 | visual::renderTooltips(); |
| 153 | ?> |
| 154 | |
| 155 | <div class="mdl-snackbar mdl-js-snackbar"> |
| 156 | <div class="mdl-snackbar__text"></div> |
| 157 | <button type="button" class="mdl-snackbar__action"></button> |
| 158 | </div> |
| 159 | |
| 160 | <?php |
| 161 | visual::smartSnackbar(incidentsView::$incidentsMsgs, 10000, false); |
| 162 | ?> |
| 163 | |
| 164 | <script> |
| 165 | var _showResultsPaginated = <?=($select["showResultsPaginated"] ? "true" : "false")?>; |
| 166 | var _limit = <?=(int)$limit?>; |
| 167 | var _page = <?=(int)$page?>; |
| 168 | </script> |
| 169 | <script src="js/incidents.js"></script> |
| 170 | <script src="js/incidentsgeneric.js"></script> |
| 171 | </body> |
| 172 | </html> |