diff --git a/application/controllers/components/stv/Notiz.php b/application/controllers/components/stv/Notiz.php index 73c06ba86..f9145bdcc 100644 --- a/application/controllers/components/stv/Notiz.php +++ b/application/controllers/components/stv/Notiz.php @@ -77,8 +77,6 @@ class Notiz extends FHC_Controller $dms_id = []; foreach ($_FILES as $k => $file) { -/* var_dump($file["name"]); - var_dump($file);*/ $dms = array( 'kategorie_kurzbz' => 'notiz', 'version' => 0, @@ -92,7 +90,6 @@ class Notiz extends FHC_Controller if (isSuccess($result)) { - //TODO(Manu) change to array $dms_id[] = $result->retval['dms_id']; } /* else { @@ -117,49 +114,12 @@ class Notiz extends FHC_Controller $erledigt = $_POST['erledigt']; $type = $_POST['typeId']; - /* $start = isset($_POST['bis']) ? ($_POST['bis'] : null; - $ende = isset($_POST['bis']) ? $_POST['bis'] : null;*/ + //get rid of null value error + $start = $this->input->post(date('von')); + $ende = $this->input->post(date('bis')); - - if(isset($_POST['von'])) - { -/* $date = $_POST['von']; - $date = DateTime::createFromFormat('F-d-Y h:i A',$date); - var_dump($date); - $timestamp = strtotime($_POST['von']); - $start = date('Y-m-d', $timestamp);*/ - -/* $dateString = $_POST['von']; - $myDateTime = DateTime::createFromFormat('Y-m-d', $dateString); - $start= $myDateTime->format('Y-m-d');*/ - - //Todo(manu) check input format datepicker.. auch ohne null!!! - $start = '2023-01-01'; - } - else - $start = null; - - - if(isset($_POST['bis'])) - { - //Todo(manu) check input format datepicker -/* $ende = strtotime($_POST['bis']); - $ende = new DateTime($ende); - $ende = $ende->format('Y-m-d');*/ - - $ende = '2023-01-01'; - } - else - $ende = null; - - - //Todo(manu) multiple files - // mit id_type $result = $this->NotizModel->addNotizForType($type, $id, $titel, $text, $uid, $dms_id, $start, $ende, $erledigt, $verfasser_uid, $bearbeiter_uid); - //vorher - //$result = $this->NotizModel->addNotizForPersonWithDoc($id, $titel, $text, $erledigt, $verfasser_uid, $start, $ende, $dms_id); - if (isError($result)) { $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); @@ -172,7 +132,7 @@ class Notiz extends FHC_Controller { $uid = getAuthUID(); $this->load->library('form_validation'); - $_POST = json_decode($this->input->raw_input_stream, true); + //$_POST = json_decode($this->input->raw_input_stream, true); $this->form_validation->set_rules('titel', 'titel', 'required'); $this->form_validation->set_rules('text', 'Text', 'required'); @@ -195,9 +155,11 @@ class Notiz extends FHC_Controller $text = isset($_POST['text']) ? $_POST['text'] : null; $verfasser_uid = isset($_POST['verfasser_uid']) ? $_POST['verfasser_uid'] : null; $bearbeiter_uid = $uid; - $start = isset($_POST['von']) ? new DateTime($_POST['von']) : null; - $ende = isset($_POST['bis']) ? new DateTime($_POST['bis']) : null; $erledigt = $_POST['erledigt']; + $start = $this->input->post(date('von')); + $ende = $this->input->post(date('bis')); + + $result = $this->NotizModel->update( [ diff --git a/public/js/components/Notiz/Notiz.js b/public/js/components/Notiz/Notiz.js index 64430294f..38b1ca22c 100644 --- a/public/js/components/Notiz/Notiz.js +++ b/public/js/components/Notiz/Notiz.js @@ -48,7 +48,8 @@ export default { return this.von; }, set(value) { - this.$emit('update:von', value); + const tempVon = new Date(value).toISOString().split('T')[0]; + this.$emit('update:von', tempVon); } }, intBis: { @@ -56,7 +57,8 @@ export default { return this.bis; }, set(value) { - this.$emit('update:bis', value); + const tempBis = new Date(value).toISOString().split('T')[0]; + this.$emit('update:bis', tempBis); } }, intDocument: { @@ -101,36 +103,11 @@ export default { } } }, -/* mounted(){ - showZuordnung(){ - this.idTyp = 'Person'; - } - },*/ methods: { -/* handleFileChange(event) { - this.intAnhang = event.target.files; - },*/ reset() { this.$refs.form.reset(); //this.$emit('update:anhang', dt.files); }, -/* deleteFile(id){ - //console.log("Delete file with id " + id ); - - //console.log(this.intAnhang[id]); - - const dt = new DataTransfer(); - const files = this.$refs.upload.files; - - for (let i = 0; i < files.length; i++) { - const file = files[i]; - if (id !== i) - dt.items.add(file); // here you exclude the file. thus removing it. - } - - this.$refs.upload.files = dt.files; // Assign the updates list - this.$emit('update:anhang', dt.files); - }*/ }, template: ` @@ -143,9 +120,7 @@ export default { [{{this.typeId}}] - +
@@ -170,24 +145,7 @@ export default {
- - - +
@@ -196,7 +154,8 @@ export default {
-
+ +
- +
- +
@@ -233,6 +206,7 @@ export default { +
` } diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Notizen.js b/public/js/components/Stv/Studentenverwaltung/Details/Notizen.js index ee203efc6..b6bb9e3ec 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Notizen.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Notizen.js @@ -28,7 +28,7 @@ export default { columns: [ {title: "Titel", field: "titel"}, {title: "Text", field: "text", width: 350}, - {title: "VerfasserIn", field: "verfasser_uid"}, + {title: "VerfasserIn", field: "verfasser_uid", visible: false}, {title: "BearbeiterIn", field: "bearbeiter_uid", visible: false}, {title: "Start", field: "start", visible: false}, {title: "Ende", field: "ende", visible: false}, @@ -71,7 +71,7 @@ export default { bearbeiter: null, anhang: [] }, - showErweitert: false, + showErweitert: true, showDocument: true, } @@ -105,7 +105,7 @@ export default { }, actionNewNotiz(){ this.resetFormData(); -/* this.formData.typeId = 'person'; + this.formData.typeId = 'person'; this.formData.titel = ''; this.formData.action = 'Neue Notiz2'; this.formData.text = null; @@ -115,7 +115,7 @@ export default { this.formData.erledigt = false; this.formData.verfasser = null; this.formData.bearbeiter = null; - this.formData.anhang = [];*/ + this.formData.anhang = []; }, addNewNotiz(notizData) { /* console.log("here: anhang noch empty"); @@ -134,14 +134,6 @@ export default { }); Object.entries(this.formData.anhang).forEach(([k, v]) => formData.append(k, v)); -/* for( var i = 0; i < this.formData.anhang.length; i++ ){ - let file = this.formData.anhang[i]; - - formData.append('files[' + i + ']', file); - }*/ - -/* console.log("after append"); - console.log(this.formData);*/ CoreRESTClient.post('components/stv/Notiz/addNewNotiz/' + this.modelValue.person_id, formData, { Headers: { "Content-Type": "multipart/form-data" } } @@ -232,7 +224,7 @@ export default { anhang: [] }; }, - updateNotiz(notiz_id){ +/* updateNotiz(notiz_id){ CoreRESTClient.post('components/stv/Notiz/updateNotiz/' + notiz_id, this.formData ).then(response => { @@ -254,6 +246,35 @@ export default { window.scrollTo(0, 0); //this.reload(); }); + },*/ + updateNotiz(notiz_id){ + const formData = new FormData(); + Object.entries(this.formData).forEach(([k, v]) => { + if(k!= 'anhang') + formData.append(k, v); + }); + Object.entries(this.formData.anhang).forEach(([k, v]) => formData.append(k, v)); + + CoreRESTClient.post('components/stv/Notiz/updateNotiz/' + notiz_id, + formData, + { Headers: { "Content-Type": "multipart/form-data" } } + ).then(response => { + if (!response.data.error) { + this.$fhcAlert.alertSuccess('Update 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 => { + this.$fhcAlert.alertError('Fehler bei Updateroutine aufgetreten'); + }).finally(() => { + window.scrollTo(0, 0); + }); }, }, template: ` @@ -305,7 +326,7 @@ export default { - +