/******************************************************************* App. Name : INVENTORY AND SALES SYSTEMS Module : /apps/js/tab/produk_grup.js Desc. : JS - Tabel Master Grup Barang Created By : Siau Pheng (siaupheng@3fonia.com). Created Date : February 8th, 2011. Last Modified : October 5th, 2025. (c) 2011 - 2025, 3FONIA Software; WWW.3FONIA.COM. *******************************************************************/ var ProdukGrupJS = { 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_detail='+mode,'Grup_InvID='+ID], onSuccess: function(txt){ this.winDetail = FoniaJS.showWindow('Detail', 'Detail Grup Barang', txt, 600, [{},{i:'butTutup'},{i:'butWSimpan',v:'Simpan',c:'success'}], function(){ $('#winDetail').find('#butWSimpan').click(function(){this.detail_check();}.bind(this)); }.bind(this)); }.bind(this) }).send(); }, detail_tambah: function(){ this.detail_show('insert', 0); }, detail_ubah: function(acell){ this.detail_show('update', acell[0]); }, detail_hapus: function(acell){ FoniaJS.showConfirm('Konfirmasi', 'Yakin akan hapus "'+acell[2]+'" ?', function(){ new Request.JSON({ url: this.PHP, sendParam: ['data=detail','mode_detail=delete','Grup_InvID='+acell[0],'Cari_Grup'], onSuccess: function(){ FoniaJS.showInfo('Proses hapus data sukses!'); } }).send(); }.bind(this), 'danger'); }, detail_check: function(){ var _kode = $('#Kode_Grup').val(); if (!_kode.match(/^[0-9]+$/)) { FoniaJS.showError('Tolong pastikan kembali Kode Grup adalah angka !'); FoniaJS.setFocus('#Kode_Grup'); return; } new Request.JSONF({ url: this.PHP, sendParam: ['data=kode-check','Grup_InvID','Kode_Grup'], onSuccess: function(adata){ if (adata.ada==true) { FoniaJS.showInfo('Kode Grup telah ada dalam sistem!'); } else { this.detail_save(); } }.bind(this) }).send(); }, detail_save: function(){ new Request.JSONF({ url: this.PHP, sendParam: ['data=detail','mode_detail','Grup_InvID','Kode_Grup','Nama_Grup','Margin','Aktif','Cari_Grup'], onSuccess: function(){ FoniaJS.showInfo('Proses simpan data sukses!'); FoniaJS.closeWindow(this.winDetail); }.bind(this) }).send(); }, data_query: function(tipe, mode){ if (tipe=="detail"){ new Request.JSONF({ url: this.PHP, sendParam: ['data=detail','Cari_Grup'] }).send(); } } };