summaryrefslogtreecommitdiff
path: root/resources/views/modules/relatives/family.phtml
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@webtrees.net>2018-10-12 11:04:12 +0100
committerGreg Roach <fisharebest@webtrees.net>2018-10-12 11:15:32 +0100
commitdd6b2bfcc550270bb6d6778e11576148f71e4330 (patch)
tree9462a8eabe1103a0e79c18c521b6b4858a3fb2dc /resources/views/modules/relatives/family.phtml
parentafb591d7c8a3029b0ca03e6d185cacca3c22eb5f (diff)
downloadwebtrees-dd6b2bfcc550270bb6d6778e11576148f71e4330.tar.gz
webtrees-dd6b2bfcc550270bb6d6778e11576148f71e4330.tar.bz2
webtrees-dd6b2bfcc550270bb6d6778e11576148f71e4330.zip
Use .phtml extension for template files
Diffstat (limited to 'resources/views/modules/relatives/family.phtml')
-rw-r--r--resources/views/modules/relatives/family.phtml214
1 files changed, 214 insertions, 0 deletions
diff --git a/resources/views/modules/relatives/family.phtml b/resources/views/modules/relatives/family.phtml
new file mode 100644
index 0000000000..51727f8fc5
--- /dev/null
+++ b/resources/views/modules/relatives/family.phtml
@@ -0,0 +1,214 @@
+<?php use Fisharebest\Webtrees\Date; ?>
+<?php use Fisharebest\Webtrees\Functions\Functions; ?>
+<?php use Fisharebest\Webtrees\GedcomTag; ?>
+<?php use Fisharebest\Webtrees\I18N; ?>
+<?php use Fisharebest\Webtrees\Individual; ?>
+<?php use Fisharebest\Webtrees\Theme; ?>
+
+<table class="table table-sm wt-facts-table">
+ <caption>
+ <i class="icon-cfamily"></i>
+ <a href="<?= e($family->url()) ?>"><?= $label ?></a>
+ </caption>
+
+ <tbody>
+ <?php
+ $found = false;
+ foreach ($family->getFacts('HUSB', false, $fam_access_level) as $fact) {
+ $found |= !$fact->isPendingDeletion();
+ $person = $fact->getTarget();
+ if ($person instanceof Individual) {
+ $row_class = 'wt-gender-' . $person->getSex();
+ if ($fact->isPendingAddition()) {
+ $row_class .= ' new';
+ } elseif ($fact->isPendingDeletion()) {
+ $row_class .= ' old';
+ }
+ ?>
+ <tr class="<?= $row_class ?>">
+ <th scope="row">
+ <?= $individual === $person ? '<i class="icon-selected"></i>' : '' ?>
+ <?= Functions::getCloseRelationshipName($individual, $person) ?>
+ </th>
+ <td class="border-0 p-0">
+ <?= Theme::theme()->individualBoxLarge($person) ?>
+ </td>
+ </tr>
+ <?php
+ }
+ }
+ if (!$found && $family->canEdit()) {
+ ?>
+ <tr>
+ <th scope="row"></th>
+ <td>
+ <a href="<?= e(route('add-spouse-to-family', ['ged' => $family->getTree()->getName(), 'xref' => $family->getXref(), 'famtag' => 'HUSB'])) ?>">
+ <?= I18N::translate('Add a husband to this family') ?>
+ </a>
+ </td>
+ </tr>
+ <?php
+ }
+
+ $found = false;
+ foreach ($family->getFacts('WIFE', false, $fam_access_level) as $fact) {
+ $person = $fact->getTarget();
+ if ($person instanceof Individual) {
+ $found |= !$fact->isPendingDeletion();
+ $row_class = 'wt-gender-' . $person->getSex();
+ if ($fact->isPendingAddition()) {
+ $row_class .= ' new';
+ } elseif ($fact->isPendingDeletion()) {
+ $row_class .= ' old';
+ }
+ ?>
+
+ <tr class="<?= $row_class ?>">
+ <th scope="row">
+ <?= $individual === $person ? '<i class="icon-selected"></i>' : '' ?>
+ <?= Functions::getCloseRelationshipName($individual, $person) ?>
+ </th>
+ <td class="border-0 p-0">
+ <?= Theme::theme()->individualBoxLarge($person) ?>
+ </td>
+ </tr>
+ <?php
+ }
+ }
+ if (!$found && $family->canEdit()) { ?>
+ <tr>
+ <th scope="row"></th>
+ <td>
+ <a href="<?= e(route('add-spouse-to-family', ['ged' => $family->getTree()->getName(), 'xref' => $family->getXref(), 'famtag' => 'WIFE'])) ?>">
+ <?= I18N::translate('Add a wife to this family') ?>
+ </a>
+ </td>
+ </tr>
+
+ <?php } ?>
+
+ <?php
+ ///// MARR /////
+ $found = false;
+ $prev = new Date('');
+ foreach ($family->getFacts(WT_EVENTS_MARR . '|' . WT_EVENTS_DIV, true) as $fact) {
+ $found |= !$fact->isPendingDeletion();
+ if ($fact->isPendingAddition()) {
+ $row_class = 'new';
+ } elseif ($fact->isPendingDeletion()) {
+ $row_class = 'old';
+ } else {
+ $row_class = '';
+ }
+ ?>
+
+ <tr class="<?= $row_class ?>">
+ <th scope="row">
+ </th>
+ <td>
+ <?= GedcomTag::getLabelValue($fact->getTag(), $fact->getDate()->display() . ' — ' . $fact->getPlace()->getFullName()) ?>
+ </td>
+ </tr>
+
+ <?php
+ if (!$prev->isOK() && $fact->getDate()->isOK()) {
+ $prev = $fact->getDate();
+ }
+ }
+
+ if (!$found && $family->canShow() && $family->canEdit()) {
+ ?>
+ <tr>
+ <th scope="row">
+ </th>
+ <td>
+ <a href="<?= e(route('add-fact', ['ged' => $family->getTree()->getName(), 'xref' => $family->getXref(), 'fact' => 'MARR'])) ?>">
+ <?= I18N::translate('Add marriage details') ?>
+ </a>
+ </td>
+ </tr>
+ <?php
+ }
+
+ ///// CHIL /////
+ $child_number = 0;
+ foreach ($family->getFacts('CHIL', false, $fam_access_level) as $fact) {
+ $person = $fact->getTarget();
+ if ($person instanceof Individual) {
+ $row_class = 'wt-gender-' . $person->getSex();
+ if ($fact->isPendingAddition()) {
+ $child_number++;
+ $row_class .= ' new';
+ } elseif ($fact->isPendingDeletion()) {
+ $row_class .= ' old';
+ } else {
+ $child_number++;
+ }
+ $next = new Date('');
+ foreach ($person->getFacts(WT_EVENTS_BIRT, true) as $bfact) {
+ if ($bfact->getDate()->isOK()) {
+ $next = $bfact->getDate();
+ break;
+ }
+ }
+ ?>
+
+ <tr class="<?= $row_class ?>">
+ <th scope="row">
+ <?php if ($individual === $person) : ?>
+ <i class="icon-selected"></i>
+ <?php endif ?>
+
+ <?php if ($prev->isOK() && $next->isOK()) : ?>
+ <div class="elderdate age">
+ <?php $days = $next->maximumJulianDay() - $prev->minimumJulianDay(); ?>
+ <?php if ($days < 0 || $child_number > 1 && $days > 1 && $days < 240) : ?>
+ <i class="icon-warning"></i>
+ <?php endif ?>
+
+ <?php $months = round($days / 30); ?>
+ <?php if (abs($months) === 12 || abs($months) >= 24) : ?>
+ <?= I18N::plural('%s year', '%s years', round($months / 12), I18N::number(round($months / 12))) ?>
+ <?php elseif ($months !== 0) : ?>
+ <?= I18N::plural('%s month', '%s months', $months, I18N::number($months)) ?>
+ <?php endif ?>
+ </div>
+ <?php endif ?>
+
+ <?= Functions::getCloseRelationshipName($individual, $person) ?>
+ </th>
+ <td class="border-0 p-0">
+ <?= Theme::theme()->individualBoxLarge($person) ?>
+ </td>
+ </tr>
+ <?php
+ $prev = $next;
+ }
+ } ?>
+
+ <?php if ($family->canEdit()) : ?>
+ <tr>
+ <th scope="row">
+ <?php if (count($family->getChildren()) > 1) : ?>
+ <a href="<?= e(route('reorder-children', ['ged' => $family->getTree()->getName(), 'xref' => $family->getXref()])) ?>">
+ <i class="icon-media-shuffle"></i> <?= I18N::translate('Re-order children') ?>
+ </a>
+ <?php endif; ?>
+ </th>
+ <td>
+ <a href="<?= e(route('add-child-to-family', ['gender' => 'U', 'ged' => $family->getTree()->getName(), 'xref' => $family->getXref()])) ?>">
+ <?php if ($type == 'FAMS') : ?>
+ <?= I18N::translate('Add a son or daughter') ?>
+ <?php else : ?>
+ <?= I18N::translate('Add a brother or sister') ?>
+ <?php endif ?>
+ </a>
+
+ <a href="<?= e(route('add-child-to-family', ['gender' => 'M', 'ged' => $family->getTree()->getName(), 'xref' => $family->getXref()])) ?>" class="icon-sex_m_15x15"></a>
+
+ <a href="<?= e(route('add-child-to-family', ['gender' => 'F', 'ged' => $family->getTree()->getName(), 'xref' => $family->getXref()])) ?>" class="icon-sex_f_15x15"></a>
+ </td>
+ </tr>
+ <?php endif ?>
+ </tbody>
+</table>