fix : contact detail not processed

This commit is contained in:
mahdahar 2026-04-17 09:57:13 +07:00
parent 30c4e47304
commit 7b2c65ac9a
2 changed files with 14 additions and 10 deletions

View File

@ -22,14 +22,14 @@ if (!function_exists('convert_array_to_utc')) {
}
}
if (!function_exists('is_datetime_string')) {
function is_datetime_string(string $value): bool {
return preg_match(
'/^\d{4}-\d{2}-\d{2}(?:[T\s]\d{2}:\d{2}:\d{2}(?:[\+\-]\d{2}:?\d{2}|Z)?)?$/',
$value
) === 1;
}
}
if (!function_exists('is_datetime_string')) {
function is_datetime_string(string $value): bool {
return preg_match(
'/^\d{4}-\d{2}-\d{2}(?:[T\s]\d{2}:\d{2}:\d{2}(?:\.\d{1,6})?(?:[\+\-]\d{2}:?\d{2}|Z)?)?$/',
$value
) === 1;
}
}
if (!function_exists('convert_array_to_utc_iso')) {
function convert_array_to_utc_iso($data) {

View File

@ -86,12 +86,16 @@ class ContactModel extends BaseModel {
$details = $data['Details'] ?? [];
unset($data['Details']);
$contactData = array_intersect_key($data, array_flip($this->allowedFields));
if (!empty($data['ContactID'])) {
$contactId = $data['ContactID'];
$this->update($contactId, $data);
if (!empty($contactData)) {
$this->update($contactId, $contactData);
}
} else {
$contactId = $this->insert($data, true);
}
}
if (!$contactId) {
throw new \RuntimeException('Failed to save contact');