diff --git a/application/controllers/api/frontend/v1/organisation/Studienjahr.php b/application/controllers/api/frontend/v1/organisation/Studienjahr.php index cdbb524c7..9da354e3c 100644 --- a/application/controllers/api/frontend/v1/organisation/Studienjahr.php +++ b/application/controllers/api/frontend/v1/organisation/Studienjahr.php @@ -24,7 +24,8 @@ class Studienjahr extends FHCAPI_Controller parent::__construct( array( 'getAll' => self::PERM_LOGGED, - 'getNext' => self::PERM_LOGGED + 'getNext' => self::PERM_LOGGED, + 'getAktNext' => self::PERM_LOGGED ) ); // Load model StudiensemesterModel @@ -77,4 +78,32 @@ class Studienjahr extends FHCAPI_Controller $this->terminateWithSuccess(current(getData($result))); } + + public function getAktNext() + { + $this->StudienjahrModel->addJoin('public.tbl_studiensemester', 'studienjahr_kurzbz'); + $this->StudienjahrModel->addOrder('ende'); + $this->StudienjahrModel->addLimit(1); + + $result = $this->StudienjahrModel->loadWhere([ + 'start <=' => 'NOW()', + 'ende >=' => 'NOW()' + ]); + + $data = $this->getDataOrTerminateWithError($result); + + if (!$data) { + $this->StudienjahrModel->addJoin('public.tbl_studiensemester', 'studienjahr_kurzbz'); + $this->StudienjahrModel->addOrder('ende'); + $this->StudienjahrModel->addLimit(1); + + $result = $this->StudienjahrModel->loadWhere([ + 'ende >=' => 'NOW()' + ]); + + $data = $this->getDataOrTerminateWithError($result); + } + + $this->terminateWithSuccess(current($data)); + } } diff --git a/public/js/api/factory/studienjahr.js b/public/js/api/factory/studienjahr.js new file mode 100644 index 000000000..f0c748217 --- /dev/null +++ b/public/js/api/factory/studienjahr.js @@ -0,0 +1,25 @@ +/** + * Copyright (C) 2026 fhcomplete.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +export default { + getAktNext() { + return { + method: 'get', + url: '/api/frontend/v1/organisation/studienjahr/getAktNext', + }; + }, +}; \ No newline at end of file