From 2b0ff28c41c84d574138449a2a8c715bccb2b0dc Mon Sep 17 00:00:00 2001 From: Cris Date: Wed, 5 Aug 2020 18:20:11 +0200 Subject: [PATCH] Added getAll_byPersonID in Kontakt Model Get all latest contact data of person, where Zustellung is true. Signed-off-by: Cris --- application/models/person/Kontakt_model.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/application/models/person/Kontakt_model.php b/application/models/person/Kontakt_model.php index 3f27604e8..b8ad67509 100644 --- a/application/models/person/Kontakt_model.php +++ b/application/models/person/Kontakt_model.php @@ -59,4 +59,22 @@ class Kontakt_model extends DB_Model return $this->execQuery($sql, array($person_id, $kontakttyp)); } + + /** + * Get all latest contact data of person, where Zustellung is true + * @param $person_id + * @return array + */ + public function getAll_byPersonID($person_id) + { + $this->addSelect('DISTINCT ON (kontakttyp) kontakttyp, kontakt'); + $this->addJoin('public.tbl_standort', 'standort_id', 'LEFT'); + $this->addJoin('public.tbl_firma', 'firma_id', 'LEFT'); + $this->addOrder('kontakttyp, kontakt, tbl_kontakt.updateamum, tbl_kontakt.insertamum'); + + return $this->loadWhere(array( + 'zustellung' => TRUE, + 'person_id' => $person_id + )); + } }