Skip to content

Commit

Permalink
Address (#7151)
Browse files Browse the repository at this point in the history
# Description & Issue number it closes 

We need to update Latitude and Longitude with address changes.

Closes: #4023

## Screenshots (if appropriate)

## How to test the changes?

Check Latitude and Longitude after updating address

## Type of change

- [X] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update

# How Has This Been Tested?

I have tested it on my server.

# Checklist:

- [X] My code follows the style guidelines of this project
- [X] I have performed a self-review of my code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [X] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream
modules
  • Loading branch information
DAcodedBEAT authored Sep 19, 2024
2 parents b774b00 + 08edb88 commit 6de5bc4
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 @@ -266,6 +267,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 6de5bc4

Please sign in to comment.