Skip to content

Commit

Permalink
Update Lat/Long when address changes
Browse files Browse the repository at this point in the history
  • Loading branch information
bigtigerku committed Sep 19, 2024
1 parent 590df47 commit 08edb88
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/FamilyEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit 08edb88

Please sign in to comment.