diff --git a/application/controllers/jobs/OrganigrammTest.php b/application/controllers/jobs/OrganigrammTest.php new file mode 100644 index 000000000..9b21441e1 --- /dev/null +++ b/application/controllers/jobs/OrganigrammTest.php @@ -0,0 +1,183 @@ +load->model('organisation/Organisationseinheit_model', 'OrganisationseinheitModel'); + } + + public function getAllActiveOes() + { + $sql = << NOW() :: date + ) + AND ( + bf.funktion_kurzbz IS NULL + OR bf.funktion_kurzbz = 'Leitung' + ) + LEFT JOIN public.tbl_benutzer b USING(uid) + LEFT JOIN public.tbl_person p USING(person_id) + WHERE + oe.aktiv = true + GROUP BY + oe.oe_kurzbz, + oe.oe_parent_kurzbz, + oe.bezeichnung, + oe.organisationseinheittyp_kurzbz + ORDER BY + oe.oe_parent_kurzbz ASC NULLS FIRST, + oe.oe_kurzbz ASC; +EOSQL; + + $result = $this->OrganisationseinheitModel->execReadOnlyQuery($sql); + $oes = getData($result); + + $errors = array(); + $assocoes = array(); + $roots = array(); + if($oes) + { + foreach($oes as &$oe) + { + $oe->parent = NULL; + $oe->childs = array(); + $assocoes[$oe->oe_kurzbz] = $oe; + } + + foreach($assocoes as &$assocoe) + { + if( $assocoe->oe_parent_kurzbz === NULL ) + { + $roots[$assocoe->oe_kurzbz] = $assocoe; + } + else + { + if( isset($assocoes[$assocoe->oe_parent_kurzbz]) ) + { + $assocoe->parent = $assocoes[$assocoe->oe_parent_kurzbz]; + $assocoes[$assocoe->oe_parent_kurzbz]->childs[] = $assocoe; + } + else + { + $errors[] = "ERROR: Missing parent oe " . $assocoe->oe_parent_kurzbz . "\n"; + } + } + } + + if(count($errors) === 0) { + $pages = count($roots); + $modified = (new DateTime('now', new DateTimeZone('UTC')))->format(DateTime::ATOM); + $agent = 'FH-Complete'; + echo <<
+ +HEADER; + + foreach($roots AS &$root) + { + + echo << + + + + + +STARTDIAGRAMM; + + renderOE($root, 0, 0); + + echo << + + + +ENDDIAGRAMM; + + } + + echo <<