|
28 | 28 | <div class="row">'; |
29 | 29 | $days = 60; |
30 | 30 | $limite_scadenze = (new Carbon())->addDays($days); |
| 31 | + |
| 32 | +// Colonna sinistra: Servizi e Risorse |
| 33 | +echo ' |
| 34 | + <div class="col-md-12 col-lg-6"> |
| 35 | + <div class="row">'; |
| 36 | + |
31 | 37 | if (Services::isEnabled()) { |
32 | 38 | echo ' |
33 | | - <!-- Informazioni sui Servizi attivi --> |
34 | | - <div class="col-md-12 col-lg-6"> |
35 | | - <div class="card card-primary card-outline"> |
36 | | - <div class="card-header"> |
37 | | - <div class="card-title"> |
38 | | - <i class="fa fa-cogs mr-2"></i>'.tr('Servizi').' |
39 | | - </div> |
40 | | - </div> |
| 39 | + <!-- Informazioni sui Servizi attivi --> |
| 40 | + <div class="col-12 mb-3"> |
| 41 | + <div class="card card-primary card-outline"> |
| 42 | + <div class="card-header"> |
| 43 | + <div class="card-title"> |
| 44 | + <i class="fa fa-cogs mr-2"></i>'.tr('Servizi').' |
| 45 | + </div> |
| 46 | + </div> |
| 47 | +
|
| 48 | + <div class="card-body p-0">'; |
41 | 49 |
|
42 | | - <div class="card-body p-0">'; |
| 50 | + $servizi = Services::getServiziAttivi(true); |
43 | 51 |
|
44 | | - $servizi = Services::getServiziAttivi(true)->flatten(1); |
45 | 52 | if (!$servizi->isEmpty()) { |
46 | 53 | echo ' |
47 | 54 | <table class="table table-hover table-striped table-sm mb-0"> |
48 | 55 | <thead> |
49 | 56 | <tr> |
50 | | - <th width="45%">'.tr('Nome').'</th> |
| 57 | + <th width="5%" class="text-center">'.tr('Stato').'</th> |
| 58 | + <th width="40%">'.tr('Nome').'</th> |
51 | 59 | <th width="20%">'.tr('Tipo').'</th> |
52 | 60 | <th width="25%">'.tr('Scadenza').'</th> |
53 | 61 | <th width="10%" class="text-center">'.tr('#').'</th> |
|
56 | 64 |
|
57 | 65 | <tbody>'; |
58 | 66 | foreach ($servizi as $servizio) { |
59 | | - $scadenza = Carbon::parse($servizio['data_conclusione']); |
| 67 | + // Verifica che $servizio sia un array e contenga i campi necessari |
| 68 | + if (!is_array($servizio) || !isset($servizio['expiration_at'])) { |
| 69 | + continue; |
| 70 | + } |
| 71 | + $scadenza = Carbon::parse($servizio['expiration_at']); |
60 | 72 | $status_class = $scadenza->lessThan(Carbon::now()) ? 'table-danger' : ($scadenza->lessThan($limite_scadenze) ? 'table-warning' : ''); |
61 | | - $status_icon = $scadenza->lessThan(Carbon::now()) ? '<i class="fa fa-exclamation-circle text-danger mr-1"></i>' : ($scadenza->lessThan($limite_scadenze) ? '<i class="fa fa-clock-o text-warning mr-1"></i>' : ''); |
| 73 | + $status_icon = $scadenza->lessThan(Carbon::now()) ? '<i class="fa fa-times-circle text-danger" title="'.tr('Scaduto').'"></i>' : ($scadenza->lessThan($limite_scadenze) ? '<i class="fa fa-exclamation-triangle text-warning" title="'.tr('In scadenza').'"></i>' : '<i class="fa fa-check-circle text-success" title="'.tr('Attivo').'"></i>'); |
| 74 | + |
| 75 | + // Usa i campi corretti dalla risposta API |
| 76 | + $codice = $servizio['code'] ?? $servizio['name'] ?? 'N/A'; |
| 77 | + $nome = $servizio['name'] ?? 'N/A'; |
| 78 | + $tipo = $servizio['type'] ?? $servizio['category'] ?? 'N/A'; |
62 | 79 |
|
63 | 80 | echo ' |
64 | 81 | <tr class="'.$status_class.'"> |
65 | | - <td><strong>'.$servizio['codice'].'</strong> - '.$servizio['nome'].'</td> |
66 | | - <td>'.$servizio['sottocategoria'].'</td> |
67 | | - <td>'.$status_icon.dateFormat($scadenza).' <small class="text-muted">('.$scadenza->diffForHumans().')</small></td> |
| 82 | + <td class="text-center">'.$status_icon.'</td> |
| 83 | + <td><strong>'.$codice.'</strong><br><small class="text-muted">'.$nome.'</small></td> |
| 84 | + <td><span class="badge badge-secondary">'.$tipo.'</span></td> |
| 85 | + <td>'.dateFormat($scadenza).' <br><small class="text-muted">'.$scadenza->diffForHumans().'</small></td> |
68 | 86 | <td class="text-center"> |
69 | | - <input type="checkbox" class="check_rinnova '.($scadenza->lessThan($limite_scadenze) ? '' : 'hide').'" name="rinnova[]" value="'.$servizio['codice'].'"> |
| 87 | + <input type="checkbox" class="check_rinnova '.($scadenza->lessThan($limite_scadenze) ? '' : 'hide').'" name="rinnova[]" value="'.$codice.'"> |
70 | 88 | </td> |
71 | 89 | </tr>'; |
72 | 90 | } |
73 | 91 |
|
74 | 92 | $servizi_in_scadenza = Services::getServiziInScadenza($limite_scadenze); |
75 | 93 | $servizi_scaduti = Services::getServiziScaduti(); |
| 94 | + |
| 95 | + echo ' </tbody> |
| 96 | + <tfoot> |
| 97 | + <tr class="table-light"> |
| 98 | + <td colspan="3"><strong>'.tr('Totale servizi: _NUM_', ['_NUM_' => $servizi->count()]).'</strong></td> |
| 99 | + <td colspan="2" class="text-right">'; |
| 100 | + |
76 | 101 | if (!$servizi_in_scadenza->isEmpty() || !$servizi_scaduti->isEmpty()) { |
77 | | - echo ' </tbody> |
78 | | - <tfoot> |
79 | | - <tr> |
80 | | - <td colspan="4" class="text-right"> |
81 | | - <a href="https://marketplace.devcode.it/" target="_blank" id="btn_rinnova" class="btn btn-sm btn-primary disabled"><i class="fa fa-shopping-cart mr-1"></i>'.tr('Rinnova').'</a> |
82 | | - </td> |
83 | | - </tr> |
84 | | - </tfoot>'; |
| 102 | + echo '<a href="https://marketplace.devcode.it/" target="_blank" id="btn_rinnova" class="btn btn-sm btn-primary"><i class="fa fa-shopping-cart mr-1"></i>'.tr('Rinnova').'</a>'; |
85 | 103 | } |
86 | 104 |
|
| 105 | + echo ' </td> |
| 106 | + </tr> |
| 107 | + </tfoot>'; |
| 108 | + |
87 | 109 | echo ' |
88 | 110 | </table>'; |
89 | 111 | } else { |
|
94 | 116 | } |
95 | 117 |
|
96 | 118 | echo ' |
97 | | - </div> |
98 | | - </div> |
99 | | - </div> |
100 | | -
|
101 | | - <!-- Informazioni sulle Risorse API --> |
102 | | - <div class="col-md-12 col-lg-6"> |
103 | | - <div class="card card-primary card-outline"> |
104 | | - <div class="card-header"> |
105 | | - <div class="card-title"> |
106 | | - <i class="fa fa-cubes mr-2"></i>'.tr('Risorse').' |
| 119 | + </div> |
107 | 120 | </div> |
108 | 121 | </div> |
109 | 122 |
|
110 | | - <div class="card-body p-0">'; |
| 123 | + <!-- Informazioni sulle Risorse API --> |
| 124 | + <div class="col-12 mb-3"> |
| 125 | + <div class="card card-success card-outline"> |
| 126 | + <div class="card-header"> |
| 127 | + <div class="card-title"> |
| 128 | + <i class="fa fa-cubes mr-2"></i>'.tr('Risorse').' |
| 129 | + </div> |
| 130 | + </div> |
| 131 | +
|
| 132 | + <div class="card-body p-0">'; |
111 | 133 |
|
112 | 134 | // Elaborazione delle risorse API in scadenza |
113 | 135 | $risorse_attive = Services::getRisorseAttive(true); |
|
146 | 168 | <table class="table table-hover table-striped table-sm mb-0"> |
147 | 169 | <thead> |
148 | 170 | <tr> |
149 | | - <th width="45%">'.tr('Nome').'</th> |
| 171 | + <th width="5%" class="text-center">'.tr('Stato').'</th> |
| 172 | + <th width="40%">'.tr('Nome').'</th> |
150 | 173 | <th width="20%">'.tr('Crediti').'</th> |
151 | 174 | <th width="35%">'.tr('Scadenza').'</th> |
152 | 175 | </tr> |
|
155 | 178 | <tbody>'; |
156 | 179 |
|
157 | 180 | foreach ($risorse_attive as $servizio) { |
| 181 | + // Verifica che $servizio sia un array e contenga i campi necessari |
| 182 | + if (!is_array($servizio) || !isset($servizio['expiration_at'])) { |
| 183 | + continue; |
| 184 | + } |
158 | 185 | $scadenza = Carbon::parse($servizio['expiration_at']); |
159 | | - $status_class = $scadenza->lessThan(Carbon::now()) ? 'table-danger' : ($scadenza->lessThan($limite_scadenze) ? 'table-warning' : ''); |
160 | | - $status_icon = $scadenza->lessThan(Carbon::now()) ? '<i class="fa fa-exclamation-circle text-danger mr-1"></i>' : ($scadenza->lessThan($limite_scadenze) ? '<i class="fa fa-clock-o text-warning mr-1"></i>' : ''); |
161 | | - $credits_warning = ($servizio['credits'] < 100 && $servizio['credits'] !== null); |
| 186 | + $credits_warning = $servizio['credits'] < 100 && $servizio['credits'] !== null; |
| 187 | + $is_expired = $scadenza->lessThan(Carbon::now()); |
| 188 | + $is_expiring = $scadenza->lessThan($limite_scadenze); |
| 189 | + |
| 190 | + $status_class = $is_expired ? 'table-danger' : ($is_expiring || $credits_warning ? 'table-warning' : ''); |
| 191 | + $status_icon = $is_expired ? '<i class="fa fa-times-circle text-danger" title="'.tr('Scaduto').'"></i>' : ($is_expiring || $credits_warning ? '<i class="fa fa-exclamation-triangle text-warning" title="'.tr('Attenzione').'"></i>' : '<i class="fa fa-check-circle text-success" title="'.tr('Attivo').'"></i>'); |
162 | 192 |
|
163 | 193 | echo ' |
164 | 194 | <tr class="'.$status_class.'"> |
| 195 | + <td class="text-center">'.$status_icon.'</td> |
165 | 196 | <td><strong>'.$servizio['name'].'</strong></td> |
166 | 197 | <td>'.($credits_warning ? '<i class="fa fa-exclamation-triangle text-warning mr-1"></i>' : '').($servizio['credits'] ?? '-').'</td> |
167 | | - <td>'.$status_icon.dateFormat($scadenza).' <small class="text-muted">('.$scadenza->diffForHumans().')</small></td> |
| 198 | + <td>'.dateFormat($scadenza).' <br><small class="text-muted">'.$scadenza->diffForHumans().'</small></td> |
168 | 199 | </tr>'; |
169 | 200 | } |
170 | 201 |
|
171 | 202 | echo ' |
172 | 203 | </tbody> |
173 | | - </table> |
174 | | - </div>'; |
| 204 | + <tfoot> |
| 205 | + <tr class="table-light"> |
| 206 | + <td colspan="4"><strong>'.tr('Totale risorse: _NUM_', ['_NUM_' => $risorse_attive->count()]).'</strong></td> |
| 207 | + </tr> |
| 208 | + </tfoot> |
| 209 | + </table>'; |
175 | 210 |
|
176 | | - // Il servizio Fatturazione Elettronica deve essere presente per visualizzare le Statistiche su Fatture Elettroniche |
177 | | - if (Services::getRisorseAttive()->where('name', 'Fatturazione Elettronica')->count()) { |
178 | | - echo ' |
| 211 | + } else { |
| 212 | + echo ' |
| 213 | + <div class="alert alert-info m-3"> |
| 214 | + <i class="fa fa-info-circle mr-2"></i>'.tr('Nessuna risorsa Services abilitata').'. |
| 215 | + </div>'; |
| 216 | + } |
| 217 | + |
| 218 | + echo ' |
| 219 | + </div> |
| 220 | + </div> |
| 221 | + </div> |
| 222 | + </div> |
| 223 | + </div> |
179 | 224 |
|
180 | | - <div class="card card-primary card-outline mt-3"> |
| 225 | + <!-- Colonna destra: Statistiche su Fatture Elettroniche --> |
| 226 | + <div class="col-md-12 col-lg-6">'; |
| 227 | + |
| 228 | + // Il servizio Fatturazione Elettronica deve essere presente per visualizzare le Statistiche su Fatture Elettroniche |
| 229 | + if (Services::isEnabled() && Services::getRisorseAttive()->where('name', 'Fatturazione Elettronica')->count()) { |
| 230 | + echo ' |
| 231 | + <!-- Statistiche su Fatture Elettroniche --> |
| 232 | + <div class="card card-info card-outline h-100"> |
181 | 233 | <div class="card-header"> |
182 | 234 | <div class="card-title"> |
183 | | - <i class="fa fa-bar-chart mr-2"></i>'.tr('Statistiche su Fatture Elettroniche').' |
| 235 | + <i class="fa fa-file-text-o mr-2"></i>'.tr('Statistiche FE').' |
| 236 | + </div> |
| 237 | + <div class="card-tools"> |
| 238 | + <button type="button" class="btn btn-tool" data-card-widget="collapse"> |
| 239 | + <i class="fas fa-minus"></i> |
| 240 | + </button> |
184 | 241 | </div> |
185 | 242 | </div> |
186 | 243 |
|
|
193 | 250 | ]).'.<br>'.tr("Contattare l'assistenza per risolvere il problema").'</span>. |
194 | 251 | </div> |
195 | 252 |
|
196 | | -
|
197 | 253 | <div class="alert hidden" role="alert" id="numero-fe"> |
198 | 254 | <i id="numero-fe-icon" class=""></i> <span>'.tr('Attenzione, numero di fatture elettroniche per l\'annualità _TEXT_: _NUM_ documenti transitati su _TOT_ disponibili', [ |
199 | 255 | '_TEXT_' => '<span id="numero-fe-text"></span>', |
|
202 | 258 | ]).'.<br>'.tr("Contattare l'assistenza per risolvere il problema").'</span>. |
203 | 259 | </div> |
204 | 260 |
|
205 | | -
|
206 | | - <table class="card-body table table-striped table-hover table-sm"> |
207 | | - <thead> |
208 | | - <tr> |
209 | | - <th>'.tr('Anno').'</th> |
210 | | - <th> |
211 | | - '.tr('N. documenti archiviati').' |
212 | | - <span class="tip" title="'.tr('Fatture attive e relative ricevute, fatture passive').'."> |
213 | | - <i class="fa fa-question-circle-o"></i> |
214 | | - </span> |
215 | | - </th> |
216 | | -
|
217 | | - <th> |
218 | | - '.tr('Spazio utilizzato').' |
219 | | - <span class="tip" title="'.tr('Fatture attive con eventuali allegati e ricevute, fatture passive con eventuali allegati').'."> |
220 | | - <i class="fa fa-question-circle-o"></i> |
221 | | - </span> |
222 | | - </th> |
223 | | - </tr> |
224 | | - </thead> |
225 | | -
|
226 | | - <tfoot id="elenco-fe"> |
227 | | - <tr style="background-color:#CCCCCC;" > |
228 | | - <td>'.tr('Totale').'</td> |
229 | | - <td id="fe_numero"></td> |
230 | | - <td id="fe_spazio"></td> |
231 | | - </tr> |
232 | | - </tfoot> |
233 | | - </table> |
| 261 | + <div class="table-responsive"> |
| 262 | + <table class="table table-striped table-sm mb-0"> |
| 263 | + <thead> |
| 264 | + <tr> |
| 265 | + <th>'.tr('Anno').'</th> |
| 266 | + <th class="text-center"> |
| 267 | + '.tr('Doc.').' |
| 268 | + <i class="fa fa-question-circle-o text-muted" title="'.tr('Fatture attive e relative ricevute, fatture passive').'"></i> |
| 269 | + </th> |
| 270 | + <th class="text-center"> |
| 271 | + '.tr('Spazio').' |
| 272 | + <i class="fa fa-question-circle-o text-muted" title="'.tr('Fatture attive con eventuali allegati e ricevute, fatture passive con eventuali allegati').'"></i> |
| 273 | + </th> |
| 274 | + </tr> |
| 275 | + </thead> |
| 276 | + <tbody id="elenco-fe"> |
| 277 | + </tbody> |
| 278 | + <tfoot> |
| 279 | + <tr class="table-secondary"> |
| 280 | + <td><strong>'.tr('Totale').'</strong></td> |
| 281 | + <td class="text-center"><strong id="fe_numero">-</strong></td> |
| 282 | + <td class="text-center"><strong id="fe_spazio">-</strong></td> |
| 283 | + </tr> |
| 284 | + </tfoot> |
| 285 | + </table> |
| 286 | + </div> |
234 | 287 | </div> |
235 | 288 | </div> |
236 | 289 | <script> |
237 | 290 | $(document).ready(function (){ |
238 | 291 | aggiornaStatisticheFE(); |
239 | 292 | }); |
240 | 293 | </script>'; |
241 | | - } |
242 | 294 | } else { |
243 | 295 | echo ' |
244 | | - <div class="alert alert-info m-3"> |
245 | | - <i class="fa fa-info-circle mr-2"></i>'.tr('Nessuna risorsa Services abilitata').'. |
| 296 | + <div class="card card-secondary card-outline h-100"> |
| 297 | + <div class="card-header"> |
| 298 | + <div class="card-title"> |
| 299 | + <i class="fa fa-file-text-o mr-2"></i>'.tr('Statistiche FE').' |
| 300 | + </div> |
| 301 | + </div> |
| 302 | + <div class="card-body text-center p-3"> |
| 303 | + <i class="fa fa-info-circle fa-2x text-muted mb-2"></i> |
| 304 | + <p class="text-muted mb-0">'.tr('Non disponibili').'<br><small>'.tr('Servizio FE non attivo').'</small></p> |
246 | 305 | </div> |
247 | 306 | </div>'; |
248 | 307 | } |
|
316 | 375 | </div> |
317 | 376 |
|
318 | 377 | </div> |
319 | | -</div>'; |
320 | | - |
321 | | -echo ' |
322 | | -
|
| 378 | +</div> |
323 | 379 | <script> |
324 | 380 |
|
325 | 381 | $(".check_rinnova").each(function() { |
|
0 commit comments