From 16db622bc98635dfad92f49e97768dcd336a1bd5 Mon Sep 17 00:00:00 2001 From: ma0068 Date: Wed, 30 Jul 2025 17:55:59 +0200 Subject: [PATCH] Tab Details - add anrede to modelValue - add Validations Alias and Lehrverbandsgruppe - add Phrase invalidAlias - add translation to validation Integer for field semester --- .../api/frontend/v1/stv/Student.php | 38 ++++++++++++++++++- system/phrasesupdate.php | 20 ++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/application/controllers/api/frontend/v1/stv/Student.php b/application/controllers/api/frontend/v1/stv/Student.php index 7c1589dd7..17cec8b26 100644 --- a/application/controllers/api/frontend/v1/stv/Student.php +++ b/application/controllers/api/frontend/v1/stv/Student.php @@ -103,6 +103,7 @@ class Student extends FHCAPI_Controller $this->PrestudentModel->addSelect('p.familienstand'); $this->PrestudentModel->addSelect('p.staatsbuergerschaft'); $this->PrestudentModel->addSelect('p.matr_nr'); + $this->PrestudentModel->addSelect('p.anrede'); if (defined('ACTIVE_ADDONS') && strpos(ACTIVE_ADDONS, 'bewerbung') !== false) { $this->PrestudentModel->addSelect( @@ -178,6 +179,7 @@ class Student extends FHCAPI_Controller $this->load->model('crm/Student_model', 'StudentModel'); $this->load->model('crm/Prestudent_model', 'PrestudentModel'); $this->load->model('education/Studentlehrverband_model', 'StudentlehrverbandModel'); + $this->load->model('organisation/Lehrverband_model', 'LehrverbandModel'); $this->load->library('form_validation'); @@ -188,7 +190,15 @@ class Student extends FHCAPI_Controller $this->form_validation->set_rules('gebdatum', 'Geburtsdatum', 'is_valid_date'); - $this->form_validation->set_rules('semester', 'Semester', 'integer'); + $this->form_validation->set_rules('semester', 'Semester', 'integer', [ + 'integer' => $this->p->t('ui', 'error_fieldNotInteger') + ] + ); + + $this->form_validation->set_rules('alias', 'Alias', 'regex_match[/^[-a-z0-9\_\.]*[a-z0-9]{1,}\.[-a-z0-9\_]{1,}$/]', + [ + 'regex_match' => $this->p->t('ui', 'error_fieldInvalidAlias') + ]); $this->load->library('UDFLib'); @@ -300,11 +310,37 @@ class Student extends FHCAPI_Controller // Do Updates if (count($update_lehrverband)) { + $curstudlvb = $this->StudentlehrverbandModel->load([ 'studiensemester_kurzbz' => $studiensemester_kurzbz, 'student_uid' => $uid ]); + $data = $this->getDataOrTerminateWithError($curstudlvb); + $data = current($data); + + $verbandCurrent = $data->verband; + $studiengang_kz = $data->studiengang_kz; + $semesterCurrent = $data->semester; + $gruppeCurrent = $data->gruppe; + + $verband = isset($update_lehrverband['verband']) ? $update_lehrverband['verband'] : $verbandCurrent; + $gruppe = isset($update_lehrverband['gruppe']) ? $update_lehrverband['gruppe'] : $gruppeCurrent; + $semester = isset($update_lehrverband['semester']) ? $update_lehrverband['semester'] : $semesterCurrent; + + //check if existing Lehrverband of new data to avoid Error + $result = $this->LehrverbandModel->loadWhere([ + 'verband' => $verband, + 'gruppe' => $gruppe, + 'semester' => $semester, + 'studiengang_kz' => $studiengang_kz, + ]); + + if(!hasData($result)) + { + $this->terminateWithError($this->p->t('lehre', 'error_noLehrverband'), self::ERROR_TYPE_GENERAL); + } + if(hasData($curstudlvb) && count(getData($curstudlvb)) > 0 ) { $update_lehrverband['updatevon'] = $authuid; diff --git a/system/phrasesupdate.php b/system/phrasesupdate.php index 355ed7186..c190d7b4f 100644 --- a/system/phrasesupdate.php +++ b/system/phrasesupdate.php @@ -44577,6 +44577,26 @@ and represent the current state of research on the topic. The prescribed citatio ) ) ), + array( + 'app' => 'core', + 'category' => 'ui', + 'phrase' => 'error_fieldInvalidAlias', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Alias ist ungültig', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'Alias is invalid', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), // FHC-4 Finetuning END );