From 1fc7f9d3e8decd60fea15b0a85b7c7b93aa0719d Mon Sep 17 00:00:00 2001 From: cgfhtw Date: Wed, 7 Aug 2024 15:37:43 +0200 Subject: [PATCH] correct checkIfExistingBewerberstatus --- .../api/frontend/v1/stv/Status.php | 11 ----- .../libraries/PrestudentstatusCheckLib.php | 9 ++-- .../models/crm/Prestudentstatus_model.php | 42 ------------------- 3 files changed, 5 insertions(+), 57 deletions(-) diff --git a/application/controllers/api/frontend/v1/stv/Status.php b/application/controllers/api/frontend/v1/stv/Status.php index 24e1dd5ae..8a7588897 100644 --- a/application/controllers/api/frontend/v1/stv/Status.php +++ b/application/controllers/api/frontend/v1/stv/Status.php @@ -17,7 +17,6 @@ class Status extends FHCAPI_Controller 'getStatusgruende' => self::PERM_LOGGED, 'getLastBismeldestichtag' => self::PERM_LOGGED, 'isLastStatus' => self::PERM_LOGGED, - 'hasStatusBewerber' => self::PERM_LOGGED, 'getStatusarray' => self::PERM_LOGGED, 'deleteStatus' => ['admin:rw','assistenz:rw'], 'loadStatus' => ['admin:r', 'assistenz:r'], @@ -129,16 +128,6 @@ class Status extends FHCAPI_Controller return $this->terminateWithSuccess($result); } - public function hasStatusBewerber($prestudent_id) - { - $result = $this->prestudentstatuschecklib->checkIfExistingBewerberstatus($prestudent_id); - if (isError($result)) - { - return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); - } - return $this->terminateWithSuccess($result); - } - public function getStudiensemesterOfStatus($prestudent_id, $status) { $result = $this->PrestudentstatusModel->loadWhere([ diff --git a/application/libraries/PrestudentstatusCheckLib.php b/application/libraries/PrestudentstatusCheckLib.php index 56739e567..d9b77fdf5 100644 --- a/application/libraries/PrestudentstatusCheckLib.php +++ b/application/libraries/PrestudentstatusCheckLib.php @@ -199,13 +199,14 @@ class PrestudentstatusCheckLib */ public function checkIfExistingBewerberstatus($prestudent_id) { - $result = $this->_ci->PrestudentstatusModel->checkIfExistingBewerberstatus( - $prestudent_id - ); + $result = $this->_ci->PrestudentstatusModel->loadWhere([ + 'prestudent_id' => $prestudent_id, + 'status_kurzbz' => Prestudentstatus_model::STATUS_BEWERBER + ]); if (isError($result)) return $result; - return success(getData($result) != '0'); + return success(hasData($result)); } diff --git a/application/models/crm/Prestudentstatus_model.php b/application/models/crm/Prestudentstatus_model.php index 37b6c6762..5093019bb 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 Bewerberstatus - * @param integer $prestudent_id - * @return error if no bewerberstatus, success if existing - */ - public function checkIfExistingBewerberstatus($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 = 'Bewerber'"; - - $result = $this->execQuery($qry, array($prestudent_id)); - - if (isError($result)) - { - return error($result); - } - elseif (!hasData($result)) - { - return success("0", $this->p->t('lehre', 'error_keinBewerber', ['name' => $studentName])); - } - else - { - return success($result); - } - } - /** * Check if Rolle there is an existing Aufgenommenerstatus * @param integer $prestudent_id