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