xref: /webtrees/resources/views/calendar-page.phtml (revision 10e0649788c8d7d4974d81c048ca2b225df8f22e)
1a69f5655SGreg Roach<?php
2d70512abSGreg Roach
3*10e06497SGreg Roachdeclare(strict_types=1);
4*10e06497SGreg Roach
5a69f5655SGreg Roachuse Fisharebest\Webtrees\Auth;
6a69f5655SGreg Roachuse Fisharebest\Webtrees\Date;
7b00cb080SGreg Roachuse Fisharebest\Webtrees\Date\AbstractCalendarDate;
8b00cb080SGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\CalendarAction;
9b00cb080SGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\CalendarEvents;
10b00cb080SGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\CalendarPage;
11a69f5655SGreg Roachuse Fisharebest\Webtrees\I18N;
12f882f05dSGreg Roachuse Fisharebest\Webtrees\Registry;
137c2c99faSGreg Roachuse Fisharebest\Webtrees\Tree;
14d70512abSGreg Roach
15b00cb080SGreg Roach/**
16b00cb080SGreg Roach * @var string               $cal
17b00cb080SGreg Roach * @var AbstractCalendarDate $cal_date
18b00cb080SGreg Roach * @var string               $cal_month
19b00cb080SGreg Roach * @var int                  $day
20b00cb080SGreg Roach * @var int                  $days_in_month
21b00cb080SGreg Roach * @var string               $filterev
22b00cb080SGreg Roach * @var string               $filterof
23b00cb080SGreg Roach * @var string               $filtersx
24b00cb080SGreg Roach * @var int                  $month
25b00cb080SGreg Roach * @var array<string>        $months
26b00cb080SGreg Roach * @var string               $title
27b00cb080SGreg Roach * @var AbstractCalendarDate $today
28b00cb080SGreg Roach * @var string               $today_month
297c2c99faSGreg Roach * @var Tree                 $tree
30b00cb080SGreg Roach * @var string               $view
31b00cb080SGreg Roach * @var int                  $year
32b00cb080SGreg Roach */
33b00cb080SGreg Roach
34a69f5655SGreg Roach?>
35dd6b2bfcSGreg Roach
36dd6b2bfcSGreg Roach<h2 class="wt-page-title">
37dd6b2bfcSGreg Roach    <?= $title ?>
38dd6b2bfcSGreg Roach</h2>
39dd6b2bfcSGreg Roach
40dd6b2bfcSGreg Roach<table class="table-sm wt-page-options w-100" role="presentation">
41dd6b2bfcSGreg Roach    <tr>
42dd6b2bfcSGreg Roach        <th class="wt-page-options-label">
43dd6b2bfcSGreg Roach            <?= I18N::translate('Day') ?>
44dd6b2bfcSGreg Roach        </th>
45dd6b2bfcSGreg Roach        <td class="wt-page-options-value" colspan="3">
46dd6b2bfcSGreg Roach            <?php for ($d = 1; $d <= $days_in_month; $d++) : ?>
47b00cb080SGreg 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">
48dd6b2bfcSGreg Roach                    <?= (new Date($cal_date->format("%@ {$d} %O %E")))->minimumDate()->format('%j') ?>
49dd6b2bfcSGreg Roach                </a>
50dd6b2bfcSGreg Roach                |
51dd6b2bfcSGreg Roach            <?php endfor ?>
52b00cb080SGreg 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">
53dd6b2bfcSGreg Roach                <b><?php $tmp = new Date($today->format('%@ %A %O %E')); echo $tmp->display() ?></b>
54dd6b2bfcSGreg Roach            </a>
55dd6b2bfcSGreg Roach        </td>
56dd6b2bfcSGreg Roach    </tr>
57dd6b2bfcSGreg Roach    <tr>
58dd6b2bfcSGreg Roach        <th class="wt-page-options-label">
59dd6b2bfcSGreg Roach            <?= I18N::translate('Month') ?>
60dd6b2bfcSGreg Roach        </th>
61dd6b2bfcSGreg Roach        <td class="wt-page-options-value" colspan="3">
62dd6b2bfcSGreg Roach            <?php foreach ($months as $m => $month_name) : ?>
63b00cb080SGreg 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">
64dd6b2bfcSGreg Roach                    <?php if ($m === $cal_month) : ?>
65dd6b2bfcSGreg Roach                        <span class="error"><?= e($month_name) ?></span>
66dd6b2bfcSGreg Roach                    <?php else : ?>
67dd6b2bfcSGreg Roach                        <?= e($month_name) ?>
68dd6b2bfcSGreg Roach                    <?php endif ?>
69dd6b2bfcSGreg Roach                </a> |
70dd6b2bfcSGreg Roach            <?php endforeach ?>
71b00cb080SGreg 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">
72dd6b2bfcSGreg Roach                <b><?= $today->format('%F %Y') ?></b>
73dd6b2bfcSGreg Roach            </a>
74dd6b2bfcSGreg Roach        </td>
75dd6b2bfcSGreg Roach    </tr>
76dd6b2bfcSGreg Roach    <tr>
77dd6b2bfcSGreg Roach        <th class="wt-page-options-label">
78dd6b2bfcSGreg Roach            <label for="year"><?= I18N::translate('Year') ?></label>
79dd6b2bfcSGreg Roach        </th>
8040296c5fSGreg Roach
81dd6b2bfcSGreg Roach        <td class="wt-page-options-value">
82b00cb080SGreg Roach            <form method="post" action="<?= e(route(CalendarAction::class, ['tree' => $tree->name(), 'view' => $view])) ?>" class="d-inline">
8340296c5fSGreg Roach                <input type="hidden" name="cal" value="<?= e($cal) ?>">
8440296c5fSGreg Roach                <input type="hidden" name="day" value="<?= e($cal_date->day()) ?>">
8540296c5fSGreg Roach                <input type="hidden" name="month" value="<?= e($cal_month) ?>">
8640296c5fSGreg Roach                <input type="hidden" name="filtersx" value="<?= e($filtersx) ?>">
875a6ecf0cSGreg Roach                <input type="hidden" name="filterof" value="<?= e($filterof) ?>">
885a6ecf0cSGreg Roach                <input type="hidden" name="filterev" value="<?= e($filterev) ?>">
8940296c5fSGreg Roach
90b00cb080SGreg 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">
91dd6b2bfcSGreg Roach                    -1
92dd6b2bfcSGreg Roach                </a>
9340296c5fSGreg Roach
94dd6b2bfcSGreg Roach                <input type="text" id="year" name="year" value="<?= $year ?>" size="4">
9540296c5fSGreg Roach
96b00cb080SGreg 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">
97dd6b2bfcSGreg Roach                    +1
98dd6b2bfcSGreg Roach                </a>
99dd6b2bfcSGreg Roach                |
100b00cb080SGreg 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">
101dd6b2bfcSGreg Roach                    <?= $today->format('%Y') ?>
102dd6b2bfcSGreg Roach                </a>
10381443e3cSGreg Roach
10481443e3cSGreg Roach                <?= csrf_field() ?>
10540296c5fSGreg Roach            </form>
106dd6b2bfcSGreg Roach        </td>
107dd6b2bfcSGreg Roach
108dd6b2bfcSGreg Roach        <th class="wt-page-options-label">
109dd6b2bfcSGreg Roach            <?= I18N::translate('Show') ?>
110dd6b2bfcSGreg Roach        </th>
111dd6b2bfcSGreg Roach
112dd6b2bfcSGreg Roach        <td class="wt-page-options-value">
113dd6b2bfcSGreg Roach            <?php if (!$tree->getPreference('HIDE_LIVE_PEOPLE') || Auth::check()) : ?>
114b00cb080SGreg Roach            <form method="post" action="<?= e(route(CalendarAction::class, ['tree' => $tree->name(), 'view' => $view])) ?>" class="d-inline">
11540296c5fSGreg Roach                <input type="hidden" name="cal" value="<?= e($cal) ?>">
11640296c5fSGreg Roach                <input type="hidden" name="day" value="<?= e($cal_date->day()) ?>">
11740296c5fSGreg Roach                <input type="hidden" name="month" value="<?= e($cal_month) ?>">
11840296c5fSGreg Roach                <input type="hidden" name="year" value="<?= e($cal_date->year()) ?>">
11940296c5fSGreg Roach                <input type="hidden" name="filtersx" value="<?= e($filtersx) ?>">
1205a6ecf0cSGreg Roach                <input type="hidden" name="filterev" value="<?= e($filterev) ?>">
12140296c5fSGreg Roach
122b00cb080SGreg Roach                <select class="list_value" name="filterof" onchange="this.form.submit();" aria-label="<?= I18N::translate('Filter') ?>">
123dd6b2bfcSGreg Roach                    <option value="all" <?= $filterof === 'all' ? 'selected' : '' ?>>
124dd6b2bfcSGreg Roach                        <?= I18N::translate('All individuals') ?>
125dd6b2bfcSGreg Roach                    </option>
126dd6b2bfcSGreg Roach                    <option value="living" <?= $filterof === 'living' ? 'selected' : '' ?>>
127dd6b2bfcSGreg Roach                        <?= I18N::translate('Living individuals') ?>
128dd6b2bfcSGreg Roach                    </option>
129dd6b2bfcSGreg Roach                    <option value="recent" <?= $filterof === 'recent' ? 'selected' : '' ?>>
130dd6b2bfcSGreg Roach                        <?= I18N::translate('Recent years (&lt; 100 yrs)') ?>
131dd6b2bfcSGreg Roach                    </option>
132dd6b2bfcSGreg Roach                </select>
13381443e3cSGreg Roach
13481443e3cSGreg Roach                <?= csrf_field() ?>
13540296c5fSGreg Roach            </form>
136dd6b2bfcSGreg Roach            <?php endif ?>
137dd6b2bfcSGreg Roach
138b00cb080SGreg 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">
13997c22350SGreg Roach                <?php if ($filtersx === '') : ?>
14008362db4SGreg Roach                    <?= view('icons/sex', ['sex' => 'M']) ?>
14108362db4SGreg Roach                    <?= view('icons/sex', ['sex' => 'F']) ?>
14297c22350SGreg Roach                <?php else : ?>
14397c22350SGreg Roach                    <small>
14408362db4SGreg Roach                        <?= view('icons/sex', ['sex' => 'M']) ?>
14508362db4SGreg Roach                        <?= view('icons/sex', ['sex' => 'F']) ?>
14697c22350SGreg Roach                    </small>
14797c22350SGreg Roach                <?php endif ?>
148dd6b2bfcSGreg Roach            </a>
149dd6b2bfcSGreg Roach            |
150b00cb080SGreg 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">
15197c22350SGreg Roach                <?php if ($filtersx === 'M') : ?>
15208362db4SGreg Roach                    <?= view('icons/sex', ['sex' => 'M']) ?>
15397c22350SGreg Roach                <?php else : ?>
15497c22350SGreg Roach                    <small>
15508362db4SGreg Roach                        <?= view('icons/sex', ['sex' => 'M']) ?>
15697c22350SGreg Roach                    </small>
15797c22350SGreg Roach                <?php endif ?>
158dd6b2bfcSGreg Roach            </a>
159dd6b2bfcSGreg Roach            |
160b00cb080SGreg 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">
16197c22350SGreg Roach                <?php if ($filtersx === 'F') : ?>
16208362db4SGreg Roach                    <?= view('icons/sex', ['sex' => 'F']) ?>
16397c22350SGreg Roach                <?php else : ?>
16497c22350SGreg Roach                    <small>
16508362db4SGreg Roach                        <?= view('icons/sex', ['sex' => 'F']) ?>
16697c22350SGreg Roach                    </small>
16797c22350SGreg Roach                <?php endif ?>
168dd6b2bfcSGreg Roach            </a>
169dd6b2bfcSGreg Roach
170b00cb080SGreg Roach            <form method="post" action="<?= e(route(CalendarAction::class, ['tree' => $tree->name(), 'view' => $view])) ?>" class="d-inline">
17140296c5fSGreg Roach                <input type="hidden" name="cal" value="<?= e($cal) ?>">
17240296c5fSGreg Roach                <input type="hidden" name="day" value="<?= e($cal_date->day()) ?>">
17340296c5fSGreg Roach                <input type="hidden" name="month" value="<?= e($cal_month) ?>">
17440296c5fSGreg Roach                <input type="hidden" name="year" value="<?= e($cal_date->year()) ?>">
17540296c5fSGreg Roach                <input type="hidden" name="filtersx" value="<?= e($filtersx) ?>">
1765a6ecf0cSGreg Roach                <input type="hidden" name="filterof" value="<?= e($filterof) ?>">
17740296c5fSGreg Roach
178b00cb080SGreg Roach                <select class="list_value" name="filterev" onchange="this.form.submit();" aria-label="<?= I18N::translate('Events') ?>">
179dd6b2bfcSGreg Roach                    <option value="BIRT-MARR-DEAT" <?= $filterev === 'BIRT-MARR-DEAT' ? 'selected' : '' ?>>
180dd6b2bfcSGreg Roach                        <?= I18N::translate('Vital records') ?>
181dd6b2bfcSGreg Roach                    </option>
182dd6b2bfcSGreg Roach                    <option value="" <?= $filterev === '' ? 'selected' : '' ?>>
183dd6b2bfcSGreg Roach                        <?= I18N::translate('All') ?>
184dd6b2bfcSGreg Roach                    </option>
185dd6b2bfcSGreg Roach                    <option value="BIRT" <?= $filterev === 'BIRT' ? 'selected' : '' ?>>
186dd6b2bfcSGreg Roach                        <?= I18N::translate('Birth') ?>
187dd6b2bfcSGreg Roach                    </option>
188dd6b2bfcSGreg Roach                    <option value="BAPM-CHR-CHRA" <?= $filterev === 'BAPM-CHR-CHRA' ? 'selected' : '' ?>>
189dd6b2bfcSGreg Roach                        <?= I18N::translate('Baptism') ?>
190dd6b2bfcSGreg Roach                    </option>
191dd6b2bfcSGreg Roach                    <option value="MARR-_COML-_NMR" <?= $filterev === 'MARR-_COML-_NMR' ? 'selected' : '' ?>>
192dd6b2bfcSGreg Roach                        <?= I18N::translate('Marriage') ?>
193dd6b2bfcSGreg Roach                    </option>
194dd6b2bfcSGreg Roach                    <option value="DIV-_SEPR" <?= $filterev === 'DIV-_SEPR' ? 'selected' : '' ?>>
195dd6b2bfcSGreg Roach                        <?= I18N::translate('Divorce') ?>
196dd6b2bfcSGreg Roach                    </option>
197dd6b2bfcSGreg Roach                    <option value="DEAT" <?= $filterev === 'DEAT' ? 'selected' : '' ?>>
198dd6b2bfcSGreg Roach                        <?= I18N::translate('Death') ?>
199dd6b2bfcSGreg Roach                    </option>
200dd6b2bfcSGreg Roach                    <option value="BURI" <?= $filterev === 'BURI' ? 'selected' : '' ?>>
201dd6b2bfcSGreg Roach                        <?= I18N::translate('Burial') ?>
202dd6b2bfcSGreg Roach                    </option>
203dd6b2bfcSGreg Roach                    <option value="IMMI,EMIG" <?= $filterev === 'IMMI,EMIG' ? 'selected' : '' ?>>
204dd6b2bfcSGreg Roach                        <?= I18N::translate('Emigration') ?>
205dd6b2bfcSGreg Roach                    </option>
206dd6b2bfcSGreg Roach                    <option value="EVEN" <?= $filterev === 'EVEN' ? 'selected' : '' ?>>
207dd6b2bfcSGreg Roach                        <?= I18N::translate('Custom event') ?>
208dd6b2bfcSGreg Roach                    </option>
209dd6b2bfcSGreg Roach                </select>
21081443e3cSGreg Roach
21181443e3cSGreg Roach                <?= csrf_field() ?>
21240296c5fSGreg Roach            </form>
213dd6b2bfcSGreg Roach        </td>
214dd6b2bfcSGreg Roach    </tr>
215dd6b2bfcSGreg Roach</table>
216dd6b2bfcSGreg Roach
217e7f5c669SGreg Roach<table class="w-100">
218dd6b2bfcSGreg Roach    <tr>
219ae92a87bSGreg Roach        <td class="wt-page-options-value text-center">
220b00cb080SGreg 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">
221dd6b2bfcSGreg Roach                <?= I18N::translate('View this day') ?>
222dd6b2bfcSGreg Roach            </a>
223dd6b2bfcSGreg Roach            |
224b00cb080SGreg 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">
225dd6b2bfcSGreg Roach                <?= I18N::translate('View this month') ?>
226dd6b2bfcSGreg Roach            </a>
227dd6b2bfcSGreg Roach            |
228b00cb080SGreg 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">
229dd6b2bfcSGreg Roach                <?= I18N::translate('View this year') ?>
230dd6b2bfcSGreg Roach            </a>
231dd6b2bfcSGreg Roach        </td>
232ae92a87bSGreg Roach        <td class="wt-page-options-value text-center">
233dd6b2bfcSGreg Roach            <?php
234dd6b2bfcSGreg Roach                $n = 0;
235f882f05dSGreg Roach            foreach (Registry::calendarDateFactory()->supportedCalendars() as $newcal => $cal_name) {
236dd6b2bfcSGreg Roach                $tmp = $cal_date->convertToCalendar($newcal);
237dd6b2bfcSGreg Roach                if ($tmp->inValidRange()) {
238dd6b2bfcSGreg Roach                    if ($n++) {
239dd6b2bfcSGreg Roach                        echo ' | ';
240dd6b2bfcSGreg Roach                    }
241b00cb080SGreg 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>';
242dd6b2bfcSGreg Roach                }
243dd6b2bfcSGreg Roach            } ?>
244dd6b2bfcSGreg Roach        </td>
245dd6b2bfcSGreg Roach    </tr>
246dd6b2bfcSGreg Roach</table>
247dd6b2bfcSGreg Roach
248d4786c66SGreg Roach<div class="wt-ajax-load wt-page-content" data-wt-ajax-url="<?= e(route(CalendarEvents::class, ['tree' => $tree->name(), 'cal' => $cal, 'day' => $cal_date->day(), 'month' => $cal_month, 'year' => $year, 'view' => $view, 'filterev' => $filterev, 'filterof' => $filterof, 'filtersx' => $filtersx])) ?>"></div>
249dd6b2bfcSGreg Roach
250dd6b2bfcSGreg Roach<?= view('modals/ajax') ?>
251