From 21060b31dc07b03fb108614a3e30049a6edd904f Mon Sep 17 00:00:00 2001 From: Cris Date: Tue, 6 Dec 2022 13:59:28 +0100 Subject: [PATCH] Bugfixed error message when LV has no lectors and only one recommendation is requested --- .../anrechnung/ApproveAnrechnungDetail.php | 19 ++++++++----------- .../ApproveAnrechnungUebersicht.php | 9 +++++++-- .../anrechnung/approveAnrechnungUebersicht.js | 8 ++++---- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php b/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php index bc5f19bd8..3f8f67639 100644 --- a/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php +++ b/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php @@ -220,15 +220,12 @@ class approveAnrechnungDetail extends Auth_Controller } $retval = array(); - $counter = 0; - - foreach ($data as $item) - { - // Check if Anrechnungs-LV has lector - if (!$this->anrechnunglib->LVhasLector($item['anrechnung_id'])) - { - // Count up LV with no lector - $counter++; + + // Check if Anrechnungs-LV has lector + if (!$this->anrechnunglib->LVhasLector($anrechnung_id)) + { + $this->terminateWithJsonError('LV has no lector'); + } // Get Fachbereichsleitung or LV Leitung. if($this->config->item('fbl') === TRUE) @@ -274,9 +271,9 @@ class approveAnrechnungDetail extends Auth_Controller } // Output json to ajax - if (isEmptyArray($retval) && $counter > 0) + if (isEmptyArray($retval)) { - return $this->outputJsonError( + $this->terminateWithJsonError( "Empfehlung wurde nicht angefordert,\nDer LV sind keine LektorInnen zugeteilt." ); } diff --git a/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php b/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php index c647138c9..77ee5bb40 100644 --- a/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php +++ b/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php @@ -248,9 +248,14 @@ class approveAnrechnungUebersicht extends Auth_Controller } // Output json to ajax - if (isEmptyArray($retval) && $counter == 0) + if (isEmptyArray($retval)) { - return $this->outputJsonError('Es wurden keine Empfehlungen angefordert'); + if ($counter > 0) + { + $this->terminateWithJsonError('Bei '. $counter.' LV sind keine LektorInnen zugeteilt.'); + } + + $this->terminateWithJsonError('Es wurden keine Empfehlungen angefordert'); } return $this->outputJsonSuccess($retval); diff --git a/public/js/lehre/anrechnung/approveAnrechnungUebersicht.js b/public/js/lehre/anrechnung/approveAnrechnungUebersicht.js index e831856d8..0198bfb26 100644 --- a/public/js/lehre/anrechnung/approveAnrechnungUebersicht.js +++ b/public/js/lehre/anrechnung/approveAnrechnungUebersicht.js @@ -603,14 +603,14 @@ $(function(){ // Print success message FHC_DialogLib.alertSuccess(FHC_PhrasesLib.t("ui", "empfehlungWurdeAngefordert")); } - } //Update status 'genehmigt' $('#tableWidgetTabulator').tabulator('updateData', data); - // Deselect rows - var indexesToDeselect = data.map(x => x.anrechnung_id); - $("#tableWidgetTabulator").tabulator('deselectRow', indexesToDeselect); + // Deselect rows + var indexesToDeselect = data.map(x => x.anrechnung_id); + $("#tableWidgetTabulator").tabulator('deselectRow', indexesToDeselect); + } }, errorCallback: function (jqXHR, textStatus, errorThrown) {