/******************************************************************* Module : /apps/js/sys/operator.js Desc. : JS - Manajemen Data Pengguna Created By : Siau Pheng (siaupheng@3fonia.com). Created Date : March 12th, 2008. Last Modified : January 1st, 2026. (c) 2008 - 2026, 3FONIA Software; WWW.3FONIA.COM. *******************************************************************/ var OperatorJS = { PHP: '', KODE: '', loading: function(){ this.data_query('detail'); $('#Cari_User').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_User').val(''); this.data_query('detail'); }.bind(this)); $('#butFilter').click(function(){this.filter_show();}.bind(this)); FoniaJS.setFocus('#Cari_User'); }, filter_show: function(){ new Request({ url: this.PHP, sendParam: ['data=detail_filter','Filter_Level'], onSuccess: function(txt){ this.winFilter = FoniaJS.showWindow('FLevel', 'Filter Data Pengguna / Level', txt, 400, [{},{i:'butTutup'},{i:'butWSimpan',v:'Simpan',c:'success'}], function(){ $('#winFLevel').find('#butWSimpan').click(function(){this.filter_simpan();}.bind(this)); $('#winFLevel').find('#Fi_Level').focus(); }.bind(this)); }.bind(this) }).send(); }, filter_simpan: function(){ $('#Filter_Level').val($('#Fi_Level').val()); FoniaJS.closeWindow(this.winFilter); this.data_query('detail'); }, detail_show: function(mode, UserID){ new Request({ url: this.PHP, sendParam: ['data=user-detail','mode='+mode,'UserID='+UserID], onSuccess: function(txt){ this.winDetail = FoniaJS.showWindow('Detail', 'Informasi Pengguna', txt, 'lg', [{},{i:'butTutup'},{i:'butWSimpan',v:'Simpan',c:'success'}], function(){ $('#winDetail').find('#butWSimpan').click(function(){this.detail_check();}.bind(this)); this.oc_Level(); }.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]+"] "+acell[2]+"?", function(){ new Request.JSON({ url: this.PHP, sendParam: ['data=save','mode=del','UserID='+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_check: function(){ if ($('#Username').val().toUpperCase()==$('#UserLama').val().toUpperCase()) { this.detail_save(); return; } new Request.JSON({ url: this.PHP, sendParam: ['data=user-check','Username'], onSuccess: function(adata){ if (adata.ada==true) { FoniaJS.showInfo("Username telah ada dalam sistem !"); } else { this.detail_save(); } }.bind(this) }).send(); }, detail_save: function(){ new Request.JSONF({ url: this.PHP, sendParam: ['data=save','mode','UserID','Username','Nama','Posisi','Level','Password','Grup_MenuID','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','UserID='+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)).end() .find('#tabMenuList thead input[type="checkbox"]:disabled').prop('indeterminate', true); }.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"]:not(:disabled)').prop('checked', true); }, menu_hapussemua: function(){ $('#tabMenuList tbody input[type="checkbox"]:not(:disabled)').prop('checked', false); }, menu_simpan: function(){ var alist = $('#R_MENU').val().split(','); $('#tabMenuList tbody input[type="checkbox"]:not(:disabled):checked').map(function(i, b){ alist.push($(b).val()); }); new Request.JSONF({ url: this.PHP, sendParam: ['data=save-menu','UserID','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','Filter_Level','Cari_User'] }).send() } }, oc_Level: function(){ } };