|
20 | 20 |
|
21 | 21 | use API\Services; |
22 | 22 | use Carbon\Carbon; |
| 23 | +use Models\Cache; |
23 | 24 | use Models\User; |
24 | 25 | use Util\FileSystem; |
25 | 26 |
|
|
150 | 151 |
|
151 | 152 | $spazio_utilizzato = FileSystem::folderSize(base_dir(), ['htaccess']) / (1024 ** 3); |
152 | 153 | $utenti_attivi = User::where('enabled', 1)->count(); |
153 | | - $spazio_warning = $servizio['spazio_limite'] && $spazio_utilizzato >= $servizio['spazio_limite']; |
154 | | - $utenti_warning = $servizio['utenti_limite'] && $utenti_attivi >= $servizio['utenti_limite']; |
| 154 | + |
| 155 | + // Calcolo percentuale spazio utilizzato e determinazione livello di allerta |
| 156 | + $spazio_percentuale = ($servizio['spazio_limite'] && $servizio['spazio_limite'] > 0) ? ($spazio_utilizzato / $servizio['spazio_limite']) * 100 : 0; |
| 157 | + $spazio_warning = ($servizio['spazio_limite'] && $servizio['spazio_limite'] > 0) && $spazio_percentuale >= 80; |
| 158 | + $spazio_danger = ($servizio['spazio_limite'] && $servizio['spazio_limite'] > 0) && $spazio_percentuale >= 100; |
| 159 | + |
| 160 | + // Determinazione livello di allerta per utenti |
| 161 | + $utenti_warning = ($servizio['utenti_limite'] && $servizio['utenti_limite'] > 0) && $utenti_attivi >= ($servizio['utenti_limite'] - 1); |
| 162 | + $utenti_danger = ($servizio['utenti_limite'] && $servizio['utenti_limite'] > 0) && $utenti_attivi >= $servizio['utenti_limite']; |
155 | 163 |
|
156 | 164 | // Determinazione dello stato |
157 | 165 | $status_class = $is_expired ? 'table-danger' : ($is_expiring ? 'table-warning' : ''); |
158 | 166 | $status_icon = $is_expired ? '<i class="fa fa-times-circle text-danger" title="'.tr('Scaduto/Esaurito').'"></i>' : |
159 | 167 | ($is_expiring ? '<i class="fa fa-exclamation-triangle text-warning" title="'.tr('Attenzione').'"></i>' : |
160 | 168 | '<i class="fa fa-check-circle text-success" title="'.tr('Attivo').'"></i>'); |
161 | 169 |
|
162 | | - $spazio_class = ($spazio_warning ? 'danger' : 'secondary'); |
163 | | - $spazio_icon = ($spazio_warning ? '<i class="fa fa-exclamation-triangle" style="font-size: 0.65rem; margin-left: 4px;" title="'.tr('Attenzione').'"></i>' : ''); |
164 | | - $utenti_class = ($utenti_warning ? 'danger' : 'secondary'); |
165 | | - $utenti_icon = ($utenti_warning ? '<i class="fa fa-exclamation-triangle" style="font-size: 0.65rem; margin-left: 4px;" title="'.tr('Attenzione').'"></i>' : ''); |
| 170 | + // Determinazione classe e icona per lo spazio |
| 171 | + if ($spazio_danger) { |
| 172 | + $spazio_class = 'danger'; |
| 173 | + $spazio_icon = '<i class="fa fa-exclamation-triangle" style="font-size: 0.65rem; margin-left: 4px;" title="'.tr('Spazio esaurito').'"></i>'; |
| 174 | + } elseif ($spazio_warning) { |
| 175 | + $spazio_class = 'warning'; |
| 176 | + $spazio_icon = '<i class="fa fa-exclamation-triangle" style="font-size: 0.65rem; margin-left: 4px;" title="'.tr('Spazio in esaurimento').'"></i>'; |
| 177 | + } else { |
| 178 | + $spazio_class = 'secondary'; |
| 179 | + $spazio_icon = ''; |
| 180 | + } |
| 181 | + |
| 182 | + // Determinazione classe e icona per gli utenti |
| 183 | + if ($utenti_danger) { |
| 184 | + $utenti_class = 'danger'; |
| 185 | + $utenti_icon = '<i class="fa fa-exclamation-triangle" style="font-size: 0.65rem; margin-left: 4px;" title="'.tr('Limite utenti raggiunto').'"></i>'; |
| 186 | + } elseif ($utenti_warning) { |
| 187 | + $utenti_class = 'warning'; |
| 188 | + $utenti_icon = '<i class="fa fa-exclamation-triangle" style="font-size: 0.65rem; margin-left: 4px;" title="'.tr('Limite utenti quasi raggiunto').'"></i>'; |
| 189 | + } else { |
| 190 | + $utenti_class = 'secondary'; |
| 191 | + $utenti_icon = ''; |
| 192 | + } |
166 | 193 | echo ' |
167 | 194 | <tr class="'.$status_class.'"> |
168 | 195 | <td class="text-center">'.$status_icon.'</td> |
169 | 196 | <td><strong>'.$servizio['codice'].'</strong><br><small class="text-muted">'.$servizio['nome'].'</small></td> |
170 | 197 | <td><span class="badge badge-primary">'.$servizio['sottocategoria'].'</span><br><small class="text-muted"> |
171 | 198 | <td>'.dateFormat($scadenza).' <br><small class="text-muted">'.$scadenza->diffForHumans().'</small></td> |
172 | 199 | <td class="text-center"> |
173 | | - '.($servizio['spazio_limite'] ? '<div class="mb-1"><span class="badge badge-'.$spazio_class.' d-inline-flex align-items-center" style="font-size: 0.7rem; padding: 0.25rem 0.5rem; line-height: 1.2;"><i class="fa fa-database" style="font-size: 0.65rem; margin-right: 4px;"></i>'.numberFormat($spazio_utilizzato,1).' / '.numberFormat($servizio['spazio_limite'],1).' '.tr('GB').$spazio_icon.'</span></div>' : '').' |
| 200 | + '.($servizio['spazio_limite'] && $servizio['utenti_limite'] ? '<div class="mb-1"><span class="badge badge-'.$spazio_class.' d-inline-flex align-items-center" style="font-size: 0.7rem; padding: 0.25rem 0.5rem; line-height: 1.2;"><i class="fa fa-database" style="font-size: 0.65rem; margin-right: 4px;"></i>'.numberFormat($spazio_utilizzato,1).' / '.numberFormat($servizio['spazio_limite'],1).' '.tr('GB').$spazio_icon.'</span></div>' : '').' |
174 | 201 | '.($servizio['utenti_limite'] ? '<div><span class="badge badge-'.$utenti_class.' d-inline-flex align-items-center" style="font-size: 0.7rem; padding: 0.25rem 0.5rem; line-height: 1.2;"><i class="fa fa-users" style="font-size: 0.65rem; margin-right: 4px;"></i>'.$utenti_attivi.' / '.$servizio['utenti_limite'].' '.tr('utenti').$utenti_icon.'</span></div>' : '').' |
175 | 202 | </td> |
176 | 203 | </tr>'; |
|
204 | 231 | $nome = $elemento['name']; |
205 | 232 |
|
206 | 233 | // Gestione crediti: mostra solo se presenti, altrimenti "-" |
207 | | - $crediti_display = $has_credits ? ($elemento['credits'] ?? '-') : 'Infiniti'; |
| 234 | + $crediti_display = $has_credits ? ($elemento['credits'] ?? '-') : '∞'; |
208 | 235 | $credits_warning_icon = ($credits_warning || $credits_expired) ? '<i class="fa fa-exclamation-triangle" style="font-size: 0.7rem; margin-left: 3px;"></i>' : ''; |
209 | 236 |
|
| 237 | + $max_size = null; |
| 238 | + if ($elemento['name'] == 'Fatturazione Elettronica') { |
| 239 | + $info = Cache::where('name', 'Informazioni su spazio FE')->first(); |
| 240 | + $max_size = $info->content['maxSize']; |
| 241 | + } |
| 242 | + |
210 | 243 | echo ' |
211 | 244 | <tr class="'.$status_class.'"> |
212 | 245 | <td class="text-center">'.$status_icon.'</td> |
213 | 246 | <td><strong>'.$nome.'</strong><br><small class="text-muted">'.$codice.'</small></td> |
214 | 247 | <td><span class="badge badge-info">'.tr('Risorsa').'</span></td> |
215 | 248 | <td>'.dateFormat($scadenza).' <br><small class="text-muted">'.$scadenza->diffForHumans().'</small></td> |
216 | 249 | <td class="text-center"> |
217 | | - <span class="badge badge-'.$credits_class.' d-inline-flex align-items-center" style="font-size: 0.75rem;">'.$crediti_display.' '.tr('Crediti').' '.$credits_warning_icon.'</span> |
| 250 | + <span class="badge badge-'.$credits_class.' d-inline-flex align-items-center" style="font-size: 0.75rem;">'.$crediti_display.' '.tr('Crediti').' '.$credits_warning_icon.'</span>'; |
| 251 | + if ($max_size) { |
| 252 | + echo '<br><span class="badge badge-secondary d-inline-flex align-items-center" style="font-size: 0.75rem;">'.$max_size.' '.tr('MB').'</span>'; |
| 253 | + } |
| 254 | + echo ' |
218 | 255 | </td> |
219 | 256 | </tr>'; |
220 | 257 | } |
@@ -410,34 +447,32 @@ function aggiornaStatisticheFE(){ |
410 | 447 | $("#spazio-fe-totale").html(response.spazio_totale); |
411 | 448 |
|
412 | 449 | if (response.avviso_spazio) { |
413 | | -
|
414 | 450 | $("#spazio-fe").removeClass("hidden"); |
| 451 | + } |
415 | 452 |
|
416 | | - response.spazio_occupato = parseFloat(response.spazio_occupato); |
417 | | - response.spazio_totale = parseFloat(response.spazio_totale); |
| 453 | + response.spazio_occupato = parseFloat(response.spazio_occupato); |
| 454 | + response.spazio_totale = parseFloat(response.spazio_totale); |
418 | 455 |
|
419 | | - if (response.spazio_totale){ |
420 | | - $("#fe_spazio").html($("#fe_spazio").html() + " / " + response.spazio_totale); |
| 456 | + if (response.spazio_totale){ |
| 457 | + $("#fe_spazio").html($("#fe_spazio").html() + " / " + response.spazio_totale + " MB"); |
421 | 458 |
|
422 | | - if (response.spazio_occupato>response.spazio_totale && response.avviso_spazio){ |
423 | | - $("#fe_spazio").html("<span style=\"font-weight:bold;\" ><i class=\"fa fa-warning text-warning\" ></i> " + $("#fe_spazio").html() + "</span>"); |
424 | | - } |
| 459 | + if (response.spazio_occupato>response.spazio_totale && response.avviso_spazio){ |
| 460 | + $("#fe_spazio").html("<span style=\"font-weight:bold;\" ><i class=\"fa fa-warning text-warning\" ></i> " + $("#fe_spazio").html() + "</span>"); |
425 | 461 | } |
| 462 | + } |
426 | 463 |
|
427 | | - if (response.spazio_occupato<response.spazio_totale){ |
428 | | - $("#spazio-fe-icon").addClass("fa fa-clock-o"); |
429 | | - $("#spazio-fe").addClass("alert-warning"); |
430 | | - $("#spazio-fe-text").html("'.tr('in esaurimento').'"); |
431 | | - } |
432 | | - else if (response.spazio_occupato>=response.spazio_totale){ |
433 | | - $("#spazio-fe-icon").addClass("fa fa-warning"); |
434 | | - $("#spazio-fe").addClass("alert-danger"); |
435 | | - $("#spazio-fe-text").html("'.tr('terminato').'"); |
436 | | - } |
| 464 | + if (response.spazio_occupato<response.spazio_totale){ |
| 465 | + $("#spazio-fe-icon").addClass("fa fa-clock-o"); |
| 466 | + $("#spazio-fe").addClass("alert-warning"); |
| 467 | + $("#spazio-fe-text").html("'.tr('in esaurimento').'"); |
| 468 | + } |
| 469 | + else if (response.spazio_occupato>=response.spazio_totale){ |
| 470 | + $("#spazio-fe-icon").addClass("fa fa-warning"); |
| 471 | + $("#spazio-fe").addClass("alert-danger"); |
| 472 | + $("#spazio-fe-text").html("'.tr('terminato').'"); |
437 | 473 | } |
438 | 474 |
|
439 | 475 | if (response.history.length) { |
440 | | -
|
441 | 476 | for (let i = 0; i < response.history.length; i++) { |
442 | 477 | const data = response.history[i]; |
443 | 478 | if (data["year"] == '.date('Y').'){ |
|
0 commit comments