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