Skip to content
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

Moved saluation utlity to ORM #2115

Merged
merged 1 commit into from
Mar 15, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion src/ChurchCRM/model/ChurchCRM/Family.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,48 @@ private function createTimeLineNote($new)

$note->save();
}

/**
* Figure out how to address a family for correspondence.
*
* Put the name if there is only one individual in the family.
* Put two first names and the last name when there are exactly two people in the family
* (e.g. "Nathaniel and Jeanette Brooks").
* Put two whole names where there are exactly two people with different names
* (e.g. "Doug Philbrook and Karen Andrews")
* When there are more than two people in the family I don't have any way to know
* which people are children, so I would have to just use the family name (e.g. "Grossman Family").
*
* @return string
*/
public function getSaluation()
{
$childRoleId = SystemConfig::getValue("sDirRoleChild");
$people = $this->getPeople();
$notChildren = null;
foreach ($people as $person) {
if ($person->getFmrId() != $childRoleId) {
$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());
return $photo;
}
Expand Down