mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 20:29:29 +00:00
first guess, generates oes and edges, pacement to be improved
This commit is contained in:
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
if (!defined("BASEPATH")) exit("No direct script access allowed");
|
||||
|
||||
/**
|
||||
* Description of OrganigrammTest
|
||||
*
|
||||
* @author bambi
|
||||
*/
|
||||
class OrganigrammTest extends JOB_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->load->model('organisation/Organisationseinheit_model', 'OrganisationseinheitModel');
|
||||
}
|
||||
|
||||
public function getAllActiveOes()
|
||||
{
|
||||
$sql = <<<EOSQL
|
||||
SELECT
|
||||
oe.oe_kurzbz,
|
||||
oe.oe_parent_kurzbz,
|
||||
oe.bezeichnung,
|
||||
oe.organisationseinheittyp_kurzbz,
|
||||
STRING_AGG(
|
||||
DISTINCT p.vorname || ' ' || p.nachname,
|
||||
', '
|
||||
) AS leitung_uid
|
||||
FROM
|
||||
"public"."tbl_organisationseinheit" oe
|
||||
LEFT JOIN public.tbl_benutzerfunktion bf ON bf.oe_kurzbz = oe.oe_kurzbz
|
||||
AND (
|
||||
bf.datum_bis IS NULL
|
||||
OR bf.datum_bis > 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
|
||||
<mxfile modified="{$modified}" host="Electron" agent="{$agent}" type="device" pages="{$pages}">
|
||||
|
||||
HEADER;
|
||||
|
||||
foreach($roots AS &$root)
|
||||
{
|
||||
|
||||
echo <<<STARTDIAGRAMM
|
||||
<diagram id="diagram_{$root->oe_kurzbz}" name="{$root->bezeichnung}">
|
||||
<mxGraphModel dx="1177" dy="687" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0" />
|
||||
<mxCell id="1" parent="0" />
|
||||
|
||||
STARTDIAGRAMM;
|
||||
|
||||
renderOE($root, 0, 0);
|
||||
|
||||
echo <<<ENDDIAGRAMM
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
|
||||
ENDDIAGRAMM;
|
||||
|
||||
}
|
||||
|
||||
echo <<<FOOTER
|
||||
</mxfile>
|
||||
|
||||
FOOTER;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ($errors as $error)
|
||||
{
|
||||
echo $error;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "Keine Oes gefunden.\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function renderOE($oe, $level, $parentchildcount)
|
||||
{
|
||||
$nextlevel = $level + 1;
|
||||
$ownchildcount = 0;
|
||||
foreach($oe->childs AS $child)
|
||||
{
|
||||
renderOE($child, $nextlevel, $ownchildcount);
|
||||
$ownchildcount++;
|
||||
}
|
||||
|
||||
$width = 200;
|
||||
$height = 100;
|
||||
$x = 100 + ($parentchildcount * 280);
|
||||
$y = 180 + ($level * 180);
|
||||
$bezeichnung = htmlspecialchars($oe->bezeichnung);
|
||||
$leitung = ($oe->leitung_uid !== null) ? htmlspecialchars($oe->leitung_uid) : 'N.N.';
|
||||
$fillcolors = array(
|
||||
'Team' => '#ffe6cc',
|
||||
'Abteilung' => '#e6ffcc',
|
||||
'Studiengang'=> '#cce6ff',
|
||||
'Lehrgang'=> '#e6ccff'
|
||||
);
|
||||
$fillcolor = (isset($fillcolors[$oe->organisationseinheittyp_kurzbz])) ? $fillcolors[$oe->organisationseinheittyp_kurzbz] : '#ffffff';
|
||||
echo <<<OE
|
||||
<mxCell id="{$oe->oe_kurzbz}" value="<div style=""><font style="font-size: 12px;">[{$oe->organisationseinheittyp_kurzbz}]</font></div><b style="">{$bezeichnung}</b><div>({$leitung})</div>" style="whiteSpace=wrap;html=1;align=center;verticalAlign=middle;treeFolding=1;treeMoving=1;newEdgeStyle={"edgeStyle":"elbowEdgeStyle","startArrow":"none","endArrow":"none"};fillColor={$fillcolor};" parent="1" vertex="1">
|
||||
<mxGeometry x="{$x}" y="{$y}" width="{$width}" height="{$height}" as="geometry" />
|
||||
</mxCell>
|
||||
|
||||
OE;
|
||||
|
||||
if( $oe->oe_parent_kurzbz !== NULL )
|
||||
{
|
||||
echo <<<EDGE
|
||||
<mxCell id="edge_{$oe->oe_parent_kurzbz}_{$oe->oe_kurzbz}" value="" style="edgeStyle=elbowEdgeStyle;elbow=vertical;sourcePerimeterSpacing=0;targetPerimeterSpacing=0;startArrow=none;endArrow=none;rounded=0;curved=0;exitX=0.25;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;dashed=1;dashPattern=12 12;" parent="1" source="{$oe->oe_parent_kurzbz}" target="{$oe->oe_kurzbz}" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
|
||||
EDGE;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user