diff --git a/application/controllers/api/frontend/v1/stv/Betriebsmittel.php b/application/controllers/api/frontend/v1/stv/Betriebsmittel.php new file mode 100644 index 000000000..d2cc870ff --- /dev/null +++ b/application/controllers/api/frontend/v1/stv/Betriebsmittel.php @@ -0,0 +1,90 @@ + ['admin:r', 'assistenz:r'], + 'addNewBetriebsmittel' => ['admin:r', 'assistenz:r'], + 'updateBetriebsmittel' => ['admin:r', 'assistenz:r'], + 'loadBetriebsmittel' => ['admin:r', 'assistenz:r'], + 'getTypenBetriebsmittel' => ['admin:r', 'assistenz:r'] + ]); + + // Load Libraries + $this->load->library('VariableLib', ['uid' => getAuthUID()]); + $this->load->library('form_validation'); + + // Load language phrases + $this->loadPhrases([ + 'ui' + ]); + } + + public function getAllBetriebsmittel($uid, $person_id) + { + $this->load->model('ressource/Betriebsmittelperson_model', 'BetriebsmittelpersonModel'); + + //uid + //$result = $this->BetriebsmittelpersonModel->getBetriebsmittelByUid($uid); + + //person_id + $result = $this->BetriebsmittelpersonModel->getBetriebsmittel($person_id); + + if (isError($result)) + { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + + $this->terminateWithSuccess((getData($result) ?: [])); + } + + public function loadBetriebsmittel() + { + $_POST = json_decode(utf8_encode($this->input->raw_input_stream), true); + + $betriebsmittel_id = $this->input->post('betriebsmittel_id'); + + $this->load->model('ressource/Betriebsmittel_model', 'BetriebsmittelModel'); + + + $result = $this->BetriebsmittelModel->loadWhere( + array( + 'betriebsmittel_id' => $betriebsmittel_id + ) + ); + if (isError($result)) + { + $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + + elseif (!hasData($result)) + { + $this->terminateWithError("no Betriebsmittel with ID found: " . $betriebsmittel_id, self::ERROR_TYPE_GENERAL); + } + + // var_dump($result); + + $this->terminateWithSuccess(getData($result) ? : []); + + } + + public function getTypenBetriebsmittel() + { + $this->load->model('ressource/Betriebsmitteltyp_model', 'BetriebsmitteltypModel'); + + $result = $this->BetriebsmitteltypModel->load(); + if (isError($result)) { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + return $this->terminateWithSuccess(getData($result) ?: []); + } + +} + + diff --git a/application/controllers/components/stv/Config.php b/application/controllers/components/stv/Config.php index 47842822c..45c26c966 100644 --- a/application/controllers/components/stv/Config.php +++ b/application/controllers/components/stv/Config.php @@ -35,6 +35,10 @@ class Config extends FHC_Controller 'title' => 'Status', 'component' => './Stv/Studentenverwaltung/Details/Status.js' ]; + $result['betriebsmittel'] = [ + 'title' => 'Betriebsmittel', + 'component' => './Stv/Studentenverwaltung/Details/Betriebsmittel.js' + ]; $result['noten'] = [ 'title' => 'Noten', 'component' => './Stv/Studentenverwaltung/Details/Noten.js' diff --git a/public/js/components/Betriebsmittel/Betriebsmittel.js b/public/js/components/Betriebsmittel/Betriebsmittel.js new file mode 100644 index 000000000..6ea8f2022 --- /dev/null +++ b/public/js/components/Betriebsmittel/Betriebsmittel.js @@ -0,0 +1,323 @@ +import VueDatePicker from '../vueDatepicker.js.php'; +import {CoreFilterCmpt} from "../filter/Filter.js"; +import BsModal from "../Bootstrap/Modal"; +import FormForm from '../Form/Form.js'; +import FormInput from '../Form/Input.js'; + +export default { + components: { + CoreFilterCmpt, + VueDatePicker, + BsModal, + FormForm, + FormInput, + }, + props: [ + 'person_id', + 'uid' + ], + data(){ + return { + tabulatorOptions: { + // ajaxURL: CoreRESTClient._generateRouterURI('components/stv/Betriebsmittel/getBetriebsmittel/' + this.id + '/' + this.typeId), + ajaxURL: 'api/frontend/v1/stv/Betriebsmittel/getAllBetriebsmittel/' + this.uid + '/' + this.person_id, + ajaxRequestFunc: this.$fhcApi.get, + ajaxResponse: (url, params, response) => response.data, + columns: [ + {title: "Nummer", field: "nummer"}, + {title: "PersonId", field: "person_id"}, + {title: "Typ", field: "betriebsmitteltyp"}, + {title: "Retourdatum", field: "retouram"}, + {title: "Beschreibung", field: "beschreibung"}, + {title: "Uid", field: "uid"}, + {title: "Anmerkung", field: "anmerkung", visible: false}, + {title: "Kaution", field: "kaution", visible: false}, + {title: "Ausgabedatum", field: "ausgegebenam", visible: false}, + {title: "Betriebsmittel_id", field: "betriebsmittel_id", visible: false}, + {title: "Betriebsmittelperson_id", field: "betriebsmittelperson_id", 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 = 'Übernahmebestätigung drucken'; + button.addEventListener( + 'click', + (event) => + this.actionPrintConfirmation(cell.getData().betriebsmittel_id) + ); + container.append(button); + + button = document.createElement('button'); + button.className = 'btn btn-outline-secondary btn-action'; + button.innerHTML = ''; + button.title = 'Betriebsmittel bearbeiten'; + button.addEventListener( + 'click', + (event) => + this.actionEditBetriebsmittel(cell.getData().betriebsmittel_id) + ); + container.append(button); + + button = document.createElement('button'); + button.className = 'btn btn-outline-secondary btn-action'; + button.innerHTML = ''; + button.title = 'Betriebsmittel löschen'; + button.addEventListener( + 'click', + () => + this.actionDeleteBetriebsmittel(cell.getData().betriebsmittel_id) + ); + container.append(button); + + return container; + }, + frozen: true + }], + layout: 'fitColumns', + layoutColumnsOnNewData: false, + height: '150', + selectableRangeMode: 'click', + selectable: true, + //index: 'betriebsmittel_id' + }, + tabulatorEvents: [], + betriebsmittelData: {}, + betriebsmittel_id: {}, + listBetriebsmitteltyp: [] + }; + }, + methods: { + actionEditBetriebsmittel(betriebsmittel_id){ + console.log("id: " + betriebsmittel_id); + this.loadBetriebsmittel(betriebsmittel_id).then(() => { + if(this.betriebsmittelData) + this.$refs.editBetriebsmittelModal.show(); + }); + }, + actionPrintConfirmation(betriebsmittel_id){ + console.log("actionPrintConfirmation of id: " + betriebsmittel_id); +/* this.loadBetriebsmittel(betriebsmittel_id).then(() => { + + if(this.betriebsmittelData) + this.$refs.editBetriebsmittelModal.show(); + });*/ + }, + loadBetriebsmittel(betriebsmittel_id){ + //console.log("2 " + betriebsmittel_id); + return this.$fhcApi.post('api/frontend/v1/stv/betriebsmittel/loadBetriebsmittel/', + betriebsmittel_id) + .then(result => { + //console.log("in load" + result); + this.betriebsmittelData = result.data; + return result; + }) + .catch(this.$fhcAlert.handleSystemError); + }, + }, + + created(){ + this.$fhcApi + .get('api/frontend/v1/stv/betriebsmittel/getTypenBetriebsmittel') + .then(result => result.data) + .then(result => { + this.listBetriebsmitteltyp = result; + }) + .catch(this.$fhcAlert.handleSystemError); + }, +/* async mounted() { + if(this.showTinyMCE){ + this.initTinyMCE(); + } + + await this.$p.loadCategory(['notiz','global']); + + let cm = this.$refs.table.tabulator.columnManager; + + cm.getColumnByField('verfasser_uid').component.updateDefinition({ + title: this.$p.t('notiz', 'verfasser') + }); + cm.getColumnByField('titel').component.updateDefinition({ + title: this.$p.t('global', 'titel') + }); + cm.getColumnByField('text_stripped').component.updateDefinition({ + title: this.$p.t('global', 'text') + }); + cm.getColumnByField('bearbeiter_uid').component.updateDefinition({ + title: this.$p.t('notiz', 'bearbeiter') + }); + cm.getColumnByField('start').component.updateDefinition({ + title: this.$p.t('global', 'gueltigVon') + }); + cm.getColumnByField('ende').component.updateDefinition({ + title: this.$p.t('global', 'gueltigBis') + }); + cm.getColumnByField('countdoc').component.updateDefinition({ + title: this.$p.t('notiz', 'document') + }); + cm.getColumnByField('erledigt').component.updateDefinition({ + title: this.$p.t('notiz', 'erledigt') + }); + cm.getColumnByField('lastupdate').component.updateDefinition({ + title: this.$p.t('notiz', 'letzte_aenderung') + }); + },*/ + template: ` +
+ + + + + + + + + +
+ +
+ + + +
+
+ +
+ +
+ + +
+
+ +
+ +
+ + +
+
+ +
+ +
+ + +
+
+ +
+ +
+ + +
+
+ +
+ +
+ + +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ + +
+ + + + + + +
+ +
` +} + diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Betriebsmittel.js b/public/js/components/Stv/Studentenverwaltung/Details/Betriebsmittel.js new file mode 100644 index 000000000..ec8a4dfc1 --- /dev/null +++ b/public/js/components/Stv/Studentenverwaltung/Details/Betriebsmittel.js @@ -0,0 +1,25 @@ +import Betriebsmittel from "../../../Betriebsmittel/Betriebsmittel.js"; + +export default { + components: { + Betriebsmittel + }, + props: { + modelValue: Object + }, + template: ` +
+

Betriebsmittel

+ + + {{modelValue}} +
+ {{modelValue.person_id}} +
+ ` +}; +