diff --git a/application/controllers/lehre/lehrauftrag/Lehrauftrag.php b/application/controllers/lehre/lehrauftrag/Lehrauftrag.php index f78649176..3c0808d42 100644 --- a/application/controllers/lehre/lehrauftrag/Lehrauftrag.php +++ b/application/controllers/lehre/lehrauftrag/Lehrauftrag.php @@ -154,8 +154,9 @@ class Lehrauftrag extends Auth_Controller $studiengang_kz = (isset($lehrauftrag->studiengang_kz)) ? $lehrauftrag->studiengang_kz : null; // Check if user is entitled to order this Lehrauftrag - if (!$this->permissionlib->isBerechtigt(self::BERECHTIGUNG_LEHRAUFTRAG_BESTELLEN, 'suid', $studiengang_kz)){ - show_error('Keine Bestellberechtigung für diesen Studiengang: '. $studiengang_kz); + if (!$this->permissionlib->isBerechtigt(self::BERECHTIGUNG_LEHRAUFTRAG_BESTELLEN, 'suid', $studiengang_kz)) + { + return $this->outputJsonError('Sie haben keine Bestellberechtigung für diesen Studiengang: '. $studiengang_kz); } // update contract if contract exists and the betrag was changed @@ -168,6 +169,10 @@ class Lehrauftrag extends Auth_Controller $vertrag_betrag = $result[0]->betrag; $vertrag_stunden = $result[0]->vertragsstunden; } + elseif (isError($result)) + { + return $this->outputJsonError('Fehler beim Laden des Vertrags'); + } $hasChanged = ($betrag != floatval($vertrag_betrag) || $stunden != $vertrag_stunden) ? true : false; @@ -190,6 +195,10 @@ class Lehrauftrag extends Auth_Controller 'erteilt' => null ); } + else + { + return $this->outputJsonError('Fehler beim Vertragsupdate'); + } } } // else save new contract @@ -215,6 +224,14 @@ class Lehrauftrag extends Auth_Controller 'vertrag_stunden' => $stunden ); } + elseif (isError($result) && $result->retval) + { + return $this->outputJsonError($result->retval); + } + else + { + return $this->outputJsonError('Fehler beim Speichern des Vertrags'); + } $new_lehrvertrag_data_arr[] = array( 'studiensemester_kurzbz' => $lehrauftrag->studiensemester_kurzbz, @@ -224,6 +241,10 @@ class Lehrauftrag extends Auth_Controller } } } + else + { + return $this->outputJsonError('Fehler beim Übertragen der Daten.'); + } if (isset($json) && !isEmptyArray($json)) { diff --git a/application/controllers/lehre/lehrauftrag/LehrauftragAkzeptieren.php b/application/controllers/lehre/lehrauftrag/LehrauftragAkzeptieren.php index 7637ef6cd..dfb1390d3 100644 --- a/application/controllers/lehre/lehrauftrag/LehrauftragAkzeptieren.php +++ b/application/controllers/lehre/lehrauftrag/LehrauftragAkzeptieren.php @@ -107,7 +107,7 @@ class LehrauftragAkzeptieren extends Auth_Controller } else { - show_error('Password is missing'); + return $this->outputJsonError('Passwort fehlt'); } // Loop through lehraufträge @@ -139,20 +139,20 @@ class LehrauftragAkzeptieren extends Auth_Controller $account_found = true; } } - + if (!$account_found) { - show_error('Keine Berechtigung für diesen Vertrag'); + return $this->outputJsonError('Sie haben keine Berechtigung für einen Vertrag'); } } else { - show_error(getError($result)); + return $this->outputJsonError('Fehler beim Laden der Benutzerdaten'); } } else { - show_error(getError($result)); + return $this->outputJsonError('Fehler beim Laden des Vertrags'); } // Set status to accepted @@ -165,6 +165,10 @@ class LehrauftragAkzeptieren extends Auth_Controller 'akzeptiert' => date('Y-m-d') ); } + else + { + return $this->outputJsonError($result->retval); + } } // Output json to ajax @@ -173,6 +177,10 @@ class LehrauftragAkzeptieren extends Auth_Controller $this->outputJsonSuccess($json); } } + else + { + return $this->outputJsonError('Fehler beim Übertragen der Daten.'); + } } /** diff --git a/application/controllers/lehre/lehrauftrag/LehrauftragErteilen.php b/application/controllers/lehre/lehrauftrag/LehrauftragErteilen.php index 48e7334a7..b70b6e2f9 100644 --- a/application/controllers/lehre/lehrauftrag/LehrauftragErteilen.php +++ b/application/controllers/lehre/lehrauftrag/LehrauftragErteilen.php @@ -146,31 +146,42 @@ class LehrauftragErteilen extends Auth_Controller } elseif (isError(($result))) { - show_error(getError($result)); + return $this->outputJsonError('Fehler beim Laden einer Lehrveranstaltung.'); } } elseif (isError($result)) { - show_error(getError($result)); + return $this->outputJsonError('Fehler beim Laden von Lehreinheitdaten.'); } // Check if user is entitled to approve this lehrauftrag (by permission and organisational unit) - if (!$this->permissionlib->isBerechtigt(self::BERECHTIGUNG_LEHRAUFTRAG_ERTEILEN, 'suid', $lv_oe_kurzbz)){ - show_error('Keine Erteilberechtigung für diese Organisationseinheit: '. $lv_oe_kurzbz); + if (!$this->permissionlib->isBerechtigt(self::BERECHTIGUNG_LEHRAUFTRAG_ERTEILEN, 'suid', $lv_oe_kurzbz)) + { + return $this->outputJsonError('Sie haben keine Erteilberechtigung für diese Organisationseinheit: '. $lv_oe_kurzbz); } // Approve lehrauftrag by setting vertragsstatus to 'erteilt' $result = $this->VertragvertragsstatusModel->setStatus($vertrag_id, $mitarbeiter_uid, 'erteilt'); - if ($result->retval) { + if (!isError($result)) + { $json [] = array( 'row_index' => $lehrauftrag->row_index, 'erteilt' => date('Y-m-d') ); } + else + { + return $this->outputJsonError($result->retval); + } } } - // output json to ajax + else + { + return $this->outputJsonError('Fehler beim Übertragen der Daten.'); + } + + // output success json to ajax if (isset($json) && !isEmptyArray($json)) { $this->outputJsonSuccess($json); diff --git a/application/models/accounting/Vertrag_model.php b/application/models/accounting/Vertrag_model.php index 44b8a0881..8725cd98d 100644 --- a/application/models/accounting/Vertrag_model.php +++ b/application/models/accounting/Vertrag_model.php @@ -60,14 +60,14 @@ class Vertrag_model extends DB_Model { if ($this->LehreinheitmitarbeiterModel->hasVertrag($mitarbeiter_uid, $lehreinheit_id)) { - return success(null); // Exit if Lehrauftrag already has Vertrag + return error('Lehrauftrag existiert bereits'); // Exit if Lehrauftrag already has Vertrag } } elseif ($vertragstyp_kurzbz == 'Betreuung') { if ($this->ProjektbetreuerModel->hasVertrag($person_id, $projektarbeit_id)) { - return success(null); // Exit if Projektbetreuung already has Vertrag + return error('Lehrauftrag existiert bereits'); // Exit if Projektbetreuung already has Vertrag } } diff --git a/application/models/accounting/Vertragvertragsstatus_model.php b/application/models/accounting/Vertragvertragsstatus_model.php index c2bd9cc7d..609394321 100644 --- a/application/models/accounting/Vertragvertragsstatus_model.php +++ b/application/models/accounting/Vertragvertragsstatus_model.php @@ -52,19 +52,21 @@ class Vertragvertragsstatus_model extends DB_Model /** * Set Vertragsstatus for the given Vertrag and Mitarbeiter. - * @param $vertrag_id - * @param $vertragsstatus_kurzbz - * @param $mitarbeiter_uid - * @return array|null On success object, retval is true. Null if status already exist for this vertrag. + * @param integer $vertrag_id + * @param string $mitarbeiter_uid + * @param string $vertragsstatus_kurzbz + * @return object On success, return success object. + * If status already exists or earlier status is missing, return error object. */ public function setStatus($vertrag_id, $mitarbeiter_uid, $vertragsstatus_kurzbz){ // Check if vertrag has already this status $result = $this->hasStatus($vertrag_id, $mitarbeiter_uid, $vertragsstatus_kurzbz); - + + // If status is already set, return error message if (hasData($result)) { - return success(null); // return null if status is already set + return error('Fehler: Status bereits vorhanden.'); } // If new status should be 'akzeptiert', the latest status has to be 'erteilt' @@ -72,10 +74,11 @@ class Vertragvertragsstatus_model extends DB_Model { $result = $this->getLastStatus($vertrag_id, $mitarbeiter_uid); $last_status = getData($result)[0]->vertragsstatus_kurzbz; - + + // If latest status is not 'erteilt', return error message if ($last_status != 'erteilt') { - return success(null); // return null if latest status is not 'erteilt' + return error('Fehler: Vor Status \'angenommen\' muss erst Status \'erteilt\' gesetzt sein.'); } } diff --git a/public/js/lehre/lehrauftrag/acceptLehrauftrag.js b/public/js/lehre/lehrauftrag/acceptLehrauftrag.js index 03c72e2f2..fffed4f87 100644 --- a/public/js/lehre/lehrauftrag/acceptLehrauftrag.js +++ b/public/js/lehre/lehrauftrag/acceptLehrauftrag.js @@ -577,15 +577,18 @@ $(function() { { successCallback: function (data, textStatus, jqXHR) { - if (data.error) + if (data.error && data.retval != null) { - // Password not verified + // Print error message FHC_DialogLib.alertWarning(data.retval); } + if (!data.error && data.retval != null) { // Update status 'Erteilt' $('#tableWidgetTabulator').tabulator('updateData', data.retval); + + // Print success message FHC_DialogLib.alertSuccess(data.retval.length + " Lehraufträge wurden akzeptiert."); } }, diff --git a/public/js/lehre/lehrauftrag/approveLehrauftrag.js b/public/js/lehre/lehrauftrag/approveLehrauftrag.js index 94e6af473..5ce99ab2e 100644 --- a/public/js/lehre/lehrauftrag/approveLehrauftrag.js +++ b/public/js/lehre/lehrauftrag/approveLehrauftrag.js @@ -674,9 +674,16 @@ $(function() { { // Update status 'Erteilt' $('#tableWidgetTabulator').tabulator('updateData', data.retval); + + // Print success message + FHC_DialogLib.alertSuccess(data.retval.length + " Lehraufträge wurden erteilt."); } - FHC_DialogLib.alertSuccess(data.retval.length + " Lehraufträge wurden erteilt."); + if (data.error && data.retval != null) + { + // Print error message + FHC_DialogLib.alertError(data.retval); + } }, errorCallback: function (jqXHR, textStatus, errorThrown) { diff --git a/public/js/lehre/lehrauftrag/orderLehrauftrag.js b/public/js/lehre/lehrauftrag/orderLehrauftrag.js index 4e58272e5..b0684d5ca 100644 --- a/public/js/lehre/lehrauftrag/orderLehrauftrag.js +++ b/public/js/lehre/lehrauftrag/orderLehrauftrag.js @@ -699,9 +699,16 @@ $(function() { { // Update status 'Bestellt' $('#tableWidgetTabulator').tabulator('updateData', data.retval); + + // Print success message + FHC_DialogLib.alertSuccess("Alle " + data.retval.length + " Lehraufträge wurden bestellt.") } - FHC_DialogLib.alertSuccess("Alle " + data.retval.length + " Lehraufträge wurden bestellt.") + if (data.error && data.retval != null) + { + // Print error message + FHC_DialogLib.alertError(data.retval); + } }, errorCallback: function (jqXHR, textStatus, errorThrown) {