@@ -140,7 +140,7 @@ function getQueryInterventiDisponibili($idanagrafica)
140140if (!empty ($ interventi )) {
141141 echo '
142142<div class="card">
143- <div class="card-header bg-primary text-white">
143+ <div class="card-header bg-info text-white">
144144 <i class="fa fa-list-alt"></i> ' .tr ('Riepilogo Interventi ' ).'
145145 </div>
146146 <div class="card-body p-0">
@@ -490,18 +490,37 @@ function getQueryInterventiDisponibili($idanagrafica)
490490 </thead>
491491 <tbody> ' ;
492492
493- // Mostra le righe raggruppate per tipo di attività delle sessioni
494- foreach ($ tipologie_ore_per_riga as $ tipo => $ dati ) {
495- // Cerca le ore a contratto per questo tipo di attività usando la mappatura
493+ // Unisci i tipi di attività dalle sessioni e dal contratto
494+ $ tipologie_unite = array_unique (array_merge (array_keys ($ tipologie_ore_per_riga ), array_keys ($ ore_contratto_per_tipo )));
495+
496+ // Crea mappatura inversa per trovare il tipo di sessione corrispondente al tipo contratto
497+ $ mappa_inversa = [];
498+ foreach ($ mappa_tipi as $ tipo_sessione => $ tipo_contratto ) {
499+ if ($ tipo_contratto !== null ) {
500+ $ mappa_inversa [$ tipo_contratto ] = $ tipo_sessione ;
501+ }
502+ }
503+
504+ // Mostra le righe raggruppate per tipo di attività
505+ foreach ($ tipologie_unite as $ tipo ) {
506+ // Cerca le ore a contratto per questo tipo di attività
496507 $ ore_contratto = 0 ;
497- $ tipo_riga_mappato = $ mappa_tipi [$ tipo ] ?? null ;
508+ if (isset ($ ore_contratto_per_tipo [$ tipo ])) {
509+ $ ore_contratto = $ ore_contratto_per_tipo [$ tipo ];
510+ } elseif (isset ($ mappa_inversa [$ tipo ]) && isset ($ ore_contratto_per_tipo [$ mappa_inversa [$ tipo ]])) {
511+ $ ore_contratto = $ ore_contratto_per_tipo [$ mappa_inversa [$ tipo ]];
512+ }
498513
499- if ($ tipo_riga_mappato !== null && isset ($ ore_contratto_per_tipo [$ tipo_riga_mappato ])) {
500- $ ore_contratto = $ ore_contratto_per_tipo [$ tipo_riga_mappato ];
514+ // Cerca i dati delle sessioni per questo tipo di attività
515+ $ dati_sessioni = null ;
516+ if (isset ($ tipologie_ore_per_riga [$ tipo ])) {
517+ $ dati_sessioni = $ tipologie_ore_per_riga [$ tipo ];
518+ } elseif (isset ($ mappa_inversa [$ tipo ]) && isset ($ tipologie_ore_per_riga [$ mappa_inversa [$ tipo ]])) {
519+ $ dati_sessioni = $ tipologie_ore_per_riga [$ mappa_inversa [$ tipo ]];
501520 }
502521
503- $ ore_erogate = $ dati ['ore_totali ' ];
504- $ ore_concluse = $ dati ['ore_completate ' ];
522+ $ ore_erogate = $ dati_sessioni ? $ dati_sessioni ['ore_totali ' ] : 0 ;
523+ $ ore_concluse = $ dati_sessioni ? $ dati_sessioni ['ore_completate ' ] : 0 ;
505524
506525 $ ore_residue = floatval ($ ore_contratto ) - floatval ($ ore_erogate );
507526 $ ore_residue_concluse = floatval ($ ore_contratto ) - floatval ($ ore_concluse );
@@ -520,11 +539,9 @@ function getQueryInterventiDisponibili($idanagrafica)
520539 </tr> ' ;
521540 }
522541
523- // Calcola i totali usando la mappatura
542+ // Calcola i totali basandosi sui tipi di attività delle sessioni
524543 $ totale_ore_erogate = 0 ;
525544 $ totale_ore_concluse = 0 ;
526-
527- // Calcola i totali basandosi sui tipi di attività delle sessioni
528545 foreach ($ tipologie_ore_per_riga as $ tipo => $ dati ) {
529546 $ totale_ore_erogate += $ dati ['ore_totali ' ];
530547 $ totale_ore_concluse += $ dati ['ore_completate ' ];
@@ -538,13 +555,13 @@ function getQueryInterventiDisponibili($idanagrafica)
538555
539556 // Riga totali
540557 echo '
541- <tr class="table-dark font-weight-bold">
542- <td class="border-0" > ' .tr ('TOTALE ' ).'</td>
543- <td class="text-right border-0 "> ' .Translator::numberToLocale ($ totale_ore_contratto ).'</td>
544- <td class="text-right border-0 "> ' .Translator::numberToLocale ($ totale_ore_erogate ).'</td>
545- <td class="text-right ' .$ bg_class_residue_totali .' border-0 "> ' .Translator::numberToLocale ($ totale_ore_residue ).'</td>
546- <td class="text-right border-0 "> ' .Translator::numberToLocale ($ totale_ore_concluse ).'</td>
547- <td class="text-right ' .$ bg_class_residue_concluse_totali .' border-0 "> ' .Translator::numberToLocale ($ totale_ore_residue_concluse ).'</td>
558+ <tr class="table-info font-weight-bold">
559+ <td> ' .tr ('TOTALE ' ).'</td>
560+ <td class="text-right"> ' .Translator::numberToLocale ($ totale_ore_contratto ).'</td>
561+ <td class="text-right"> ' .Translator::numberToLocale ($ totale_ore_erogate ).'</td>
562+ <td class="text-right ' .$ bg_class_residue_totali .'"> ' .Translator::numberToLocale ($ totale_ore_residue ).'</td>
563+ <td class="text-right"> ' .Translator::numberToLocale ($ totale_ore_concluse ).'</td>
564+ <td class="text-right ' .$ bg_class_residue_concluse_totali .'"> ' .Translator::numberToLocale ($ totale_ore_residue_concluse ).'</td>
548565 </tr>
549566 </tbody>
550567 </table>
@@ -560,7 +577,7 @@ function getQueryInterventiDisponibili($idanagrafica)
560577<div class="row">
561578 <div class="col-md-6">
562579 <div class="card mb-4">
563- <div class="card-header bg-primary text-white">
580+ <div class="card-header bg-info text-white">
564581 <i class="fa fa-list"></i> ' .tr ('Tipologia ' ).'
565582 </div>
566583 <div class="card-body p-0">
@@ -598,7 +615,7 @@ function getQueryInterventiDisponibili($idanagrafica)
598615 </div>
599616 <div class="col-md-6">
600617 <div class="card mb-4">
601- <div class="card-header bg-success text-white">
618+ <div class="card-header bg-info text-white">
602619 <i class="fa fa-users"></i> ' .tr ('Tecnici ' ).'
603620 </div>
604621 <div class="card-body p-0">
@@ -640,7 +657,7 @@ function getQueryInterventiDisponibili($idanagrafica)
640657<div class="row">
641658 <div class="col-md-6">
642659 <div class="card mb-4">
643- <div class="card-header bg-warning text-white">
660+ <div class="card-header bg-info text-white">
644661 <i class="fa fa-flag"></i> ' .tr ('Stato ' ).'
645662 </div>
646663 <div class="card-body p-0">
@@ -825,7 +842,7 @@ function getQueryInterventiDisponibili($idanagrafica)
825842
826843echo '<hr>
827844<div class="card">
828- <div class="card-header bg-primary text-white">
845+ <div class="card-header bg-info text-white">
829846 <i class="fa fa-plus"></i> ' .tr ('Aggiungi intervento ' ).'
830847 </div>
831848 <div class="card-body">
0 commit comments