From 53ac4d11ba33eb31c5350d3b50a545cce15eebe6 Mon Sep 17 00:00:00 2001 From: Paolo Date: Tue, 4 Feb 2020 14:42:53 +0100 Subject: [PATCH] Do not retrieve the degree program name from studiengang table but directly from the organization unit table in student sent messages page and student write to organisation unit page --- application/models/CL/Messages_model.php | 4 ++-- application/models/crm/Prestudent_model.php | 7 ++++--- application/models/system/Recipient_model.php | 15 +++++---------- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/application/models/CL/Messages_model.php b/application/models/CL/Messages_model.php index 84f4e59aa..87eff0f99 100644 --- a/application/models/CL/Messages_model.php +++ b/application/models/CL/Messages_model.php @@ -183,7 +183,7 @@ class Messages_model extends CI_Model public function prepareAjaxReadSent() { // Retrieves sent messages from the logged user - $sentMessagesResult = $this->RecipientModel->getSentMessages(getAuthPersonId(), self::ALT_OE); + $sentMessagesResult = $this->RecipientModel->getSentMessages(getAuthPersonId()); if (isError($sentMessagesResult)) return $sentMessagesResult; // If an error occurred return it if (hasData($sentMessagesResult)) @@ -205,7 +205,7 @@ class Messages_model extends CI_Model if ($sentMessage->person_id == $this->config->item(MessageLib::CFG_SYSTEM_PERSON_ID)) { - $jsonRecord->to = $sentMessage->sg; + $jsonRecord->to = $sentMessage->oe; } else { diff --git a/application/models/crm/Prestudent_model.php b/application/models/crm/Prestudent_model.php index 5b74ed5e4..94d77f8d3 100644 --- a/application/models/crm/Prestudent_model.php +++ b/application/models/crm/Prestudent_model.php @@ -524,11 +524,12 @@ class Prestudent_model extends DB_Model /** * Get organisation units for all the prestudents of a person + * TODO */ public function getOrganisationunitsByPersonId($person_id) { $query = 'SELECT o.oe_kurzbz, - sg.bezeichnung, + o.bezeichnung, ps.prestudent_id FROM public.tbl_prestudent p JOIN public.tbl_studiengang sg USING(studiengang_kz) @@ -541,9 +542,9 @@ class Prestudent_model extends DB_Model ) ps USING(prestudent_id) WHERE p.person_id = ? GROUP BY o.oe_kurzbz, - sg.bezeichnung, + o.bezeichnung, ps.prestudent_id - ORDER BY sg.bezeichnung'; + ORDER BY o.bezeichnung'; return $this->execQuery($query, array($person_id)); } diff --git a/application/models/system/Recipient_model.php b/application/models/system/Recipient_model.php index 8f5dfa397..c2acd2d56 100644 --- a/application/models/system/Recipient_model.php +++ b/application/models/system/Recipient_model.php @@ -446,7 +446,7 @@ class Recipient_model extends DB_Model /** * Gets all the sent message by the given person */ - public function getSentMessages($person_id, $altOe = '') + public function getSentMessages($person_id) { $sql = 'SELECT mm.message_id, mm.relationmessage_id, @@ -458,18 +458,13 @@ class Recipient_model extends DB_Model p.nachname, MAX(ms.status) AS status, ms.person_id AS statusPersonId, - sg.bezeichnung AS sg, + oe.bezeichnung AS oe, mr.token FROM public.tbl_msg_message mm JOIN public.tbl_msg_recipient mr ON (mr.message_id = mm.message_id) JOIN public.tbl_msg_status ms ON (ms.message_id = mm.message_id AND mr.person_id = mr.person_id) JOIN public.tbl_person p ON (p.person_id = mr.person_id) - LEFT JOIN ( - SELECT oe_kurzbz, bezeichnung - FROM public.tbl_studiengang - UNION - SELECT ?, ? - ) sg ON (sg.oe_kurzbz = mr.oe_kurzbz) + JOIN public.tbl_organisationseinheit oe ON (oe.oe_kurzbz = mr.oe_kurzbz) WHERE mm.person_id = ? AND mr.sent IS NOT NULL AND mr.sentinfo IS NULL @@ -482,10 +477,10 @@ class Recipient_model extends DB_Model p.vorname, p.nachname, ms.person_id, - sg.bezeichnung, + oe.bezeichnung, mr.token ORDER BY mr.sent DESC'; - return $this->execQuery($sql, array($altOe, ucfirst($altOe), $person_id)); + return $this->execQuery($sql, array($person_id)); } }