From 4b7def9b74d3c76816f6938aa05e264688a7e645 Mon Sep 17 00:00:00 2001 From: Johann Hoffmann Date: Wed, 15 Apr 2026 16:58:08 +0200 Subject: [PATCH] defined new searchbar endpoint searchPV which uses searchbar config searchPV.php -> mostly just curated imports of the actually adapted base search.php config, since the main point of this story was enabling phonenumber lookup. basically works everywhere, unless deliberately unset like in searchcis.php config; also added personalnummer searchfield for employees; adapted phonenumber lookup to be the old version where type needs to be 'telefon' AND the standort_id needs to match, or type is a whider range of options including 'firmenhandy' and 'mobil' but is only matched via person_id; fixed unassigned_employee config by letting the config check for benutzerfunktion.uid instead of benutzerfunktion.bezeichnung after the left join, so the results are actually only employees without kostenstellen or oezuordnung, not all mitarbeiter with empty benutzerfunktion bezeichnungen; --- application/config/search.php | 37 ++++++++++++++----- application/config/searchPV.php | 34 +++++++++++++++++ application/config/searchcis.php | 1 + .../controllers/api/frontend/v1/Searchbar.php | 12 +++++- public/js/api/factory/searchbar.js | 7 ++++ system/phrasesupdate.php | 20 ++++++++++ 6 files changed, 101 insertions(+), 10 deletions(-) create mode 100644 application/config/searchPV.php diff --git a/application/config/search.php b/application/config/search.php index bedf8d888..e098bb60c 100644 --- a/application/config/search.php +++ b/application/config/search.php @@ -45,7 +45,7 @@ $config['person'] = [ 'field' => 'kontakt', 'join' => [ 'table' => "public.tbl_kontakt", - 'on' => "kontakttyp IN ('telefon', 'so.tel', 'mobil') AND tbl_kontakt.person_id = tbl_person.person_id" + 'on' => "kontakttyp IN ('telefon', 'so.tel', 'mobil', 'firmenhandy') AND tbl_kontakt.person_id = tbl_person.person_id" ], "1-n" => true ], @@ -360,6 +360,10 @@ $config['employee'] = [ 'comparison' => 'equals', 'field' => "mitarbeiter_uid" ], + 'personalnummer' => [ + 'comparison' => 'equal-int', + 'field' => "personalnummer" + ], 'vorname' => [ 'alias' => ['firstname'], 'comparison' => 'similar', @@ -415,12 +419,27 @@ $config['employee'] = [ 'tel' => [ 'alias' => ['phone', 'telefon'], 'comparison' => 'similar', - 'field' => "TRIM(COALESCE(kontakt, '') || ' ' || COALESCE(telefonklappe, ''))", + 'field' => 'kontakt', + 'prepare' => "employee_tel (mitarbeiter_uid, kontakt) AS ( + SELECT m.mitarbeiter_uid, + TRIM(COALESCE(k.kontakt, '') || ' ' || COALESCE(m.telefonklappe, '')) + FROM public.tbl_mitarbeiter m + LEFT JOIN public.tbl_kontakt k + ON k.standort_id = m.standort_id + AND k.kontakttyp = 'telefon' + UNION + SELECT m.mitarbeiter_uid, k.kontakt + FROM public.tbl_mitarbeiter m + JOIN public.tbl_benutzer b ON b.uid = m.mitarbeiter_uid + JOIN public.tbl_kontakt k + ON k.person_id = b.person_id + AND k.kontakttyp IN ('telefon', 'so.tel', 'mobil', 'firmenhandy') + )", 'join' => [ - 'table' => "public.tbl_kontakt", - 'on' => "kontakttyp = 'telefon' AND tbl_kontakt.standort_id = tbl_mitarbeiter.standort_id" + 'table' => "employee_tel", + 'using' => "mitarbeiter_uid" ], - "1-n" => true + '1-n' => true ], 'pid' => [ 'alias' => ['person_id'], @@ -471,6 +490,7 @@ $config['employee'] = [ ], 'resultfields' => [ "b.uid", + "m.personalnummer", "p.person_id", "(p.vorname || ' ' || p.nachname) AS name", "ARRAY( @@ -512,7 +532,6 @@ $config['employee'] = [ ) k ON (k.standort_id = m.standort_id)" ]; -// TODO(chris): move to searchpv21.php $config['unassigned_employee'] = $config['employee']; $config['unassigned_employee']['alias'] = ['mitarbeiter_ohne_zuordnung']; $config['unassigned_employee']['prepare'] = "unassigned_employee AS ( @@ -524,7 +543,7 @@ $config['unassigned_employee']['prepare'] = "unassigned_employee AS ( AND (datum_von IS NULL OR datum_von <= NOW()) AND (datum_bis IS NULL OR datum_bis >= NOW()) ) - WHERE tbl_benutzerfunktion.bezeichnung IS NULL + WHERE tbl_benutzerfunktion.uid IS NULL UNION SELECT tbl_mitarbeiter.* FROM public.tbl_mitarbeiter @@ -534,10 +553,10 @@ $config['unassigned_employee']['prepare'] = "unassigned_employee AS ( AND (datum_von IS NULL OR datum_von <= NOW()) AND (datum_bis IS NULL OR datum_bis >= NOW()) ) - WHERE tbl_benutzerfunktion.bezeichnung IS NULL + WHERE tbl_benutzerfunktion.uid IS NULL )"; $config['unassigned_employee']['table'] = "unassigned_employee"; -$config['unassigned_employee']['searchfields']['tel']['join']['on'] = " +$config['unassigned_employee']['searchfields']['tel'] = " kontakttyp = 'telefon' AND tbl_kontakt.standort_id = unassigned_employee.standort_id "; diff --git a/application/config/searchPV.php b/application/config/searchPV.php new file mode 100644 index 000000000..b05db2fff --- /dev/null +++ b/application/config/searchPV.php @@ -0,0 +1,34 @@ +config->item('person', 'search'); + +$config['employee'] = $CI->config->item('employee', 'search'); +$config['employee']['resultjoin'] = " + JOIN public.tbl_mitarbeiter m USING (mitarbeiter_uid) + JOIN public.tbl_benutzer b ON (b.uid = m.mitarbeiter_uid AND b.aktiv = true) + JOIN public.tbl_person p USING(person_id) + LEFT JOIN ( + SELECT kontakt, standort_id + FROM public.tbl_kontakt + WHERE kontakttyp = 'telefon' + ) k ON (k.standort_id = m.standort_id)"; + +$config['unassigned_employee'] = $CI->config->item('unassigned_employee', 'search'); +$config['unassigned_employee']['resultjoin'] = " + JOIN public.tbl_mitarbeiter m USING (mitarbeiter_uid) + JOIN public.tbl_benutzer b ON (b.uid = m.mitarbeiter_uid AND b.aktiv = true) + JOIN public.tbl_person p USING(person_id) + LEFT JOIN ( + SELECT kontakt, standort_id + FROM public.tbl_kontakt + WHERE kontakttyp = 'telefon' + ) k ON (k.standort_id = m.standort_id)"; + +$config['room'] = $CI->config->item('room', 'search'); + +$config['organisationunit'] = $CI->config->item('organisationunit', 'search'); \ No newline at end of file diff --git a/application/config/searchcis.php b/application/config/searchcis.php index 12bad025d..b09bf89be 100644 --- a/application/config/searchcis.php +++ b/application/config/searchcis.php @@ -7,6 +7,7 @@ $CI =& get_instance(); $config['employee'] = $CI->config->item('employee', 'search'); +unset($config['employee']['searchfields']['tel']); $config['employee']['resultjoin'] = " JOIN public.tbl_mitarbeiter m USING (mitarbeiter_uid) JOIN public.tbl_benutzer b ON (b.uid = m.mitarbeiter_uid AND b.aktiv = true) diff --git a/application/controllers/api/frontend/v1/Searchbar.php b/application/controllers/api/frontend/v1/Searchbar.php index b4c251555..5a4dcaa1c 100644 --- a/application/controllers/api/frontend/v1/Searchbar.php +++ b/application/controllers/api/frontend/v1/Searchbar.php @@ -37,7 +37,8 @@ class Searchbar extends FHCAPI_Controller parent::__construct([ 'search' => self::PERM_LOGGED, 'searchCis' => self::PERM_LOGGED, - 'searchStv' => self::PERM_LOGGED + 'searchStv' => self::PERM_LOGGED, + 'searchPV' => self::PERM_LOGGED ]); $this->load->model('system/Webservicelog_model', 'WebservicelogModel'); @@ -87,6 +88,15 @@ class Searchbar extends FHCAPI_Controller return $this->searchAdvanced([ 'config' => 'searchstv' ]); } + /** + * Gets a JSON body via HTTP POST and provides the parameters + */ + public function searchPV() + { + return $this->searchAdvanced([ 'config' => 'searchPV' ]); + } + + /** * Gets a JSON body via HTTP POST and provides the parameters */ diff --git a/public/js/api/factory/searchbar.js b/public/js/api/factory/searchbar.js index 6bcf577b4..c68c301a1 100644 --- a/public/js/api/factory/searchbar.js +++ b/public/js/api/factory/searchbar.js @@ -36,5 +36,12 @@ export default { url: '/api/frontend/v1/searchbar/searchStv', params }; + }, + searchPV(params) { + return { + method: 'post', + url: '/api/frontend/v1/searchbar/searchPV', + params + }; } }; \ No newline at end of file diff --git a/system/phrasesupdate.php b/system/phrasesupdate.php index f7628f8ef..9163fce4a 100644 --- a/system/phrasesupdate.php +++ b/system/phrasesupdate.php @@ -53762,6 +53762,26 @@ and represent the current state of research on the topic. The prescribed citatio ) ) ), + array( + 'app' => 'core', + 'category' => 'search', + 'phrase' => 'type_unassigned_employee', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Mitarbeiter ohne Zuordnung', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'unassigned employee', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), array( 'app' => 'core', 'category' => 'search',