xref: /webtrees/resources/views/calendar-page.phtml (revision f882f05da0a9f2819b41b45c490062299137542d)
1a69f5655SGreg Roach<?php
2d70512abSGreg Roach
3a69f5655SGreg Roachuse Fisharebest\Webtrees\Auth;
4a69f5655SGreg Roachuse Fisharebest\Webtrees\Date;
5b00cb080SGreg Roachuse Fisharebest\Webtrees\Date\AbstractCalendarDate;
6b00cb080SGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\CalendarAction;
7b00cb080SGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\CalendarEvents;
8b00cb080SGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\CalendarPage;
9a69f5655SGreg Roachuse Fisharebest\Webtrees\I18N;
10*f882f05dSGreg Roachuse Fisharebest\Webtrees\Registry;
117c2c99faSGreg Roachuse Fisharebest\Webtrees\Tree;
12d70512abSGreg Roach
13b00cb080SGreg Roach/**
14b00cb080SGreg Roach * @var string               $cal
15b00cb080SGreg Roach * @var AbstractCalendarDate $cal_date
16b00cb080SGreg Roach * @var string               $cal_month
17b00cb080SGreg Roach * @var int                  $day
18b00cb080SGreg Roach * @var int                  $days_in_month
19b00cb080SGreg Roach * @var string               $filterev
20b00cb080SGreg Roach * @var string               $filterof
21b00cb080SGreg Roach * @var string               $filtersx
22b00cb080SGreg Roach * @var int                  $month
23b00cb080SGreg Roach * @var array<string>        $months
24b00cb080SGreg Roach * @var string               $title
25b00cb080SGreg Roach * @var AbstractCalendarDate $today
26b00cb080SGreg Roach * @var string               $today_month
277c2c99faSGreg Roach * @var Tree                 $tree
28b00cb080SGreg Roach * @var string               $view
29b00cb080SGreg Roach * @var int                  $year
30b00cb080SGreg Roach */
31b00cb080SGreg Roach
32a69f5655SGreg Roach?>
33dd6b2bfcSGreg Roach
34dd6b2bfcSGreg Roach<h2 class="wt-page-title">
35dd6b2bfcSGreg Roach    <?= $title ?>
36dd6b2bfcSGreg Roach</h2>
37dd6b2bfcSGreg Roach
38dd6b2bfcSGreg Roach<table class="table-sm wt-page-options w-100" role="presentation">
39dd6b2bfcSGreg Roach    <tr>
40dd6b2bfcSGreg Roach        <th class="wt-page-options-label">
41dd6b2bfcSGreg Roach            <?= I18N::translate('Day') ?>
42dd6b2bfcSGreg Roach        </th>
43dd6b2bfcSGreg Roach        <td class="wt-page-options-value" colspan="3">
44dd6b2bfcSGreg Roach            <?php for ($d = 1; $d <= $days_in_month; $d++) : ?>
45b00cb080SGreg 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">
46dd6b2bfcSGreg Roach                    <?= (new Date($cal_date->format("%@ {$d} %O %E")))->minimumDate()->format('%j') ?>
47dd6b2bfcSGreg Roach                </a>
48dd6b2bfcSGreg Roach                |
49dd6b2bfcSGreg Roach            <?php endfor ?>
50b00cb080SGreg 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">
51dd6b2bfcSGreg Roach                <b><?php $tmp = new Date($today->format('%@ %A %O %E')); echo $tmp->display() ?></b>
52dd6b2bfcSGreg Roach            </a>
53dd6b2bfcSGreg Roach        </td>
54dd6b2bfcSGreg Roach    </tr>
55dd6b2bfcSGreg Roach    <tr>
56dd6b2bfcSGreg Roach        <th class="wt-page-options-label">
57dd6b2bfcSGreg Roach            <?= I18N::translate('Month') ?>
58dd6b2bfcSGreg Roach        </th>
59dd6b2bfcSGreg Roach        <td class="wt-page-options-value" colspan="3">
60dd6b2bfcSGreg Roach            <?php foreach ($months as $m => $month_name) : ?>
61b00cb080SGreg 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">
62dd6b2bfcSGreg Roach                    <?php if ($m === $cal_month) : ?>
63dd6b2bfcSGreg Roach                        <span class="error"><?= e($month_name) ?></span>
64dd6b2bfcSGreg Roach                    <?php else : ?>
65dd6b2bfcSGreg Roach                        <?= e($month_name) ?>
66dd6b2bfcSGreg Roach                    <?php endif ?>
67dd6b2bfcSGreg Roach                </a> |
68dd6b2bfcSGreg Roach            <?php endforeach ?>
69b00cb080SGreg 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">
70dd6b2bfcSGreg Roach                <b><?= $today->format('%F %Y') ?></b>
71dd6b2bfcSGreg Roach            </a>
72dd6b2bfcSGreg Roach        </td>
73dd6b2bfcSGreg Roach    </tr>
74dd6b2bfcSGreg Roach    <tr>
75dd6b2bfcSGreg Roach        <th class="wt-page-options-label">
76dd6b2bfcSGreg Roach            <label for="year"><?= I18N::translate('Year') ?></label>
77dd6b2bfcSGreg Roach        </th>
7840296c5fSGreg Roach
79dd6b2bfcSGreg Roach        <td class="wt-page-options-value">
80b00cb080SGreg Roach            <form method="post" action="<?= e(route(CalendarAction::class, ['tree' => $tree->name(), 'view' => $view])) ?>" class="d-inline">
8140296c5fSGreg Roach                <?= csrf_field() ?>
8240296c5fSGreg Roach                <input type="hidden" name="cal" value="<?= e($cal) ?>">
8340296c5fSGreg Roach                <input type="hidden" name="day" value="<?= e($cal_date->day()) ?>">
8440296c5fSGreg Roach                <input type="hidden" name="month" value="<?= e($cal_month) ?>">
8540296c5fSGreg Roach                <input type="hidden" name="filtersx" value="<?= e($filtersx) ?>">
865a6ecf0cSGreg Roach                <input type="hidden" name="filterof" value="<?= e($filterof) ?>">
875a6ecf0cSGreg Roach                <input type="hidden" name="filterev" value="<?= e($filterev) ?>">
8840296c5fSGreg Roach
89b00cb080SGreg 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">
90dd6b2bfcSGreg Roach                    -1
91dd6b2bfcSGreg Roach                </a>
9240296c5fSGreg Roach
93dd6b2bfcSGreg Roach                <input type="text" id="year" name="year" value="<?= $year ?>" size="4">
9440296c5fSGreg Roach
95b00cb080SGreg 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">
96dd6b2bfcSGreg Roach                    +1
97dd6b2bfcSGreg Roach                </a>
98dd6b2bfcSGreg Roach                |
99b00cb080SGreg 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">
100dd6b2bfcSGreg Roach                    <?= $today->format('%Y') ?>
101dd6b2bfcSGreg Roach                </a>
10240296c5fSGreg Roach            </form>
103dd6b2bfcSGreg Roach        </td>
104dd6b2bfcSGreg Roach
105dd6b2bfcSGreg Roach        <th class="wt-page-options-label">
106dd6b2bfcSGreg Roach            <?= I18N::translate('Show') ?>
107dd6b2bfcSGreg Roach        </th>
108dd6b2bfcSGreg Roach
109dd6b2bfcSGreg Roach        <td class="wt-page-options-value">
110dd6b2bfcSGreg Roach            <?php if (!$tree->getPreference('HIDE_LIVE_PEOPLE') || Auth::check()) : ?>
111b00cb080SGreg Roach            <form method="post" action="<?= e(route(CalendarAction::class, ['tree' => $tree->name(), 'view' => $view])) ?>" class="d-inline">
11240296c5fSGreg Roach                <?= csrf_field() ?>
11340296c5fSGreg Roach                <input type="hidden" name="cal" value="<?= e($cal) ?>">
11440296c5fSGreg Roach                <input type="hidden" name="day" value="<?= e($cal_date->day()) ?>">
11540296c5fSGreg Roach                <input type="hidden" name="month" value="<?= e($cal_month) ?>">
11640296c5fSGreg Roach                <input type="hidden" name="year" value="<?= e($cal_date->year()) ?>">
11740296c5fSGreg Roach                <input type="hidden" name="filtersx" value="<?= e($filtersx) ?>">
1185a6ecf0cSGreg Roach                <input type="hidden" name="filterev" value="<?= e($filterev) ?>">
11940296c5fSGreg Roach
120b00cb080SGreg Roach                <select class="list_value" name="filterof" onchange="this.form.submit();" aria-label="<?= I18N::translate('Filter') ?>">
121dd6b2bfcSGreg Roach                    <option value="all" <?= $filterof === 'all' ? 'selected' : '' ?>>
122dd6b2bfcSGreg Roach                        <?= I18N::translate('All individuals') ?>
123dd6b2bfcSGreg Roach                    </option>
124dd6b2bfcSGreg Roach                    <option value="living" <?= $filterof === 'living' ? 'selected' : '' ?>>
125dd6b2bfcSGreg Roach                        <?= I18N::translate('Living individuals') ?>
126dd6b2bfcSGreg Roach                    </option>
127dd6b2bfcSGreg Roach                    <option value="recent" <?= $filterof === 'recent' ? 'selected' : '' ?>>
128dd6b2bfcSGreg Roach                        <?= I18N::translate('Recent years (&lt; 100 yrs)') ?>
129dd6b2bfcSGreg Roach                    </option>
130dd6b2bfcSGreg Roach                </select>
13140296c5fSGreg Roach            </form>
132dd6b2bfcSGreg Roach            <?php endif ?>
133dd6b2bfcSGreg Roach
134b00cb080SGreg 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">
13597c22350SGreg Roach                <?php if ($filtersx === '') : ?>
13608362db4SGreg Roach                    <?= view('icons/sex', ['sex' => 'M']) ?>
13708362db4SGreg Roach                    <?= view('icons/sex', ['sex' => 'F']) ?>
13897c22350SGreg Roach                <?php else : ?>
13997c22350SGreg Roach                    <small>
14008362db4SGreg Roach                        <?= view('icons/sex', ['sex' => 'M']) ?>
14108362db4SGreg Roach                        <?= view('icons/sex', ['sex' => 'F']) ?>
14297c22350SGreg Roach                    </small>
14397c22350SGreg Roach                <?php endif ?>
144dd6b2bfcSGreg Roach            </a>
145dd6b2bfcSGreg Roach            |
146b00cb080SGreg 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">
14797c22350SGreg Roach                <?php if ($filtersx === 'M') : ?>
14808362db4SGreg Roach                    <?= view('icons/sex', ['sex' => 'M']) ?>
14997c22350SGreg Roach                <?php else : ?>
15097c22350SGreg Roach                    <small>
15108362db4SGreg Roach                        <?= view('icons/sex', ['sex' => 'M']) ?>
15297c22350SGreg Roach                    </small>
15397c22350SGreg Roach                <?php endif ?>
154dd6b2bfcSGreg Roach            </a>
155dd6b2bfcSGreg Roach            |
156b00cb080SGreg 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">
15797c22350SGreg Roach                <?php if ($filtersx === 'F') : ?>
15808362db4SGreg Roach                    <?= view('icons/sex', ['sex' => 'F']) ?>
15997c22350SGreg Roach                <?php else : ?>
16097c22350SGreg Roach                    <small>
16108362db4SGreg Roach                        <?= view('icons/sex', ['sex' => 'F']) ?>
16297c22350SGreg Roach                    </small>
16397c22350SGreg Roach                <?php endif ?>
164dd6b2bfcSGreg Roach            </a>
165dd6b2bfcSGreg Roach
166b00cb080SGreg Roach            <form method="post" action="<?= e(route(CalendarAction::class, ['tree' => $tree->name(), 'view' => $view])) ?>" class="d-inline">
16740296c5fSGreg Roach                <?= csrf_field() ?>
16840296c5fSGreg Roach                <input type="hidden" name="cal" value="<?= e($cal) ?>">
16940296c5fSGreg Roach                <input type="hidden" name="day" value="<?= e($cal_date->day()) ?>">
17040296c5fSGreg Roach                <input type="hidden" name="month" value="<?= e($cal_month) ?>">
17140296c5fSGreg Roach                <input type="hidden" name="year" value="<?= e($cal_date->year()) ?>">
17240296c5fSGreg Roach                <input type="hidden" name="filtersx" value="<?= e($filtersx) ?>">
1735a6ecf0cSGreg Roach                <input type="hidden" name="filterof" value="<?= e($filterof) ?>">
17440296c5fSGreg Roach
175b00cb080SGreg Roach                <select class="list_value" name="filterev" onchange="this.form.submit();" aria-label="<?= I18N::translate('Events') ?>">
176dd6b2bfcSGreg Roach                <option value="BIRT-MARR-DEAT" <?= $filterev === 'BIRT-MARR-DEAT' ? 'selected' : '' ?>>
177dd6b2bfcSGreg Roach                    <?= I18N::translate('Vital records') ?>
178dd6b2bfcSGreg Roach                </option>
179dd6b2bfcSGreg Roach                <option value="" <?= $filterev === '' ? 'selected' : '' ?>>
180dd6b2bfcSGreg Roach                    <?= I18N::translate('All') ?>
181dd6b2bfcSGreg Roach                </option>
182dd6b2bfcSGreg Roach                <option value="BIRT" <?= $filterev === 'BIRT' ? 'selected' : '' ?>>
183dd6b2bfcSGreg Roach                    <?= I18N::translate('Birth') ?>
184dd6b2bfcSGreg Roach                </option>
185dd6b2bfcSGreg Roach                <option value="BAPM-CHR-CHRA" <?= $filterev === 'BAPM-CHR-CHRA' ? 'selected' : '' ?>>
186dd6b2bfcSGreg Roach                    <?= I18N::translate('Baptism') ?>
187dd6b2bfcSGreg Roach                </option>
188dd6b2bfcSGreg Roach                <option value="MARR-_COML-_NMR" <?= $filterev === 'MARR-_COML-_NMR' ? 'selected' : '' ?>>
189dd6b2bfcSGreg Roach                    <?= I18N::translate('Marriage') ?>
190dd6b2bfcSGreg Roach                </option>
191dd6b2bfcSGreg Roach                <option value="DIV-_SEPR" <?= $filterev === 'DIV-_SEPR' ? 'selected' : '' ?>>
192dd6b2bfcSGreg Roach                    <?= I18N::translate('Divorce') ?>
193dd6b2bfcSGreg Roach                </option>
194dd6b2bfcSGreg Roach                <option value="DEAT" <?= $filterev === 'DEAT' ? 'selected' : '' ?>>
195dd6b2bfcSGreg Roach                    <?= I18N::translate('Death') ?>
196dd6b2bfcSGreg Roach                </option>
197dd6b2bfcSGreg Roach                <option value="BURI" <?= $filterev === 'BURI' ? 'selected' : '' ?>>
198dd6b2bfcSGreg Roach                    <?= I18N::translate('Burial') ?>
199dd6b2bfcSGreg Roach                </option>
200dd6b2bfcSGreg Roach                <option value="IMMI,EMIG" <?= $filterev === 'IMMI,EMIG' ? 'selected' : '' ?>>
201dd6b2bfcSGreg Roach                    <?= I18N::translate('Emigration') ?>
202dd6b2bfcSGreg Roach                </option>
203dd6b2bfcSGreg Roach                <option value="EVEN" <?= $filterev === 'EVEN' ? 'selected' : '' ?>>
204dd6b2bfcSGreg Roach                    <?= I18N::translate('Custom event') ?>
205dd6b2bfcSGreg Roach                </option>
206dd6b2bfcSGreg Roach            </select>
20740296c5fSGreg Roach            </form>
208dd6b2bfcSGreg Roach        </td>
209dd6b2bfcSGreg Roach    </tr>
210dd6b2bfcSGreg Roach</table>
211dd6b2bfcSGreg Roach
212e7f5c669SGreg Roach<table class="w-100">
213dd6b2bfcSGreg Roach    <tr>
214ae92a87bSGreg Roach        <td class="wt-page-options-value text-center">
215b00cb080SGreg 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">
216dd6b2bfcSGreg Roach                <?= I18N::translate('View this day') ?>
217dd6b2bfcSGreg Roach            </a>
218dd6b2bfcSGreg Roach            |
219b00cb080SGreg 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">
220dd6b2bfcSGreg Roach                <?= I18N::translate('View this month') ?>
221dd6b2bfcSGreg Roach            </a>
222dd6b2bfcSGreg Roach            |
223b00cb080SGreg 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">
224dd6b2bfcSGreg Roach                <?= I18N::translate('View this year') ?>
225dd6b2bfcSGreg Roach            </a>
226dd6b2bfcSGreg Roach        </td>
227ae92a87bSGreg Roach        <td class="wt-page-options-value text-center">
228dd6b2bfcSGreg Roach            <?php
229dd6b2bfcSGreg Roach                $n = 0;
230*f882f05dSGreg Roach            foreach (Registry::calendarDateFactory()->supportedCalendars() as $newcal => $cal_name) {
231dd6b2bfcSGreg Roach                $tmp = $cal_date->convertToCalendar($newcal);
232dd6b2bfcSGreg Roach                if ($tmp->inValidRange()) {
233dd6b2bfcSGreg Roach                    if ($n++) {
234dd6b2bfcSGreg Roach                        echo ' | ';
235dd6b2bfcSGreg Roach                    }
236b00cb080SGreg 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>';
237dd6b2bfcSGreg Roach                }
238dd6b2bfcSGreg Roach            } ?>
239dd6b2bfcSGreg Roach        </td>
240dd6b2bfcSGreg Roach    </tr>
241dd6b2bfcSGreg Roach</table>
242dd6b2bfcSGreg Roach
243d4786c66SGreg 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>
244dd6b2bfcSGreg Roach
245dd6b2bfcSGreg Roach<?= view('modals/ajax') ?>
246