From 1ede34773d6f575fa746c91983bbb3041d96d00d Mon Sep 17 00:00:00 2001
From: Antony Le Courtes <antony.lecourtes@unicaen.fr>
Date: Thu, 20 Feb 2025 14:42:36 +0100
Subject: [PATCH] Correction affichage totale hetd

---
 module/Formule/src/Service/AfficheurService.php | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/module/Formule/src/Service/AfficheurService.php b/module/Formule/src/Service/AfficheurService.php
index 95b7bed9a0..81e62f93d9 100755
--- a/module/Formule/src/Service/AfficheurService.php
+++ b/module/Formule/src/Service/AfficheurService.php
@@ -93,17 +93,25 @@ class AfficheurService
 
         if (count($types) > 1) {
             $types[] = 'total';
-            foreach ($data['heures'] as $categorie => $null) {
-                $data['heures'][$categorie]['total'] = $fr->getHeures($categorie);
+            foreach ($data['heures'] as $categorie => $values) {
+                foreach($values as $type => $heures){
+                    if(!array_key_exists('total',$data['heures'][$categorie])){
+                        $data['heures'][$categorie]['total'] = 0;
+                    }
+                    if($type != 'total')
+                    {
+                        $data['heures'][$categorie]['total'] += $heures;
+                    }
+                }
             }
         }
 
         if (count($data['heures']) > 1) {
             $data['heures']['total'] = array_fill_keys($types, 0.0);
             foreach ($data['heures'] as $categorie => $ht) {
-                if ('primes' !== $categorie) {
+                if ('primes' !== $categorie && 'total' !== $categorie) {
                     foreach ($types as $type) {
-                        $data['heures']['total'][$type] += $ht[$type];
+                            $data['heures']['total'][$type] += $ht[$type];
                     }
                 }
             }
-- 
GitLab