115 lines
2.8 KiB
PHP
115 lines
2.8 KiB
PHP
|
<script type="text/javascript">
|
||
|
|
||
|
// INIT
|
||
|
var routeTable = "{{$table}}";
|
||
|
|
||
|
var colum = [
|
||
|
{ data: 'action'},
|
||
|
{ data: 'description'},
|
||
|
{ data: 'list_menu'}
|
||
|
];
|
||
|
|
||
|
var columStyle =
|
||
|
[
|
||
|
{ "orderable": false, "targets": [0] }
|
||
|
];
|
||
|
|
||
|
var table = znGetTable(routeTable,colum,columStyle,'indexTable');
|
||
|
// INIT
|
||
|
|
||
|
$('#formData').on('keyup keypress', function (e) {
|
||
|
var keyCode = e.keyCode || e.which;
|
||
|
if (keyCode === 13) {
|
||
|
e.preventDefault();
|
||
|
return false;
|
||
|
}
|
||
|
});
|
||
|
|
||
|
function modalMenu(id,title) {
|
||
|
$('#get_id').val('');
|
||
|
$("#form-data")[0].reset();
|
||
|
$('#form-data').bootstrapValidator("resetForm", true);
|
||
|
|
||
|
$('#mForm_title').html('Hak Akses '+title);
|
||
|
|
||
|
|
||
|
$.ajax({
|
||
|
url: "{{$admin_menu_get}}",
|
||
|
type: 'POST',
|
||
|
data:{id:id},
|
||
|
beforeSend: function() {
|
||
|
znLoadingPage();
|
||
|
},
|
||
|
success: function (res) {
|
||
|
$('#get_id').val(id);
|
||
|
//console.log(res);
|
||
|
|
||
|
var data = $.parseJSON(res);
|
||
|
$.each(data, function (k,v) {
|
||
|
$('#'+v.menu_uid).prop('checked', 'checked');
|
||
|
});
|
||
|
}
|
||
|
}).done(function(msg) {
|
||
|
znLoadingPageEnd();
|
||
|
znModal('mForm');
|
||
|
|
||
|
}).fail(function(msg) {
|
||
|
znLoadingPageEnd();
|
||
|
});
|
||
|
}
|
||
|
|
||
|
|
||
|
function store() {
|
||
|
let myForm = document.getElementById('form-data');
|
||
|
let formData = new FormData(myForm);
|
||
|
|
||
|
$.ajax({
|
||
|
type: "POST",
|
||
|
url: '{{$admin_menu_store}}',
|
||
|
data : formData,
|
||
|
dataType:'JSON',
|
||
|
contentType: false,
|
||
|
cache: false,
|
||
|
processData: false,
|
||
|
beforeSend: function() {
|
||
|
znLoadingModal('mForm');
|
||
|
KTUtil.btnWait(btnLoader, "spinner spinner-right spinner-white pr-15", "Processing..");
|
||
|
},
|
||
|
success: function( msg ) {
|
||
|
KTUtil.btnRelease(btnLoader);
|
||
|
znLoadingModalEnd('mForm');
|
||
|
}
|
||
|
}).done(function( msg ) {
|
||
|
znNotif('success','Berhasil Menyimpan Data');
|
||
|
$('#mForm').modal('hide');
|
||
|
table.ajax.url(routeTable).load();
|
||
|
}).fail(function(msg) {
|
||
|
KTUtil.btnRelease(btnLoader);
|
||
|
znLoadingModalEnd('mForm');
|
||
|
znNotif('warning','Gagal Menyimpan Data');
|
||
|
});
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
function setChild(id,check) {
|
||
|
$('.c'+id).prop('checked', check);
|
||
|
}
|
||
|
|
||
|
function setParent(id,check) {
|
||
|
var sThisVal = 0;
|
||
|
$('input:checkbox.c'+id).each(function () {
|
||
|
sThisVal += parseInt(this.checked ? 1 : 0);
|
||
|
});
|
||
|
|
||
|
if (sThisVal > 0) {
|
||
|
$('.p'+id).prop('checked', true);
|
||
|
}else {
|
||
|
$('.p'+id).prop('checked', false);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
</script>
|