xref: /webtrees/resources/views/calendar-page.phtml (revision b00cb0803076e110dca2c79f5ec82262cdba0b94)
1a69f5655SGreg Roach<?php
2d70512abSGreg Roach
3a69f5655SGreg Roachuse Fisharebest\Webtrees\Auth;
4a69f5655SGreg Roachuse Fisharebest\Webtrees\Date;
5*b00cb080SGreg Roachuse Fisharebest\Webtrees\Date\AbstractCalendarDate;
6*b00cb080SGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\CalendarAction;
7*b00cb080SGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\CalendarEvents;
8*b00cb080SGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\CalendarPage;
9a69f5655SGreg Roachuse Fisharebest\Webtrees\I18N;
10d70512abSGreg Roach
11*b00cb080SGreg Roach/**
12*b00cb080SGreg Roach * @var string               $cal
13*b00cb080SGreg Roach * @var AbstractCalendarDate $cal_date
14*b00cb080SGreg Roach * @var string               $cal_month
15*b00cb080SGreg Roach * @var int                  $day
16*b00cb080SGreg Roach * @var int                  $days_in_month
17*b00cb080SGreg Roach * @var string               $filterev
18*b00cb080SGreg Roach * @var string               $filterof
19*b00cb080SGreg Roach * @var string               $filtersx
20*b00cb080SGreg Roach * @var int                  $month
21*b00cb080SGreg Roach * @var array<string>        $months
22*b00cb080SGreg Roach * @var string               $title
23*b00cb080SGreg Roach * @var AbstractCalendarDate $today
24*b00cb080SGreg Roach * @var string               $today_month
25*b00cb080SGreg Roach * @var string               $view
26*b00cb080SGreg Roach * @var int                  $year
27*b00cb080SGreg Roach */
28*b00cb080SGreg Roach
29a69f5655SGreg Roach?>
30dd6b2bfcSGreg Roach
31dd6b2bfcSGreg Roach<h2 class="wt-page-title">
32dd6b2bfcSGreg Roach    <?= $title ?>
33dd6b2bfcSGreg Roach</h2>
34dd6b2bfcSGreg Roach
35dd6b2bfcSGreg Roach<table class="table-sm wt-page-options w-100" role="presentation">
36dd6b2bfcSGreg Roach    <tr>
37dd6b2bfcSGreg Roach        <th class="wt-page-options-label">
38dd6b2bfcSGreg Roach            <?= I18N::translate('Day') ?>
39dd6b2bfcSGreg Roach        </th>
40dd6b2bfcSGreg Roach        <td class="wt-page-options-value" colspan="3">
41dd6b2bfcSGreg Roach            <?php for ($d = 1; $d <= $days_in_month; $d++) : ?>
42*b00cb080SGreg Roach                <a <?= $d === $cal_date->day() ? 'class="error"' : '' ?> href="<?= e(route(CalendarPage::class, ['cal' => $cal, 'day' => $d, 'month' => $cal_month, 'year' => $cal_date->year(), 'filterev' => $filterev, 'filterof' => $filterof, 'filtersx' => $filtersx, 'view' => 'day', 'tree' => $tree->name()])) ?>" rel="nofollow">
43dd6b2bfcSGreg Roach                    <?= (new Date($cal_date->format("%@ {$d} %O %E")))->minimumDate()->format('%j') ?>
44dd6b2bfcSGreg Roach                </a>
45dd6b2bfcSGreg Roach                |
46dd6b2bfcSGreg Roach            <?php endfor ?>
47*b00cb080SGreg Roach            <a href="<?= e(route(CalendarPage::class, ['cal' => $cal, 'day' => $today->day(), 'month' => $today_month, 'year' => $today->year(), 'filterev' => $filterev, 'filterof' => $filterof, 'filtersx' => $filtersx, 'view' => 'day', 'tree' => $tree->name()])) ?>" rel="nofollow">
48dd6b2bfcSGreg Roach                <b><?php $tmp = new Date($today->format('%@ %A %O %E')); echo $tmp->display() ?></b>
49dd6b2bfcSGreg Roach            </a>
50dd6b2bfcSGreg Roach        </td>
51dd6b2bfcSGreg Roach    </tr>
52dd6b2bfcSGreg Roach    <tr>
53dd6b2bfcSGreg Roach        <th class="wt-page-options-label">
54dd6b2bfcSGreg Roach            <?= I18N::translate('Month') ?>
55dd6b2bfcSGreg Roach        </th>
56dd6b2bfcSGreg Roach        <td class="wt-page-options-value" colspan="3">
57dd6b2bfcSGreg Roach            <?php foreach ($months as $m => $month_name) : ?>
58*b00cb080SGreg Roach                <a href="<?= e(route(CalendarPage::class, ['cal' => $cal, 'day' => $cal_date->day(), 'month' => $m, 'year' => $cal_date->year(), 'filterev' => $filterev, 'filterof' => $filterof, 'filtersx' => $filtersx, 'view' => 'month', 'tree' => $tree->name()])) ?>" rel="nofollow">
59dd6b2bfcSGreg Roach                    <?php if ($m === $cal_month) : ?>
60dd6b2bfcSGreg Roach                        <span class="error"><?= e($month_name) ?></span>
61dd6b2bfcSGreg Roach                    <?php else : ?>
62dd6b2bfcSGreg Roach                        <?= e($month_name) ?>
63dd6b2bfcSGreg Roach                    <?php endif ?>
64dd6b2bfcSGreg Roach                </a> |
65dd6b2bfcSGreg Roach            <?php endforeach ?>
66*b00cb080SGreg Roach            <a href="<?= e(route(CalendarPage::class, ['cal' => $cal, 'day' => min($cal_date->day(), $today->daysInMonth()), 'month' => $today_month, 'year' => $today->year(), 'filterev' => $filterev, 'filterof' => $filterof, 'filtersx' => $filtersx, 'view' => 'month', 'tree' => $tree->name()])) ?>" rel="nofollow">
67dd6b2bfcSGreg Roach                <b><?= $today->format('%F %Y') ?></b>
68dd6b2bfcSGreg Roach            </a>
69dd6b2bfcSGreg Roach        </td>
70dd6b2bfcSGreg Roach    </tr>
71dd6b2bfcSGreg Roach    <tr>
72dd6b2bfcSGreg Roach        <th class="wt-page-options-label">
73dd6b2bfcSGreg Roach            <label for="year"><?= I18N::translate('Year') ?></label>
74dd6b2bfcSGreg Roach        </th>
7540296c5fSGreg Roach
76dd6b2bfcSGreg Roach        <td class="wt-page-options-value">
77*b00cb080SGreg Roach            <form method="post" action="<?= e(route(CalendarAction::class, ['tree' => $tree->name(), 'view' => $view])) ?>" class="d-inline">
7840296c5fSGreg Roach                <?= csrf_field() ?>
7940296c5fSGreg Roach                <input type="hidden" name="cal" value="<?= e($cal) ?>">
8040296c5fSGreg Roach                <input type="hidden" name="day" value="<?= e($cal_date->day()) ?>">
8140296c5fSGreg Roach                <input type="hidden" name="month" value="<?= e($cal_month) ?>">
8240296c5fSGreg Roach                <input type="hidden" name="filtersx" value="<?= e($filtersx) ?>">
835a6ecf0cSGreg Roach                <input type="hidden" name="filterof" value="<?= e($filterof) ?>">
845a6ecf0cSGreg Roach                <input type="hidden" name="filterev" value="<?= e($filterev) ?>">
8540296c5fSGreg Roach
86*b00cb080SGreg Roach                <a href="<?= e(route(CalendarPage::class, ['cal' => $cal, 'day' => $cal_date->day(), 'month' => $cal_month, 'year' => $cal_date->year() === 1 ? -1 : $cal_date->year() - 1, 'filterev' => $filterev, 'filterof' => $filterof, 'filtersx' => $filtersx, 'view' => $view, 'tree' => $tree->name()])) ?>" rel="nofollow">
87dd6b2bfcSGreg Roach                    -1
88dd6b2bfcSGreg Roach                </a>
8940296c5fSGreg Roach
90dd6b2bfcSGreg Roach                <input type="text" id="year" name="year" value="<?= $year ?>" size="4">
9140296c5fSGreg Roach
92*b00cb080SGreg Roach                <a href="<?= e(route(CalendarPage::class, ['cal' => $cal, 'day' => $cal_date->day(), 'month' => $cal_month, 'year' => $cal_date->year() === -1 ? 1 : $cal_date->year() + 1, 'filterev' => $filterev, 'filterof' => $filterof, 'filtersx' => $filtersx, 'view' => $view, 'tree' => $tree->name()])) ?>" rel="nofollow">
93dd6b2bfcSGreg Roach                    +1
94dd6b2bfcSGreg Roach                </a>
95dd6b2bfcSGreg Roach                |
96*b00cb080SGreg Roach                <a href="<?= e(route(CalendarPage::class, ['cal' => $cal, 'day' => $cal_date->day(), 'month' => $cal_month, 'year' => $today->year(), 'filterev' => $filterev, 'filterof' => $filterof, 'filtersx' => $filtersx, 'view' => $view, 'tree' => $tree->name()])) ?>" rel="nofollow">
97dd6b2bfcSGreg Roach                    <?= $today->format('%Y') ?>
98dd6b2bfcSGreg Roach                </a>
9940296c5fSGreg Roach            </form>
100dd6b2bfcSGreg Roach        </td>
101dd6b2bfcSGreg Roach
102dd6b2bfcSGreg Roach        <th class="wt-page-options-label">
103dd6b2bfcSGreg Roach            <?= I18N::translate('Show') ?>
104dd6b2bfcSGreg Roach        </th>
105dd6b2bfcSGreg Roach
106dd6b2bfcSGreg Roach        <td class="wt-page-options-value">
107dd6b2bfcSGreg Roach            <?php if (!$tree->getPreference('HIDE_LIVE_PEOPLE') || Auth::check()) : ?>
108*b00cb080SGreg Roach            <form method="post" action="<?= e(route(CalendarAction::class, ['tree' => $tree->name(), 'view' => $view])) ?>" class="d-inline">
10940296c5fSGreg Roach                <?= csrf_field() ?>
11040296c5fSGreg Roach                <input type="hidden" name="cal" value="<?= e($cal) ?>">
11140296c5fSGreg Roach                <input type="hidden" name="day" value="<?= e($cal_date->day()) ?>">
11240296c5fSGreg Roach                <input type="hidden" name="month" value="<?= e($cal_month) ?>">
11340296c5fSGreg Roach                <input type="hidden" name="year" value="<?= e($cal_date->year()) ?>">
11440296c5fSGreg Roach                <input type="hidden" name="filtersx" value="<?= e($filtersx) ?>">
1155a6ecf0cSGreg Roach                <input type="hidden" name="filterev" value="<?= e($filterev) ?>">
11640296c5fSGreg Roach
117*b00cb080SGreg Roach                <select class="list_value" name="filterof" onchange="this.form.submit();" aria-label="<?= I18N::translate('Filter') ?>">
118dd6b2bfcSGreg Roach                    <option value="all" <?= $filterof === 'all' ? 'selected' : '' ?>>
119dd6b2bfcSGreg Roach                        <?= I18N::translate('All individuals') ?>
120dd6b2bfcSGreg Roach                    </option>
121dd6b2bfcSGreg Roach                    <option value="living" <?= $filterof === 'living' ? 'selected' : '' ?>>
122dd6b2bfcSGreg Roach                        <?= I18N::translate('Living individuals') ?>
123dd6b2bfcSGreg Roach                    </option>
124dd6b2bfcSGreg Roach                    <option value="recent" <?= $filterof === 'recent' ? 'selected' : '' ?>>
125dd6b2bfcSGreg Roach                        <?= I18N::translate('Recent years (&lt; 100 yrs)') ?>
126dd6b2bfcSGreg Roach                    </option>
127dd6b2bfcSGreg Roach                </select>
12840296c5fSGreg Roach            </form>
129dd6b2bfcSGreg Roach            <?php endif ?>
130dd6b2bfcSGreg Roach
131*b00cb080SGreg Roach            <a title="<?= I18N::translate('All individuals') ?>" href="<?= e(route(CalendarPage::class, ['cal' => $cal, 'day' => $cal_date->day(), 'month' => $cal_month, 'year' => $cal_date->year(), 'filterev' => $filterev, 'filterof' => $filterof, 'filtersx' => '', 'view' => $view, 'tree' => $tree->name()])) ?>" rel="nofollow">
13297c22350SGreg Roach                <?php if ($filtersx === '') : ?>
13308362db4SGreg Roach                    <?= view('icons/sex', ['sex' => 'M']) ?>
13408362db4SGreg Roach                    <?= view('icons/sex', ['sex' => 'F']) ?>
13597c22350SGreg Roach                <?php else : ?>
13697c22350SGreg Roach                    <small>
13708362db4SGreg Roach                        <?= view('icons/sex', ['sex' => 'M']) ?>
13808362db4SGreg Roach                        <?= view('icons/sex', ['sex' => 'F']) ?>
13997c22350SGreg Roach                    </small>
14097c22350SGreg Roach                <?php endif ?>
141dd6b2bfcSGreg Roach            </a>
142dd6b2bfcSGreg Roach            |
143*b00cb080SGreg Roach            <a title="<?= I18N::translate('Males') ?>" href="<?= e(route(CalendarPage::class, ['cal' => $cal, 'day' => $cal_date->day(), 'month' => $cal_month, 'year' => $cal_date->year(), 'filterev' => $filterev, 'filterof' => $filterof, 'filtersx' => 'M', 'view' => $view, 'tree' => $tree->name()])) ?>" rel="nofollow">
14497c22350SGreg Roach                <?php if ($filtersx === 'M') : ?>
14508362db4SGreg Roach                    <?= view('icons/sex', ['sex' => 'M']) ?>
14697c22350SGreg Roach                <?php else : ?>
14797c22350SGreg Roach                    <small>
14808362db4SGreg Roach                        <?= view('icons/sex', ['sex' => 'M']) ?>
14997c22350SGreg Roach                    </small>
15097c22350SGreg Roach                <?php endif ?>
151dd6b2bfcSGreg Roach            </a>
152dd6b2bfcSGreg Roach            |
153*b00cb080SGreg Roach            <a title="<?= I18N::translate('Females') ?>" href="<?= e(route(CalendarPage::class, ['cal' => $cal, 'day' => $cal_date->day(), 'month' => $cal_month, 'year' => $cal_date->year(), 'filterev' => $filterev, 'filterof' => $filterof, 'filtersx' => 'F', 'view' => $view, 'tree' => $tree->name()])) ?>" rel="nofollow">
15497c22350SGreg Roach                <?php if ($filtersx === 'F') : ?>
15508362db4SGreg Roach                    <?= view('icons/sex', ['sex' => 'F']) ?>
15697c22350SGreg Roach                <?php else : ?>
15797c22350SGreg Roach                    <small>
15808362db4SGreg Roach                        <?= view('icons/sex', ['sex' => 'F']) ?>
15997c22350SGreg Roach                    </small>
16097c22350SGreg Roach                <?php endif ?>
161dd6b2bfcSGreg Roach            </a>
162dd6b2bfcSGreg Roach
163*b00cb080SGreg Roach            <form method="post" action="<?= e(route(CalendarAction::class, ['tree' => $tree->name(), 'view' => $view])) ?>" class="d-inline">
16440296c5fSGreg Roach                <?= csrf_field() ?>
16540296c5fSGreg Roach                <input type="hidden" name="cal" value="<?= e($cal) ?>">
16640296c5fSGreg Roach                <input type="hidden" name="day" value="<?= e($cal_date->day()) ?>">
16740296c5fSGreg Roach                <input type="hidden" name="month" value="<?= e($cal_month) ?>">
16840296c5fSGreg Roach                <input type="hidden" name="year" value="<?= e($cal_date->year()) ?>">
16940296c5fSGreg Roach                <input type="hidden" name="filtersx" value="<?= e($filtersx) ?>">
1705a6ecf0cSGreg Roach                <input type="hidden" name="filterof" value="<?= e($filterof) ?>">
17140296c5fSGreg Roach
172*b00cb080SGreg Roach                <select class="list_value" name="filterev" onchange="this.form.submit();" aria-label="<?= I18N::translate('Events') ?>">
173dd6b2bfcSGreg Roach                <option value="BIRT-MARR-DEAT" <?= $filterev === 'BIRT-MARR-DEAT' ? 'selected' : '' ?>>
174dd6b2bfcSGreg Roach                    <?= I18N::translate('Vital records') ?>
175dd6b2bfcSGreg Roach                </option>
176dd6b2bfcSGreg Roach                <option value="" <?= $filterev === '' ? 'selected' : '' ?>>
177dd6b2bfcSGreg Roach                    <?= I18N::translate('All') ?>
178dd6b2bfcSGreg Roach                </option>
179dd6b2bfcSGreg Roach                <option value="BIRT" <?= $filterev === 'BIRT' ? 'selected' : '' ?>>
180dd6b2bfcSGreg Roach                    <?= I18N::translate('Birth') ?>
181dd6b2bfcSGreg Roach                </option>
182dd6b2bfcSGreg Roach                <option value="BAPM-CHR-CHRA" <?= $filterev === 'BAPM-CHR-CHRA' ? 'selected' : '' ?>>
183dd6b2bfcSGreg Roach                    <?= I18N::translate('Baptism') ?>
184dd6b2bfcSGreg Roach                </option>
185dd6b2bfcSGreg Roach                <option value="MARR-_COML-_NMR" <?= $filterev === 'MARR-_COML-_NMR' ? 'selected' : '' ?>>
186dd6b2bfcSGreg Roach                    <?= I18N::translate('Marriage') ?>
187dd6b2bfcSGreg Roach                </option>
188dd6b2bfcSGreg Roach                <option value="DIV-_SEPR" <?= $filterev === 'DIV-_SEPR' ? 'selected' : '' ?>>
189dd6b2bfcSGreg Roach                    <?= I18N::translate('Divorce') ?>
190dd6b2bfcSGreg Roach                </option>
191dd6b2bfcSGreg Roach                <option value="DEAT" <?= $filterev === 'DEAT' ? 'selected' : '' ?>>
192dd6b2bfcSGreg Roach                    <?= I18N::translate('Death') ?>
193dd6b2bfcSGreg Roach                </option>
194dd6b2bfcSGreg Roach                <option value="BURI" <?= $filterev === 'BURI' ? 'selected' : '' ?>>
195dd6b2bfcSGreg Roach                    <?= I18N::translate('Burial') ?>
196dd6b2bfcSGreg Roach                </option>
197dd6b2bfcSGreg Roach                <option value="IMMI,EMIG" <?= $filterev === 'IMMI,EMIG' ? 'selected' : '' ?>>
198dd6b2bfcSGreg Roach                    <?= I18N::translate('Emigration') ?>
199dd6b2bfcSGreg Roach                </option>
200dd6b2bfcSGreg Roach                <option value="EVEN" <?= $filterev === 'EVEN' ? 'selected' : '' ?>>
201dd6b2bfcSGreg Roach                    <?= I18N::translate('Custom event') ?>
202dd6b2bfcSGreg Roach                </option>
203dd6b2bfcSGreg Roach            </select>
20440296c5fSGreg Roach            </form>
205dd6b2bfcSGreg Roach        </td>
206dd6b2bfcSGreg Roach    </tr>
207dd6b2bfcSGreg Roach</table>
208dd6b2bfcSGreg Roach
209e7f5c669SGreg Roach<table class="w-100">
210dd6b2bfcSGreg Roach    <tr>
21197c22350SGreg Roach        <td class="topbottombar text-center">
212*b00cb080SGreg Roach            <a class="<?= $view === 'day' ? 'error' : '' ?>" href="<?= e(route(CalendarPage::class, ['cal' => $cal, 'day' => $cal_date->day(), 'month' => $cal_month, 'year' => $cal_date->year(), 'filterev' => $filterev, 'filterof' => $filterof, 'filtersx' => $filtersx, 'view' => 'day', 'tree' => $tree->name()])) ?>" rel="nofollow">
213dd6b2bfcSGreg Roach                <?= I18N::translate('View this day') ?>
214dd6b2bfcSGreg Roach            </a>
215dd6b2bfcSGreg Roach            |
216*b00cb080SGreg Roach            <a class="<?= $view === 'month' ? 'error' : '' ?>" href="<?= e(route(CalendarPage::class, ['cal' => $cal, 'day' => $cal_date->day(), 'month' => $cal_month, 'year' => $cal_date->year(), 'filterev' => $filterev, 'filterof' => $filterof, 'filtersx' => $filtersx, 'view' => 'month', 'tree' => $tree->name()])) ?>" rel="nofollow">
217dd6b2bfcSGreg Roach                <?= I18N::translate('View this month') ?>
218dd6b2bfcSGreg Roach            </a>
219dd6b2bfcSGreg Roach            |
220*b00cb080SGreg Roach            <a class="<?= $view === 'year' ? 'error' : '' ?>" href="<?= e(route(CalendarPage::class, ['cal' => $cal, 'day' => $cal_date->day(), 'month' => $cal_month, 'year' => $cal_date->year(), 'filterev' => $filterev, 'filterof' => $filterof, 'filtersx' => $filtersx, 'view' => 'year', 'tree' => $tree->name()])) ?>" rel="nofollow">
221dd6b2bfcSGreg Roach                <?= I18N::translate('View this year') ?>
222dd6b2bfcSGreg Roach            </a>
223dd6b2bfcSGreg Roach        </td>
22497c22350SGreg Roach        <td class="topbottombar text-center">
225dd6b2bfcSGreg Roach            <?php
226dd6b2bfcSGreg Roach                $n = 0;
227dd6b2bfcSGreg Roach            foreach (Date::calendarNames() as $newcal => $cal_name) {
228dd6b2bfcSGreg Roach                $tmp = $cal_date->convertToCalendar($newcal);
229dd6b2bfcSGreg Roach                if ($tmp->inValidRange()) {
230dd6b2bfcSGreg Roach                    if ($n++) {
231dd6b2bfcSGreg Roach                        echo ' | ';
232dd6b2bfcSGreg Roach                    }
233*b00cb080SGreg Roach                    echo '<a ' . (get_class($tmp) === get_class($cal_date) ? 'class="error"' : '') . ' href="' . e(route(CalendarPage::class, ['cal' => $tmp->format('%@'), 'day' => $tmp->day(), 'month' => $tmp->format('%O'), 'year' => $tmp->year(), 'filterev' => $filterev, 'filterof' => $filterof, 'filtersx' => $filtersx, 'view' => $view, 'tree' => $tree->name()])) . '" rel="nofollow">', $cal_name, '</a>';
234dd6b2bfcSGreg Roach                }
235dd6b2bfcSGreg Roach            } ?>
236dd6b2bfcSGreg Roach        </td>
237dd6b2bfcSGreg Roach    </tr>
238dd6b2bfcSGreg Roach</table>
239dd6b2bfcSGreg Roach
240*b00cb080SGreg Roach<div class="wt-ajax-load wt-page-content" data-ajax-url="<?= e(route(CalendarEvents::class, ['tree' => $tree->name(), 'cal' => $cal, 'day' => $day, 'month' => $month, 'year' => $year, 'view' => $view, 'filterev' => $filterev, 'filterof' => $filterof, 'filtersx' => $filtersx])) ?>"></div>
241dd6b2bfcSGreg Roach
242dd6b2bfcSGreg Roach<?= view('modals/ajax') ?>
243