- Fixed bug when inactive parents are not retrieved even when includeinactive = true

This commit is contained in:
alex
2018-10-03 17:59:47 +02:00
parent fa75380fb4
commit 80b6f24f43
@@ -119,7 +119,7 @@ class Organisationseinheit_model extends DB_Model
/**
* Liefert die ChildNodes einer Organisationseinheit
* @param $oe_kurzbz
* @param bool $includeinactive - wether to include inactive parent oes
* @param bool $includeinactive wether to include inactive parent oes
* @return array mit den Childs inkl dem Uebergebenen Element
*/
public function getChilds($oe_kurzbz, $includeinactive = false)
@@ -131,19 +131,20 @@ class Organisationseinheit_model extends DB_Model
WHERE oe_kurzbz=? %s
UNION ALL
SELECT o.oe_kurzbz, o.oe_parent_kurzbz FROM public.tbl_organisationseinheit o, oes
WHERE o.oe_parent_kurzbz=oes.oe_kurzbz
WHERE o.oe_parent_kurzbz=oes.oe_kurzbz %s
)
SELECT oe_kurzbz
FROM oes
GROUP BY oe_kurzbz;";
return $this->execQuery(sprintf($query, $includeinactive === true ? "" : "AND aktiv = true"), array($oe_kurzbz));
$aktivstring = $includeinactive === true ? "" : "AND aktiv = true";
return $this->execQuery(sprintf($query, $aktivstring, $aktivstring), array($oe_kurzbz));
}
/**
* Liefert die OEs die im Tree ueberhalb der uebergebene OE liegen
* @param $oe_kurzbz
* @param bool $includeinactive - wether to include inactive parent oes
* @param bool $includeinactive wether to include inactive parent oes
* @return array|null
*/
public function getParents($oe_kurzbz, $includeinactive = false)
@@ -155,12 +156,13 @@ class Organisationseinheit_model extends DB_Model
WHERE oe_kurzbz=? %s
UNION ALL
SELECT o.oe_kurzbz, o.oe_parent_kurzbz FROM public.tbl_organisationseinheit o, oes
WHERE o.oe_kurzbz=oes.oe_parent_kurzbz and aktiv = true
WHERE o.oe_kurzbz=oes.oe_parent_kurzbz %s
)
SELECT oe_kurzbz
FROM oes";
return $this->execQuery(sprintf($query, $includeinactive === true ? "" : "AND aktiv = true"), array($oe_kurzbz));
$aktivstring = $includeinactive === true ? "" : "AND aktiv = true";
return $this->execQuery(sprintf($query, $aktivstring, $aktivstring), array($oe_kurzbz));
}
}