mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-25 08:34:29 +00:00
Adapted method getUntergebene() in mitarbeiter.class.php
Added an optional parameter include_OE_childs. If true, the query will return not only the sub-employees but all sub-employees of all the sub organisational units which the superleader is in charge of.
This commit is contained in:
@@ -1091,8 +1091,12 @@ class mitarbeiter extends benutzer
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gibt ein Array mit den UIDs der aktiv beschäftigten Untergebenen zurueck
|
* Gibt ein Array mit den UIDs der aktiv beschäftigten Untergebenen zurueck
|
||||||
|
* @param string $uid UID.
|
||||||
|
* @param boolean $include_OE_childs Wenn true, dann werden auch alle aktiv
|
||||||
|
* beschäftigten Untergebenen der Kind-OEs des Leiters zurückgegeben.
|
||||||
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function getUntergebene($uid=null)
|
public function getUntergebene($uid=null, $include_OE_childs = false)
|
||||||
{
|
{
|
||||||
if (is_null($uid))
|
if (is_null($uid))
|
||||||
$uid=$this->uid;
|
$uid=$this->uid;
|
||||||
@@ -1114,6 +1118,70 @@ class mitarbeiter extends benutzer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Kinder-Organisationseinheiten holen
|
||||||
|
if ($include_OE_childs == true)
|
||||||
|
{
|
||||||
|
if (!empty($oe))
|
||||||
|
{
|
||||||
|
$child_oe_arr = array(); // array of string child oes
|
||||||
|
|
||||||
|
$qry = '
|
||||||
|
WITH RECURSIVE
|
||||||
|
oes (oe_kurzbz, oe_parent_kurzbz) AS
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
oe_kurzbz,
|
||||||
|
oe_parent_kurzbz
|
||||||
|
FROM
|
||||||
|
public.tbl_organisationseinheit
|
||||||
|
WHERE
|
||||||
|
oe_kurzbz IN ('. $oe. ')
|
||||||
|
|
||||||
|
UNION ALL
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
o.oe_kurzbz,
|
||||||
|
o.oe_parent_kurzbz
|
||||||
|
FROM
|
||||||
|
public.tbl_organisationseinheit o, oes
|
||||||
|
WHERE
|
||||||
|
o.oe_parent_kurzbz = oes.oe_kurzbz
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
oe_kurzbz
|
||||||
|
FROM
|
||||||
|
oes
|
||||||
|
GROUP BY
|
||||||
|
oe_kurzbz';
|
||||||
|
|
||||||
|
if($this->db_query($qry))
|
||||||
|
{
|
||||||
|
while($row = $this->db_fetch_object())
|
||||||
|
{
|
||||||
|
$child_oe_arr []= $this->db_add_param($row->oe_kurzbz);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// eliminate duplicates
|
||||||
|
$child_oe_arr = array_unique($child_oe_arr);
|
||||||
|
|
||||||
|
// check if leader has child oes by comparing the original
|
||||||
|
// string of oes with string of child oes.
|
||||||
|
if ($oe == implode(',', $child_oe_arr))
|
||||||
|
{
|
||||||
|
$this->result ['isIndirectSupervisor']= false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->result ['isIndirectSupervisor']= true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// overwrite $oe with child oes for further query
|
||||||
|
$oe = implode(',', $child_oe_arr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//Alle Personen holen die dieser Organisationseinheit untergeordnet sind
|
//Alle Personen holen die dieser Organisationseinheit untergeordnet sind
|
||||||
$qry = "
|
$qry = "
|
||||||
SELECT distinct
|
SELECT distinct
|
||||||
|
|||||||
Reference in New Issue
Block a user