xref: /webtrees/resources/views/search-general-page.phtml (revision b2000e41e11e639ec77e52c58e48ae0ed90443f4)
1<?php
2
3use Fisharebest\Webtrees\Http\RequestHandlers\SearchGeneralAction;
4use Fisharebest\Webtrees\I18N;
5use Fisharebest\Webtrees\Tree;
6
7/**
8 * @var array<Tree>                                                      $all_trees
9 * @var \Illuminate\Support\Collection<\Fisharebest\Webtrees\Family>     $families
10 * @var \Illuminate\Support\Collection<\Fisharebest\Webtrees\Individual> $individuals
11 * @var \Illuminate\Support\Collection<\Fisharebest\Webtrees\Note>       $notes
12 * @var string                                                           $query
13 * @var \Illuminate\Support\Collection<\Fisharebest\Webtrees\Repository> $repositories
14 * @var \Illuminate\Support\Collection<\Fisharebest\Webtrees\Source>     $sources
15 * @var bool                                                             $search_families
16 * @var bool                                                             $search_individuals
17 * @var bool                                                             $search_notes
18 * @var bool                                                             $search_repositories
19 * @var bool                                                             $search_sources
20 * @var array<Tree>                                                      $search_trees
21 * @var string                                                           $title
22 * @var Tree                                                             $tree
23 */
24
25?>
26
27<h2 class="wt-page-title">
28    <?= $title ?>
29</h2>
30
31<form method="post" action="<?= e(route(SearchGeneralAction::class, ['tree' => $tree->name()])) ?>"
32      class="wt-page-options wt-page-options-search hidden-print mb-4" name="searchform">
33    <?= csrf_field() ?>
34    <div class="row form-group">
35        <label class="col-sm-3 col-form-label wt-page-options-label" for="query">
36            <?= I18N::translate('Search for') ?>
37        </label>
38        <div class="col-sm-9 wt-page-options-value">
39            <div class="input-group">
40                <input id="query" class="form-control" type="text" name="query" value="<?= e($query) ?>" required="required">
41                <?= view('edit/input-addon-keyboard', ['id' => 'query']) ?>
42            </div>
43        </div>
44    </div>
45    <fieldset class="form-group">
46        <div class="row">
47            <label class="col-sm-3 col-form-label wt-page-options-label">
48                <?= I18N::translate('Records') ?>
49            </label>
50            <div class="col-sm-9 wt-page-options-value">
51                <div class="form-check form-check-inline">
52                    <label class="form-check-label">
53                        <input class="form-check-input" <?= $search_individuals ? 'checked' : '' ?>
54                               name="search_individuals" type="checkbox">
55                        <?= I18N::translate('Individuals') ?>
56                    </label>
57                </div>
58
59                <div class="form-check form-check-inline">
60                    <label class="form-check-label">
61                        <input class="form-check-input" <?= $search_families ? 'checked' : '' ?> name="search_families"
62                               type="checkbox">
63                        <?= I18N::translate('Families') ?>
64                    </label>
65                </div>
66
67                <div class="form-check form-check-inline">
68                    <label class="form-check-label">
69                        <input class="form-check-input" <?= $search_sources ? 'checked' : '' ?> name="search_sources"
70                               type="checkbox">
71                        <?= I18N::translate('Sources') ?>
72                    </label>
73                </div>
74
75                <div class="form-check form-check-inline">
76                    <label class="form-check-label">
77                        <input class="form-check-input" <?= $search_repositories ? 'checked' : '' ?>
78                               name="search_repositories" type="checkbox">
79                        <?= I18N::translate('Repositories') ?>
80                    </label>
81                </div>
82
83                <div class="form-check form-check-inline">
84                    <label class="form-check-label">
85                        <input class="form-check-input" <?= $search_notes ? 'checked' : '' ?> name="search_notes"
86                               type="checkbox">
87                        <?= I18N::translate('Shared notes') ?>
88                    </label>
89                </div>
90            </div>
91        </div>
92    </fieldset>
93
94    <?php if (count($all_trees) > 1) : ?>
95        <fieldset class="form-group">
96            <div class="row">
97                <label class="col-sm-3 col-form-label wt-page-options-label">
98                    <?= I18N::translate('Family trees') ?>
99                </label>
100                <div class="col-sm-9 wt-page-options-value pt-2">
101                    <div class="d-flex justify-content-between">
102                        <div id="search-trees" class="form-check">
103                            <?php foreach ($all_trees as $tree) : ?>
104                                <div class="col px-0">
105                                    <label class="form-check-label">
106                                        <input class="form-check form-check-input"
107                                               type="checkbox" <?= in_array($tree, $search_trees, true) ? 'checked' : '' ?>
108                                               value="<?= $tree->name() ?>" name="search_trees[]">
109                                        <?= e($tree->title()) ?>
110                                    </label>
111                                </div>
112                            <?php endforeach ?>
113                        </div>
114                        <?php if (count($all_trees) > 3) : ?>
115                            <div class="d-row align-self-end mb-2">
116                                <input type="button" class="btn btn-sm btn-secondary mx-1"
117                                       value="<?= /* I18N: select all (of the family trees) */
118                                       I18N::translate('select all') ?>"
119                                       onclick="$('#search-trees :checkbox').each(function(){$(this).attr('checked', true);});return false;">
120                                <input type="button" class="btn btn-sm btn-secondary mx-1"
121                                       value="<?= /* I18N: select none (of the family trees) */
122                                       I18N::translate('select none') ?>"
123                                       onclick="$('#search-trees :checkbox').each(function(){$(this).attr('checked', false);});return false;">
124                                <?php if (count($all_trees) > 10) : ?>
125                                    <input type="button" value="<?= I18N::translate('invert selection') ?>"
126                                           onclick="$('#search-trees :checkbox').each(function(){$(this).attr('checked', !$(this).attr('checked'));});return false;">
127                                <?php endif ?>
128                            </div>
129                        <?php endif ?>
130                    </div>
131                </div>
132            </div>
133        </fieldset>
134    <?php endif ?>
135
136    <div class="row form-group">
137        <label class="col-sm-3 col-form-label wt-page-options-label"></label>
138        <div class="col-sm-9 wt-page-options-value">
139            <input type="submit" class="btn btn-primary" value="<?= /* I18N: A button label. */
140            I18N::translate('search') ?>">
141        </div>
142    </div>
143</form>
144
145<?php if ($query !== '') : ?>
146    <?php if ($individuals->isEmpty() && $families->isEmpty() && $repositories->isEmpty() && $sources->isEmpty() && $notes->isEmpty()) : ?>
147        <div class="alert alert-info row">
148            <?= I18N::translate('No results found.') ?>
149        </div>
150    <?php else : ?>
151        <?= view('search-results', ['families' => $families, 'individuals' => $individuals, 'notes' => $notes, 'repositories' => $repositories, 'sources' => $sources, 'search_families' => $search_families, 'search_individuals' => $search_individuals, 'search_notes' => $search_notes, 'search_repositories' => $search_repositories, 'search_sources' => $search_sources, 'tree' => $tree]) ?>
152    <?php endif ?>
153<?php endif ?>
154
155<?= view('modals/on-screen-keyboard') ?>
156