xref: /webtrees/resources/views/calendar-page.phtml (revision ae92a87b25505bfd2d3dc5285c0690c9b0fbd8ca)
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;
107c2c99faSGreg Roachuse Fisharebest\Webtrees\Tree;
11d70512abSGreg Roach
12b00cb080SGreg Roach/**
13b00cb080SGreg Roach * @var string               $cal
14b00cb080SGreg Roach * @var AbstractCalendarDate $cal_date
15b00cb080SGreg Roach * @var string               $cal_month
16b00cb080SGreg Roach * @var int                  $day
17b00cb080SGreg Roach * @var int                  $days_in_month
18b00cb080SGreg Roach * @var string               $filterev
19b00cb080SGreg Roach * @var string               $filterof
20b00cb080SGreg Roach * @var string               $filtersx
21b00cb080SGreg Roach * @var int                  $month
22b00cb080SGreg Roach * @var array<string>        $months
23b00cb080SGreg Roach * @var string               $title
24b00cb080SGreg Roach * @var AbstractCalendarDate $today
25b00cb080SGreg Roach * @var string               $today_month
267c2c99faSGreg Roach * @var Tree                 $tree
27b00cb080SGreg Roach * @var string               $view
28b00cb080SGreg Roach * @var int                  $year
29b00cb080SGreg Roach */
30b00cb080SGreg Roach
31a69f5655SGreg Roach?>
32dd6b2bfcSGreg Roach
33dd6b2bfcSGreg Roach<h2 class="wt-page-title">
34dd6b2bfcSGreg Roach    <?= $title ?>
35dd6b2bfcSGreg Roach</h2>
36dd6b2bfcSGreg Roach
37dd6b2bfcSGreg Roach<table class="table-sm wt-page-options w-100" role="presentation">
38dd6b2bfcSGreg Roach    <tr>
39dd6b2bfcSGreg Roach        <th class="wt-page-options-label">
40dd6b2bfcSGreg Roach            <?= I18N::translate('Day') ?>
41dd6b2bfcSGreg Roach        </th>
42dd6b2bfcSGreg Roach        <td class="wt-page-options-value" colspan="3">
43dd6b2bfcSGreg Roach            <?php for ($d = 1; $d <= $days_in_month; $d++) : ?>
44b00cb080SGreg 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">
45dd6b2bfcSGreg Roach                    <?= (new Date($cal_date->format("%@ {$d} %O %E")))->minimumDate()->format('%j') ?>
46dd6b2bfcSGreg Roach                </a>
47dd6b2bfcSGreg Roach                |
48dd6b2bfcSGreg Roach            <?php endfor ?>
49b00cb080SGreg 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">
50dd6b2bfcSGreg Roach                <b><?php $tmp = new Date($today->format('%@ %A %O %E')); echo $tmp->display() ?></b>
51dd6b2bfcSGreg Roach            </a>
52dd6b2bfcSGreg Roach        </td>
53dd6b2bfcSGreg Roach    </tr>
54dd6b2bfcSGreg Roach    <tr>
55dd6b2bfcSGreg Roach        <th class="wt-page-options-label">
56dd6b2bfcSGreg Roach            <?= I18N::translate('Month') ?>
57dd6b2bfcSGreg Roach        </th>
58dd6b2bfcSGreg Roach        <td class="wt-page-options-value" colspan="3">
59dd6b2bfcSGreg Roach            <?php foreach ($months as $m => $month_name) : ?>
60b00cb080SGreg 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">
61dd6b2bfcSGreg Roach                    <?php if ($m === $cal_month) : ?>
62dd6b2bfcSGreg Roach                        <span class="error"><?= e($month_name) ?></span>
63dd6b2bfcSGreg Roach                    <?php else : ?>
64dd6b2bfcSGreg Roach                        <?= e($month_name) ?>
65dd6b2bfcSGreg Roach                    <?php endif ?>
66dd6b2bfcSGreg Roach                </a> |
67dd6b2bfcSGreg Roach            <?php endforeach ?>
68b00cb080SGreg 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">
69dd6b2bfcSGreg Roach                <b><?= $today->format('%F %Y') ?></b>
70dd6b2bfcSGreg Roach            </a>
71dd6b2bfcSGreg Roach        </td>
72dd6b2bfcSGreg Roach    </tr>
73dd6b2bfcSGreg Roach    <tr>
74dd6b2bfcSGreg Roach        <th class="wt-page-options-label">
75dd6b2bfcSGreg Roach            <label for="year"><?= I18N::translate('Year') ?></label>
76dd6b2bfcSGreg Roach        </th>
7740296c5fSGreg Roach
78dd6b2bfcSGreg Roach        <td class="wt-page-options-value">
79b00cb080SGreg Roach            <form method="post" action="<?= e(route(CalendarAction::class, ['tree' => $tree->name(), 'view' => $view])) ?>" class="d-inline">
8040296c5fSGreg Roach                <?= csrf_field() ?>
8140296c5fSGreg Roach                <input type="hidden" name="cal" value="<?= e($cal) ?>">
8240296c5fSGreg Roach                <input type="hidden" name="day" value="<?= e($cal_date->day()) ?>">
8340296c5fSGreg Roach                <input type="hidden" name="month" value="<?= e($cal_month) ?>">
8440296c5fSGreg Roach                <input type="hidden" name="filtersx" value="<?= e($filtersx) ?>">
855a6ecf0cSGreg Roach                <input type="hidden" name="filterof" value="<?= e($filterof) ?>">
865a6ecf0cSGreg Roach                <input type="hidden" name="filterev" value="<?= e($filterev) ?>">
8740296c5fSGreg Roach
88b00cb080SGreg 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">
89dd6b2bfcSGreg Roach                    -1
90dd6b2bfcSGreg Roach                </a>
9140296c5fSGreg Roach
92dd6b2bfcSGreg Roach                <input type="text" id="year" name="year" value="<?= $year ?>" size="4">
9340296c5fSGreg Roach
94b00cb080SGreg 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">
95dd6b2bfcSGreg Roach                    +1
96dd6b2bfcSGreg Roach                </a>
97dd6b2bfcSGreg Roach                |
98b00cb080SGreg 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">
99dd6b2bfcSGreg Roach                    <?= $today->format('%Y') ?>
100dd6b2bfcSGreg Roach                </a>
10140296c5fSGreg Roach            </form>
102dd6b2bfcSGreg Roach        </td>
103dd6b2bfcSGreg Roach
104dd6b2bfcSGreg Roach        <th class="wt-page-options-label">
105dd6b2bfcSGreg Roach            <?= I18N::translate('Show') ?>
106dd6b2bfcSGreg Roach        </th>
107dd6b2bfcSGreg Roach
108dd6b2bfcSGreg Roach        <td class="wt-page-options-value">
109dd6b2bfcSGreg Roach            <?php if (!$tree->getPreference('HIDE_LIVE_PEOPLE') || Auth::check()) : ?>
110b00cb080SGreg Roach            <form method="post" action="<?= e(route(CalendarAction::class, ['tree' => $tree->name(), 'view' => $view])) ?>" class="d-inline">
11140296c5fSGreg Roach                <?= csrf_field() ?>
11240296c5fSGreg Roach                <input type="hidden" name="cal" value="<?= e($cal) ?>">
11340296c5fSGreg Roach                <input type="hidden" name="day" value="<?= e($cal_date->day()) ?>">
11440296c5fSGreg Roach                <input type="hidden" name="month" value="<?= e($cal_month) ?>">
11540296c5fSGreg Roach                <input type="hidden" name="year" value="<?= e($cal_date->year()) ?>">
11640296c5fSGreg Roach                <input type="hidden" name="filtersx" value="<?= e($filtersx) ?>">
1175a6ecf0cSGreg Roach                <input type="hidden" name="filterev" value="<?= e($filterev) ?>">
11840296c5fSGreg Roach
119b00cb080SGreg Roach                <select class="list_value" name="filterof" onchange="this.form.submit();" aria-label="<?= I18N::translate('Filter') ?>">
120dd6b2bfcSGreg Roach                    <option value="all" <?= $filterof === 'all' ? 'selected' : '' ?>>
121dd6b2bfcSGreg Roach                        <?= I18N::translate('All individuals') ?>
122dd6b2bfcSGreg Roach                    </option>
123dd6b2bfcSGreg Roach                    <option value="living" <?= $filterof === 'living' ? 'selected' : '' ?>>
124dd6b2bfcSGreg Roach                        <?= I18N::translate('Living individuals') ?>
125dd6b2bfcSGreg Roach                    </option>
126dd6b2bfcSGreg Roach                    <option value="recent" <?= $filterof === 'recent' ? 'selected' : '' ?>>
127dd6b2bfcSGreg Roach                        <?= I18N::translate('Recent years (&lt; 100 yrs)') ?>
128dd6b2bfcSGreg Roach                    </option>
129dd6b2bfcSGreg Roach                </select>
13040296c5fSGreg Roach            </form>
131dd6b2bfcSGreg Roach            <?php endif ?>
132dd6b2bfcSGreg Roach
133b00cb080SGreg 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">
13497c22350SGreg Roach                <?php if ($filtersx === '') : ?>
13508362db4SGreg Roach                    <?= view('icons/sex', ['sex' => 'M']) ?>
13608362db4SGreg Roach                    <?= view('icons/sex', ['sex' => 'F']) ?>
13797c22350SGreg Roach                <?php else : ?>
13897c22350SGreg Roach                    <small>
13908362db4SGreg Roach                        <?= view('icons/sex', ['sex' => 'M']) ?>
14008362db4SGreg Roach                        <?= view('icons/sex', ['sex' => 'F']) ?>
14197c22350SGreg Roach                    </small>
14297c22350SGreg Roach                <?php endif ?>
143dd6b2bfcSGreg Roach            </a>
144dd6b2bfcSGreg Roach            |
145b00cb080SGreg 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">
14697c22350SGreg Roach                <?php if ($filtersx === 'M') : ?>
14708362db4SGreg Roach                    <?= view('icons/sex', ['sex' => 'M']) ?>
14897c22350SGreg Roach                <?php else : ?>
14997c22350SGreg Roach                    <small>
15008362db4SGreg Roach                        <?= view('icons/sex', ['sex' => 'M']) ?>
15197c22350SGreg Roach                    </small>
15297c22350SGreg Roach                <?php endif ?>
153dd6b2bfcSGreg Roach            </a>
154dd6b2bfcSGreg Roach            |
155b00cb080SGreg 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">
15697c22350SGreg Roach                <?php if ($filtersx === 'F') : ?>
15708362db4SGreg Roach                    <?= view('icons/sex', ['sex' => 'F']) ?>
15897c22350SGreg Roach                <?php else : ?>
15997c22350SGreg Roach                    <small>
16008362db4SGreg Roach                        <?= view('icons/sex', ['sex' => 'F']) ?>
16197c22350SGreg Roach                    </small>
16297c22350SGreg Roach                <?php endif ?>
163dd6b2bfcSGreg Roach            </a>
164dd6b2bfcSGreg Roach
165b00cb080SGreg Roach            <form method="post" action="<?= e(route(CalendarAction::class, ['tree' => $tree->name(), 'view' => $view])) ?>" class="d-inline">
16640296c5fSGreg Roach                <?= csrf_field() ?>
16740296c5fSGreg Roach                <input type="hidden" name="cal" value="<?= e($cal) ?>">
16840296c5fSGreg Roach                <input type="hidden" name="day" value="<?= e($cal_date->day()) ?>">
16940296c5fSGreg Roach                <input type="hidden" name="month" value="<?= e($cal_month) ?>">
17040296c5fSGreg Roach                <input type="hidden" name="year" value="<?= e($cal_date->year()) ?>">
17140296c5fSGreg Roach                <input type="hidden" name="filtersx" value="<?= e($filtersx) ?>">
1725a6ecf0cSGreg Roach                <input type="hidden" name="filterof" value="<?= e($filterof) ?>">
17340296c5fSGreg Roach
174b00cb080SGreg Roach                <select class="list_value" name="filterev" onchange="this.form.submit();" aria-label="<?= I18N::translate('Events') ?>">
175dd6b2bfcSGreg Roach                <option value="BIRT-MARR-DEAT" <?= $filterev === 'BIRT-MARR-DEAT' ? 'selected' : '' ?>>
176dd6b2bfcSGreg Roach                    <?= I18N::translate('Vital records') ?>
177dd6b2bfcSGreg Roach                </option>
178dd6b2bfcSGreg Roach                <option value="" <?= $filterev === '' ? 'selected' : '' ?>>
179dd6b2bfcSGreg Roach                    <?= I18N::translate('All') ?>
180dd6b2bfcSGreg Roach                </option>
181dd6b2bfcSGreg Roach                <option value="BIRT" <?= $filterev === 'BIRT' ? 'selected' : '' ?>>
182dd6b2bfcSGreg Roach                    <?= I18N::translate('Birth') ?>
183dd6b2bfcSGreg Roach                </option>
184dd6b2bfcSGreg Roach                <option value="BAPM-CHR-CHRA" <?= $filterev === 'BAPM-CHR-CHRA' ? 'selected' : '' ?>>
185dd6b2bfcSGreg Roach                    <?= I18N::translate('Baptism') ?>
186dd6b2bfcSGreg Roach                </option>
187dd6b2bfcSGreg Roach                <option value="MARR-_COML-_NMR" <?= $filterev === 'MARR-_COML-_NMR' ? 'selected' : '' ?>>
188dd6b2bfcSGreg Roach                    <?= I18N::translate('Marriage') ?>
189dd6b2bfcSGreg Roach                </option>
190dd6b2bfcSGreg Roach                <option value="DIV-_SEPR" <?= $filterev === 'DIV-_SEPR' ? 'selected' : '' ?>>
191dd6b2bfcSGreg Roach                    <?= I18N::translate('Divorce') ?>
192dd6b2bfcSGreg Roach                </option>
193dd6b2bfcSGreg Roach                <option value="DEAT" <?= $filterev === 'DEAT' ? 'selected' : '' ?>>
194dd6b2bfcSGreg Roach                    <?= I18N::translate('Death') ?>
195dd6b2bfcSGreg Roach                </option>
196dd6b2bfcSGreg Roach                <option value="BURI" <?= $filterev === 'BURI' ? 'selected' : '' ?>>
197dd6b2bfcSGreg Roach                    <?= I18N::translate('Burial') ?>
198dd6b2bfcSGreg Roach                </option>
199dd6b2bfcSGreg Roach                <option value="IMMI,EMIG" <?= $filterev === 'IMMI,EMIG' ? 'selected' : '' ?>>
200dd6b2bfcSGreg Roach                    <?= I18N::translate('Emigration') ?>
201dd6b2bfcSGreg Roach                </option>
202dd6b2bfcSGreg Roach                <option value="EVEN" <?= $filterev === 'EVEN' ? 'selected' : '' ?>>
203dd6b2bfcSGreg Roach                    <?= I18N::translate('Custom event') ?>
204dd6b2bfcSGreg Roach                </option>
205dd6b2bfcSGreg Roach            </select>
20640296c5fSGreg Roach            </form>
207dd6b2bfcSGreg Roach        </td>
208dd6b2bfcSGreg Roach    </tr>
209dd6b2bfcSGreg Roach</table>
210dd6b2bfcSGreg Roach
211e7f5c669SGreg Roach<table class="w-100">
212dd6b2bfcSGreg Roach    <tr>
213*ae92a87bSGreg Roach        <td class="wt-page-options-value text-center">
214b00cb080SGreg 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">
215dd6b2bfcSGreg Roach                <?= I18N::translate('View this day') ?>
216dd6b2bfcSGreg Roach            </a>
217dd6b2bfcSGreg Roach            |
218b00cb080SGreg 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">
219dd6b2bfcSGreg Roach                <?= I18N::translate('View this month') ?>
220dd6b2bfcSGreg Roach            </a>
221dd6b2bfcSGreg Roach            |
222b00cb080SGreg 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">
223dd6b2bfcSGreg Roach                <?= I18N::translate('View this year') ?>
224dd6b2bfcSGreg Roach            </a>
225dd6b2bfcSGreg Roach        </td>
226*ae92a87bSGreg Roach        <td class="wt-page-options-value text-center">
227dd6b2bfcSGreg Roach            <?php
228dd6b2bfcSGreg Roach                $n = 0;
229dd6b2bfcSGreg Roach            foreach (Date::calendarNames() as $newcal => $cal_name) {
230dd6b2bfcSGreg Roach                $tmp = $cal_date->convertToCalendar($newcal);
231dd6b2bfcSGreg Roach                if ($tmp->inValidRange()) {
232dd6b2bfcSGreg Roach                    if ($n++) {
233dd6b2bfcSGreg Roach                        echo ' | ';
234dd6b2bfcSGreg Roach                    }
235b00cb080SGreg 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>';
236dd6b2bfcSGreg Roach                }
237dd6b2bfcSGreg Roach            } ?>
238dd6b2bfcSGreg Roach        </td>
239dd6b2bfcSGreg Roach    </tr>
240dd6b2bfcSGreg Roach</table>
241dd6b2bfcSGreg Roach
24274aba441SGreg Roach<div class="wt-ajax-load wt-page-content" data-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>
243dd6b2bfcSGreg Roach
244dd6b2bfcSGreg Roach<?= view('modals/ajax') ?>
245