diff --git a/application/controllers/components/stv/Notiz.php b/application/controllers/api/frontend/v1/stv/Notiz.php similarity index 59% rename from application/controllers/components/stv/Notiz.php rename to application/controllers/api/frontend/v1/stv/Notiz.php index 7b78b06f8..3d84c2d68 100644 --- a/application/controllers/components/stv/Notiz.php +++ b/application/controllers/api/frontend/v1/stv/Notiz.php @@ -2,15 +2,28 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); +use \DateTime as DateTime; -class Notiz extends FHC_Controller +class Notiz extends FHCAPI_Controller { public function __construct() { - parent::__construct(); + parent::__construct([ + 'getUid' => ['admin:r', 'assistenz:r'], + 'getNotizen' => ['admin:r', 'assistenz:r'], + 'loadNotiz' => 'assistenz:r', // TODO(manu): self::PERM_LOGGED + 'addNewNotiz' => 'assistenz:r', // TODO(manu): self::PERM_LOGGED + 'updateNotiz' => 'assistenz:r', // TODO(manu): self::PERM_LOGGED + 'deleteNotiz' => ['admin:r', 'assistenz:r'], + 'loadDokumente' => ['admin:r', 'assistenz:r'], + 'getMitarbeiter' => ['admin:r', 'assistenz:r'] + ]); + + //Load Models + $this->load->model('person/Notiz_model', 'NotizModel'); + $this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel'); // Load Libraries - $this->load->library('AuthLib'); $this->load->library('VariableLib', ['uid' => getAuthUID()]); // Load language phrases @@ -21,19 +34,11 @@ class Notiz extends FHC_Controller public function getUid() { - // Load Libraries - $this->load->library('AuthLib'); - $this->load->library('VariableLib', ['uid' => getAuthUID()]); - $result = getAuthUid(); - - $this->outputJsonError($result); + $this->terminateWithSuccess(getAuthUID()); } public function getNotizen($id, $type) { - $this->load->model('person/Notiz_model', 'NotizModel'); - $this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel'); - //check if valid type $isValidType = $this->NotizzuordnungModel->isValidType($type); @@ -42,23 +47,23 @@ class Notiz extends FHC_Controller $result = $this->NotizModel->getNotizWithDocEntries($id, $type); if (isError($result)) { - $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); - $this->outputJson(getError($result)); - } else { - $this->outputJson(getData($result) ?: []); + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); } + return $this->terminateWithSuccess(getData($result) ?: []); } else { - //Todo manu (phrases, response?) - $result = "datatype not yet implemented for notes"; - $this->outputJson(getError($result)); + return $this->terminateWithError("type not valid", self::ERROR_TYPE_GENERAL); } } - public function loadNotiz($notiz_id) + public function loadNotiz() { - $this->load->model('person/Notiz_model', 'NotizModel'); + $_POST = json_decode(utf8_encode($this->input->raw_input_stream), true); + + $notiz_id = $this->input->post('notiz_id'); + + //$this->load->model('person/Notiz_model', 'NotizModel'); $this->NotizModel->addJoin('public.tbl_notiz_dokument', 'notiz_id', 'LEFT'); $this->NotizModel->addSelect('*'); $this->NotizModel->addSelect("TO_CHAR(CASE WHEN public.tbl_notiz.updateamum >= public.tbl_notiz.insertamum @@ -68,23 +73,23 @@ class Notiz extends FHC_Controller $result = $this->NotizModel->loadWhere( array('notiz_id' => $notiz_id) ); - if (isError($result)) { - $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); - $this->outputJson($result); + if (isError($result)) + { + $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); } - - elseif (!hasData($result)) { - $this->outputJson($result); + elseif (!hasData($result)) + { + $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=>'Notiz_id']), self::ERROR_TYPE_GENERAL); } else { - $this->outputJsonSuccess(current(getData($result))); + $this->terminateWithSuccess(current(getData($result))); } } public function addNewNotiz($id, $paramTyp = null) { - $this->load->model('person/Notiz_model', 'NotizModel'); + //$this->load->model('person/Notiz_model', 'NotizModel'); $this->load->library('DmsLib'); $this->load->library('form_validation'); @@ -101,12 +106,17 @@ class Notiz extends FHC_Controller } //Form Validation - $this->form_validation->set_rules('titel', 'titel', 'callback_titel_required'); - $this->form_validation->set_rules('text', 'text', 'callback_text_required'); + $this->form_validation->set_rules('titel', 'Titel', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Titel']) + ]); + + $this->form_validation->set_rules('text', 'Text', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Text']) + ]); if ($this->form_validation->run() == false) { - return $this->outputJsonError($this->form_validation->error_array()); + $this->terminateWithValidationErrors($this->form_validation->error_array()); } $titel = $this->input->post('titel'); @@ -115,15 +125,14 @@ class Notiz extends FHC_Controller $verfasser_uid = isset($_POST['verfasser']) ? $_POST['verfasser'] : $uid; $bearbeiter_uid = isset($_POST['bearbeiter']) ? $_POST['bearbeiter'] : null; $type = $this->input->post('typeId'); - $start = $this->input->post('Von'); - $ende = $this->input->post('Bis'); + $start = $this->input->post('start'); + $ende = $this->input->post('ende'); //Speichern der Notiz und Notizzuordnung inkl Prüfung ob valid type $result = $this->NotizModel->addNotizForType($type, $id, $titel, $text, $uid, $start, $ende, $erledigt, $verfasser_uid, $bearbeiter_uid); if (isError($result)) { - $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); - return $this->outputJson(getError($result)); + return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); } $notiz_id = $result->retval; @@ -141,12 +150,12 @@ class Notiz extends FHC_Controller ); //Todo(manu) check if filetypes weiter eingeschränkt werden sollen + //Todo(manu)check name files: nicht gleiches file 2mal hochladen $result = $this->dmslib->upload($dms, $k, ['*']); -/* $result = $this->dmslib->upload($dms, $k, ['application/pdf','application/x.fhc-dms+json']);*/ + /* $result = $this->dmslib->upload($dms, $k, ['application/pdf','application/x.fhc-dms+json']);*/ if (isError($result)) { - $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); - return $this->outputJson(getError($result)); + return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); } $dms_id_arr[] = $result->retval['dms_id']; } @@ -161,20 +170,16 @@ class Notiz extends FHC_Controller $result = $this->NotizdokumentModel->insert(array('notiz_id' => $notiz_id, 'dms_id' => $dms_id)); if (isError($result)) { - $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); - return $this->outputJson(getError($result)); + return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); } } } - return $this->outputJsonSuccess(true); + return $this->terminateWithSuccess($result); } - public function updateNotiz($notiz_id) + public function updateNotiz() { - $this->load->model('person/Notiz_model', 'NotizModel'); - $this->load->model('person/Notizdokument_model', 'NotizdokumentModel'); - $this->load->library('form_validation'); $this->load->library('DmsLib'); @@ -187,18 +192,25 @@ class Notiz extends FHC_Controller } } + $notiz_id = $this->input->post('notiz_id'); + if(!$notiz_id) { - return $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + $this->terminateWithError($this->p->t('ui','error_missingId',['id'=>'Notiz_id']), self::ERROR_TYPE_GENERAL); } //Form Validation - $this->form_validation->set_rules('titel', 'titel', 'callback_titel_required'); - $this->form_validation->set_rules('text', 'text', 'callback_text_required'); + $this->form_validation->set_rules('titel', 'Titel', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Titel']) + ]); + + $this->form_validation->set_rules('text', 'Text', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Text']) + ]); if ($this->form_validation->run() == false) { - return $this->outputJsonError($this->form_validation->error_array()); + $this->terminateWithValidationErrors($this->form_validation->error_array()); } //update Notiz @@ -208,9 +220,8 @@ class Notiz extends FHC_Controller $verfasser_uid = $this->input->post('verfasser'); $bearbeiter_uid = isset($_POST['bearbeiter']) ? $_POST['bearbeiter'] : $uid; $erledigt = $this->input->post('erledigt'); - //$type = $this->input->post('typeId'); //soll auch dieser geändert werden können? - $start = $this->input->post('von'); - $ende = $this->input->post('bis'); + $start = $this->input->post('start'); + $ende = $this->input->post('ende'); $result = $this->NotizModel->update( [ @@ -230,8 +241,7 @@ class Notiz extends FHC_Controller ); if (isError($result)) { - $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); - return $this->outputJson(getError($result)); + return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); } //update(1) laden aller bereits mit dieser notiz_id verknüpften DMS-Einträge @@ -242,8 +252,7 @@ class Notiz extends FHC_Controller $result = $this->NotizdokumentModel->loadWhere(array('notiz_id' => $notiz_id)); if (isError($result)) { - $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); - $this->outputJson(getError($result)); + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); } elseif (!hasData($result)) { @@ -256,7 +265,7 @@ class Notiz extends FHC_Controller $dms_id_arr[] = array( 'name' => $doc->name, 'dms_id' => $doc->dms_id - ); + ); } } @@ -281,20 +290,19 @@ class Notiz extends FHC_Controller ); //Todo(manu) check if filetypes weiter eingeschränkt werden sollen + //Todo(manu)check name files: nicht gleiches file 2mal hochladen $result = $this->dmslib->upload($dms, $k, array('*')); if (isError($result)) { - $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); - return $this->outputJson(getError($result)); + return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); } $dms_id = $result->retval['dms_id']; $result = $this->NotizdokumentModel->insert(array('notiz_id' => $notiz_id, 'dms_id' => $dms_id)); if (isError($result)) { - $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); - return $this->outputJson(getError($result)); + return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); } } } @@ -302,11 +310,18 @@ class Notiz extends FHC_Controller //update(3) check if Dateien gelöscht wurden if(count($dms_uploaded) != count($dms_id_arr)) { - $upload_new_names = array_column($dms_uploaded, "name"); + if (count($dms_uploaded) == 0) + { + $filesDeleted = $dms_id_arr; + } + else + { + $upload_new_names = array_column($dms_uploaded, "name"); - $filesDeleted = array_filter($dms_id_arr, function ($file) use ($upload_new_names) { - return !in_array($file["name"], $upload_new_names); - }); + $filesDeleted = array_filter($dms_id_arr, function ($file) use ($upload_new_names) { + return !in_array($file["name"], $upload_new_names); + }); + } foreach ($filesDeleted as $file) { @@ -314,18 +329,20 @@ class Notiz extends FHC_Controller if (isError($result)) { - $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); - return $this->outputJson(getError($result)); + return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); } else $this->outputJson($result); } } - return $this->outputJsonSuccess(true); + return $this->terminateWithSuccess($result); } - public function deleteNotiz($notiz_id) + public function deleteNotiz() { + $_POST = json_decode(utf8_encode($this->input->raw_input_stream), true); + $notiz_id = $this->input->post('notiz_id'); + //dms_id auslesen aus notizdokument wenn vorhanden $dms_id_arr = []; $this->load->model('person/Notizdokument_model', 'NotizdokumentModel'); @@ -334,17 +351,13 @@ class Notiz extends FHC_Controller if (isError($result)) { - $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); - $this->outputJson(getError($result)); + return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); } - elseif (!hasData($result)) - { - $this->outputJson($result); - } - else + + if(hasData($result)) { $result = getData($result); - foreach($result as $doc) { + foreach ($result as $doc) { $dms_id_arr[] = $doc->dms_id; } } @@ -358,15 +371,13 @@ class Notiz extends FHC_Controller if (isError($result)) { - $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); - return $this->outputJson(getError($result)); + return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); } - else - $this->outputJson($result); + + $this->outputJson($result); } } - //Todo(manu) rollback? //delete Notiz und Notizzuordnung $this->load->model('person/Notiz_model', 'NotizModel'); $this->NotizModel->addJoin('public.tbl_notizzuordnung', 'notiz_id'); @@ -377,20 +388,20 @@ class Notiz extends FHC_Controller if (isError($result)) { - $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); - $this->outputJson($result); + return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); } - elseif (!hasData($result)) { - $this->outputJson($result); + if(!hasData($result)) + { + return $this->terminateWithError($this->p->t('ui','error_missingId', ['id'=> 'Notiz_id']), self::ERROR_TYPE_GENERAL); } - return $this->outputJsonSuccess(current(getData($result))); + return $this->terminateWithSuccess(current(getData($result))); } - public function loadDokumente($notiz_id) + public function loadDokumente() { - $this->load->model('person/Notiz_model', 'NotizModel'); - + $_POST = json_decode(utf8_encode($this->input->raw_input_stream), true); + $notiz_id = $this->input->post('notiz_id'); $this->NotizModel->addSelect('campus.tbl_dms_version.*'); @@ -401,51 +412,24 @@ class Notiz extends FHC_Controller array('public.tbl_notiz.notiz_id' => $notiz_id) ); if (isError($result)) { - $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); - $this->outputJson($result); + return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); } - elseif (!hasData($result)) { - $this->outputJson($result); - } - else + if(!hasData($result)) { - $this->outputJsonSuccess(getData($result)); + return $this->terminateWithError($this->p->t('ui','error_missingId', ['id'=> 'Notiz_id']), self::ERROR_TYPE_GENERAL); } + return $this->terminateWithSuccess(getData($result)); } public function getMitarbeiter($searchString) { $this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel'); - $result = $this->MitarbeiterModel->searchMitarbeiter($searchString); if (isError($result)) { - $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); } - $this->outputJson($result); + return $this->terminateWithSuccess($result); } - public function titel_required($value) - { - if (empty($value)) { - $this->form_validation->set_message('titel_required', $this->p->t('ui', 'error_fieldRequired', ['field' => 'Titel'])); - return false; - } - else - { - return true; - } - } - - public function text_required($value) - { - if (empty($value)) { - $this->form_validation->set_message('text_required', $this->p->t('ui', 'error_fieldRequired', ['field' => 'Text'])); - return false; - } - else - { - return true; - } - } -} +} \ No newline at end of file diff --git a/application/models/person/Notiz_model.php b/application/models/person/Notiz_model.php index 2822cac47..f9cd76724 100644 --- a/application/models/person/Notiz_model.php +++ b/application/models/person/Notiz_model.php @@ -271,20 +271,6 @@ class Notiz_model extends DB_Model */ public function getNotizWithDocEntries($id, $type) { - // ci query builder returns null -/* $this->db->select('n.*, count(dms_id) as countDoc, z.notizzuordnung_id'); - $this->db->select('(CASE WHEN n.updateamum >= n.insertamum THEN n.updateamum ELSE n.insertamum END) AS lastUpdate'); - $this->db->from('public.tbl_notiz n'); - $this->db->join('public.tbl_notizzuordnung z', 'n.notiz_id = z.notiz_id'); - $this->db->join('public.tbl_notiz_dokument dok', 'n.notiz_id = dok.notiz_id', 'left'); - $this->db->join('campus.tbl_dms_version', 'dok.notiz_id = campus.tbl_dms_version.dms_id', 'left'); - $this->db->where("z.$type", $id); - $this->db->group_by('n.notiz_id, z.notizzuordnung_id'); - - $query = $this->db->get(); - return $query->result();*/ - - $qry = " SELECT n.*, count(dms_id) as countDoc, z.notizzuordnung_id, @@ -292,7 +278,10 @@ class Notiz_model extends DB_Model WHEN n.updateamum >= n.insertamum THEN n.updateamum ELSE n.insertamum END::timestamp, 'DD.MM.YYYY HH24:MI:SS') AS lastUpdate, - regexp_replace(n.text, '<[^>]*>', '', 'g') as text_stripped + regexp_replace(n.text, '<[^>]*>', '', 'g') as text_stripped, + TO_CHAR(n.start::timestamp, 'DD.MM.YYYY') AS start_format, + TO_CHAR(n.ende::timestamp, 'DD.MM.YYYY') AS ende_format + FROM public.tbl_notiz n JOIN diff --git a/public/js/components/Betriebsmittel/Betriebsmittel.js b/public/js/components/Betriebsmittel/Betriebsmittel.js index 6011ff98c..209ca9380 100644 --- a/public/js/components/Betriebsmittel/Betriebsmittel.js +++ b/public/js/components/Betriebsmittel/Betriebsmittel.js @@ -137,6 +137,11 @@ export default { filteredInventar: [] } }, + watch: { + uid(){ + this.$refs.table.tabulator.setData('api/frontend/v1/stv/Betriebsmittel/getAllBetriebsmittel/' + this.uid + '/' + this.person_id); + } + }, methods: { actionEditBetriebsmittel(betriebsmittelperson_id){ this.statusNew = false; diff --git a/public/js/components/Form/Upload/Dms.js b/public/js/components/Form/Upload/Dms.js index c531065ff..6ad69848c 100644 --- a/public/js/components/Form/Upload/Dms.js +++ b/public/js/components/Form/Upload/Dms.js @@ -53,8 +53,14 @@ export default { }, watch: { modelValue(n) { - if (n instanceof FileList) + if (!n) + return; + if (n instanceof FileList) { + if (!this.$refs.upload) { + return; + } return this.$refs.upload.files = n; + } const dt = new DataTransfer(); const dms = []; diff --git a/public/js/components/Notiz/NotizComponent.js b/public/js/components/Notiz/NotizComponent.js index eb8b8dd1d..fe2ecc3e8 100644 --- a/public/js/components/Notiz/NotizComponent.js +++ b/public/js/components/Notiz/NotizComponent.js @@ -1,9 +1,10 @@ import VueDatePicker from '../vueDatepicker.js.php'; import PvAutoComplete from "../../../../index.ci.php/public/js/components/primevue/autocomplete/autocomplete.esm.min.js"; import FormUploadDms from '../Form/Upload/Dms.js'; -import {CoreRESTClient} from "../../RESTClient"; 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 { @@ -12,109 +13,226 @@ export default { VueDatePicker, PvAutoComplete, FormUploadDms, + FormForm, + FormInput, BsModal }, props: [ 'typeId', 'id', + 'notizLayout', 'showErweitert', 'showDocument', - 'showTinyMCE' + 'showTinyMCE', + 'visibleColumns' ], data(){ - return { - tabulatorOptions: { - ajaxURL: CoreRESTClient._generateRouterURI('components/stv/Notiz/getNotizen/' + this.id + '/' + this.typeId), - columns: [ - {title: "Titel", field: "titel"}, - {title: "Text", field: "text_stripped", width: 250}, - {title: "VerfasserIn", field: "verfasser_uid"}, - {title: "BearbeiterIn", field: "bearbeiter_uid", visible: false}, - {title: "Start", field: "start", visible: false}, - {title: "Ende", field: "ende", visible: false}, - {title: "Dokumente", field: "countdoc"}, - {title: "Erledigt", field: "erledigt", visible: false}, - {title: "Notiz_id", field: "notiz_id", visible: false}, - {title: "Notizzuordnung_id", field: "notizzuordnung_id", visible: false}, - {title: "letzte Änderung", field: "lastupdate", 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"; + return { + tabulatorOptions: { + ajaxURL: 'api/frontend/v1/stv/Notiz/getNotizen/' + this.id + '/' + this.typeId, + ajaxRequestFunc: this.$fhcApi.get, + ajaxResponse: (url, params, response) => response.data, + //ajaxURL: CoreRESTClient._generateRouterURI('components/stv/Notiz/getNotizen/' + this.id + '/' + this.typeId), + columns: [ + { + title: "Titel", + field: "titel", + width: 100, + visible: true, + tooltip:function(e, cell, onRendered){ + var el = document.createElement("div"); + el.style.backgroundColor = "white"; + el.style.fontWeight = "bold"; + el.style.padding = "5px"; + el.style.border = "1px solid black"; - let button = document.createElement('button'); - button.className = 'btn btn-outline-secondary btn-action'; - button.innerHTML = ''; - button.addEventListener( - 'click', - (event) => - this.actionEditNotiz(cell.getData().notiz_id) - ); - container.append(button); + el.innerText = cell.getColumn().getField() + " - " + cell.getValue(); - button = document.createElement('button'); - button.className = 'btn btn-outline-secondary btn-action'; - button.innerHTML = ''; - button.addEventListener( - 'click', - () => - this.actionDeleteNotiz(cell.getData().notiz_id) - ); - container.append(button); - - return container; + return el; + }, }, - frozen: true - }], - layout: 'fitColumns', - layoutColumnsOnNewData: false, - height: '150', - selectableRangeMode: 'click', - selectable: true, - index: 'notiz_id' - }, - tabulatorEvents: [], - notizen: [], - multiupload: true, - mitarbeiter: [], - filteredMitarbeiter: [], - zwischenvar: '', - editorInitialized: false, - editor: null, - notizData: { - typeId: this.typeId, - titel: null, - statusNew: true, - text: null, - lastChange: null, - von: null, - bis: null, - document: null, - erledigt: false, - verfasser: null, - bearbeiter: null, - anhang: [] - }, - }; + { + title: "Text", + field: "text_stripped", + width: 250, + visible: true, + tooltip:function(e, cell, onRendered){ + var el = document.createElement("div"); + el.style.backgroundColor = "white"; + el.style.fontWeight = "bold"; + el.style.padding = "5px"; + el.style.border = "1px solid black"; + el.style.borderRadius = "5px"; + + el.innerText = cell.getValue(); + + return el; + }, + }, + {title: "VerfasserIn", field: "verfasser_uid", width: 124, visible: false}, + {title: "BearbeiterIn", field: "bearbeiter_uid", width: 126, visible: false}, + {title: "Start", field: "start_format", width: 86, visible: false}, + {title: "Ende", field: "ende_format", width: 86, visible: false}, + {title: "Dokumente", field: "countdoc", width: 100, visible: false}, + { + title: "Erledigt", + field: "erledigt", + width: 97, + visible: false, + formatter:"tickCross", + hozAlign:"center", + formatterParams: { + tickElement: '', + crossElement: '' + } + }, + {title: "Notiz_id", field: "notiz_id", width: 92, visible: false}, + {title: "Notizzuordnung_id", field: "notizzuordnung_id", width: 164, visible: false}, + {title: "letzte Änderung", field: "lastupdate", width: 146, visible: false}, + { + title: 'Aktionen', field: 'actions', + width: 100, + 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.addEventListener( + 'click', + (event) => + this.actionEditNotiz(cell.getData().notiz_id) + ); + container.append(button); + + button = document.createElement('button'); + button.className = 'btn btn-outline-secondary btn-action'; + button.innerHTML = ''; + button.addEventListener( + 'click', + () => + this.actionDeleteNotiz(cell.getData().notiz_id) + ); + container.append(button); + + return container; + }, + frozen: true + }], + layout: 'fitColumns', + layoutColumnsOnNewData: false, + height: '250', + selectableRangeMode: 'click', + selectable: true, + index: 'notiz_id' + }, + tabulatorEvents: [ + { + event: 'tableBuilt', + handler: async () => { + + 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'), + visible: this.showVariables.showVerfasser + }); + cm.getColumnByField('titel').component.updateDefinition({ + title: this.$p.t('global', 'titel'), + visible: this.showVariables.showTitel + }); + cm.getColumnByField('text_stripped').component.updateDefinition({ + title: this.$p.t('global', 'text'), + visible: this.showVariables.showText + }); + cm.getColumnByField('bearbeiter_uid').component.updateDefinition({ + title: this.$p.t('notiz', 'bearbeiter'), + visible: this.showVariables.showBearbeiter + }); + cm.getColumnByField('start_format').component.updateDefinition({ + title: this.$p.t('global', 'gueltigVon'), + visible: this.showVariables.showVon + }); + cm.getColumnByField('ende_format').component.updateDefinition({ + title: this.$p.t('global', 'gueltigBis'), + visible: this.showVariables.showBis + }); + cm.getColumnByField('countdoc').component.updateDefinition({ + title: this.$p.t('notiz', 'document'), + visible: this.showVariables.showDokumente + }); + cm.getColumnByField('erledigt').component.updateDefinition({ + title: this.$p.t('notiz', 'erledigt'), + visible: this.showVariables.showErledigt + }); + cm.getColumnByField('lastupdate').component.updateDefinition({ + title: this.$p.t('notiz', 'letzte_aenderung'), + visible: this.showVariables.showLastupdate + }); + cm.getColumnByField('notiz_id').component.updateDefinition({ + visible: this.showVariables.showNotiz_id + }); + cm.getColumnByField('notizzuordnung_id').component.updateDefinition({ + visible: this.showVariables.showNotizzuordnung_id + }); + + } + } + ], + notizen: [], + multiupload: true, + mitarbeiter: [], + filteredMitarbeiter: [], + zwischenvar: '', + editorInitialized: false, + editor: null, + notizData: { + typeId: this.typeId, + titel: null, + statusNew: true, + text: null, + lastUpdate: null, + von: null, + bis: null, + document: null, + erledigt: false, + verfasser: null, + bearbeiter: null, + anhang: [] + }, + showVariables: { + showTitel: false, + showText: false, + showVerfasser: false, + showBearbeiter: false, + showVon: false, + showBis: false, + showDokumente: false, + showErledigt: false, + showNotiz_id: false, + showNotizzuordnung_id: false, + showLastupdate: false + }, + } }, methods: { - actionDeleteNotiz(notiz_id){ + actionDeleteNotiz(notiz_id) { this.loadNotiz(notiz_id).then(() => { - if(this.notizen.notiz_id) { - this.$refs.deleteNotizModal.show(); - } + this.$refs.deleteNotizModal.show(); }); }, - actionEditNotiz(notiz_id){ + actionEditNotiz(notiz_id) { this.loadNotiz(notiz_id).then(() => { - console.log(this.notizen); - if(this.notizen.notiz_id) { + if (this.notizen.notiz_id) { + this.notizData.typeId = this.typeId; this.notizData.titel = this.notizen.titel; this.notizData.statusNew = false; this.notizData.text = this.notizen.text; this.notizData.intText = this.notizen.text; - this.notizData.lastChange = this.notizen.lastupdate; + this.notizData.lastupdate = this.notizen.lastupdate; this.notizData.von = this.notizen.start; this.notizData.bis = this.notizen.ende; this.notizData.document = this.notizen.dms_id; @@ -126,13 +244,13 @@ export default { } }) .then(() => { - if(this.notizen.dms_id){ - console.log("loadEntries with " + this.notizen.notiz_id); - this.loadDocEntries(this.notizen.notiz_id); - } + if (this.notizData.dms_id) { + this.loadDocEntries(this.notizData.notiz_id); + } else + this.notizData.anhang = []; }); }, - actionNewNotiz(){ + actionNewNotiz() { this.resetFormData(); }, addNewNotiz() { @@ -140,107 +258,86 @@ export default { formData.append('data', JSON.stringify(this.notizData)); Object.entries(this.notizData.anhang).forEach(([k, v]) => formData.append(k, v)); - CoreRESTClient.post( - 'components/stv/Notiz/addNewNotiz/' + this.id, + this.$fhcApi.post('api/frontend/v1/stv/notiz/addNewNotiz/' + this.id, formData, - { Headers: { "Content-Type": "multipart/form-data" } } + {Headers: {"Content-Type": "multipart/form-data"}} ).then(response => { - if (!response.data.error) { - this.$fhcAlert.alertSuccess('Anlegen von neuer Notiz erfolgreich'); - this.resetFormData(); - this.reload(); - } else { - const errorData = response.data.retval; - Object.entries(errorData).forEach(entry => { - const [key, value] = entry; - this.$fhcAlert.alertError(value); - }); - } - }).catch(error => { - if (error.response) { - console.log(error.response); - this.$fhcAlert.alertError(error.response.data); - } - }).finally(() => { - window.scrollTo(0, 0); - }); - }, - deleteNotiz(notiz_id){ - CoreRESTClient.post('components/stv/Notiz/deleteNotiz/' + notiz_id) - .then(response => { - if (!response.data.error) { - this.$fhcAlert.alertSuccess('Löschen erfolgreich'); - this.$refs.deleteNotizModal.hide(); - this.reload(); - } else { - this.$fhcAlert.alertError('Keine Notiz mit Id ' + notiz_id + ' gefunden'); - } - }).catch(error => { - this.$fhcAlert.alertError('Fehler bei Löschroutine aufgetreten'); - }).finally(()=> { + this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave')); + this.resetFormData(); + this.reload(); + }) + .catch(this.$fhcAlert.handleSystemError) + .finally(() => { window.scrollTo(0, 0); }); }, - loadNotiz(notiz_id){ - return CoreRESTClient.get('components/stv/Notiz/loadNotiz/' + notiz_id) + deleteNotiz(notiz_id) { + this.param = { + 'notiz_id': notiz_id + }; + + return this.$fhcApi.post('api/frontend/v1/stv/notiz/deleteNotiz/', this.param) + .then(result => { + this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successDelete')); + this.$refs.deleteNotizModal.hide(); + this.reload(); + this.resetFormData(); + }) + .catch(this.$fhcAlert.handleSystemError) + .finally(() => { + window.scrollTo(0, 0); + }); + }, + loadNotiz(notiz_id) { + this.param = { + 'notiz_id': notiz_id + }; + return this.$fhcApi.post('api/frontend/v1/stv/notiz/loadNotiz/', + this.param) + .then(result => { + this.notizData = result.data; + this.notizData.typeId = this.typeId; + return result; + }) + .catch(this.$fhcAlert.handleSystemError); + }, + loadDocEntries(notiz_id) { + this.param = { + 'notiz_id': notiz_id + }; + return this.$fhcApi.post('api/frontend/v1/stv/notiz/loadDokumente/', + this.param) .then( result => { - if(result.data.retval) { - this.notizen = result.data.retval; - } - else { - this.notizen = {}; - this.$fhcAlert.alertError('Keine Notiz mit Id ' + notiz_id + ' gefunden'); - } + this.notizData.anhang = result.data; return result; - } - ); + }) + .catch(this.$fhcAlert.handleSystemError); }, - loadDocEntries(notiz_id){ - return CoreRESTClient.get('components/stv/Notiz/loadDokumente/' + notiz_id) - .then( - result => { - if(result.data.retval) { - this.notizData.anhang = result.data.retval; - console.log(this.notizData.anhang); - } - else - { - this.notizData.anhang = {}; - this.$fhcAlert.alertError('Kein Dokumenteneintrag mit NotizId ' + notiz_id + ' gefunden'); - } - return result; - } - ); - }, - updateNotiz(notiz_id){ + updateNotiz(notiz_id) { const formData = new FormData(); formData.append('data', JSON.stringify(this.notizData)); Object.entries(this.notizData.anhang).forEach(([k, v]) => formData.append(k, v)); - CoreRESTClient.post( - 'components/stv/Notiz/updateNotiz/' + notiz_id, + this.param = { + 'notiz_id': notiz_id + }; + + return this.$fhcApi.post( + 'api/frontend/v1/stv/notiz/updateNotiz/', formData, - { Headers: { "Content-Type": "multipart/form-data" } } + {Headers: {"Content-Type": "multipart/form-data"}} ).then(response => { - if (!response.data.error) { - this.$fhcAlert.alertSuccess('Update von Notiz erfolgreich'); - this.resetFormData(); - this.reload(); - } 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 Updateroutine aufgetreten'); - }).finally(() => { - window.scrollTo(0, 0); - }); + this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave')); + this.resetFormData(); + this.reload(); + }) + .catch(this.$fhcAlert.handleSystemError) + .finally(() => { + window.scrollTo(0, 0); + }); }, - reload(){ + reload() { this.$refs.table.reloadTable(); }, resetFormData() { @@ -250,7 +347,7 @@ export default { titel: null, statusNew: true, text: null, - lastChange: null, + lastUpdate: null, von: null, bis: null, document: null, @@ -260,21 +357,19 @@ export default { anhang: [] }; }, - getUid(){ - CoreRESTClient - .get('components/stv/Notiz/getUid') + getUid() { + this.$fhcApi + .get('api/frontend/v1/stv/notiz/getUid') .then(result => { - if(result.data.retval) { - this.notizData.intVerfasser = result.data.retval; - } + this.notizData.intVerfasser = result.data; }) .catch(this.$fhcAlert.handleSystemError); }, search(event) { - return CoreRESTClient - .get('components/stv/Notiz/getMitarbeiter/' + event.query) + return this.$fhcApi + .get('api/frontend/v1/stv/notiz/getMitarbeiter/' + event.query) .then(result => { - this.filteredMitarbeiter = CoreRESTClient.getData(result.data); + this.filteredMitarbeiter = result.data.retval; }); }, initTinyMCE() { @@ -287,14 +382,14 @@ export default { //toolbar: " blocks | bold italic underline | alignleft aligncenter alignright alignjustify", toolbar: 'styleselect | bold italic underline | alignleft aligncenter alignright alignjustify', style_formats: [ - { title: 'Blocks', block: 'div' }, - { title: 'Paragraph', block: 'p' }, - { title: 'Heading 1', block: 'h1' }, - { title: 'Heading 2', block: 'h2' }, - { title: 'Heading 3', block: 'h3' }, - { title: 'Heading 4', block: 'h4' }, - { title: 'Heading 5', block: 'h5' }, - { title: 'Heading 6', block: 'h6' }, + {title: 'Blocks', block: 'div'}, + {title: 'Paragraph', block: 'p'}, + {title: 'Heading 1', block: 'h1'}, + {title: 'Heading 2', block: 'h2'}, + {title: 'Heading 3', block: 'h3'}, + {title: 'Heading 4', block: 'h4'}, + {title: 'Heading 5', block: 'h5'}, + {title: 'Heading 6', block: 'h6'}, ], autoresize_bottom_margin: 16, @@ -310,47 +405,22 @@ export default { }, updateText(value) { this.notizData.text = value; - } + }, + initializeShowVariables() { + this.visibleColumns.forEach(column => { + const columnToShow = "show" + column.charAt(0).toUpperCase() + column.slice(1); + this.showVariables[columnToShow] = true; + }); + }, }, created(){ + this.initializeShowVariables(); this.getUid(); }, 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') - }); }, watch: { //watcher für Tinymce-Textfeld @@ -388,9 +458,9 @@ export default { } }, template: ` -
- +
+ @@ -410,12 +480,13 @@ export default { :side-menu="false" reload new-btn-show - new-btn-label="Neu" + new-btn-label="Notiz" @click:new="actionNewNotiz" >
+


@@ -433,14 +504,14 @@ export default {
- +
- +
@@ -477,7 +548,11 @@ export default {
-
+ +
+ +
+
@@ -485,7 +560,7 @@ export default {
-
+ +
+ +
+ +
@@ -506,7 +586,7 @@ export default {
- +
-

{{notizData.lastChange}}

+

{{notizData.lastupdate}}

- + -
` +
+ +
+ + + + + + + + +
+
+
+ + +
+ +
+ + + + +
+ + +
+

{{$p.t('notiz','notiz_new')}} [{{notizData.typeId}}]

+

{{$p.t('notiz','notiz_edit')}} [{{notizData.typeId}}]

+
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ + +
+ +
+ + +
+ +
+ + +
+
+ +
+ + + +
+ +
+
+ + +
+ +
+ + + + + + +
+ +
+ + + + + + + + + + + +
+ +
+
+ + +
+ +
+ +
+ +
+ +
+

{{notizData.lastupdate}}

+
+
+ +
+
+
+
+ +
+ + + + + + + + +
+ +
+ +
+ +
+

{{$p.t('notiz','notiz_new')}} [{{notizData.typeId}}]

+

{{$p.t('notiz','notiz_edit')}} [{{notizData.typeId}}]

+
+ + +
+ + +
+ +
+ + +
+ + +
+ +
+ + +
+ +
+ + +
+
+ +
+ + + +
+ +
+
+ + +
+ +
+ + + + + + +
+ + +
+ + + + + + + + + + + +
+ +
+
+ + +
+ +
+ +
+ +
+ +
+

{{notizData.lastupdate}}

+
+
+ +
+ + +
+ +
+
+ +
+
+ + +
+ + +
+ +
+ +
+

Kein Layout übergeben

+
+
+
+`, } diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Address.js b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Address.js index 6d0ba0750..017f3a056 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Address.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Address.js @@ -168,6 +168,11 @@ export default{ }, {})); } }, + watch: { + uid(){ + this.$refs.table.tabulator.setData('api/frontend/v1/stv/Kontakt/getAdressen/' + this.uid); + } + }, methods:{ actionNewAdress(){ this.$refs.newAdressModal.show(); @@ -266,9 +271,6 @@ export default{ this.filteredFirmen = result.data.retval; }); }, - reload(){ - this.$refs.table.reloadTable(); - }, hideModal(modalRef){ this.$refs[modalRef].hide(); }, diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Bankaccount.js b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Bankaccount.js index ed58e55ae..1d5833044 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Bankaccount.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Bankaccount.js @@ -114,6 +114,11 @@ export default{ } } }, + watch: { + uid(){ + this.$refs.table.tabulator.setData('api/frontend/v1/stv/Kontakt/getBankverbindung/' + this.uid); + } + }, methods:{ actionNewBankverbindung(){ this.$refs.newBankverbindungModal.show(); diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Contact.js b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Contact.js index ef6c475ae..a9d89b89c 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Contact.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Contact.js @@ -111,6 +111,11 @@ export default{ filteredStandorte: null } }, + watch: { + uid(){ + this.$refs.table.tabulator.setData('api/frontend/v1/stv/Kontakt/getKontakte/' + this.uid); + } + }, methods:{ actionNewContact(){ this.$refs.newContactModal.show(); diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Notizen.js b/public/js/components/Stv/Studentenverwaltung/Details/Notizen.js index 3b95ed156..ddea790da 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Notizen.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Notizen.js @@ -14,13 +14,50 @@ export default { ref="formc" typeId="person_id" :id="modelValue.person_id" - :showErweitert=true - :showDocument=true - :showTinyMCE="true" + notizLayout="twoColumnsFormLeft" + :showErweitert="false" + :showDocument="false" + :showTinyMCE="false" + :visibleColumns=['titel','text','verfasser','bearbeiter'] > - + + + + +