From 08edb88c7a5c363ea1ff1c47e18c48cb8f70aedd Mon Sep 17 00:00:00 2001 From: BigTigerKU Date: Wed, 18 Sep 2024 22:25:50 -0700 Subject: [PATCH] Update Lat/Long when address changes --- src/FamilyEditor.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/FamilyEditor.php b/src/FamilyEditor.php index 41e69e57a4..1edc025cc0 100644 --- a/src/FamilyEditor.php +++ b/src/FamilyEditor.php @@ -9,6 +9,7 @@ use ChurchCRM\dto\SystemURLs; use ChurchCRM\Emails\notifications\NewPersonOrFamilyEmail; use ChurchCRM\model\ChurchCRM\FamilyQuery; +use ChurchCRM\model\ChurchCRM\Map\FamilyTableMap; use ChurchCRM\model\ChurchCRM\Note; use ChurchCRM\model\ChurchCRM\Person; use ChurchCRM\model\ChurchCRM\PersonQuery; @@ -265,6 +266,20 @@ ->setEmail($sEmail) ->setLatitude($nLatitude) ->setLongitude($nLongitude); + + // Update Lat/Long if address changes + if (($family->isColumnModified(FamilyTableMap::COL_FAM_ADDRESS1) + || $family->isColumnModified(FamilyTableMap::COL_FAM_ADDRESS2) + || $family->isColumnModified(FamilyTableMap::COL_FAM_CITY) + || $family->isColumnModified(FamilyTableMap::COL_FAM_STATE) + || $family->isColumnModified(FamilyTableMap::COL_FAM_ZIP) + || $family->isColumnModified(FamilyTableMap::COL_FAM_COUNTRY)) + && (!$family->isColumnModified(FamilyTableMap::COL_FAM_LATITUDE) + && !$family->isColumnModified(FamilyTableMap::COL_FAM_LONGITUDE))) { + $family->setLatitude(null); + $family->setLongitude(null); + } + $family->save(); $family->reload();