-
Notifications
You must be signed in to change notification settings - Fork 443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revamp of the geocoder system #2320
Changes from all commits
8f0b8ff
70ed420
6ef953f
2ae3405
80a0df6
76f96e2
4fbb8b3
bfbdf99
2201295
1ef0833
3250653
109dd8d
d645c19
b17c766
d078635
ca7204d
e890cb4
db5d16b
907665a
a72aaf0
4f0c6c0
577fc14
9740579
bb1d588
17176f7
f712135
be66b03
e47b54b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
namespace ChurchCRM\dto; | ||
|
||
use ChurchCRM\Utils\GeoUtils; | ||
|
||
class ChurchMetaData | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we get that info in many places this is now a single place to get the Church Info... I'm planning to use this in the email system after both PRs are merged. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 |
||
{ | ||
public static function getChurchName() | ||
{ | ||
return SystemConfig::getValue('sChurchName'); | ||
} | ||
|
||
public static function getChurchFullAddress() | ||
{ | ||
$address = []; | ||
if (!empty(self::getChurchAddress())) { | ||
array_push($address, self::getChurchAddress()); | ||
} | ||
|
||
if (!empty(self::getChurchCity())) { | ||
array_push($address, self::getChurchCity() . ','); | ||
} | ||
|
||
if (!empty(self::getChurchState())) { | ||
array_push($address, self::getChurchState()); | ||
} | ||
|
||
if (!empty(self::getChurchZip())) { | ||
array_push($address, self::getChurchZip()); | ||
} | ||
if (!empty(self::getChurchCountry())) { | ||
array_push($address, self::getChurchCountry()); | ||
} | ||
|
||
return implode(' ', $address); | ||
} | ||
|
||
public static function getChurchAddress() | ||
{ | ||
return SystemConfig::getValue('sChurchAddress'); | ||
} | ||
|
||
public static function getChurchCity() | ||
{ | ||
return SystemConfig::getValue('sChurchCity'); | ||
} | ||
|
||
public static function getChurchState() | ||
{ | ||
return SystemConfig::getValue('sChurchState'); | ||
} | ||
|
||
public static function getChurchZip() | ||
{ | ||
return SystemConfig::getValue('sChurchZip'); | ||
} | ||
|
||
public static function getChurchCountry() | ||
{ | ||
return SystemConfig::getValue('sChurchCountry'); | ||
} | ||
|
||
public static function getChurchLatitude() | ||
{ | ||
if (empty(SystemConfig::getValue('nChurchLatitude'))) { | ||
self::updateLatLng(); | ||
} | ||
return SystemConfig::getValue('nChurchLatitude'); | ||
} | ||
|
||
public static function getChurchLongitude() | ||
{ | ||
if (empty(SystemConfig::getValue('nChurchLongitude'))) { | ||
self::updateLatLng(); | ||
} | ||
return SystemConfig::getValue('nChurchLongitude'); | ||
} | ||
|
||
private static function updateLatLng() | ||
{ | ||
if (!empty(self::getChurchFullAddress())) { | ||
$latLng = GeoUtils::getLatLong(self::getChurchFullAddress()); | ||
if (!empty($latLng['Latitude']) && !empty($latLng['Longitude'])) { | ||
SystemConfig::setValue('nChurchLatitude', $latLng['Latitude']); | ||
SystemConfig::setValue('nChurchLongitude', $latLng['Longitude']); | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,7 +81,9 @@ private static function buildConfigs() | |
"sXML_RPC_PATH" => new ConfigItem(41, "sXML_RPC_PATH", "text", "XML/RPC.php", gettext("Path to RPC.php, required for Lat/Lon address lookup")), | ||
"sGeocoderID" => new ConfigItem(42, "sGeocoderID", "text", "", gettext("User ID for rpc.geocoder.us")), | ||
"sGeocoderPW" => new ConfigItem(43, "sGeocoderPW", "text", "", gettext("Password for rpc.geocoder.us")), | ||
"sGoogleMapKey" => new ConfigItem(44, "sGoogleMapKey", "text", "", gettext("Google map API requires a unique key from https://developers.google.com/maps/documentation/javascript/get-api-key")), | ||
"sGoogleMapKey" => new ConfigItem(44, "sGoogleMapKey", "text", "", gettext("Google map API requires a unique key") . " - https://developers.google.com/maps/documentation/javascript/get-api-key"), | ||
"sBingMapKey" => new ConfigItem(10000, "sBingMapKey", "text", "", gettext("Bing map API requires a unique key") . " - https://www.microsoft.com/maps/create-a-bing-maps-key.aspx"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I created a new Issue to so that we can another icon that is for external docs so that we do not put URLs in tool tips #2321 |
||
"iMapZoom" => new ConfigItem(10001, "iMapZoom", "number", "10", gettext("Google Maps Zoom")), | ||
"nChurchLatitude" => new ConfigItem(45, "nChurchLatitude", "number", "", gettext("Latitude of the church, used to center the Google map")), | ||
"nChurchLongitude" => new ConfigItem(46, "nChurchLongitude", "number", "", gettext("Longitude of the church, used to center the Google map")), | ||
"bHidePersonAddress" => new ConfigItem(47, "bHidePersonAddress", "boolean", "1", gettext("Set true to disable entering addresses in Person Editor. Set false to enable entering addresses in Person Editor.")), | ||
|
@@ -91,9 +93,9 @@ private static function buildConfigs() | |
"bHideLatLon" => new ConfigItem(51, "bHideLatLon", "boolean", "0", gettext("Set true to disable entering Latitude and Longitude in Family Editor. Set false to enable entering Latitude and Longitude in Family Editor. Lookups are still performed, just not displayed.")), | ||
"bUseDonationEnvelopes" => new ConfigItem(52, "bUseDonationEnvelopes", "boolean", "0", gettext("Set true to enable use of donation envelopes")), | ||
"sHeader" => new ConfigItem(53, "sHeader", "textarea", "", gettext("Enter in HTML code which will be displayed as a header at the top of each page. Be sure to close your tags! Note: You must REFRESH YOUR BROWSER A SECOND TIME to view the new header.")), | ||
"sISTusername" => new ConfigItem(54, "sISTusername", "text", "username", gettext("Intelligent Search Technolgy, Ltd. CorrectAddress Username for https://www.intelligentsearch.com/Hosted/User")), | ||
"sISTpassword" => new ConfigItem(55, "sISTpassword", "text", "", gettext("Intelligent Search Technolgy, Ltd. CorrectAddress Password for https://www.intelligentsearch.com/Hosted/User")), | ||
"bUseGoogleGeocode" => new ConfigItem(56, "bUseGoogleGeocode", "boolean", "1", gettext("Set true to use the Google geocoder. Set false to use rpc.geocoder.us.")), | ||
"sISTusername" => new ConfigItem(54, "sISTusername", "text", "username", gettext("Intelligent Search Technolgy, Ltd. CorrectAddress Username for") . " - https://www.intelligentsearch.com/Hosted/User"), | ||
"sISTpassword" => new ConfigItem(55, "sISTpassword", "text", "", gettext("Intelligent Search Technolgy, Ltd. CorrectAddress Password for") . " - https://www.intelligentsearch.com/Hosted/User"), | ||
"sGeoCoderProvider" => new ConfigItem(56, "sGeoCoderProvider", "choice", "GoogleMaps", gettext("Select GeoCoder Provider") . " - https://github.com/geocoder-php/Geocoder/blob/3.x/README.md#address-based-providers", '{"Choices":["GoogleMaps", "BingMaps"]}'), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 |
||
"iChecksPerDepositForm" => new ConfigItem(57, "iChecksPerDepositForm", "number", "14", gettext("Number of checks for Deposit Slip Report")), | ||
"bUseScannedChecks" => new ConfigItem(58, "bUseScannedChecks", "boolean", "0", gettext("Set true to enable use of scanned checks")), | ||
"sDistanceUnit" => new ConfigItem(64, "sDistanceUnit", "choice", "miles", gettext("Unit used to measure distance, miles or km."), '{"Choices":["'.gettext("miles").'","'.gettext("kilometers").'"]}'), | ||
|
@@ -178,7 +180,7 @@ private static function buildCategories() | |
gettext('Email Setup') => ["sSMTPHost","sSMTPAuth","sSMTPUser","sSMTPPass", "iSMTPTimeout","sToEmailAddress","mailChimpApiKey"], | ||
gettext('Member Setup') => ["sDirClassifications","sDirRoleHead","sDirRoleSpouse","sDirRoleChild","sDefaultCity","sDefaultState","sDefaultCountry","bShowFamilyData","bHidePersonAddress","bHideFriendDate","bHideFamilyNewsletter","bHideWeddingDate","bHideLatLon","cfgForceUppercaseZip","sEnableGravatarPhotos","sEnableSelfRegistration", "bAllowEmptyLastName", "iPersonNameStyle"], | ||
gettext('System Settings') => ["sLastBackupTimeStamp","sExternalBackupAutoInterval","sExternalBackupPassword","sEnableExternalBackupTarget","sExternalBackupType","sExternalBackupEndpoint","sExternalBackupUsername","debug","sLogFile", "bRegistered","sXML_RPC_PATH","sGZIPname","sZIPname","sPGPname","bCSVAdminOnly","sHeader","sEnableIntegrityCheck","sIntegrityCheckInterval","sLastIntegrityCheckTimeStamp"], | ||
gettext('Map Settings') => ["sGoogleMapKey","bUseGoogleGeocode","sGMapIcons","sISTusername","sISTpassword","sGeocoderID","sGeocoderPW"], | ||
gettext('Map Settings') => ["sGeoCoderProvider","sGoogleMapKey","sBingMapKey","sGMapIcons", "iMapZoom","sISTusername","sISTpassword","sGeocoderID","sGeocoderPW"], | ||
gettext('Report Settings') => ["sQBDTSettings","leftX","incrementY","sTaxReport1","sTaxReport2","sTaxReport3","sTaxSigner","sReminder1","sReminderSigner","sReminderNoPledge","sReminderNoPayments","sConfirm1","sConfirm2","sConfirm3","sConfirm4","sConfirm5","sConfirm6","sDear","sConfirmSincerely","sConfirmSigner","sPledgeSummary1","sPledgeSummary2","sDirectoryDisclaimer1","sDirectoryDisclaimer2","bDirLetterHead","sZeroGivers","sZeroGivers2","sZeroGivers3"], | ||
gettext('Localization') => ["sLanguage","sDistanceUnit","sPhoneFormat","sPhoneFormatWithExt","sDateFormatLong","sDateFormatNoYear","sDateFormatShort","sDateTimeFormat","sDateFilenameFormat"], | ||
gettext('Financial Settings') => ["sDepositSlipType","iChecksPerDepositForm","bDisplayBillCounts","bUseScannedChecks","sElectronicTransactionProcessor","bEnableNonDeductible","iFYMonth","bUseDonationEnvelopes","aFinanceQueries"], | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
use ChurchCRM\Base\Family as BaseFamily; | ||
use Propel\Runtime\Connection\ConnectionInterface; | ||
use ChurchCRM\dto\Photo; | ||
use ChurchCRM\Utils\GeoUtils; | ||
|
||
/** | ||
* Skeleton subclass for representing a row from the 'family_fam' table. | ||
|
@@ -19,6 +20,7 @@ | |
*/ | ||
class Family extends BaseFamily implements iPhoto | ||
{ | ||
|
||
public function getAddress() | ||
{ | ||
$address = []; | ||
|
@@ -187,22 +189,22 @@ public function getSaluation() | |
$notChildren[] = $person; | ||
} | ||
} | ||
|
||
$notChildrenCount = count($notChildren); | ||
if ($notChildrenCount === 1) { | ||
return $notChildren[0]->getFullName(); | ||
} | ||
|
||
if ($notChildrenCount === 2) { | ||
if ($notChildren[0]->getLastName() == $notChildren[1]->getLastName()) { | ||
return $notChildren[0]->getFirstName() .' & '. $notChildren[1]->getFirstName() .' '. $notChildren[0]->getLastName(); | ||
} | ||
return $notChildren[0]->getFullName() .' & '. $notChildren[1]->getFullName(); | ||
} | ||
|
||
return $this->getName() . ' Family'; | ||
} | ||
|
||
private function getPhoto() | ||
{ | ||
$photo = new Photo("Family", $this->getId()); | ||
|
@@ -282,27 +284,23 @@ public function getFamilyString() | |
{ | ||
return $this->getName(). " " . $this->getAddress(); | ||
} | ||
|
||
/** | ||
|
||
public function hasLatitudeAndLongitude() { | ||
return !empty($this->getLatitude()) && !empty($this->getLongitude()); | ||
} | ||
|
||
/** | ||
* if the latitude or longitude is empty find the lat/lng from the address and update the lat lng for the family. | ||
* @return array of Lat/Lng | ||
*/ | ||
public function getLatLng() { | ||
if ($this->getLatitude() == 0 || $this->getLongitude() == 0 ) { | ||
$prepAddr = str_replace(' ','+',$this->getAddress()); | ||
$geocode=file_get_contents("https://maps.googleapis.com/maps/api/geocode/json?address=".$prepAddr."&key=". SystemConfig::getValue('sGoogleMapKey')); | ||
$output= json_decode($geocode); | ||
if($output->results[0]->geometry->location->lat && $output->results[0]->geometry->location->lng) { | ||
$this->setLatitude($output->results[0]->geometry->location->lat); | ||
$this->setLongitude($output->results[0]->geometry->location->lng); | ||
public function updateLanLng() { | ||
if (!empty($this->getAddress()) && (!$this->hasLatitudeAndLongitude())) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if we want to update the lat/lng of an existing family? |
||
$latLng = GeoUtils::getLatLong($this->getAddress()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this causes a traceback:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is also what's causing the travis tests to fail There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ya bad last min refactor ... i just fixed it |
||
if(!empty( $latLng['Latitude']) && !empty($latLng['Longitude'])) { | ||
$this->setLatitude($latLng['Latitude']); | ||
$this->setLongitude($latLng['Longitude']); | ||
$this->save(); | ||
} | ||
|
||
} | ||
return array( | ||
'Latitude' => $this->getLatitude(), | ||
'Longitude' => $this->getLongitude() | ||
); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there was a log warning about $context is not a valid var
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a reason for this.... I just can't remember what lol. I'll try to find a resolution - not blocking merge.