diff --git a/application/controllers/system/infocenter/InfoCenter.php b/application/controllers/system/infocenter/InfoCenter.php index deaee0e10..187a006bd 100644 --- a/application/controllers/system/infocenter/InfoCenter.php +++ b/application/controllers/system/infocenter/InfoCenter.php @@ -175,6 +175,7 @@ class InfoCenter extends Auth_Controller $this->load->model('codex/Nation_model', 'NationModel'); $this->load->model('person/Kontakt_model', 'KontaktModel'); $this->load->model('person/Geschlecht_model', 'GeschlechtModel'); + $this->load->model('person/adresse_model', 'AdresseModel'); // Loads libraries $this->load->library('PersonLogLib'); @@ -1367,7 +1368,7 @@ class InfoCenter extends Auth_Controller $this->terminateWithJsonError($this->p->t('ui', 'fehlerBeimSpeichern')); $kontakte = $this->input->post('kontakt'); - foreach($kontakte as $kontakt) + foreach ($kontakte as $kontakt) { $kontaktExists = $this->KontaktModel->loadWhere(array( 'kontakt_id' => $kontakt['id'], @@ -1398,6 +1399,47 @@ class InfoCenter extends Auth_Controller $this->terminateWithJsonError($this->p->t('ui', 'fehlerBeimSpeichern')); } } + + $adressen = $this->input->post('adresse'); + + foreach ($adressen as $adresse) + { + $adresseExists = $this->AdresseModel->loadWhere(array( + 'adresse_id' => $adresse['id'], + 'person_id' => $person_id, + )); + + if (hasData($adresseExists)) + { + $adresse = $adresse['value']; + $adresseExists = getData($adresseExists)[0]; + if ($adresseExists->strasse !== $adresse['strasse'] || + $adresseExists->plz !== $adresse['plz'] || + $adresseExists->ort !== $adresse['ort'] || + $adresseExists->nation !== $adresse['nation']) + { + $update = $this->AdresseModel->update( + array + ( + 'adresse_id' => $adresseExists->adresse_id + ), + array + ( + 'strasse' => isEmptyString($adresse['strasse']) ? null : $adresse['strasse'], + 'plz' => isEmptyString($adresse['plz']) ? null : $adresse['plz'], + 'ort' => isEmptyString($adresse['ort']) ? null : $adresse['ort'], + 'nation' => isEmptyString($adresse['nation']) ? null : $adresse['nation'], + 'updateamum' => date('Y-m-d H:i:s'), + 'updatevon' => $this->_uid + ) + ); + + if (isError($update)) + $this->terminateWithJsonError($this->p->t('ui', 'fehlerBeimSpeichern')); + } + + } + } $this->outputJsonSuccess('Success'); } diff --git a/application/views/system/infocenter/stammdaten.php b/application/views/system/infocenter/stammdaten.php index ac8f6347c..47cf7b253 100644 --- a/application/views/system/infocenter/stammdaten.php +++ b/application/views/system/infocenter/stammdaten.php @@ -3,36 +3,52 @@ - + + - + +
nachname ?>
+ + - + +
gebdatum), 'd.m.Y') ?>
+ + +
svnr ?>
+ + - +
p->t('person','titelpre')) ?> +
titelpre ?>
+
p->t('person','vorname')) ?> +
vorname ?>
+ + +
p->t('person','nachname')) ?> -
p->t('person','titelpost')) ?> +
titelpost ?>
+ +
p->t('person','geburtsdatum')) ?> -
p->t('person','svnr')) ?> -
p->t('person','staatsbuergerschaft')) ?> - - p->t('person','geburtsnation')) ?> -
p->t('person','geburtsort')) ?> +
gebort ?>
+ +
@@ -111,14 +130,14 @@ kontakttyp) ?> - kontakttyp.'" data-value="'. $kontakt->kontakt .'">';?> + kontakttyp.'" data-id="'. $kontakt->kontakt_id .'" data-value="' . $kontakt->kontakt .'">';?> kontakttyp === 'email'): ?> kontakt; endif; - if (($kontakt->kontakttyp === 'telefon' || $kontakt->kontakttyp === 'mobil')) - echo ''; - else + /*if (($kontakt->kontakttyp === 'telefon' || $kontakt->kontakttyp === 'mobil')) + echo ''; + else*/ echo $kontakt->kontakt; if ($kontakt->kontakttyp === 'email'): ?> @@ -135,8 +154,33 @@ p->t('person','adresse')) ?> - strasse.', '.$adresse->plz.' '.$adresse->ort : '' ?> - nationkurztext) ? '
'.$adresse->nationkurztext : '' ?> + +
+
strasse ?>
+ + +
plz ?>
+ + +
ort ?>
+ + + nationkurztext)): ?> + +
+
+ + heimatadresse === true ? 'Heimatadresse' : ''). diff --git a/public/js/infocenter/stammdaten.js b/public/js/infocenter/stammdaten.js index d63df7b2f..a8a15b23b 100644 --- a/public/js/infocenter/stammdaten.js +++ b/public/js/infocenter/stammdaten.js @@ -15,13 +15,27 @@ $(document).ready(function () $('.saveStammdaten').click(function() { var kontakt = []; - $('.kontakt_nummer').each(function(){ + $('.kontakt_input').each(function(){ kontakt.push({ - id: $(this).data('value'), + id: $(this).data('id'), value: $(this).val() }); }); + var adresse = []; + $('.adresse').each(function(){ + var id = $(this).data('value'); + adresse.push({ + id: id, + value: { + 'strasse': $('#input_strasse_' + id).val(), + 'plz': $('#input_plz_' + id).val(), + 'ort': $('#input_ort_' + id).val(), + 'nation': $('#nation_' + id).val(), + } + }); + }); + var data = { "personid" : personid, "titelpre" : $('#titelpre').val(), @@ -34,8 +48,8 @@ $(document).ready(function () "geschlecht" : $('#geschlecht').val(), "gebnation" : $('#gebnation').val(), "gebort" : $('#gebort').val(), - "kontakt" : kontakt - + "kontakt" : kontakt, + "adresse" : adresse, }; Stammdaten.update(personid, data); }); @@ -52,6 +66,8 @@ var Stammdaten = { if (FHC_AjaxClient.isSuccess(data)) { FHC_DialogLib.alertSuccess("Done!"); + Stammdaten._showKontakt(); + Stammdaten._showAdresse(); Stammdaten._hide(); } else @@ -66,9 +82,62 @@ var Stammdaten = { ); }, + _showKontakt: function() + { + $('.kontakt_input').each(function() { + var span = $(this).parent('td').children('span'); + var value = $(this).val(); + + var oldSpanValue = span.data('value'); + span.data('value', value); + var newhtml = span.html().replace(oldSpanValue, value); + span.html(newhtml); + if (span.hasClass('email')) + span.find('a').attr('href', 'mailto:' + value); + + span.show(); + $(this).remove(); + }); + }, + + _showAdresse: function() + { + $('.adresse').each(function() { + var adressenID = $(this).data('value'); + $(this).children('input').each(function() { + $(this).attr('id'); + var div = $(this).attr('id').replace('input_', ''); + $('#' + div).html($(this).val()) + $('#' + div).show(); + $(this).remove(); + }); + }); + + }, + _hide: function() { - $('.stammdaten_form').find('input, select').attr('readonly', true); + var stammdatenform = $('.stammdaten_form'); + stammdatenform.find('select').attr('disabled', true); + + $('.stammdaten').each(function(){ + var id = $(this).attr('id'); + var div = $('
'); + div.attr('id', id); + div.addClass('stammdaten'); + div.html($(this).val()); + $(this).parent('td').html(div); + }); + + $('.kontakt_input').each(function(){ + $(this).parent('td').children('span').show(); + $(this).remove(); + }); + + $('.adresse_input').each(function(){ + $(this).parent('div').children('div').show(); + $(this).remove(); + }); $('.editActionStammdaten').hide(); $('.editStammdaten').show(); @@ -76,9 +145,56 @@ var Stammdaten = { _show: function() { - $('.stammdaten_form').find('input, select').attr('readonly', false); + $('.stammdaten').each(function() { + var id = $(this).attr('id'); + var input = $(''); + input.attr('id', id); + input.addClass('form-control stammdaten'); + input.val($(this).html()); + $(this).parent('td').html(input); + }); + $('.kontakt').each(function() { + var id = $(this).data('id'); + var value = $(this).data('value'); + + $(this).hide(); + + var input = $(''); + input.attr('data-id', id); + input.attr('value', value); + input.addClass('form-control kontakt_input'); + input.val(value); + $(this).parent('td').append(input); + }); + + $('.adresse').each(function() { + var adressenID = $(this).data('value'); + $($(this).children('div').get().reverse()).each(function() { + $(this).hide(); + var id = $(this).attr('id'); + + var input = $(''); + var value = $(this).html(); + + input.attr('id', 'input_' + Stammdaten._getPlaceholder(id) + "_" + adressenID); + input.attr('value', value); + input.attr('placeholder', Stammdaten._getPlaceholder(id).toUpperCase()); + input.addClass('form-control adresse_input'); + input.val(value); + $(this).parent().prepend(input); + }); + }); + + var stammdatenform = $('.stammdaten_form'); + + stammdatenform.find('select').attr('disabled', false); $('.editActionStammdaten').show(); $('.editStammdaten').hide(); + }, + + _getPlaceholder(elementid) + { + return elementid.substr(0, elementid.indexOf("_")); } } \ No newline at end of file