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