From 5d4ec93b0905d3c06dea1edefb68b1658f74bd64 Mon Sep 17 00:00:00 2001 From: ma0068 Date: Wed, 20 Dec 2023 11:39:28 +0100 Subject: [PATCH] Change Font-Size in Tabulator 5, Start Dateiupload --- .../controllers/components/stv/Notiz.php | 40 +++- application/models/person/Notiz_model.php | 34 +++- public/css/Tabulator5.css | 3 + .../js/components/Form/Upload/SingleFile.js | 36 ++++ public/js/components/Notiz/Notiz.js | 176 ++++++++++++------ .../Studentenverwaltung/Details/Notizen.js | 81 ++++++-- 6 files changed, 283 insertions(+), 87 deletions(-) create mode 100644 public/js/components/Form/Upload/SingleFile.js diff --git a/application/controllers/components/stv/Notiz.php b/application/controllers/components/stv/Notiz.php index 439e7c7fb..00935a95d 100644 --- a/application/controllers/components/stv/Notiz.php +++ b/application/controllers/components/stv/Notiz.php @@ -23,7 +23,7 @@ class Notiz extends FHC_Controller { $this->load->model('person/Notiz_model', 'NotizModel'); - $result = $this->NotizModel->getNotiz($person_id, true); + $result = $this->NotizModel->getNotizWithDocEntries($person_id); if (isError($result)) { $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); @@ -62,7 +62,9 @@ class Notiz extends FHC_Controller public function addNewNotiz($person_id) { - $_POST = json_decode($this->input->raw_input_stream, true); + var_dump($this->input->post('titel')); + var_dump($this->input->post('anhang')); + var_dump($_FILES); $this->load->library('form_validation'); @@ -79,17 +81,11 @@ class Notiz extends FHC_Controller $uid = getAuthUID(); $titel = isset($_POST['titel']) ? $_POST['titel'] : null; $text = isset($_POST['text']) ? $_POST['text'] : null; - //$verfasser_uid = isset($_POST['verfasser_uid']) ? $_POST['verfasser_uid'] : null; $verfasser_uid = $uid; $start = isset($_POST['von']) ? $_POST['von'] : null; $ende = isset($_POST['bis']) ? $_POST['bis'] : null; $erledigt = $_POST['erledigt']; -/* $dms_id = isset($_POST['dms_id']) ? $_POST['dms_id'] : null; - $bearbeiter_uid = isset($_POST['bearbeiter_uid']) ? $_POST['bearbeiter_uid'] : null; - -*/ - $result = $this->NotizModel->addNotizForPersonWithDoc($person_id, $titel, $text, $erledigt, $verfasser_uid, $start, $ende); // var_dump($result); @@ -191,4 +187,32 @@ class Notiz extends FHC_Controller return $this->outputJsonSuccess(current(getData($result))); } + public function loadDokumente($notiz_id) + { + $this->load->model('person/Notiz_model', 'NotizModel'); + + //TODO(manu) check, ob mehr Dateien bzw. -versionen + //warum nur ein Eintrag??? + $this->NotizModel->addSelect('campus.tbl_dms_version.*'); + + $this->NotizModel->addJoin('public.tbl_notiz_dokument','ON (public.tbl_notiz_dokument.notiz_id = public.tbl_notiz.notiz_id)'); + $this->NotizModel->addJoin('campus.tbl_dms_version','ON (public.tbl_notiz_dokument.dms_id = campus.tbl_dms_version.dms_id)'); + + $result = $this->NotizModel->loadWhere( + 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); + } + + elseif (!hasData($result)) { + $this->outputJson($result); + } + else + { + $this->outputJsonSuccess(getData($result)); + } + } + } \ No newline at end of file diff --git a/application/models/person/Notiz_model.php b/application/models/person/Notiz_model.php index 5a8bf1858..fbebc3bd8 100644 --- a/application/models/person/Notiz_model.php +++ b/application/models/person/Notiz_model.php @@ -175,17 +175,41 @@ class Notiz_model extends DB_Model * gets all Notizen for a person * @param $person_id */ - public function getNotiz($person_id, $withDoc=false) + public function getNotiz($person_id) { - // Join with the table public.tbl_notizzuordnung using notiz_id + $this->addSelect('public.tbl_notiz.*'); $this->addJoin('public.tbl_notizzuordnung', 'notiz_id'); - if($withDoc) - $this->addJoin('public.tbl_notiz_dokument', 'notiz_id', 'LEFT'); - return $this->loadWhere(array('person_id' => $person_id)); } + /** + * gets all Notizen with Documententries for a person + * @param $person_id + */ + public function getNotizWithDocEntries($person_id) + { + $qry = " + SELECT + n.*, count(dms_id) as countDoc + FROM + public.tbl_notiz n + JOIN + public.tbl_notizzuordnung z USING (notiz_id) + LEFT JOIN + public.tbl_notiz_dokument dok USING (notiz_id) + LEFT JOIN + campus.tbl_dms_version USING (dms_id) + WHERE + z.person_id = ? + GROUP BY + notiz_id + "; + + return $this->execQuery($qry, array($person_id)); + + } + /** * gets all Notizen for a person with a specific title * @param $person_id diff --git a/public/css/Tabulator5.css b/public/css/Tabulator5.css index 48124335f..a9a79a6d8 100644 --- a/public/css/Tabulator5.css +++ b/public/css/Tabulator5.css @@ -38,3 +38,6 @@ .tabulator .tabulator-col-resize-handle:last-of-type { z-index: 999999; } +.tabulator { + font-size: 1rem; +} diff --git a/public/js/components/Form/Upload/SingleFile.js b/public/js/components/Form/Upload/SingleFile.js new file mode 100644 index 000000000..74c60fcb8 --- /dev/null +++ b/public/js/components/Form/Upload/SingleFile.js @@ -0,0 +1,36 @@ +export default { + data() { + return { + file: null, + }; + }, + methods: { + handleFileChange(event) { + this.file = event.target.files[0]; + }, + uploadFile() { + if (this.file) { + // You can perform your file upload logic here + console.log('Uploading file:', this.file); + // Reset the file input + this.$refs.fileInput.value = ''; + this.file = null; + } else { + console.error('No file selected'); + } + }, + }, +}; +template: ` +
+

File Upload

+
+ + +
+
+

Selected File: {{file.name}}

+
+
+` \ No newline at end of file diff --git a/public/js/components/Notiz/Notiz.js b/public/js/components/Notiz/Notiz.js index eb9788516..88bffa711 100644 --- a/public/js/components/Notiz/Notiz.js +++ b/public/js/components/Notiz/Notiz.js @@ -1,5 +1,26 @@ +import VueDatePicker from '../vueDatepicker.js.php'; +//import SingleFile from '../Form/Upload/SingleFile.js'; + export default { - props: ['titel', 'text', 'von', 'bis', 'action', 'document', 'erledigt', 'verfasser', 'bearbeiter'], + components: { + VueDatePicker, + //BsModal + //SingleFile + }, + props: [ + 'titel', + 'text', + 'von', + 'bis', + 'action', + 'document', + 'erledigt', + 'verfasser', + 'bearbeiter', + 'showErweitert', + 'showDocument', + 'anhang' + ], computed: { intTitel: { get() { @@ -65,72 +86,111 @@ export default { this.$emit('update:bearbeiter', value); } }, + intAnhang: { + get() { + return this.anhang; + }, + set(value) { + console.log(value); + this.$emit('update:anhang', value); + } + } }, methods: { - + handleFileChange(event) { + this.intAnhang = event.target.files[0]; + }, }, template: `
- + +component: {{intTitel}} {{intVon}} || {{intAnhang.name}} {{intAnhang}}
-
- {{action}} -
-
- -
- -
+
+
+ {{action}} +
+
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ + + + + +
+ + + +
+

Selected File: {{ intAnhang.name }}

+ +
+
+ +
    +
  • + +
  • +
+
+
+
+
+
+ +
+ +
+ +
+ + {{uid}} +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+ + +
+ +
+ + +
+ +
+
+
-
- -
- -
-
+
-
- -
- -
-
- -
- -
- -
-
-
- -
- -
-
- -
- -
- -
-
- -
- -
- - {{uid}} -
-
- -
- -
- -
-
` diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Notizen.js b/public/js/components/Stv/Studentenverwaltung/Details/Notizen.js index 1b87aaf21..7e28e6985 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Notizen.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Notizen.js @@ -15,7 +15,7 @@ export default { CoreRESTClient, CoreFilterCmpt, Notiz, - BsModal + BsModal, }, props: { modelValue: Object @@ -31,7 +31,8 @@ export default { {title: "BearbeiterIn", field: "bearbeiter_uid", visible: false}, {title: "Start", field: "start"}, {title: "Ende", field: "ende"}, - {title: "Dokumente", field: "dms_id"}, +/* {title: "Dokumente", field: "dms_id"},*/ + {title: "Dokumente", field: "countdoc"}, {title: "Erledigt", field: "erledigt"}, {title: "Notiz_id", field: "notiz_id", visible: false}, {title: "Notizzuordnung_id", field: "notizzuordnung_id", visible: false}, @@ -62,18 +63,23 @@ export default { text: null, von: null, bis: null, - dms_id: null, + document: null, erledigt: false, verfasser: null, - bearbeiter: null + bearbeiter: null, + anhang: [] }, + showErweitert: true, + showDocument: true, + } }, methods:{ actionDeleteNotiz(notiz_id){ this.loadNotiz(notiz_id).then(() => { - if(this.notizen.notiz_id) + if(this.notizen.notiz_id) { this.$refs.deleteNotizModal.show(); + } }); }, actionEditNotiz(notiz_id){ @@ -84,10 +90,14 @@ export default { this.formData.text = this.notizen.text; this.formData.von = this.notizen.start; this.formData.bis = this.notizen.ende; - this.formData.doc = this.notizen.dms_id; + this.formData.document = this.notizen.dms_id; this.formData.erledigt = this.notizen.erledigt; this.formData.verfasser = this.notizen.verfasser_uid; this.formData.bearbeiter = this.notizen.bearbeiter_uid; + if(this.notizen.dms_id){ + console.log("loadEntries"); + this.loadDocEntries(this.notizen.notiz_id); + } } }); }, @@ -97,14 +107,20 @@ export default { this.formData.text = null; this.formData.von = null; this.formData.bis = null; - this.formData.dms_id = null; + this.formData.document = null; this.formData.erledigt = false; this.formData.verfasser = null; this.formData.bearbeiter = null; + this.formData.anhang = []; }, addNewNotiz(notizData) { + console.log(this.formData); + const formData = new FormData(); + Object.entries(this.formData).forEach(([k, v]) => formData.append(k, v)); + console.log(formData); CoreRESTClient.post('components/stv/Notiz/addNewNotiz/' + this.modelValue.person_id, - this.formData + formData, + { Headers: { "Content-Type": "multipart/form-data" } } ).then(response => { if (!response.data.error) { this.$fhcAlert.alertSuccess('Anlegen von neuer Notiz erfolgreich'); @@ -123,6 +139,9 @@ export default { window.scrollTo(0, 0); }); }, + attachFile(){ + console.log("ATTACH FILE"); + }, deleteNotiz(notiz_id){ CoreRESTClient.post('components/stv/Notiz/deleteNotiz/' + notiz_id) .then(response => { @@ -139,12 +158,30 @@ export default { window.scrollTo(0, 0); }); }, + loadDocEntries(notiz_id){ + return CoreRESTClient.get('components/stv/Notiz/loadDokumente/' + notiz_id) + .then( + result => { + console.log(result.data); + if(result.data.retval) + this.formData.anhang = result.data.retval; + else + { + this.formData.anhang = {}; + this.$fhcAlert.alertError('Kein Dokumenteneintrag mit NotizId ' + notiz_id + ' gefunden'); + } + return result; + } + ); + }, loadNotiz(notiz_id){ return CoreRESTClient.get('components/stv/Notiz/loadNotiz/' + notiz_id) .then( result => { - if(result.data.retval) + if(result.data.retval) { this.notizen = result.data.retval; + + } else { this.notizen = {}; @@ -162,10 +199,11 @@ export default { this.formData.text = null; this.formData.von = null; this.formData.bis = null; - this.formData.dms_id = null; + this.formData.document = null; this.formData.erledigt = false; this.formData.verfasser = null; this.formData.bearbeiter = null; + this.formData.anhang = []; }, updateNotiz(notiz_id){ CoreRESTClient.post('components/stv/Notiz/updateNotiz/' + notiz_id, @@ -189,11 +227,12 @@ export default { window.scrollTo(0, 0); //this.reload(); }); - } + }, }, template: `
- + {{modelValue}} + @@ -205,7 +244,7 @@ export default { - +
+
+ v-model:anhang="formData.anhang" + > + + + +
+ parent: {{anhang}} | {{formData.anhang.name}} +
` }; \ No newline at end of file