270 lines
9.9 KiB
PHP
270 lines
9.9 KiB
PHP
<div class="row">
|
|
<div class="col-lg-4">
|
|
<div class="panel panel-flat">
|
|
<div class="jumbotron" style="background-color:#F3DFE5; padding:10px;">
|
|
<?php if ($msg) { ?>
|
|
<div class="col-12">
|
|
<div class="alert alert-danger alert-dismissible bg-danger text-white border-0" role="alert">
|
|
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
|
<span aria-hidden="true">×</span>
|
|
</button>
|
|
<?php echo $msg ? $msg : '' ?>
|
|
</div>
|
|
</div>
|
|
<?php } ?>
|
|
<font id="message" color=red></font>
|
|
<h3>ACL ADDING</h3>
|
|
<form id="acl-form" name="acl-form" method="post" action="create" autocomplete="off">
|
|
<div class="form-group">
|
|
<label for="class_name">Controller</lrbel>
|
|
<?= $controller_name ?>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="address">Method</label>
|
|
<select class="form-control" name="method_name"></select>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="plevel">Permission</label>
|
|
<?= $permission_level ?>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<button type="submit" id="btn-add" class="btn btn-info btn-block btn-sm">Add</button>
|
|
<button type="button" id="btn-update" class="btn btn-info btn-block btn-sm hidden">Update</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-lg-8">
|
|
<div class="panel panel-white">
|
|
<form class="search-block" method="GET" autocomplete="off">
|
|
<div class="search-block-item">
|
|
<div class="form-group">
|
|
<label for="card_class_filter">Class</label>
|
|
<?= $card_class_filter ?>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="method_filter">Method</label>
|
|
<input type="search" class="form-control" id="method_filter" name="method_filter" value='<?= isset($method_filter) ? $method_filter : '' ?>'>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="card_permission_level_filter">Permission</label>
|
|
<?= $card_permission_level_filter ?>
|
|
</div>
|
|
<div class="form-group">
|
|
<input class="btn btn-primary btn-search" type="button" value="Search">
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<div class="row col-lg-12">
|
|
<div class="panel-heading" style="margin-bottom: 15px">
|
|
<div class="heading-elements">
|
|
<div id="pagination"></div>
|
|
</div>
|
|
</div>
|
|
<table id="acl-list" class="table-bordered table-condensed table-hover table-striped table-condensed col-lg-12" style="padding:0px; background-color:lightgreen;">
|
|
<thead class="bg-indigo">
|
|
<th>ID</th>
|
|
<th>Class</th>
|
|
<th>Method</th>
|
|
<th>Permission</th>
|
|
<th></th>
|
|
</thead>
|
|
<tbody></tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="/assets/js/app.js"></script>
|
|
<script type='text/javascript'>
|
|
$(document).ready(function() {
|
|
|
|
// Detect pagination click
|
|
$('#pagination').on('click', 'a', function(e) {
|
|
e.preventDefault();
|
|
|
|
if ($(this).attr('href').trim() === '#') {
|
|
return;
|
|
}
|
|
|
|
var pageno = $(this).attr('data-ci-pagination-page');
|
|
loadPagination(pageno, $('.search-block').serialize());
|
|
});
|
|
|
|
// Prevent submit form by press the enter button
|
|
$(window).keydown(function(event) {
|
|
if (event.keyCode == 13) {
|
|
loadPagination(0);
|
|
event.preventDefault();
|
|
return false;
|
|
}
|
|
});
|
|
|
|
// Load Page
|
|
loadPagination(0);
|
|
|
|
function loadPagination(pagno, filters = null, btn_search = null) {
|
|
loadingButton(btn_search);
|
|
|
|
$.ajax({
|
|
url: '/acl/loadRecord',
|
|
type: 'get',
|
|
dataType: 'json',
|
|
data: {
|
|
'rowno': pagno,
|
|
'filters': filters
|
|
},
|
|
success: function(response) {
|
|
$('#pagination').html(response.pagination);
|
|
createTable(response.result);
|
|
},
|
|
complete: function() {
|
|
stopLoadingButton(btn_search);
|
|
}
|
|
});
|
|
}
|
|
|
|
function createTable(result) {
|
|
|
|
$('#acl-list tbody').empty();
|
|
|
|
for (index in result) {
|
|
var id = result[index].id;
|
|
var controller = result[index].class_name;
|
|
var method = result[index].method_name;
|
|
var plevel = result[index].plevel;
|
|
var permission = result[index].name;
|
|
|
|
var tr =
|
|
`<tr>
|
|
<td>${id}</td>
|
|
<td>${controller}</td>
|
|
<td>${method}</td>
|
|
<td class="hidden">${plevel}</td>
|
|
<td>${permission}</td>
|
|
<td class="input-group-btn">
|
|
<button type='button' class='btn btn-info btn-sm btn-update'>Update</button>
|
|
<button type='button' class='btn btn-secondary btn-sm btn-cancel hidden'>Cancel</button>
|
|
<button type='button' class='btn btn-danger btn-sm btn-delete'>Delete</button>
|
|
</td>
|
|
</tr>`;
|
|
|
|
$('#acl-list tbody').append(tr);
|
|
}
|
|
}
|
|
|
|
// Init page
|
|
getMethodsByController($('[name="controller_name"]').val());
|
|
|
|
function getMethodsByController(controller) {
|
|
|
|
$('#btn-add').button("loading");
|
|
$.ajax({
|
|
url: '/Acl/getMethodsByController',
|
|
type: 'post',
|
|
dataType: 'json',
|
|
data: {
|
|
'controller': controller
|
|
},
|
|
success: function(data) {
|
|
var options = $('[name="method_name"]');
|
|
options.empty();
|
|
$.each(data, function(value) {
|
|
$.each(this, function(k, v) {
|
|
options.append($("<option />").val(v).text(v));
|
|
});
|
|
});
|
|
},
|
|
complete: function() {
|
|
$('#btn-add').button("reset");
|
|
}
|
|
});
|
|
}
|
|
|
|
// Detect controller combobox changed
|
|
$('[name="controller_name"]').change(function() {
|
|
var controller = $(this).val();
|
|
|
|
getMethodsByController(controller);
|
|
});
|
|
|
|
// Detect on click the update button on form
|
|
$('#btn-update').click(function() {
|
|
$('#acl-form').submit();
|
|
});
|
|
|
|
// button search for filter
|
|
$('.btn-search').on('click', function() {
|
|
loadPagination(0, $('.search-block').serialize());
|
|
})
|
|
});
|
|
|
|
// Detect on click the update button
|
|
$(document).on('click', '.btn-update', function(e) {
|
|
var $row = $(this).closest("tr"); // Finds the closest row <tr>
|
|
var $tds = $row.find("td"); // Finds all children <td> elements
|
|
|
|
$('.btn-cancel').addClass('hidden');
|
|
$('.btn-update').removeClass('hidden');
|
|
$('#btn-add').addClass('hidden');
|
|
$('#btn-update').removeClass('hidden');
|
|
|
|
$(this).siblings('.btn-cancel').removeClass('hidden');
|
|
$(this).addClass('hidden');
|
|
|
|
$('[name="controller_name"]').prop('disabled', true).val('');
|
|
$('[name="method_name"]').prop('disabled', true).val('');
|
|
$('[name="permission_level"]').val($tds[3].innerText);
|
|
|
|
$('#acl-form').attr('action', origin + "/Acl/update/" + $tds[0].innerText);
|
|
});
|
|
|
|
// Detect on click the cancel button
|
|
$(document).on('click', '.btn-cancel', function(e) {
|
|
var $row = $(this).closest("tr"); // Finds the closest row <tr>
|
|
var $tds = $row.find("td"); // Finds all children <td> elements
|
|
|
|
$(this).siblings('.btn-update').removeClass('hidden');
|
|
$(this).addClass('hidden');
|
|
$('#btn-add').removeClass('hidden');
|
|
$('#btn-update').addClass('hidden');
|
|
|
|
$('[name="controller_name"]').prop('disabled', false);
|
|
$('[name="method_name"]').prop('disabled', false);
|
|
|
|
$('#acl-form').attr('action', origin + "/Acl/create");
|
|
});
|
|
|
|
// Detect on click the delete button
|
|
$(document).on('click', '.btn-delete', function(e) {
|
|
|
|
if (!confirm('Are you sure want to delete?')) {
|
|
return;
|
|
}
|
|
|
|
var $row = $(this).closest("tr"); // Finds the closest row <tr>
|
|
var $tds = $row.find("td"); // Finds all children <td> elements
|
|
|
|
$('#acl-form').attr('action', origin + "/Acl/destroy/" + $tds[0].innerText);
|
|
$('#acl-form').submit();
|
|
});
|
|
|
|
// Detect on click the add button on form
|
|
$('#btn-add').click(function() {
|
|
$('#acl-form').attr('action', origin + "/Acl/create");
|
|
});
|
|
</script>
|
|
|
|
<style>
|
|
.search-block-item {
|
|
display: flex;
|
|
justify-content: space-around;
|
|
align-items: flex-end;
|
|
}
|
|
</style>
|