From a1d616ff033710795ea8ddb98aacc4ecacec4681 Mon Sep 17 00:00:00 2001 From: Harald Bamberger Date: Mon, 6 Oct 2025 18:27:19 +0200 Subject: [PATCH] alter profilupdate api if heimatadresse is updated create new adress, readd missing isMitarbeiter info in frontend an provide/inject it --- .../api/frontend/v1/ProfilUpdate.php | 31 ++++++++++++++++--- application/libraries/ProfilLib.php | 2 +- .../Cis/Profil/MitarbeiterProfil.js | 2 +- .../Cis/Profil/ProfilModal/EditProfil.js | 5 +++ .../EditProfilComponents/EditAdresse.js | 6 +--- .../Profil/ProfilModal/EditProfilSelect.js | 7 +++-- 6 files changed, 38 insertions(+), 15 deletions(-) diff --git a/application/controllers/api/frontend/v1/ProfilUpdate.php b/application/controllers/api/frontend/v1/ProfilUpdate.php index 6752c805a..d0eb26858 100644 --- a/application/controllers/api/frontend/v1/ProfilUpdate.php +++ b/application/controllers/api/frontend/v1/ProfilUpdate.php @@ -825,12 +825,33 @@ class ProfilUpdate extends FHCAPI_Controller } //! UPDATE else { - $requested_change['updateamum'] = "NOW()"; - $requested_change['updatevon'] = getAuthUID(); - $update_adresse_id = $this->AdresseModel->update($adresse_id, $requested_change); - $update_adresse_id = $this->getDataOrTerminateWithError($update_adresse_id, $this->p->t('profilUpdate', 'profilUpdate_updateAdresse_error')); - $this->handleDupplicateZustellAdressen($requested_change['zustelladresse'], $update_adresse_id, $personID); + $curadresse_res = $this->AdresseModel->load($adresse_id); + $curadresse = ($this->getDataOrTerminateWithError($curadresse_res))[0]; + if($curadresse->heimatadresse) + { + $tmpadresse = array_merge((array) $curadresse, $requested_change); + unset($tmpadresse["adresse_id"]); + $tmpadresse['insertamum'] = "NOW()"; + $tmpadresse['insertvon'] = getAuthUID(); + $tmpadresse['person_id'] = $personID; + unset($tmpadresse["heimatadresse"]); + unset($tmpadresse["updateamum"]); + unset($tmpadresse["updatevon"]); + + $tmpadresse_res = $this->AdresseModel->insert($tmpadresse); + $tmpadresse_id = $this->getDataOrTerminateWithError($tmpadresse_res, $this->p->t('profilUpdate', 'profilUpdate_insertAdresse_error')); + $this->handleDupplicateZustellAdressen($requested_change['zustelladresse'], $tmpadresse_id, $personID); + } + else + { + $requested_change['updateamum'] = "NOW()"; + $requested_change['updatevon'] = getAuthUID(); + + $update_adresse_id = $this->AdresseModel->update($adresse_id, $requested_change); + $update_adresse_id = $this->getDataOrTerminateWithError($update_adresse_id, $this->p->t('profilUpdate', 'profilUpdate_updateAdresse_error')); + $this->handleDupplicateZustellAdressen($requested_change['zustelladresse'], $update_adresse_id, $personID); + } } return $insertID ?? null; } diff --git a/application/libraries/ProfilLib.php b/application/libraries/ProfilLib.php index 6e93a0943..e4bbf5a25 100644 --- a/application/libraries/ProfilLib.php +++ b/application/libraries/ProfilLib.php @@ -196,7 +196,7 @@ class ProfilLib{ private function getAdressenInfo($pid) { $this->ci->load->model("person/Adresse_model","AdresseModel"); - $adresse_res = $this->ci->AdresseModel->addSelect(["adresse_id", "strasse", "tbl_adressentyp.bezeichnung as typ", "plz", "ort", "zustelladresse", "gemeinde", "nation"]); + $adresse_res = $this->ci->AdresseModel->addSelect(["adresse_id", "strasse", "tbl_adressentyp.bezeichnung as typ", "plz", "ort", "heimatadresse", "zustelladresse", "gemeinde", "nation"]); $adresse_res = $this->ci->AdresseModel->addOrder("zustelladresse", "DESC"); $adresse_res = $this->ci->AdresseModel->addJoin("tbl_adressentyp", "typ=adressentyp_kurzbz"); diff --git a/public/js/components/Cis/Profil/MitarbeiterProfil.js b/public/js/components/Cis/Profil/MitarbeiterProfil.js index bf3c4cf49..559006a1b 100644 --- a/public/js/components/Cis/Profil/MitarbeiterProfil.js +++ b/public/js/components/Cis/Profil/MitarbeiterProfil.js @@ -328,7 +328,7 @@ export default { }, template: /*html*/ `
- +

{{item.title}}

@@ -156,7 +157,7 @@ export default {
- +