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