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