From 0621073f8d14f37d80467915e8b7347748ba37ce Mon Sep 17 00:00:00 2001 From: cgfhtw Date: Wed, 7 Aug 2024 15:40:11 +0200 Subject: [PATCH] correct checkIfExistingAufgenommenerstatus --- .../libraries/PrestudentstatusCheckLib.php | 16 +++---- .../models/crm/Prestudentstatus_model.php | 42 ------------------- 2 files changed, 8 insertions(+), 50 deletions(-) diff --git a/application/libraries/PrestudentstatusCheckLib.php b/application/libraries/PrestudentstatusCheckLib.php index d9b77fdf5..b14542e8f 100644 --- a/application/libraries/PrestudentstatusCheckLib.php +++ b/application/libraries/PrestudentstatusCheckLib.php @@ -219,14 +219,14 @@ class PrestudentstatusCheckLib */ public function checkIfExistingAufgenommenerstatus($prestudent_id) { - $result = $this->_ci->PrestudentstatusModel->checkIfExistingAufgenommenerstatus( - $prestudent_id - ); - if(isError($result)) - { - return getData($result); - } - return success(getData($result) != '0'); + $result = $this->_ci->PrestudentstatusModel->loadWhere([ + 'prestudent_id' => $prestudent_id, + 'status_kurzbz' => Prestudentstatus_model::STATUS_AUFGENOMMENER + ]); + if (isError($result)) + return $result; + + return success(hasData($result)); } /** diff --git a/application/models/crm/Prestudentstatus_model.php b/application/models/crm/Prestudentstatus_model.php index 5093019bb..1695d5b02 100644 --- a/application/models/crm/Prestudentstatus_model.php +++ b/application/models/crm/Prestudentstatus_model.php @@ -408,48 +408,6 @@ class Prestudentstatus_model extends DB_Model } } - /** - * Check if Rolle there is an existing Aufgenommenerstatus - * @param integer $prestudent_id - * @return error if no status Aufgenommener, success if existing - */ - public function checkIfExistingAufgenommenerstatus($prestudent_id) - { - $studentName = ''; - - $nameRes = $this->PersonModel->loadPrestudent($prestudent_id); - - if (hasData($nameRes)) - { - $nameData = getData($nameRes)[0]; - $studentName = $nameData->vorname.' '.$nameData->nachname; - } - - $qry = "SELECT - * - FROM - public.tbl_prestudentstatus - WHERE - prestudent_id = ? - AND - status_kurzbz = 'Aufgenommener'"; - - $result = $this->execQuery($qry, array($prestudent_id)); - - if (isError($result)) - { - return error($result); - } - elseif (!hasData($result)) - { - return success("0", $this->p->t('lehre', 'error_keinAufgenommener', ['name' => $studentName])); - } - else - { - return success($result); - } - } - /** * Check if there is only one prestudentstatus left *