alter profilupdate api if heimatadresse is updated create new adress, readd missing isMitarbeiter info in frontend an provide/inject it

This commit is contained in:
Harald Bamberger
2025-10-06 18:27:19 +02:00
parent 1340e762c3
commit a1d616ff03
6 changed files with 38 additions and 15 deletions
@@ -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;
}