mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-16 14:32:18 +00:00
- Added new constant PHOTO_IMG_URL to application/libraries/SearchBarLib.php
- phone and photo_url are now return from SearchBarLib->_mitarbeiter - SearchBarLib->_organisationunit fixed correct number of employees per organisation unit - SearchBarLib->_organisationunit now returns the mailgroup - SearchBarLib->_organisationunit returns an array of leaders, each element of this array is an object having the properties uid and name
This commit is contained in:
@@ -16,6 +16,8 @@ class SearchBarLib
|
||||
// List of allowed types of search
|
||||
const ALLOWED_TYPES = ['mitarbeiter', 'organisationunit', 'raum', 'person', 'student', 'prestudent', 'document', 'cms'];
|
||||
|
||||
const PHOTO_IMG_URL = '/cis/public/bild.php?src=person&person_id=';
|
||||
|
||||
private $_ci; // Code igniter instance
|
||||
|
||||
/**
|
||||
@@ -103,7 +105,8 @@ class SearchBarLib
|
||||
p.vorname || \' \' || p.nachname AS name,
|
||||
ARRAY_AGG(DISTINCT(org.bezeichnung)) AS organisationunit_name,
|
||||
b.uid || \''.'@'.DOMAIN.'\' AS email,
|
||||
m.telefonklappe AS phone
|
||||
TRIM(COALESCE(k.kontakt, \'\') || \' \' || COALESCE(m.telefonklappe, \'\')) AS phone,
|
||||
\''.base_url(self::PHOTO_IMG_URL).'\' || p.person_id AS photo_url
|
||||
FROM public.tbl_mitarbeiter m
|
||||
JOIN public.tbl_benutzer b ON(b.uid = m.mitarbeiter_uid)
|
||||
JOIN public.tbl_person p USING(person_id)
|
||||
@@ -111,14 +114,20 @@ class SearchBarLib
|
||||
SELECT o.bezeichnung, bf.uid
|
||||
FROM public.tbl_benutzerfunktion bf
|
||||
JOIN public.tbl_organisationseinheit o USING(oe_kurzbz)
|
||||
WHERE (bf.datum_von IS NULL OR bf.datum_von <= NOW())
|
||||
WHERE bf.funktion_kurzbz = \'oezuordnung\'
|
||||
AND (bf.datum_von IS NULL OR bf.datum_von <= NOW())
|
||||
AND (bf.datum_bis IS NULL OR bf.datum_bis >= NOW())
|
||||
GROUP BY o.bezeichnung, bf.uid
|
||||
) org USING(uid)
|
||||
LEFT JOIN (
|
||||
SELECT kontakt, standort_id
|
||||
FROM public.tbl_kontakt
|
||||
WHERE kontakttyp = \'telefon\'
|
||||
) k ON(k.standort_id = m.standort_id)
|
||||
WHERE b.uid ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\'
|
||||
OR p.vorname ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\'
|
||||
OR p.nachname ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\'
|
||||
GROUP BY type, b.uid, p.person_id, name, email, m.telefonklappe
|
||||
GROUP BY type, b.uid, p.person_id, name, email, m.telefonklappe, phone
|
||||
');
|
||||
|
||||
// If something has been found then return it
|
||||
@@ -143,33 +152,62 @@ class SearchBarLib
|
||||
oParent.oe_kurzbz AS parentoe_kurzbz,
|
||||
oParent.bezeichnung AS parentoe_name,
|
||||
ARRAY_AGG(DISTINCT(bfLeader.uid)) AS leader_uid,
|
||||
ARRAY_AGG(DISTINCT(p.vorname || \' \' || p.nachname)) AS leader_name,
|
||||
COUNT(bfCount.benutzerfunktion_id) AS number_of_people
|
||||
ARRAY_AGG(DISTINCT(bfLeader.vorname || \' \' || bfLeader.nachname)) AS leader_name,
|
||||
COUNT(bfCount.benutzerfunktion_id) AS number_of_people,
|
||||
(CASE WHEN o.mailverteiler = TRUE THEN o.oe_kurzbz || \''.'@'.DOMAIN.'\' END) AS mailgroup
|
||||
FROM public.tbl_organisationseinheit o
|
||||
LEFT JOIN public.tbl_organisationseinheit oParent ON(oParent.oe_kurzbz = o.oe_parent_kurzbz)
|
||||
LEFT JOIN (
|
||||
SELECT benutzerfunktion_id, oe_kurzbz, uid
|
||||
SELECT benutzerfunktion_id, oe_kurzbz
|
||||
FROM public.tbl_benutzerfunktion
|
||||
WHERE (datum_von IS NULL OR datum_von <= NOW())
|
||||
WHERE funktion_kurzbz = \'oezuordnung\'
|
||||
AND (datum_von IS NULL OR datum_von <= NOW())
|
||||
AND (datum_bis IS NULL OR datum_bis >= NOW())
|
||||
) bfCount ON(bfCount.oe_kurzbz = o.oe_kurzbz)
|
||||
LEFT JOIN (
|
||||
SELECT oe_kurzbz, uid
|
||||
FROM public.tbl_benutzerfunktion
|
||||
SELECT bf.oe_kurzbz, bf.uid, p.vorname, p.nachname
|
||||
FROM public.tbl_benutzerfunktion bf
|
||||
JOIN public.tbl_benutzer b USING(uid)
|
||||
JOIN public.tbl_person p USING(person_id)
|
||||
WHERE funktion_kurzbz = \'Leitung\'
|
||||
AND (datum_von IS NULL OR datum_von <= NOW())
|
||||
AND (datum_bis IS NULL OR datum_bis >= NOW())
|
||||
AND b.aktiv = TRUE
|
||||
) bfLeader ON(bfLeader.oe_kurzbz = o.oe_kurzbz)
|
||||
LEFT JOIN public.tbl_benutzer b ON(b.uid = bfLeader.uid)
|
||||
LEFT JOIN public.tbl_person p USING(person_id)
|
||||
WHERE b.aktiv = TRUE
|
||||
AND o.oe_kurzbz ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\'
|
||||
WHERE o.oe_kurzbz ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\'
|
||||
OR o.bezeichnung ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\'
|
||||
GROUP BY type, o.oe_kurzbz, o.bezeichnung, oParent.oe_kurzbz, oParent.bezeichnung
|
||||
');
|
||||
|
||||
// If something has been found then return it
|
||||
if (hasData($ous)) return getData($ous);
|
||||
// If something has been found
|
||||
if (hasData($ous))
|
||||
{
|
||||
// Loop through the returned dataset
|
||||
foreach (getData($ous) as $ou)
|
||||
{
|
||||
// Create the new property leaders as an empty array
|
||||
$ou->leaders = array();
|
||||
|
||||
// Loop through the found leaders for this organisation unit
|
||||
for ($i = 0; $i < count($ou->leader_uid); $i++)
|
||||
{
|
||||
// Empty object that will contains the leader uid and name
|
||||
$leader = new stdClass();
|
||||
// Set the properties name and uid
|
||||
$leader->uid = $ou->leader_uid[$i];
|
||||
$leader->name = $ou->leader_name[$i];
|
||||
// Add the leader object to the leaders array
|
||||
$ou->leaders[] = $leader;
|
||||
}
|
||||
|
||||
// Remove the not needed properties leader_uid and leader_name
|
||||
unset($ou->leader_uid);
|
||||
unset($ou->leader_name);
|
||||
}
|
||||
|
||||
// Returns the changed dataset
|
||||
return getData($ous);
|
||||
}
|
||||
|
||||
// Otherwise return an empty array
|
||||
return array();
|
||||
|
||||
Reference in New Issue
Block a user