From 716601cf0e074216fd5b1ced208921a6599f1f1e Mon Sep 17 00:00:00 2001
From: hahn <axel.hahn@iml.unibe.ch>
Date: Fri, 12 Aug 2022 16:04:01 +0200
Subject: [PATCH] sorted project group list in overview

---
 .../deployment/classes/projectlist.class.php  | 30 ++++++++++++++++---
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/public_html/deployment/classes/projectlist.class.php b/public_html/deployment/classes/projectlist.class.php
index 7ecdcc46..396a79ee 100644
--- a/public_html/deployment/classes/projectlist.class.php
+++ b/public_html/deployment/classes/projectlist.class.php
@@ -56,6 +56,7 @@ class projectlist extends base{
         $sTrClass = "trproject";
         $sColClass = "tdphase";
 
+        $sNone='none';
         $oPrj1 = new project();
         $oHtml=new htmlguielements();
 
@@ -96,6 +97,7 @@ class projectlist extends base{
             }
             $aProgress=$oPrj->getProgress();
             $sPrjGroup=$oPrj->getProjectGroup();
+            $sPrjGroup=$sPrjGroup?$sPrjGroup:$sNone;
 
             $sClasses=$sPrj . ' ' . $sTrClass
                 . ' trprogress'
@@ -116,14 +118,20 @@ class projectlist extends base{
 
 
             if($sPrjGroup){
-                if(!isset($aPrjGroups[$sPrjGroup])){
-                    $aPrjGroups[$sPrjGroup]=0;
-                    $sPrjGroupFilter.='<option value="' . $sPrjGroup . '">' . $oPrj->getProjectGroupLabel() . '</option>';
+                $sPrjLabel=$oPrj->getProjectGroupLabel();
+                $sPrjLabel=$sPrjLabel ? $sPrjLabel : $sNone;
+                if(!isset($aPrjGroups[$sPrjLabel])){
+                    $aPrjGroups[$sPrjLabel]=[
+                        'id'=>$sPrjGroup,
+                        'count'=>1
+                    ];
+                    // $sPrjGroupFilter.='<option value="' . $sPrjGroup . '">' . $oPrj->getProjectGroupLabel() . '</option>';
                 } else {
-                    $aPrjGroups[$sPrjGroup]++;
+                    $aPrjGroups[$sPrjLabel]['count']++;
                 }
             }
 
+
             $sOut2 .= '<div class="' . $sClasses . ' prjbox"><div class="title">'
                     .$oHtml->getLink(array(
                         'href'=>'#',
@@ -192,6 +200,20 @@ class projectlist extends base{
             $sRowHead1 = '';
             $sRowHead2 = '';
 
+            $aGrouplist=array_keys($aPrjGroups);
+            sort($aGrouplist);
+
+            $iNone=isset($aPrjGroups[$sNone]['count']) && $aPrjGroups[$sNone]['count'] ? $aPrjGroups[$sNone]['count'] : 0;
+            $sPrjGroupFilter.= ($iNone ? '<option value="none">'.t("none").' ('.$iNone.')</option>' : '')
+                . '<option value="">-----</option>'
+            ;
+            foreach ($aGrouplist as $sLabel){
+                $sId=$aPrjGroups[$sLabel]['id'];
+                $iCount=$aPrjGroups[$sLabel]['count'];
+                
+                $sPrjGroupFilter.=($sLabel!=$sNone) ? '<option value="' . $sId . '">' . $sLabel . ' ('.$iCount.')</option>' : '';
+            }
+
             foreach (array_keys($oPrj1->getPhases()) as $sPhase) {
                 // Anzahl colspan ist hartcodiert :-/
                 $sRowHead1.='<th class="' . $sPhase . ' ' . $sColClass . '" colspan="3">' . $oHtml->getIcon('phase').$sPhase . '</th>';
-- 
GitLab