diff --git a/application/controllers/system/infocenter/InfoCenter.php b/application/controllers/system/infocenter/InfoCenter.php index 1f808da53..65a6aec07 100644 --- a/application/controllers/system/infocenter/InfoCenter.php +++ b/application/controllers/system/infocenter/InfoCenter.php @@ -84,6 +84,7 @@ class InfoCenter extends Auth_Controller 'saveZgvPruefung' => 'infocenter:rw', 'saveAbsage' => 'infocenter:rw', 'saveFreigabe' => 'infocenter:rw', + 'getNotiz' => 'infocenter:r', 'saveNotiz' => 'infocenter:rw', 'updateNotiz' => 'infocenter:rw', 'reloadZgvPruefungen' => 'infocenter:r', @@ -533,6 +534,20 @@ class InfoCenter extends Auth_Controller $this->output->set_content_type('application/json')->set_output(json_encode($json)); } + /** + * Gets a Notiz + */ + public function getNotiz() + { + $notiz_id = $this->input->get('notiz_id'); + + $result = $this->NotizModel->load( + $notiz_id + ); + + $this->output->set_content_type('application/json')->set_output(json_encode($result)); + } + /** * Saves a new Notiz for a person * @param $person_id @@ -557,10 +572,10 @@ class InfoCenter extends Auth_Controller * Updates a new Notiz for a person * @param int $notiz_id * @param int $person_id - * @return bool true if success */ - public function updateNotiz($notiz_id, $person_id) + public function updateNotiz($notiz_id) { + $person_id = $this->input->post('person_id'); $titel = $this->input->post('notiztitel'); $text = $this->input->post('notiz'); diff --git a/application/views/system/infocenter/notizen.php b/application/views/system/infocenter/notizen.php index 53d289721..13f7bb6e1 100644 --- a/application/views/system/infocenter/notizen.php +++ b/application/views/system/infocenter/notizen.php @@ -9,11 +9,11 @@ + title="text) ? html_escape($notiz->text) : '' ?>" style="cursor: pointer"> insertamum), 'd.m.Y H:i:s') ?> titel) ?> verfasser_uid ?> - notiz_id ?> + notiz_id ?> diff --git a/public/js/infocenter/infocenterDetails.js b/public/js/infocenter/infocenterDetails.js index 8de1d2c6f..84f68bf11 100644 --- a/public/js/infocenter/infocenterDetails.js +++ b/public/js/infocenter/infocenterDetails.js @@ -45,10 +45,12 @@ $(document).ready(function () $("#notizform").on("submit", function (e) { e.preventDefault(); - var notizId = $("#notizform :input[name='hiddenNotizId']").val(); + var notizid = $("#notizform :input[name='hiddenNotizId']").val(); var formdata = $(this).serializeArray(); var data = {}; + data.person_id = personid; + for (var i = 0; i < formdata.length; i++) { data[formdata[i].name] = formdata[i].value; @@ -56,9 +58,9 @@ $(document).ready(function () $("#notizmsg").empty(); - if (notizId !== '') + if (notizid !== '') { - InfocenterDetails.updateNotiz(notizId, personid, data); + InfocenterDetails.updateNotiz(notizid, data); } else { @@ -72,16 +74,9 @@ $(document).ready(function () { $("#notizmsg").empty(); - var notizId = $(this).find("td:eq(3)").html(); - var notizTitle = $(this).find("td:eq(1)").text(); - var notizContent = this.title; + var notizid = $(this).find("td.hiddennotizid").html(); - $("#notizform label:first").text(FHC_PhrasesLib.t('infocenter', 'notizAendern')).css("color", "red"); - $("#notizform :input[type='reset']").css("display", "inline-block"); - - $("#notizform :input[name='hiddenNotizId']").val(notizId); - $("#notizform :input[name='notiztitel']").val(notizTitle); - $("#notizform :input[name='notiz']").val(notizContent); + InfocenterDetails.getNotiz(notizid); } ); @@ -297,7 +292,40 @@ var InfocenterDetails = { } ); }, - saveNotiz: function(personid, data) + getNotiz: function(notiz_id) + { + FHC_AjaxClient.ajaxCallGet( + CALLED_PATH + '/getNotiz', + { + "notiz_id": notiz_id + }, + { + successCallback: function(data, textStatus, jqXHR) { + if (FHC_AjaxClient.hasData(data)) + { + var notiz = data.retval[0]; + + $("#notizform label:first").text(FHC_PhrasesLib.t('infocenter', 'notizAendern')).css("color", "red"); + $("#notizform :input[type='reset']").css("display", "inline-block"); + + $("#notizform :input[name='hiddenNotizId']").val(notiz_id); + $("#notizform :input[name='notiztitel']").val(notiz.titel); + $("#notizform :input[name='notiz']").val(notiz.text); + } + else + { + InfocenterDetails._notizError('fehlerBeimLesen'); + } + }, + errorCallback: function() + { + InfocenterDetails._notizError('fehlerBeimLesen'); + }, + veilTimeout: 0 + } + ); + }, + saveNotiz: function(data) { FHC_AjaxClient.ajaxCallPost( CALLED_PATH + '/saveNotiz/' + encodeURIComponent(personid), @@ -311,18 +339,21 @@ var InfocenterDetails = { } else { - InfocenterDetails._errorSaveNotiz(); + InfocenterDetails._notizError('fehlerBeimSpeichern'); } }, - errorCallback: InfocenterDetails._errorSaveNotiz, + errorCallback: function() + { + InfocenterDetails._notizError('fehlerBeimSpeichern'); + }, veilTimeout: 0 } ); }, - updateNotiz: function(notizId, personId, data) + updateNotiz: function(notizid, data) { FHC_AjaxClient.ajaxCallPost( - CALLED_PATH + '/updateNotiz/' + encodeURIComponent(notizId) + "/" + encodeURIComponent(personId), + CALLED_PATH + '/updateNotiz/' + encodeURIComponent(notizid), data, { successCallback: function(data, textStatus, jqXHR) { @@ -334,10 +365,13 @@ var InfocenterDetails = { } else { - InfocenterDetails._errorSaveNotiz(); + InfocenterDetails._notizError('fehlerBeimSpeichern'); } }, - errorCallback: InfocenterDetails._errorSaveNotiz, + errorCallback: function() + { + InfocenterDetails._notizError('fehlerBeimSpeichern'); + }, veilTimeout: 0 } ); @@ -815,8 +849,8 @@ var InfocenterDetails = { $("#notizform label:first").text(FHC_PhrasesLib.t('infocenter', 'notizHinzufuegen')).css("color", "black"); $("#notizform :input[type='reset']").css("display", "none"); }, - _errorSaveNotiz: function() + _notizError: function(phrasename) { - $("#notizmsg").text(FHC_PhrasesLib.t('ui', 'fehlerBeimSpeichern')); + $("#notizmsg").text(FHC_PhrasesLib.t('ui', phrasename)); } }; diff --git a/system/phrasesupdate.php b/system/phrasesupdate.php index 5bbef50b2..4f9d885d0 100644 --- a/system/phrasesupdate.php +++ b/system/phrasesupdate.php @@ -1394,6 +1394,26 @@ $phrases = array( ) ) ), + array( + 'app' => 'core', + 'category' => 'ui', + 'phrase' => 'fehlerBeimLesen', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Fehler beim Lesen', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'Error on Reading', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), array( 'app' => 'core', 'category' => 'ui',