diff --git a/application/controllers/api/frontend/v1/stv/Status.php b/application/controllers/api/frontend/v1/stv/Status.php index 11528214c..ac6d4b3aa 100644 --- a/application/controllers/api/frontend/v1/stv/Status.php +++ b/application/controllers/api/frontend/v1/stv/Status.php @@ -11,6 +11,7 @@ class Status extends FHCAPI_Controller { parent::__construct([ 'getHistoryPrestudent' => ['admin:r', 'assistenz:r'], + 'getMaxSemester' => ['admin:r', 'assistenz:r'], 'changeStatus' => ['admin:r', 'assistenz:r', 'student/keine_studstatuspruefung'], 'addStudent' => ['admin:r', 'assistenz:r', 'student/keine_studstatuspruefung'], 'getStatusgruende' => self::PERM_LOGGED, @@ -63,6 +64,41 @@ class Status extends FHCAPI_Controller $this->terminateWithSuccess($data); } + /** + * Gets the maximum possible semester for one or more Studiengaenge. + * If there are more than one Studiengang each maximum is calculated and + * the smallest result is returned. + * + * @return void + */ + public function getMaxSemester() + { + $studiengang_kzs = $this->input->post('studiengang_kzs'); + + if (!$studiengang_kzs || !is_array($studiengang_kzs)) { + $this->load->library('form_validation'); + + $this->form_validation->set_rules('studiengang_kzs', '', 'required|is_null', [ + 'is_null' => $this->p->t('ui', 'error_fieldMustBeArray') + ]); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + + + if (defined('VORRUECKUNG_STATUS_MAX_SEMESTER') && VORRUECKUNG_STATUS_MAX_SEMESTER == false) + $this->terminateWithSuccess(100); + + $this->load->model('organisation/Lehrverband_model', 'LehrverbandModel'); + + $result = $this->LehrverbandModel->getMaxSemester($studiengang_kzs); + + $maxsem = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($maxsem ? current($maxsem)->maxsem : 10); + } + public function getStatusgruende() { $this->load->model('crm/Statusgrund_model', 'StatusgrundModel'); diff --git a/application/models/organisation/Lehrverband_model.php b/application/models/organisation/Lehrverband_model.php index 2573b92e8..bc4858e5f 100644 --- a/application/models/organisation/Lehrverband_model.php +++ b/application/models/organisation/Lehrverband_model.php @@ -53,4 +53,34 @@ class Lehrverband_model extends DB_Model return success("1","Lehrverband vorhanden!"); } } + + /** + * Gets the maximum possible semester for one or more Studiengaenge. + * If there are more than one Studiengang each maximum is calculated and + * the smallest result is returned. + * + * @param array $studiengang_kzs + * + * @return stdClass + */ + public function getMaxSemester($studiengang_kzs) + { + $sqls = []; + foreach ($studiengang_kzs as $studiengang_kz) { + $this->addSelect('MAX(semester) AS maxsem'); + $this->db->where('studiengang_kz', $studiengang_kz); + $sqls[] = $this->db->get_compiled_select($this->dbTable); + } + + $this->addSelect('MIN(a.maxsem) AS maxsem'); + + $dbTable = $this->dbTable; + $this->dbTable = '(' . implode(' UNION ', $sqls) . ') AS a'; + + $result = $this->load(); + + $this->dbTable = $dbTable; + + return $result; + } } diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Prestudent/MultiStatus.js b/public/js/components/Stv/Studentenverwaltung/Details/Prestudent/MultiStatus.js index 146450341..8cab0ea1a 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Prestudent/MultiStatus.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Prestudent/MultiStatus.js @@ -235,7 +235,8 @@ export default{ statusData: {}, statusId: {}, dataMeldestichtag: null, - statusNew: true + statusNew: true, + maxSem: 0 }; }, watch: { @@ -246,9 +247,20 @@ export default{ else this.data.tabulatorOptions.ajaxURL = 'api/frontend/v1/stv/Status/getHistoryPrestudent/' + this.modelValue.prestudent_id; } + this.getMaxSem(); } }, methods: { + getMaxSem() { + const studiengang_kzs = this.modelValue.studiengang_kz + ? [this.modelValue.studiengang_kz] + : this.modelValue.map(prestudent => prestudent.studiengang_kz); + this.maxSem = 0; + this.$fhcApi + .post('api/frontend/v1/stv/status/getMaxSemester/', {studiengang_kzs}) + .then(result => this.maxSem = result.data) + .catch(this.$fhcAlert.handleSystemError); + }, actionNewStatus() { this.$refs.test.open(this.modelValue); }, @@ -317,6 +329,8 @@ export default{ } }, created() { + this.getMaxSem(); + this.$fhcApi .get('api/frontend/v1/stv/status/getLastBismeldestichtag/') .then(result => { @@ -327,9 +341,9 @@ export default{ .catch(this.$fhcAlert.handleSystemError); }, template: ` -
+
- + index), + ] }; }, computed: { + semester() { + return Array.from({length: this.maxSem}, (_, index) => index); + }, bisLocked() { if (this.statusNew || this.hasPermissionToSkipStatusCheck) return false; @@ -207,7 +212,7 @@ export default{ - +

@@ -249,7 +254,6 @@ export default{ {{ sem.studiensemester_kurzbz }} -