xref: /webtrees/resources/views/admin/site-logs.phtml (revision 0115bc1678cafd957052cd2d256563ad3e242cc1)
1<?php use Fisharebest\Webtrees\Bootstrap4; ?>
2<?php use Fisharebest\Webtrees\I18N; ?>
3<?php use Fisharebest\Webtrees\View; ?>
4
5<?= view('components/breadcrumbs', ['links' => [route('admin-control-panel') => I18N::translate('Control panel'), $title]]) ?>
6
7<h1><?= $title ?></h1>
8
9<form class="form" name="logs">
10    <input type="hidden" name="route" value="admin-site-logs" id="route">
11    <input type="hidden" name="action" value="show">
12
13    <div class="row">
14        <div class="form-group col-xs-6 col-sm-3">
15            <label for="from">
16                <?= /* I18N: label for the start of a date range (from x to y) */ I18N::translate('From') ?>
17            </label>
18            <input type="date" class="form-control" id="from" max="<?= e($latest) ?>" min="<?= e($earliest) ?>" name="from" value="<?= e($from) ?>" required>
19        </div>
20
21        <div class="form-group col-xs-6 col-sm-3">
22            <label for="to">
23                <?= /* I18N: label for the end of a date range (from x to y) */ I18N::translate('To') ?>
24            </label>
25            <input type="date" class="form-control" id="to" max="<?= e($latest) ?>" min="<?= e($earliest) ?>" name="to" value="<?= e($to) ?>" required>
26        </div>
27
28        <div class="form-group col-xs-6 col-sm-2">
29            <label for="type">
30                <?= I18N::translate('Type') ?>
31            </label>
32            <?= Bootstrap4::select(['' => '', 'auth' => 'auth', 'config' => 'config', 'debug' => 'debug', 'edit' => 'edit', 'error' => 'error', 'media' => 'media', 'search' => 'search'], $type, ['id' => 'type', 'name' => 'type']) ?>
33        </div>
34
35        <div class="form-group col-xs-6 col-sm-4">
36            <label for="ip">
37                <?= I18N::translate('IP address') ?>
38            </label>
39            <input class="form-control" type="text" id="ip" name="ip" value="<?= e($ip) ?>">
40        </div>
41    </div>
42
43    <div class="row">
44        <div class="form-group col-sm-4">
45            <label for="text">
46                <?= I18N::translate('Message') ?>
47            </label>
48            <input class="form-control" type="text" id="text" name="text" value="<?= e($text) ?>">
49        </div>
50
51        <div class="form-group col-sm-4">
52            <label for="username">
53                <?= I18N::translate('User') ?>
54            </label>
55            <?= Bootstrap4::select($user_options, $username, ['id' => 'username', 'name' => 'username']) ?>
56        </div>
57
58        <div class="form-group col-sm-4">
59            <label for="gedc">
60                <?= I18N::translate('Family tree') ?>
61            </label>
62            <?= Bootstrap4::select($tree_options, $gedc, ['id' => 'gedc', 'name' => 'gedc']) ?>
63        </div>
64    </div>
65
66    <div class="text-center">
67        <button type="submit" class="btn btn-primary">
68        <?= view('icons/search') ?>
69            <?= /* I18N: A button label. */ I18N::translate('search') ?>
70        </button>
71
72        <a href="<?= e(route('admin-site-logs-export', ['from' => $from, 'to' => $to, 'type' => $type, 'text' => $text, 'ip' => $ip, 'username' => $username, 'gedc' => $gedc])) ?>" class="btn btn-primary" <?= $action === 'show' ? '' : 'disabled' ?>>
73        <?= view('icons/download') ?>
74            <?= /* I18N: A button label. */ I18N::translate('download') ?>
75        </a>
76
77        <a href="#" class="btn btn-primary" data-confirm="<?= I18N::translate('Permanently delete these records?') ?>" id="delete-button" <?= $action === 'show' ? '' : 'disabled' ?>>
78        <?= view('icons/delete') ?>
79            <?= /* I18N: A button label. */ I18N::translate('delete') ?>
80        </a>
81    </div>
82</form>
83
84<?php if ($action) : ?>
85    <table class="table table-bordered table-sm table-hover table-site-logs" data-ajax="<?= e(route('admin-site-logs-data', ['from' => $from, 'to' => $to, 'type' => $type, 'text' => $text, 'ip' => $ip, 'user' => $username, 'gedc' => $gedc])) ?>" data-server-side="true">
86        <thead>
87            <tr>
88                <th></th>
89                <th><?= I18N::translate('Timestamp') ?></th>
90                <th><?= I18N::translate('Type') ?></th>
91                <th><?= I18N::translate('Message') ?></th>
92                <th><?= I18N::translate('IP address') ?></th>
93                <th><?= I18N::translate('User') ?></th>
94                <th><?= I18N::translate('Family tree') ?></th>
95            </tr>
96        </thead>
97    </table>
98<?php endif ?>
99
100<?php View::push('javascript') ?>
101<script>
102    $("#delete-button").click(function() {
103    if (confirm(this.dataset.confirm)) {
104      var data = $(this).closest('form').serialize();
105      data.csrf = <?= json_encode(csrf_token()) ?>;
106
107      jQuery.post(
108        <?= json_encode(route('admin-site-logs-delete')) ?>,
109          data,
110        function() { document.location.reload(); }
111      )
112    }
113  });
114
115  $(".table-site-logs").dataTable( {
116    processing: true,
117    sorting: [[ 0, "desc" ]],
118    columns: [
119      /* log_id      */ { visible: false },
120      /* Timestamp   */ { sort: 0 },
121      /* Type        */ { },
122      /* message     */ { },
123      /* IP address  */ { },
124      /* User        */ { },
125      /* Family tree */ { }
126    ],
127    <?= I18N::datatablesI18N([10, 20, 50, 100, 500, 1000, -1]) ?>
128  });
129</script>
130<?php View::endpush() ?>
131