summaryrefslogtreecommitdiff
path: root/resources/views/search-advanced-page.phtml
blob: deadee5d131dfb04a47005c80e635b1bd988f4ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php

use Fisharebest\Webtrees\Http\RequestHandlers\SearchAdvancedAction;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\Tree;
use Illuminate\Support\Collection;

/**
 * @var array<string,string>       $date_options
 * @var array<string,string>       $fields
 * @var array<string,string>       $field_labels
 * @var Collection<int,Individual> $individuals
 * @var array<string,string>       $name_options
 * @var array<string,string>       $other_fields
 * @var string                     $title
 * @var Tree                       $tree
 */

?>

<h2 class="wt-page-title">
    <?= $title ?>
</h2>

<div id="advanced-search-page">
    <form method="post" action="<?= e(route(SearchAdvancedAction::class, ['tree' => $tree->name()])) ?>" class="wt-page-options wt-page-options-search-advanced hidden-print mb-4">
        <?= csrf_field() ?>

        <div class="row form-group">
            <div class="col col-form-label wt-page-options-label">
                <?= I18N::translate('Individual') ?>
            </div>
        </div>

        <?php foreach ($fields as $field_name => $field_value) : ?>
            <?php if (!str_starts_with($field_name, 'FATHER:') && !str_starts_with($field_name, 'MOTHER:')) : ?>
                <?= view('search-advanced-field', ['field_label' => $field_labels[$field_name], 'field_name' => $field_name, 'field_value' => $field_value, 'modifier' => $modifiers[$field_name] ?? '', 'date_options' => $date_options, 'name_options' => $name_options]) ?>
            <?php endif ?>
        <?php endforeach ?>

        <div class="row form-group">
            <div class="col-sm-3 col-form-label wt-page-options-label">
                <?= I18N::translate('Add more fields') ?>
            </div>

            <div class="col-sm-3 wt-page-options-value">
                <?= view('components/select', ['name' => 'other_field', 'selected' => '', 'options' => ['' => ''] + $other_fields]) ?>
            </div>

            <div class="col-sm-3 wt-page-options-value">
                <input type="text" class="form-control" name="other_value">
            </div>

            <div class="col-sm-3 wt-page-options-value">
            </div>
        </div>

        <br>

        <div class="row form-group">
            <div class="col col-form-label wt-page-options-label">
                <?= I18N::translate('Father') ?>
            </div>
        </div>

        <?php foreach ($fields as $field_name => $field_value) : ?>
            <?php if (str_starts_with($field_name, 'FATHER:')) : ?>
                <?= view('search-advanced-field', ['field_label' => $field_labels[$field_name], 'field_name' => $field_name, 'field_value' => $field_value, 'modifier' => $modifiers[$field_name] ?? '', 'date_options' => $date_options, 'name_options' => $name_options]) ?>
            <?php endif ?>
        <?php endforeach ?>

        <br>

        <div class="row form-group">
            <div class="col col-form-label wt-page-options-label">
                <?= I18N::translate('Mother') ?>
            </div>
        </div>

        <?php foreach ($fields as $field_name => $field_value) : ?>
            <?php if (str_starts_with($field_name, 'MOTHER:')) : ?>
                <?= view('search-advanced-field', ['field_label' => $field_labels[$field_name], 'field_name' => $field_name, 'field_value' => $field_value, 'modifier' => $modifiers[$field_name] ?? '', 'date_options' => $date_options, 'name_options' => $name_options]) ?>
            <?php endif ?>
        <?php endforeach ?>

        <br>

        <div class="row form-group mb-3">
            <div class="col">
                <input type="submit" class="btn btn-primary" value="<?= /* I18N: A button label. */ I18N::translate('search') ?>">
            </div>
        </div>
    </form>
</div>

<?php if (array_filter($fields) !== []) : ?>
    <?php if ($individuals->isEmpty()) : ?>
        <div class="alert alert-info">
            <?= I18N::translate('No results found.') ?>
        </div>
    <?php else : ?>
        <?= view('search-results', ['individuals' => $individuals, 'search_families' => false, 'search_individuals' => true, 'search_locations' => false, 'search_notes' => false, 'search_sources' => false, 'search_repositories' => false, 'tree' => $tree]) ?>
    <?php endif ?>
<?php endif ?>