xref: /webtrees/resources/views/pending-changes-page.phtml (revision 2ebcf907ed34213f816592af04e6c160335d6311)
1<?php
2
3use Fisharebest\Webtrees\Http\RequestHandlers\MessagePage;
4use Fisharebest\Webtrees\Http\RequestHandlers\PendingChangesAcceptChange;
5use Fisharebest\Webtrees\Http\RequestHandlers\PendingChangesAcceptTree;
6use Fisharebest\Webtrees\Http\RequestHandlers\PendingChangesRejectChange;
7use Fisharebest\Webtrees\Http\RequestHandlers\PendingChangesRejectTree;
8use Fisharebest\Webtrees\I18N;
9use Fisharebest\Webtrees\Tree;
10
11/**
12 * @var array<array<object>> $changes
13 * @var int                  $count
14 * @var string               $title
15 * @var Tree                 $tree
16 * @var string               $url
17 */
18
19?>
20
21<h2 class="wt-page-title">
22    <?= $title ?>
23    <?php if ($count > count($changes)): ?>
24<?= I18N::translate('Showing %1$s to %2$s of %3$s', I18N::number(1), I18N::number(count($changes)), I18N::number($count)) ?>
25    <?php endif ?>
26</h2>
27
28<?php if ($changes === []) : ?>
29    <p>
30        <?= I18N::translate('There are no pending changes.') ?>
31    </p>
32    <p>
33        <a class="btn btn-primary" href="<?= e($url) ?>">
34            <?= I18N::translate('continue') ?>
35        </a>
36    </p>
37<?php endif ?>
38
39<?php foreach ($changes as $change) : ?>
40    <h3 class="pt-2">
41        <a href="<?= e($change[0]->record->url()) ?>"><?= $change[0]->record->fullName() ?></a>
42    </h3>
43
44    <table class="table table-bordered table-sm">
45        <thead class="thead-default">
46            <tr>
47                <th><?= I18N::translate('Accept') ?></th>
48                <th><?= I18N::translate('Changes') ?></th>
49                <th><?= I18N::translate('Editor') ?></th>
50                <th><?= I18N::translate('Date') ?></th>
51                <th><?= I18N::translate('Reject') ?></th>
52            </tr>
53        </thead>
54        <tbody>
55            <?php foreach ($change as $record_change) : ?>
56                <tr>
57                    <td>
58                        <button type="button" class="btn btn-primary" data-wt-post-url="<?= e(route(PendingChangesAcceptChange::class, ['tree' => $tree->name(), 'xref' => $record_change->xref, 'change' => $record_change->change_id])) ?>">
59                            <?= I18N::translate('Accept') ?>
60                        </button>
61                    </td>
62
63                    <td>
64                        <?php foreach ($record_change->record->facts() as $fact) : ?>
65                            <?php if (!str_ends_with($fact->tag(), ':CHAN') && $fact->isPendingAddition()) : ?>
66                                <div class="wt-new">
67                                    <?= strip_tags($fact->summary()) ?>
68                                </div>
69                            <?php elseif (!str_ends_with($fact->tag(), ':CHAN') && $fact->isPendingDeletion()) : ?>
70                                <div class="wt-old">
71                                    <?= strip_tags($fact->summary()) ?>
72                                </div>
73                            <?php endif ?>
74                        <?php endforeach ?>
75                    </td>
76
77                    <td>
78                        <a href="<?= e(route(MessagePage::class, ['to' => $record_change->user_name, 'subject' => I18N::translate('Pending changes') . ' - ' . strip_tags($record_change->record->fullName()), 'body' => $record_change->record->url(), 'tree' => $tree->name()])) ?>" title="<?= I18N::translate('Send a message') ?>">
79                            <?= e($record_change->real_name) ?> - <?= e($record_change->user_name) ?>
80                        </a>
81                    </td>
82
83                    <td>
84                        <?= view('components/datetime', ['timestamp' => $record_change->change_time]) ?>
85                    </td>
86
87                    <td>
88                        <button type="button" class="btn btn-secondary" data-wt-post-url="<?= e(route(PendingChangesRejectChange::class, ['tree' => $tree->name(), 'xref' => $record_change->xref, 'change' => $record_change->change_id])) ?>">
89                            <?= I18N::translate('Reject') ?>
90                        </button>
91                    </td>
92                </tr>
93            <?php endforeach ?>
94        </tbody>
95    </table>
96<?php endforeach ?>
97
98<?php if ($changes !== []) : ?>
99    <div class="d-flex justify-content-between">
100        <button type="button" class="btn btn-primary" data-wt-post-url="<?= e(route(PendingChangesAcceptTree::class, ['tree' => $tree->name(), 'n' => count($changes)])) ?>">
101            <?= I18N::translate('Accept all changes') ?>
102        </button>
103
104        <button type="button" class="btn btn-secondary" data-wt-post-url="<?= e(route(PendingChangesRejectTree::class, ['tree' => $tree->name()])) ?>" data-wt-confirm="<?= I18N::translate('Are you sure you want to reject all the changes to this family tree?') ?>">
105            <?= I18N::translate('Reject all changes') ?>
106        </button>
107    </div>
108<?php endif ?>
109