diff --git a/application/controllers/components/stv/Prestudent.php b/application/controllers/components/stv/Prestudent.php index 855d53a56..3851a0144 100644 --- a/application/controllers/components/stv/Prestudent.php +++ b/application/controllers/components/stv/Prestudent.php @@ -160,18 +160,6 @@ class Prestudent extends FHC_Controller $this->outputJson(getData($result) ?: []); } - public function getHistoryPrestudent($prestudent_id) - { - $this->load->model('crm/Prestudent_model', 'PrestudentModel'); - - $result = $this->PrestudentModel->getHistoryPrestudent($prestudent_id); - if (isError($result)) - { - $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); - } - $this->outputJson(getData($result) ?: []); - } - public function getBezeichnungZgv() { $this->load->model('codex/Zgv_model', 'ZgvModel'); @@ -268,5 +256,45 @@ class Prestudent extends FHC_Controller $this->outputJson($result); } + public function getStudiensemester() + { + $this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel'); + + $this->StudiensemesterModel->addOrder('start', 'DESC'); + $this->StudiensemesterModel->addLimit(20); + + $result = $this->StudiensemesterModel->load(); + if (isError($result)) { + $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + } + $this->outputJson($result); + } + + public function getStudienplaene($prestudent_id) + { + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + + $result = $this->PrestudentModel->loadWhere( + array('prestudent_id' => $prestudent_id) + ); + if (isError($result)) { + $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + } + + $result = current(getData($result)); + $studiengang_kz = $result->studiengang_kz; + + $this->load->model('organisation/Studienplan_model', 'StudienplanModel'); + + $this->StudienplanModel->addOrder('studienplan_id', 'DESC'); + + $result = $this->StudienplanModel->getStudienplaene($studiengang_kz); + + if (isError($result)) { + $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + } + $this->outputJson($result); + } + } \ No newline at end of file diff --git a/application/controllers/components/stv/Status.php b/application/controllers/components/stv/Status.php new file mode 100644 index 000000000..fa0ea5a80 --- /dev/null +++ b/application/controllers/components/stv/Status.php @@ -0,0 +1,171 @@ +load->library('AuthLib'); + $this->load->library('VariableLib', ['uid' => getAuthUID()]); + + // Load language phrases + /* $this->loadPhrases([ + 'ui' + ]);*/ + } + + public function getHistoryPrestudent($prestudent_id) + { + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + + $result = $this->PrestudentModel->getHistoryPrestudent($prestudent_id); + if (isError($result)) + { + $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + } + $this->outputJson(getData($result) ?: []); + } + + public function getStatusgruende() + { + $this->load->model('crm/Statusgrund_model', 'StatusgrundModel'); + + $result = $this->StatusgrundModel->load(); + if (isError($result)) { + $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + } + $this->outputJson($result); + } + + public function addNewStatus($prestudent_id) + { +/* $this->load->library('form_validation'); + + + if ($this->form_validation->run() == false) + { + return $this->outputJsonError($this->form_validation->error_array()); + }*/ + + $_POST = json_decode(utf8_encode($this->input->raw_input_stream), true); + $this->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel'); + + //var_dump($_POST); + + $status_kurzbz = $this->input->post('status_kurzbz'); + $ausbildungssemester = $this->input->post('ausbildungssemester'); + $datum = $this->input->post('datum'); + $bestaetigtam = $this->input->post('bestaetigtam'); + $bewerbung_abgeschicktamum = $this->input->post('bewerbung_abgeschicktamum'); + $studiensemester_kurzbz = $this->input->post('studiensemester_kurzbz'); + $studienplan_id = $this->input->post('studienplan_id'); + $anmerkung = $this->input->post('anmerkung '); + $statusgrund_id = $this->input->post('statusgrund_id'); + $rt_stufe = $this->input->post('rt_stufe'); + $bestaetigtvon = $this->input->post('bestaetigtvon'); + + // Start DB transaction + //$this->db->trans_start(false); + + $result = $this->PrestudentstatusModel->insert( + [ + 'prestudent_id' => $prestudent_id, + 'status_kurzbz' => $status_kurzbz, + 'bewerbung_abgeschicktamum' => $bewerbung_abgeschicktamum, + 'studiensemester_kurzbz' => $studiensemester_kurzbz, + 'studienplan_id' => $studienplan_id, + 'ausbildungssemester' => $ausbildungssemester, + 'anmerkung' => $anmerkung, + 'statusgrund_id' => $statusgrund_id, + 'insertvon' => 'uid', + 'insertamum' => date('c'), + 'bestaetigtam' => $bestaetigtam, + 'bestaetigtvon' => $bestaetigtvon, + 'datum' => $datum, + 'rt_stufe' => $rt_stufe + ] + ); + if (isError($result)) + { + $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + return $this->outputJson(getError($result)); + } + return $this->outputJsonSuccess(true); + } + + public function loadStatus() + { + $_POST = json_decode(utf8_encode($this->input->raw_input_stream), true); + + $prestudent_id = $this->input->post('prestudent_id'); + $status_kurzbz = $this->input->post('status_kurzbz'); + $ausbildungssemester = $this->input->post('ausbildungssemester'); + $studiensemester_kurzbz = $this->input->post('studiensemester_kurzbz'); + //echo $prestudent_id . $status_kurzbz . $ausbildungssemester . $studiensemester_kurzbz; + + + $this->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel'); + + $result = $this->PrestudentstatusModel->loadWhere( + array( + 'prestudent_id' => $prestudent_id, + 'status_kurzbz' => $status_kurzbz, + 'ausbildungssemester' => $ausbildungssemester, + 'studiensemester_kurzbz' => $studiensemester_kurzbz + ) + ); + if (isError($result)) { + $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + $this->outputJson($result); + } + + elseif (!hasData($result)) { + $this->outputJson($result); + } + else + { + //var_dump($result); + $this->outputJsonSuccess(current(getData($result))); + } + } + + public function deleteStatus() + { + $_POST = json_decode(utf8_encode($this->input->raw_input_stream), true); + + $prestudent_id = $this->input->post('prestudent_id'); + $status_kurzbz = $this->input->post('status_kurzbz'); + $ausbildungssemester = $this->input->post('ausbildungssemester'); + $studiensemester_kurzbz = $this->input->post('studiensemester_kurzbz'); + + $this->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel'); + + $result = $this->PrestudentstatusModel->delete( + array( + 'prestudent_id' => $prestudent_id, + 'status_kurzbz' => $status_kurzbz, + 'ausbildungssemester' => $ausbildungssemester, + 'studiensemester_kurzbz' => $studiensemester_kurzbz + ) + ); + + if (isError($result)) + { + $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + $this->outputJson($result); + } + elseif (!hasData($result)) { + $this->outputJson($result); + } + return $this->outputJsonSuccess(current(getData($result))); + } + + + +} diff --git a/application/models/crm/Prestudent_model.php b/application/models/crm/Prestudent_model.php index a8dab8a6a..0d0399bed 100644 --- a/application/models/crm/Prestudent_model.php +++ b/application/models/crm/Prestudent_model.php @@ -754,8 +754,10 @@ class Prestudent_model extends DB_Model ps.anmerkung, ps.bestaetigtvon, ps.insertamum, + TO_CHAR(ps.insertamum::timestamp, 'DD.MM.YYYY HH24:MI:SS') AS format_insertamum, ps.insertvon, ps.updateamum, + TO_CHAR(ps.updateamum::timestamp, 'DD.MM.YYYY HH24:MI:SS') AS format_updateamum, ps.updatevon FROM public.tbl_prestudentstatus ps JOIN public.tbl_student st USING (prestudent_id) @@ -768,6 +770,8 @@ class Prestudent_model extends DB_Model ORDER BY datum DESC "; + // var_dump($query); + return $this->execQuery($query, array($prestudent_id)); } } diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Prestudent/Status.js b/public/js/components/Stv/Studentenverwaltung/Details/Prestudent/Status.js index 777a94e9e..6acb6259b 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Prestudent/Status.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Prestudent/Status.js @@ -1,9 +1,15 @@ import {CoreFilterCmpt} from "../../../../filter/Filter.js"; import {CoreRESTClient} from "../../../../../RESTClient"; +import BsModal from "../../../../Bootstrap/Modal.js"; +import FormForm from '../../../../Form/Form.js'; +import FormInput from '../../../../Form/Input.js'; export default{ components: { - CoreFilterCmpt + CoreFilterCmpt, + BsModal, + FormForm, + FormInput, }, props: { prestudent_id: String @@ -11,143 +17,562 @@ export default{ data() { return { tabulatorOptions: { - ajaxURL: CoreRESTClient._generateRouterURI('components/stv/Prestudent/getHistoryPrestudent/' + this.prestudent_id), + ajaxURL: CoreRESTClient._generateRouterURI('components/stv/Status/getHistoryPrestudent/' + this.prestudent_id), //autoColumns: true, - columns:[ - {title:"Kurzbz", field:"status_kurzbz"}, - {title:"StSem", field:"studiensemester_kurzbz"}, - {title:"Sem", field:"ausbildungssemester"}, - {title:"Lehrverband", field:"lehrverband"}, - {title:"Datum", field:"format_datum"}, - {title:"Studienplan", field:"bezeichnung"}, - {title:"BestätigtAm", field:"format_bestaetigtam"}, - {title:"AbgeschicktAm", field:"format_bewerbung_abgeschicktamum"}, - {title:"Statusgrund", field:"statusgrund_kurzbz"}, - {title:"Organisationsform", field:"ps.orgform_kurzbz"}, - {title:"PrestudentInId", field:"prestudent_id"}, - {title:"StudienplanId", field:"studienplan_id"}, - {title:"Anmerkung", field:"anmerkung"}, - {title:"BestätigtVon", field:"bestaetigtvon"}, - {title:"InsertAmUm", field:"insertamum"}, - {title:"InsertVon", field:"insertvon"}, - {title:"UpdateAmUm", field:"updateamum"}, - {title:"UpdateVon", field:"updatevon"}, + columns: [ + {title: "Kurzbz", field: "status_kurzbz", tooltip: true}, + {title: "StSem", field: "studiensemester_kurzbz"}, + {title: "Sem", field: "ausbildungssemester"}, + {title: "Lehrverband", field: "lehrverband"}, + {title: "Datum", field: "format_datum"}, + {title: "Studienplan", field: "bezeichnung"}, + {title: "BestätigtAm", field: "format_bestaetigtam"}, + {title: "AbgeschicktAm", field: "format_bewerbung_abgeschicktamum"}, + {title: "Statusgrund", field: "statusgrund_kurzbz", visible: false}, + {title: "Organisationsform", field: "ps.orgform_kurzbz", visible: false}, + {title: "PrestudentInId", field: "prestudent_id", visible: false}, + {title: "StudienplanId", field: "studienplan_id", visible: false}, + {title: "Anmerkung", field: "anmerkung", visible: false}, + {title: "BestätigtVon", field: "bestaetigtvon", visible: false}, + {title: "InsertAmUm", field: "format_insertamum", visible: false}, + {title: "InsertVon", field: "insertvon", visible: false}, + {title: "UpdateAmUm", field: "format_updateamum", visible: false}, + {title: "UpdateVon", field: "updatevon", visible: false}, + { + title: 'Aktionen', field: 'actions', + minWidth: 150, // Ensures Action-buttons will be always fully displayed + formatter: (cell, formatterParams, onRendered) => { + let container = document.createElement('div'); + container.className = "d-flex gap-2"; + + let button = document.createElement('button'); + button.className = 'btn btn-outline-secondary btn-action'; + button.innerHTML = ''; + button.title = 'Status vorrücken'; + button.addEventListener('click', () => + this.actionAdvanceStatus(cell.getData().status_kurzbz, cell.getData().studiensemester_kurzbz, cell.getData().ausbildungssemester) + ); + container.append(button); + + button = document.createElement('button'); + button.className = 'btn btn-outline-secondary btn-action'; + button.innerHTML = ''; + button.title = 'Status bestätigen'; + button.addEventListener('click', () => + this.actionConfirmStatus(cell.getData().status_kurzbz, cell.getData().studiensemester_kurzbz, cell.getData().ausbildungssemester) + ); + container.append(button); + + button = document.createElement('button'); + button.className = 'btn btn-outline-secondary btn-action'; + button.innerHTML = ''; + button.title = 'Status bearbeiten'; + button.addEventListener('click', (event) => + this.actionEditStatus(cell.getData().status_kurzbz, cell.getData().studiensemester_kurzbz, cell.getData().ausbildungssemester) + ); + container.append(button); + + button = document.createElement('button'); + button.className = 'btn btn-outline-secondary btn-action'; + button.innerHTML = ''; + button.title = 'Status löschen'; + button.addEventListener('click', () => + this.actionDeleteStatus(cell.getData().status_kurzbz, cell.getData().studiensemester_kurzbz, cell.getData().ausbildungssemester) + ); + container.append(button); + + return container; + }, + frozen: true + }, ], layout: 'fitDataFill', - layoutColumnsOnNewData: false, - height: 'auto', - selectable: false, - rowClickMenu:[ - { - label:"Bearbeiten", - action:function(e, row){ - console.log("bearbeiten: " + row.getData().status_kurzbz + ' ' + row.getData().prestudent_id); - } - }, - { - separator:true, - }, - { - disabled:true, - label:"Status bestätigen", - action:function(e, column){ - column.move("col"); - } - }, - { - separator:true, - }, - { - disabled:true, - label:"Neuen Status hinzufügen", - action:function(e, column){ - column.move("col"); - } - }, - { - separator:true, - }, - { - disabled:true, - label:"Entfernen", - action:function(e, column){ - column.move("col"); - } - }, - { - separator:true, - }, - { - disabled:true, - label:"Status vorrücken", - action:function(e, column){ - column.move("col"); - } - }, - { - separator:true, - }, - { - label:" Select Row", - action:function(e, row){ - row.select(); - } - }, - ], -/* rowContextMenu:[ - { - label:"Bearbeiten", - action:function(e, column){ - console.log("bearbeiten" + column); - column.hide(); - } - }, - { - separator:true, - }, - { - disabled:true, - label:"Status bestätigen", - action:function(e, column){ - column.move("col"); - } - }, - { - separator:true, - }, - { - disabled:true, - label:"Neuen Status hinzufügen", - action:function(e, column){ - column.move("col"); - } - }, - { - separator:true, - }, - { - disabled:true, - label:"Entfernen", - action:function(e, column){ - column.move("col"); - } - }, - { - separator:true, - }, - { - disabled:true, - label:"Status vorrücken", - action:function(e, column){ - column.move("col"); - } - }, - ]*/ + layoutColumnsOnNewData: false, + height: 'auto', + selectable: false, }, + tabulatorEvents: [], + statusData: {}, + listStudiensemester: [], + //maySem: [0,1,2,4,6,7], + maxSem: Array.from({ length: 11 }, (_, index) => index), + listStudienplaene: [], + aufnahmestufen: {'': '-- keine Auswahl --', 1: 1, 2: 2, 3: 3}, + listStatusgruende: [] } }, + computed: { + gruende() { + return this.listStatusgruende.filter(grund => grund.status_kurzbz == this.statusData.status_kurzbz); + }, + }, + methods:{ + actionNewStatus(){ + console.log("Action: Neuen Status hinzufügen"); + this.$refs.newStatusModal.show(); + }, + actionEditStatus(status, stdsem, ausbildungssemester){ + console.log("Action: Status bearbeiten: (" + status + ": " + stdsem + "/" + ausbildungssemester + ")") + this.loadStatus({ + 'prestudent_id': this.prestudent_id, + 'status_kurzbz': status, + 'studiensemester_kurzbz': stdsem, + 'ausbildungssemester': ausbildungssemester + }).then(() => { + if(this.statusData) + this.$refs.editStatusModal.show(); + }); + }, + actionDeleteStatus(status, stdsem, ausbildungssemester){ + console.log("Action: Status löschen: (" + status + ": " + stdsem + "/" + ausbildungssemester + ")") + //this.$refs.deleteStatusModal.show(); + + this.loadStatus({ + 'prestudent_id': this.prestudent_id, + 'status_kurzbz': status, + 'studiensemester_kurzbz': stdsem, + 'ausbildungssemester': ausbildungssemester + }).then(() => { + if(this.statusData) + this.$refs.deleteStatusModal.show(); + }); + }, + actionAdvanceStatus(status, stdsem, ausbildungssemester){ + console.log("Action: Status vorrücken: (" + status + ": " + stdsem + "/" + ausbildungssemester + ")") + //this.$refs.deleteStatusModal.show(); + + /* this.loadStatus(status_id).then(() => { + if(this.statusData.bankverbindung_id) + this.$refs.deleteStatusModal.show(); + });*/ + }, + actionConfirmStatus(status, stdsem, ausbildungssemester){ + console.log("Action: Status bestätigen: (" + status + ": " + stdsem + "/" + ausbildungssemester + ")") + //this.$refs.deleteStatusModal.show(); + + /* this.loadStatus(status_id).then(() => { + if(this.statusData.bankverbindung_id) + this.$refs.deleteStatusModal.show(); + });*/ + }, + addNewStatus(statusData){ + CoreRESTClient.post('components/stv/Status/addNewStatus/' + this.prestudent_id, + this.statusData + ).then(response => { + if (!response.data.error) { + this.$fhcAlert.alertSuccess('Speichern erfolgreich'); + this.hideModal('newStatusModal'); + this.resetModal(); + } else { + const errorData = response.data.retval; + Object.entries(errorData).forEach(entry => { + const [key, value] = entry; + this.$fhcAlert.alertError(value); + }); + } + }).catch(error => { + this.$fhcAlert.alertError('Fehler bei Speichern Status aufgetreten'); + }).finally(() => { + window.scrollTo(0, 0); + this.reload(); + }); + }, + loadStatus(status_id){ + return CoreRESTClient.post('components/stv/Status/loadStatus/', + status_id) + .then( + result => { + if(result.data.retval) + this.statusData = result.data.retval; + else + { + this.statusData = {}; + this.$fhcAlert.alertError('Kein Status mit Id ' + status_id + ' gefunden'); + } + return result; + } + ); + }, + reload(){ + this.$refs.table.reloadTable(); + }, + hideModal(modalRef){ + this.$refs[modalRef].hide(); + }, + resetModal(){ + this.statusData = {}; + }, + }, + created(){ + CoreRESTClient + .get('components/stv/Prestudent/getStudiensemester') + .then(result => CoreRESTClient.getData(result.data) || []) + .then(result => { + this.listStudiensemester = result; + }) + .catch(this.$fhcAlert.handleSystemError); + CoreRESTClient + .get('components/stv/Prestudent/getStudienplaene/' + this.prestudent_id) + .then(result => CoreRESTClient.getData(result.data) || []) + .then(result => { + this.listStudienplaene = result; + }) + .catch(this.$fhcAlert.handleSystemError); + CoreRESTClient + .get('components/stv/Status/getStatusgruende/') + .then(result => CoreRESTClient.getData(result.data) || []) + .then(result => { + this.listStatusgruende = result; + }) + .catch(this.$fhcAlert.handleSystemError); + }, template: `
+ + +

TestData

+ {{statusData}} + + + + + + + +
+ +
+ + + + + + + + + + +
+
+
+ +
+ + + +
+
+ +
+ +
+ + + +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + + +
+
+
+ +
+ + +
+
+ +
+ +
+ + + +
+
+ + +
+ +
+ + + +
+
+ +
+ + + +
+ + + + + + +
+ +
+ + + + + + + + + + +
+
+
+ +
+ + + f +
+
+ +
+ +
+ + + +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + + +
+
+
+ +
+ + +
+
+ +
+ +
+ + + +
+
+ + +
+ +
+ + + +
+
+ +
+ + + +
+ + + + + + + + + +
` -} \ No newline at end of file +}; \ No newline at end of file