From 806e1ed7a237bdbe6fa04197065dc33c41e9f807 Mon Sep 17 00:00:00 2001 From: OpenXE <> Date: Mon, 27 Jan 2025 12:58:09 +0100 Subject: [PATCH] projekte show simple tree view --- www/pages/content/projekt_uebersicht.tpl | 28 +++++++-------- www/pages/projekt.php | 45 ++++++++++++++++++++++-- 2 files changed, 55 insertions(+), 18 deletions(-) diff --git a/www/pages/content/projekt_uebersicht.tpl b/www/pages/content/projekt_uebersicht.tpl index 1ba449a4..5ee6a9ca 100644 --- a/www/pages/content/projekt_uebersicht.tpl +++ b/www/pages/content/projekt_uebersicht.tpl @@ -30,16 +30,19 @@ + + + Status: + + + - - Kunde: - Verantwortlicher: @@ -52,20 +55,17 @@ Für Nummernkreise - - Status: + + Struktur: - +
[PROJEKTBAUM]
- + [FREIFELDER] - + - - -
@@ -84,15 +84,11 @@ - - -
- - +
diff --git a/www/pages/projekt.php b/www/pages/projekt.php index 7ca8bfd3..10876dbb 100644 --- a/www/pages/projekt.php +++ b/www/pages/projekt.php @@ -1884,7 +1884,6 @@ class Projekt extends GenProjekt { $id = (int)$this->app->Secure->GetGET('id'); $this->ProjektMenu(); - $speichern = $this->app->Secure->GetPOST('speichern'); if($speichern!='') { @@ -1935,7 +1934,7 @@ class Projekt extends GenProjekt { } $this->app->FormHandler->FormGetVars("projekt",$id); - $data = $this->app->DB->SelectArr("SELECT CONCAT(a.kundennummer,' ',a.name) as kunde, CONCAT(a2.id,' ',a2.name) as mitarbeiter, status, uebergeordnetes_projekt FROM projekt p + $data = $this->app->DB->SelectArr("SELECT CONCAT(a.kundennummer,' ',a.name) as kunde, CONCAT(a2.id,' ',a2.name) as mitarbeiter, status, uebergeordnetes_projekt, abkuerzung FROM projekt p LEFT JOIN adresse a ON a.id=p.kunde LEFT JOIN adresse a2 ON a2.id=p.verantwortlicher WHERE p.id='$id' LIMIT 1"); if(isset($data[0])) { @@ -2044,6 +2043,48 @@ class Projekt extends GenProjekt { $this->app->Tpl->Set("FREIFELDER",$output); + // Build simple tree view + $projekte = $this->app->DB->SelectArr("SELECT id, abkuerzung, name, uebergeordnetes_projekt FROM projekt"); + function buildTree(array $elements, $parentId = 0, $limit = 10) { + $limit--; + if ($limit < 1) { + return; + } + $branch = array(); + foreach ($elements as $element) { + if ($element['uebergeordnetes_projekt'] == $parentId) { + $children = buildTree($elements, $element['id'], $limit); + if ($children) { + $element['children'] = $children; + } + $branch[] = $element; + } + } + return $branch; + } + $projektbaum = buildTree($projekte, $id); + if (!empty($projektbaum)) { + $root = array(); + $root['abkuerzung'] = $data[0]['abkuerzung']; + $root['children'] = $projektbaum; + function printleaf($leaf, $level, $first = false) { + if (!$first) { + $s = $level; + } + $s .= "- ".$leaf['abkuerzung']."\n"; + if ($leaf['children']) { + foreach ($leaf['children'] as $childleaf) { + $s .= printleaf($childleaf, $level.$level); + } + } + return($s); + } + $baum .= printleaf($root," ", true); + $this->app->Tpl->Set("PROJEKTBAUM",$baum); + } else { + $this->app->Tpl->Set("PROJEKTBAUMHIDDEN",'hidden'); + } + // $this->app->YUI->AutoComplete("abkuerzung","projektname",1); $this->app->YUI->AutoComplete("kunde","kunde"); $this->app->YUI->AutoComplete("verantwortlicher","adresse");