xref: /webtrees/resources/views/calendar-page.phtml (revision 4ff0652c9f716485ce1866f88c40897142051b8b)
1<?php
2
3use Fisharebest\Webtrees\Auth;
4use Fisharebest\Webtrees\Date;
5use Fisharebest\Webtrees\Date\AbstractCalendarDate;
6use Fisharebest\Webtrees\Http\RequestHandlers\CalendarAction;
7use Fisharebest\Webtrees\Http\RequestHandlers\CalendarEvents;
8use Fisharebest\Webtrees\Http\RequestHandlers\CalendarPage;
9use Fisharebest\Webtrees\I18N;
10use Fisharebest\Webtrees\Registry;
11use Fisharebest\Webtrees\Tree;
12
13/**
14 * @var string               $cal
15 * @var AbstractCalendarDate $cal_date
16 * @var string               $cal_month
17 * @var int                  $day
18 * @var int                  $days_in_month
19 * @var string               $filterev
20 * @var string               $filterof
21 * @var string               $filtersx
22 * @var int                  $month
23 * @var array<string>        $months
24 * @var string               $title
25 * @var AbstractCalendarDate $today
26 * @var string               $today_month
27 * @var Tree                 $tree
28 * @var string               $view
29 * @var int                  $year
30 */
31
32?>
33
34<h2 class="wt-page-title">
35    <?= $title ?>
36</h2>
37
38<table class="table-sm wt-page-options w-100" role="presentation">
39    <tr>
40        <th class="wt-page-options-label">
41            <?= I18N::translate('Day') ?>
42        </th>
43        <td class="wt-page-options-value" colspan="3">
44            <?php for ($d = 1; $d <= $days_in_month; $d++) : ?>
45                <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">
46                    <?= (new Date($cal_date->format("%@ {$d} %O %E")))->minimumDate()->format('%j') ?>
47                </a>
48                |
49            <?php endfor ?>
50            <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">
51                <b><?php $tmp = new Date($today->format('%@ %A %O %E')); echo $tmp->display() ?></b>
52            </a>
53        </td>
54    </tr>
55    <tr>
56        <th class="wt-page-options-label">
57            <?= I18N::translate('Month') ?>
58        </th>
59        <td class="wt-page-options-value" colspan="3">
60            <?php foreach ($months as $m => $month_name) : ?>
61                <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">
62                    <?php if ($m === $cal_month) : ?>
63                        <span class="error"><?= e($month_name) ?></span>
64                    <?php else : ?>
65                        <?= e($month_name) ?>
66                    <?php endif ?>
67                </a> |
68            <?php endforeach ?>
69            <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">
70                <b><?= $today->format('%F %Y') ?></b>
71            </a>
72        </td>
73    </tr>
74    <tr>
75        <th class="wt-page-options-label">
76            <label for="year"><?= I18N::translate('Year') ?></label>
77        </th>
78
79        <td class="wt-page-options-value">
80            <form method="post" action="<?= e(route(CalendarAction::class, ['tree' => $tree->name(), 'view' => $view])) ?>" class="d-inline">
81                <?= csrf_field() ?>
82                <input type="hidden" name="cal" value="<?= e($cal) ?>">
83                <input type="hidden" name="day" value="<?= e($cal_date->day()) ?>">
84                <input type="hidden" name="month" value="<?= e($cal_month) ?>">
85                <input type="hidden" name="filtersx" value="<?= e($filtersx) ?>">
86                <input type="hidden" name="filterof" value="<?= e($filterof) ?>">
87                <input type="hidden" name="filterev" value="<?= e($filterev) ?>">
88
89                <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">
90                    -1
91                </a>
92
93                <input type="text" id="year" name="year" value="<?= $year ?>" size="4">
94
95                <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">
96                    +1
97                </a>
98                |
99                <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">
100                    <?= $today->format('%Y') ?>
101                </a>
102            </form>
103        </td>
104
105        <th class="wt-page-options-label">
106            <?= I18N::translate('Show') ?>
107        </th>
108
109        <td class="wt-page-options-value">
110            <?php if (!$tree->getPreference('HIDE_LIVE_PEOPLE') || Auth::check()) : ?>
111            <form method="post" action="<?= e(route(CalendarAction::class, ['tree' => $tree->name(), 'view' => $view])) ?>" class="d-inline">
112                <?= csrf_field() ?>
113                <input type="hidden" name="cal" value="<?= e($cal) ?>">
114                <input type="hidden" name="day" value="<?= e($cal_date->day()) ?>">
115                <input type="hidden" name="month" value="<?= e($cal_month) ?>">
116                <input type="hidden" name="year" value="<?= e($cal_date->year()) ?>">
117                <input type="hidden" name="filtersx" value="<?= e($filtersx) ?>">
118                <input type="hidden" name="filterev" value="<?= e($filterev) ?>">
119
120                <select class="list_value" name="filterof" onchange="this.form.submit();" aria-label="<?= I18N::translate('Filter') ?>">
121                    <option value="all" <?= $filterof === 'all' ? 'selected' : '' ?>>
122                        <?= I18N::translate('All individuals') ?>
123                    </option>
124                    <option value="living" <?= $filterof === 'living' ? 'selected' : '' ?>>
125                        <?= I18N::translate('Living individuals') ?>
126                    </option>
127                    <option value="recent" <?= $filterof === 'recent' ? 'selected' : '' ?>>
128                        <?= I18N::translate('Recent years (&lt; 100 yrs)') ?>
129                    </option>
130                </select>
131            </form>
132            <?php endif ?>
133
134            <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">
135                <?php if ($filtersx === '') : ?>
136                    <?= view('icons/sex', ['sex' => 'M']) ?>
137                    <?= view('icons/sex', ['sex' => 'F']) ?>
138                <?php else : ?>
139                    <small>
140                        <?= view('icons/sex', ['sex' => 'M']) ?>
141                        <?= view('icons/sex', ['sex' => 'F']) ?>
142                    </small>
143                <?php endif ?>
144            </a>
145            |
146            <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">
147                <?php if ($filtersx === 'M') : ?>
148                    <?= view('icons/sex', ['sex' => 'M']) ?>
149                <?php else : ?>
150                    <small>
151                        <?= view('icons/sex', ['sex' => 'M']) ?>
152                    </small>
153                <?php endif ?>
154            </a>
155            |
156            <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">
157                <?php if ($filtersx === 'F') : ?>
158                    <?= view('icons/sex', ['sex' => 'F']) ?>
159                <?php else : ?>
160                    <small>
161                        <?= view('icons/sex', ['sex' => 'F']) ?>
162                    </small>
163                <?php endif ?>
164            </a>
165
166            <form method="post" action="<?= e(route(CalendarAction::class, ['tree' => $tree->name(), 'view' => $view])) ?>" class="d-inline">
167                <?= csrf_field() ?>
168                <input type="hidden" name="cal" value="<?= e($cal) ?>">
169                <input type="hidden" name="day" value="<?= e($cal_date->day()) ?>">
170                <input type="hidden" name="month" value="<?= e($cal_month) ?>">
171                <input type="hidden" name="year" value="<?= e($cal_date->year()) ?>">
172                <input type="hidden" name="filtersx" value="<?= e($filtersx) ?>">
173                <input type="hidden" name="filterof" value="<?= e($filterof) ?>">
174
175                <select class="list_value" name="filterev" onchange="this.form.submit();" aria-label="<?= I18N::translate('Events') ?>">
176                <option value="BIRT-MARR-DEAT" <?= $filterev === 'BIRT-MARR-DEAT' ? 'selected' : '' ?>>
177                    <?= I18N::translate('Vital records') ?>
178                </option>
179                <option value="" <?= $filterev === '' ? 'selected' : '' ?>>
180                    <?= I18N::translate('All') ?>
181                </option>
182                <option value="BIRT" <?= $filterev === 'BIRT' ? 'selected' : '' ?>>
183                    <?= I18N::translate('Birth') ?>
184                </option>
185                <option value="BAPM-CHR-CHRA" <?= $filterev === 'BAPM-CHR-CHRA' ? 'selected' : '' ?>>
186                    <?= I18N::translate('Baptism') ?>
187                </option>
188                <option value="MARR-_COML-_NMR" <?= $filterev === 'MARR-_COML-_NMR' ? 'selected' : '' ?>>
189                    <?= I18N::translate('Marriage') ?>
190                </option>
191                <option value="DIV-_SEPR" <?= $filterev === 'DIV-_SEPR' ? 'selected' : '' ?>>
192                    <?= I18N::translate('Divorce') ?>
193                </option>
194                <option value="DEAT" <?= $filterev === 'DEAT' ? 'selected' : '' ?>>
195                    <?= I18N::translate('Death') ?>
196                </option>
197                <option value="BURI" <?= $filterev === 'BURI' ? 'selected' : '' ?>>
198                    <?= I18N::translate('Burial') ?>
199                </option>
200                <option value="IMMI,EMIG" <?= $filterev === 'IMMI,EMIG' ? 'selected' : '' ?>>
201                    <?= I18N::translate('Emigration') ?>
202                </option>
203                <option value="EVEN" <?= $filterev === 'EVEN' ? 'selected' : '' ?>>
204                    <?= I18N::translate('Custom event') ?>
205                </option>
206            </select>
207            </form>
208        </td>
209    </tr>
210</table>
211
212<table class="w-100">
213    <tr>
214        <td class="wt-page-options-value text-center">
215            <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">
216                <?= I18N::translate('View this day') ?>
217            </a>
218            |
219            <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">
220                <?= I18N::translate('View this month') ?>
221            </a>
222            |
223            <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">
224                <?= I18N::translate('View this year') ?>
225            </a>
226        </td>
227        <td class="wt-page-options-value text-center">
228            <?php
229                $n = 0;
230            foreach (Registry::calendarDateFactory()->supportedCalendars() as $newcal => $cal_name) {
231                $tmp = $cal_date->convertToCalendar($newcal);
232                if ($tmp->inValidRange()) {
233                    if ($n++) {
234                        echo ' | ';
235                    }
236                    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>';
237                }
238            } ?>
239        </td>
240    </tr>
241</table>
242
243<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>
244
245<?= view('modals/ajax') ?>
246