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