mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-23 01:42:17 +00:00
Task #1353: First solution, to be refined
This commit is contained in:
@@ -59,7 +59,56 @@ class OrganisationseinheitLib
|
||||
return $this->treeSearch($schema, $table, $select, $where, $orderby, $result->retval[0]->_ppk);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function treeSearchEntire($table, $alias, $fields, $where, $orderby, $oe_kurzbz, $entireTree = false)
|
||||
{
|
||||
$select = "";
|
||||
if (is_array($fields))
|
||||
{
|
||||
for ($i = 0; $i < count($fields); $i++)
|
||||
{
|
||||
$select .= $fields[$i];
|
||||
if ($i != count($fields) - 1)
|
||||
{
|
||||
$select .= ", ";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$select = $fields;
|
||||
}
|
||||
|
||||
$result = $this->ci->OrganisationseinheitModel->getOneLevel2($table, $alias, $select, $where, $orderby, $oe_kurzbz);
|
||||
|
||||
if (hasData($result))
|
||||
{
|
||||
if ($result->retval[0]->_pk != null && $result->retval[0]->_ppk != null)
|
||||
{
|
||||
$tmpResult = error();
|
||||
|
||||
if (($entireTree == false && $result->retval[0]->oe_kurzbz == null) || $entireTree === true)
|
||||
{
|
||||
$tmpResult = $this->treeSearchEntire($table, $alias, $select, $where, $orderby, $result->retval[0]->_ppk, $entireTree);
|
||||
}
|
||||
|
||||
if ($entireTree === true)
|
||||
{
|
||||
if (hasData($tmpResult))
|
||||
{
|
||||
$result->retval = array_merge($result->retval, $tmpResult->retval);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ($result->retval[0]->_pk == null && $result->retval[0]->_ppk != null)
|
||||
{
|
||||
$result = $this->treeSearchEntire($table, $alias, $select, $where, $orderby, $result->retval[0]->_ppk, $entireTree);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -78,9 +78,34 @@ class Organisationseinheit_model extends DB_Model
|
||||
) _joined_table ON (orgs._pk = _joined_table._pk)
|
||||
WHERE orgs._pk = ?
|
||||
ORDER BY %s";
|
||||
|
||||
|
||||
$query = sprintf($query, $table, $fields, $schema, $table, $where, $orderby);
|
||||
|
||||
|
||||
return $this->execQuery($query, array($oe_kurzbz));
|
||||
}
|
||||
}
|
||||
|
||||
public function getOneLevel2($table, $alias, $fields, $where, $orderby, $oe_kurzbz)
|
||||
{
|
||||
$query = "WITH RECURSIVE organizations(_pk, _ppk) AS
|
||||
(
|
||||
SELECT o.oe_kurzbz, o.oe_parent_kurzbz
|
||||
FROM public.tbl_organisationseinheit o
|
||||
WHERE o.oe_parent_kurzbz IS NULL
|
||||
UNION ALL
|
||||
SELECT o.oe_kurzbz, o.oe_parent_kurzbz
|
||||
FROM public.tbl_organisationseinheit o INNER JOIN organizations orgs ON (o.oe_parent_kurzbz = orgs._pk)
|
||||
)
|
||||
SELECT orgs._pk, orgs._ppk, _joined_table.*
|
||||
FROM organizations orgs LEFT JOIN (
|
||||
SELECT %s.oe_kurzbz as _pk, %s
|
||||
FROM %s
|
||||
WHERE %s
|
||||
) _joined_table ON (orgs._pk = _joined_table._pk)
|
||||
WHERE orgs._pk = ?
|
||||
ORDER BY %s";
|
||||
|
||||
$query = sprintf($query, $alias, $fields, $table, $where, $orderby);
|
||||
|
||||
return $this->execQuery($query, array($oe_kurzbz));
|
||||
}
|
||||
}
|
||||
@@ -4,13 +4,29 @@ class Vorlage_widget extends DropdownWidget
|
||||
{
|
||||
public function display($widgetData)
|
||||
{
|
||||
$this->load->model('system/Vorlage_model', 'VorlageModel');
|
||||
$this->VorlageModel->addOrder('vorlage_kurzbz');
|
||||
// Loads
|
||||
$this->load->library('OrganisationseinheitLib');
|
||||
|
||||
$this->addSelectToModel($this->VorlageModel, 'vorlage_kurzbz', 'bezeichnung');
|
||||
$vorlage = $this->organisationseinheitlib->treeSearchEntire(
|
||||
'(
|
||||
SELECT v.vorlage_kurzbz, v.bezeichnung, vs.version, vs.oe_kurzbz, vs.aktiv, vs.subject, vs.text, v.mimetype
|
||||
FROM tbl_vorlagestudiengang vs INNER JOIN tbl_vorlage v USING(vorlage_kurzbz)
|
||||
) templates',
|
||||
'templates',
|
||||
array("templates.vorlage_kurzbz AS id", "UPPER(templates.oe_kurzbz) || ' - ' || templates.bezeichnung || ' - V' || templates.version AS description"),
|
||||
'templates.aktiv = TRUE
|
||||
AND templates.subject IS NOT NULL
|
||||
AND templates.text IS NOT NULL
|
||||
AND templates.mimetype = \'text/html\'',
|
||||
"description ASC",
|
||||
'eas',
|
||||
true
|
||||
);
|
||||
|
||||
array_pop($vorlage->retval);
|
||||
|
||||
$this->setElementsArray(
|
||||
$this->VorlageModel->loadWhere(array('mimetype' => 'text/html')),
|
||||
$vorlage,
|
||||
true,
|
||||
'Select a vorlage...',
|
||||
'No vorlage found'
|
||||
|
||||
Reference in New Issue
Block a user