147 lines
5.3 KiB
JavaScript
147 lines
5.3 KiB
JavaScript
/*******************************************************************
|
|
|
|
Module : /apps/js/sys/menu_grup.js
|
|
Desc. : JS - Manajemen Data Grup Login Menu
|
|
Created By : Siau Pheng ([email protected]).
|
|
Created Date : August 8th, 2013.
|
|
Last Modified : January 1st, 2026.
|
|
|
|
(c) 2013 - 2026, 3FONIA Software; WWW.3FONIA.COM.
|
|
|
|
*******************************************************************/
|
|
|
|
var MenuGrupJS = {
|
|
PHP: '',
|
|
KODE: '',
|
|
|
|
loading: function(){
|
|
this.data_query('detail');
|
|
$('#Cari_Grup').keydown(function(e){
|
|
var key = e.keyCode || e.which || 0;
|
|
if (key==13 && e.target.value!='') this.data_query('detail');
|
|
}.bind(this));
|
|
$('#butSearch').click(function(e){
|
|
this.data_query('detail');
|
|
}.bind(this));
|
|
$('#butAll').click(function(){
|
|
$('#Cari_Grup').val('');
|
|
this.data_query('detail');
|
|
}.bind(this));
|
|
FoniaJS.setFocus('#Cari_Grup');
|
|
},
|
|
|
|
detail_show: function(mode, ID){
|
|
new Request({
|
|
url: this.PHP,
|
|
sendParam: ['data=grup-detail','mode='+mode,'Grup_MenuID='+ID],
|
|
onSuccess: function(txt){
|
|
this.winDetail = FoniaJS.showWindow('Detail', 'Informasi Grup Menu', txt, 'lg', [{},{i:'butTutup'},{i:'butWSimpan',v:'Simpan',c:'success'}], function(){
|
|
$('#winDetail').find('#butWSimpan').click(function(){this.detail_save();}.bind(this));
|
|
}.bind(this));
|
|
}.bind(this)
|
|
}).send();
|
|
},
|
|
|
|
detail_tambah: function(){
|
|
this.detail_show('add', 0);
|
|
},
|
|
|
|
detail_ubah: function(acell){
|
|
this.detail_show('edit', acell[0]);
|
|
},
|
|
|
|
detail_hapus: function(acell){
|
|
FoniaJS.showConfirm("Konfirmasi", "Yakin akan hapus "+acell[1]+"?", function(){
|
|
new Request.JSON({
|
|
url: this.PHP,
|
|
sendParam: ['data=save','mode=del','Grup_MenuID='+acell[0]],
|
|
onSuccess: function(adata){
|
|
if (adata.status==true){
|
|
this.data_query('detail');
|
|
FoniaJS.showInfo('Proses hapus data sukses!');
|
|
}else{
|
|
FoniaJS.showInfo('Ada masalah dalam proses hapus data!');
|
|
}
|
|
}.bind(this)
|
|
}).send();
|
|
}.bind(this), 'danger');
|
|
},
|
|
|
|
detail_save: function(){
|
|
new Request.JSONF({
|
|
url: this.PHP,
|
|
sendParam: ['data=save','mode','Grup_MenuID','Nama_Grup','Ket','Aktif'],
|
|
onSuccess: function(adata){
|
|
if (adata.status==true){
|
|
this.data_query('detail');
|
|
FoniaJS.showInfo('Proses simpan data sukses!');
|
|
}else{
|
|
FoniaJS.showInfo('Ada masalah dalam proses simpan data!');
|
|
}
|
|
FoniaJS.closeWindow(this.winDetail);
|
|
}.bind(this)
|
|
}).send();
|
|
},
|
|
|
|
menu_show: function(acell){
|
|
new Request({
|
|
url: this.PHP,
|
|
sendParam: ['data=menu','Grup_MenuID='+acell[0]],
|
|
onSuccess: function(txt){
|
|
this.winMenu = FoniaJS.showWindow('Menu', 'Hak Akses Modul', txt, 'lg', [{i:'butWSelAll',v:'Pilih Semua',c:'info'},{i:'butWClrAll',v:'Hapus Semua',c:'info'},{},{i:'butTutup'},{i:'butWSimpan',v:'Simpan',c:'success'}], function(){
|
|
$('#winMenu')
|
|
.find('#butWSelAll').click(function(){this.menu_ceksemua();}.bind(this)).end()
|
|
.find('#butWClrAll').click(function(){this.menu_hapussemua();}.bind(this)).end()
|
|
.find('#butWSimpan').click(function(){this.menu_simpan();}.bind(this));
|
|
}.bind(this));
|
|
}.bind(this)
|
|
}).send();
|
|
},
|
|
|
|
menu_cek: function(el){
|
|
var t_modul = el.value, b_check = el.checked;
|
|
$('#tabMenuList tbody input[type="checkbox"]').map(function(i, b){
|
|
var t_menu = $(b);
|
|
if (t_menu.hasClass(t_modul)) t_menu.prop('checked', b_check);
|
|
});
|
|
el.prop('checked', !b_check);
|
|
},
|
|
|
|
menu_ceksemua: function(){
|
|
$('#tabMenuList tbody input[type="checkbox"]').prop('checked', true);
|
|
},
|
|
|
|
menu_hapussemua: function(){
|
|
$('#tabMenuList tbody input[type="checkbox"]').prop('checked', false);
|
|
},
|
|
|
|
menu_simpan: function(){
|
|
var alist = $('#R_MENU').val().split(',');
|
|
$('#tabMenuList tbody input[type="checkbox"]:checked').map(function(i, b){
|
|
alist.push($(b).val());
|
|
});
|
|
new Request.JSONF({
|
|
url: this.PHP,
|
|
sendParam: ['data=save-menu','Grup_MenuID','Menu='+alist.join()],
|
|
onSuccess: function(adata){
|
|
if (adata.status==true){
|
|
FoniaJS.showInfo('Proses simpan data sukses!');
|
|
}else{
|
|
FoniaJS.showInfo('Ada masalah dalam proses simpan data!');
|
|
}
|
|
FoniaJS.closeWindow(this.winMenu);
|
|
}.bind(this)
|
|
}).send();
|
|
},
|
|
|
|
data_query: function(tipe, mode){
|
|
if (tipe=="detail"){
|
|
new Request.JSONF({
|
|
url: this.PHP,
|
|
sendParam: ['data=detail','Cari_Grup']
|
|
}).send()
|
|
}
|
|
}
|
|
|
|
};
|