From c4557787313424095a0346aad7d3794f77a288c3 Mon Sep 17 00:00:00 2001 From: Cris Date: Mon, 29 Mar 2021 17:50:19 +0200 Subject: [PATCH] Fixed: Added formatted download-document-link after application was done After refactoring the code and doing the application via AJAX call, the document-download-link must be created on ajax success. This was missing and is fixed now. Signed-off-by: cris-technikum --- .../lehre/anrechnung/RequestAnrechnung.php | 10 ++++++---- public/js/lehre/anrechnung/requestAnrechnung.js | 12 ++++++++++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/application/controllers/lehre/anrechnung/RequestAnrechnung.php b/application/controllers/lehre/anrechnung/RequestAnrechnung.php index 1b305d186..cd2c995d3 100644 --- a/application/controllers/lehre/anrechnung/RequestAnrechnung.php +++ b/application/controllers/lehre/anrechnung/RequestAnrechnung.php @@ -110,12 +110,13 @@ class requestAnrechnung extends Auth_Controller // Validate data if (empty($_FILES['uploadfile']['name'])) { - show_error('Missing upload file'); + return $this->outputJsonError($this->p->t('ui', 'errorUploadFehlt')); } - if (isEmptyString($begruendung_id) || isEmptyString($lehrveranstaltung_id) || isEmptyString($studiensemester_kurzbz)) + if (isEmptyString($begruendung_id) || isEmptyString($anmerkung) || + isEmptyString($lehrveranstaltung_id) || isEmptyString($studiensemester_kurzbz)) { - show_error('Missing correct parameter'); + return $this->outputJsonError($this->p->t('ui', 'errorFelderFehlen')); } // Exit if user is not a student @@ -172,7 +173,8 @@ class requestAnrechnung extends Auth_Controller // Output to AJAX return $this->outputJsonSuccess(array( - 'antragdatum' => (new DateTime())->format('d.m.Y') + 'antragdatum' => (new DateTime())->format('d.m.Y'), + 'dms_id' => $lastInsert_dms_id )); } diff --git a/public/js/lehre/anrechnung/requestAnrechnung.js b/public/js/lehre/anrechnung/requestAnrechnung.js index 6c4c5c9ca..b7b1229da 100644 --- a/public/js/lehre/anrechnung/requestAnrechnung.js +++ b/public/js/lehre/anrechnung/requestAnrechnung.js @@ -34,7 +34,9 @@ $(function(){ if (!data.error && data.retval != null) { requestAnrechnung.formatAnrechnungIsApplied( - data.retval.antragdatum + data.retval.antragdatum, + data.retval.dms_id, + formdata.get('uploadfile').name ); FHC_DialogLib.alertSuccess(FHC_PhrasesLib.t("global", "antragWurdeGestellt")); @@ -83,11 +85,17 @@ var requestAnrechnung = { } ); }, - formatAnrechnungIsApplied: function (antragdatum){ + formatAnrechnungIsApplied: function (antragdatum, dms_id, filename){ $('#requestAnrechnung-antragdatum').text(antragdatum); $('#requestAnrechnung-status_kurzbz').text(FHC_PhrasesLib.t("ui", "inBearbeitung")); $('#requestAnrechnung-status_kurzbz').closest('div').addClass('alert-warning'); + // Display File-Downloadlink + $('#requestAnrechnung-downloadDocLink') + .removeClass('hidden') + .attr('href', 'RequestAnrechnung/download?dms_id=' + dms_id) + .html(filename); + // Disable all form elements $("#requestAnrechnung-form :input").prop("disabled", true); }