8 isset(
$user) or require
$_SERVER[
'DOCUMENT_ROOT'] .
'/page/404.php';
10 if (!in_array($_GET[
'table'], Wrong\Database\Controller::$tables)) {
11 exit(
'<script>errorToast("Ошибка!");</script>');
16 'owner_group' => array_map(
'strval', array_column(Wrong\Rights\Group::$groups_owners,
'id')),
17 'groups' => array_map(
'strval', array_column(Wrong\Rights\Group::$groups_not_system,
'id'))
20 if ($_GET[
'table'] ==
'templates') {
21 $template_types = [
'page',
'incode',
'modal',
'select',
'action'];
22 $initial[
'type'] = array_map(
'strval', array_keys($template_types));
29 <div
class=
"modal fade" id=
"<?= $basename ?>" tabindex=
"-1" data-backdrop=
"static">
30 <div
class=
"modal-dialog modal-dialog-centered" role=
"document">
31 <div
class=
"modal-content">
32 <div
class=
"modal-header">
33 <h5
class=
"modal-title"><i
class=
"fa fa-filter mr-2"></i>Фильтр
"<?= $dbh->query("SHOW TABLE STATUS WHERE Name =
'{$_GET['table
']}'")->fetch()->Comment ?>"</h5>
34 <button type=
"button" class=
"close" data-dismiss=
"modal" aria-label=
"Close">
35 <span aria-hidden=
"true">×</span>
38 <div
class=
"modal-body pt-2">
39 <form action=
"<?= Wrong\Models\Actions::find(41)->request ?>">
40 <input type=
"hidden" name=
"table" value=
"<?= $_GET['table'] ?>">
41 <div
class=
"border px-2 py-1 rounded bg-light-info">
42 <div
class=
"custom-control custom-checkbox small">
43 <input type=
"checkbox" name=
"act[0]" value=
"0" class=
"custom-control-input" id=
"check-group-0">
44 <label
class=
"custom-control-label" for=
"check-group-0">Не активные</label>
46 <div
class=
"custom-control custom-checkbox small">
47 <input type=
"checkbox" name=
"act[1]" value=
"1" class=
"custom-control-input" id=
"check-group-1">
48 <label
class=
"custom-control-label" for=
"check-group-1">Активные</label>
51 <?php
if ($_GET[
'table'] ==
'templates') : ?>
52 <div
class=
"border px-2 py-1 rounded bg-light-info masscheck mt-2">
53 <small>Типы шаблонов <a onclick=
"if(~~this.dataset.checked){$(this).html('отметить все');this.dataset.checked=0;$(this).parents('form').find('[name^=type]').prop('checked', false);}else{$(this).html('снять все');this.dataset.checked=1;$(this).parents('form').find('[name^=type]').prop('checked', true);}$('#<?= $basename ?> form').trigger('change');return false;" href=
"#"></a></small>
56 echo
'<div class="custom-control custom-checkbox small">
57 <input type="checkbox" name="type[' . $key .
']" value="' . $key .
'" class="custom-control-input" id="check-type-' . $key .
'">
58 <label class="custom-control-label" for="check-type-' . $key .
'">' . $template_types[$key] .
'</label>
64 <div
class=
"border px-2 py-1 rounded bg-light-info masscheck mt-2">
65 <small>Группа владелец <a onclick=
"if(~~this.dataset.checked){$(this).html('отметить все');this.dataset.checked=0;$(this).parents('form').find('[name^=owner_group]').prop('checked', false);}else{$(this).html('снять все');this.dataset.checked=1;$(this).parents('form').find('[name^=owner_group]').prop('checked', true);}$('#<?= $basename ?> form').trigger('change');return false;" href=
"#"></a></small>
67 foreach (Wrong\Rights\Group::$groups_owners as $row) {
68 echo
'<div class="custom-control custom-checkbox small">
69 <input type="checkbox" name="owner_group[' . $row->id .
']" value="' . $row->id .
'" class="custom-control-input" id="check-owner_group-' . $row->id .
'">
70 <label class="custom-control-label" for="check-owner_group-' . $row->id .
'">' .
Wrong\Rights\Group::text($row->id) .
'</label>
75 <div
class=
"border px-2 py-1 rounded bg-light-info masscheck mt-2 <?= in_array($_GET['table'], ['crontabs', 'groups']) ? 'd-none' : '' ?>">
76 <small>Группы доступа <a onclick=
"if(~~this.dataset.checked){$(this).html('отметить все');this.dataset.checked=0;$(this).parents('form').find('[name^=groups]').prop('checked', false);}else{$(this).html('снять все');this.dataset.checked=1;$(this).parents('form').find('[name^=groups]').prop('checked', true);}$('#<?= $basename ?> form').trigger('change');return false;" href=
"#"></a></small>
78 foreach (Wrong\Rights\Group::$groups_not_system as $row) {
79 echo
'<div class="custom-control custom-checkbox small">
80 <input type="checkbox" name="groups[' . $row->id .
']" value="' . $row->id .
'" class="custom-control-input" id="check-groups-' . $row->id .
'">
81 <label class="custom-control-label" for="check-groups-' . $row->id .
'">' .
Wrong\Rights\Group::text($row->id) .
'</label>
92 let filter = <?= json_encode(
$filter) ?>;
93 for (let key in filter) {
94 filter[key].forEach(el => {
95 $(
'#<?= $basename ?> [name="' + key +
'[' + el +
']"]').prop(
'checked',
true);
99 $(
"#<?= $basename ?> .masscheck").each(
function() {
100 if ($(
this).find(
'input[type=checkbox]').not(
':checked').length) {
101 $(
this).find(
'a').html(
'отметить все');
102 $(
this).find(
'a')[0].dataset.checked = 0;
104 $(
this).find(
'a').html(
'снять все');
105 $(
this).find(
'a')[0].dataset.checked = 1;
110 $(
"#<?= $basename ?> form").change(
function() {
111 $(
this).trigger(
'submit');
114 function isEqual(object1, object2) {
115 const props1 = Object.getOwnPropertyNames(object1);
116 const props2 = Object.getOwnPropertyNames(object2);
118 if (props1.length !== props2.length) {
122 for (let i = 0; i < props1.length; i += 1) {
123 const prop = props1[i];
124 const bothAreObjects = typeof(object1[prop]) ===
'object' && typeof(object2[prop]) ===
'object';
126 if ((!bothAreObjects && (object1[prop] !== object2[prop])) ||
127 (bothAreObjects && !isEqual(object1[prop], object2[prop]))) {
135 $(
"#<?= $basename ?> form").submit(
function(e) {
139 url: $(
this).attr(
"action"),
140 data: $(
this).serialize(),
148 if (response.error) {
149 errorToast(response.error);
152 if (!isEqual(response.filter, <?= json_encode(
$initial) ?>)) {
153 $(
'#reset-filter').show();
154 $(
'.toast').toast(
'hide');
155 successToast(response.message);
157 $(
'#reset-filter').trigger(
'click');
158 $(
'#reset-filter').hide();
160 $(
'.dataTable').DataTable().ajax.reload(
null,
false);
setcookie('FROM_UID', $uid, [ 'expires'=> time()+31536000, 'path'=> '/', 'domain'=> $_SERVER['HTTP_HOST'], 'secure'=> Wrong\Start\Env::$e->IS_SECURE, 'httponly'=> false, 'samesite'=> Wrong\Start\Env::$e->IS_SECURE ? 'None' :'Lax']) or setcookie('FROM_UID' $_SERVER['HTTP_HOST']
if(($dbh=Connect::getInstance(true) ->dbh) && $dbh->query("SHOW TABLES") ->fetchAll() && $dbh->query("SELECT COUNT(*) FROM `users`") ->fetchColumn()) if(!empty($_POST)) exit
this parents( 'form').find(' endif[name^ foreach($initial['type'] as $key)
if(!in_array($_GET['table'], Wrong\Database\Controller::$tables)) $initial
if($_GET['table']=='templates') $filter