diff --git a/application/controllers/api/frontend/v1/stv/Status.php b/application/controllers/api/frontend/v1/stv/Status.php index bb1b512c6..af9effa99 100644 --- a/application/controllers/api/frontend/v1/stv/Status.php +++ b/application/controllers/api/frontend/v1/stv/Status.php @@ -851,7 +851,7 @@ class Status extends FHCAPI_Controller } $this->load->library('PrestudentLib'); - $result = $this->prestudentlib->setFirstStudent($prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, null, $bestaetigtam, $bestaetigtvon, $stg, $uidStudent); + $result = $this->prestudentlib->setFirstStudent($prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, $statusgrund_id, $bestaetigtam, $bestaetigtvon, $stg, $uidStudent); if (isError($result)) { return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); diff --git a/application/libraries/PrestudentLib.php b/application/libraries/PrestudentLib.php index 693f328f5..38ae487d3 100644 --- a/application/libraries/PrestudentLib.php +++ b/application/libraries/PrestudentLib.php @@ -568,6 +568,7 @@ class PrestudentLib 'status_kurzbz' => Prestudentstatus_model::STATUS_STUDENT, 'studiensemester_kurzbz' => $studiensemester_kurzbz, 'ausbildungssemester' => $ausbildungssemester, + 'statusgrund_id' => $statusgrund_id, 'datum' => date('c'), 'insertvon' => $insertvon, 'insertamum' => date('c'), diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Prestudent/MultiStatus.js b/public/js/components/Stv/Studentenverwaltung/Details/Prestudent/MultiStatus.js index 41b3c93bc..306c940c6 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Prestudent/MultiStatus.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Prestudent/MultiStatus.js @@ -133,6 +133,14 @@ export default{ toolbarStudent() { return this.listDataToolbar.filter(item => this.statiStudent.includes(item.status_kurzbz)); }, + sortedGruende() { + return this.listDataToolbar.reduce((result,current) => { + if (!result[current.status_kurzbz]) + result[current.status_kurzbz] = []; + result[current.status_kurzbz].push(current); + return result; + }, {}); + }, resultInteressentArray() { const result = []; this.statiInteressent.forEach(status => { @@ -140,18 +148,16 @@ export default{ status_kurzbz: status, statusgrund_id: null, link: `changeStatusTo${status}`, - dropEntry: null + dropEntry: null, + children: [] }; if (status === "Student") { defaultObject.link = 'changeInteressentToStudent'; } - result.push(defaultObject); - - this.toolbarInteressent.forEach(item => { - if (item.status_kurzbz === status) { - + if(this.sortedGruende[status]) { + this.sortedGruende[status].forEach(item => { const itemObject = { status_kurzbz: item.status_kurzbz, statusgrund_id: item.statusgrund_id, @@ -164,10 +170,9 @@ export default{ itemObject.link = `changeInteressentTo${item.status_kurzbz}(${item.statusgrund_id})`; } - result.push(itemObject); - - } - }); + defaultObject.children.push(itemObject); + }); + } }); return result; }, @@ -667,7 +672,7 @@ export default{ this.actionConfirmDialogue(this.updateData, 'wartender','Wartenden'); }, addStudent(prestudentIds){ - + //this.hideModal('confirmStatusAction'); let changeData = {}; //for Feedback Sucess, Error @@ -968,17 +973,18 @@ export default{ const today = new Date(); return today; }, - handleSelectionChange(event) { - const selectedValue = event.target.value; - const selectedItem = this.resultInteressentArray.find(item => - item.status_kurzbz + (item.statusgrund_id !== null ? '-' + item.statusgrund_id : '') === selectedValue - ); - if (selectedItem && typeof this[selectedItem.link] === 'function') { - this[selectedItem.link](); + executeLink(link) { + // Split the link string to extract the function name and arguments + const match = link.match(/(\w+)\(([^)]*)\)/); + const functionName = match ? match[1] : link; + const args = match ? match[2].split(',').map(arg => arg.trim()) : []; + + if (typeof this[functionName] === 'function') { + this[functionName](...args); } else { - console.warn(`No method found for ${selectedItem.link}`); + console.error(`Method ${functionName} not found`); } - } + }, }, created(){ this.$fhcApi @@ -1014,27 +1020,7 @@ export default{ template: `