/******************************************************************* PHP Class : /Controller/Table/Member/PointskemaController Description : Master Skema Point Member Created By : Siau Pheng (siaupheng@3fonia.com). Created Date : September 28th, 2014. Last Modified : September 4th, 2026. (c) 3FONIA Software; WWW.3FONIA.COM. *******************************************************************/ var PointSkemaJS = { PHP: '', KODE: '', index() { this.data_query('detail'); $('#Cari_Skema').keydown((e) => { var key = e.keyCode || e.which || 0; if (key==13 && e.target.value!='') this.data_query('detail'); }); $('#butSearch').click(() => this.data_query('detail')); $('#butAll').click(() => { $('#Cari_Skema').val(''); this.data_query('detail'); }); FoniaJS.setFocus('#Cari_Skema'); }, detail_show(mode, ID) { new Request({ url: this.PHP + '/form_skema', sendParam: ['mode_detail='+mode,'PointID='+ID], onSuccess: (ajson) => { this.winDetail = FoniaJS.showWindow('Detail', 'Detail Skema Point Member', ajson.html, 'xl', [{},{i:'butTutup'},{i:'butWSimpan',v:'Simpan',c:'success'}], () => { $('#winDetail') .find('#butWSimpan').click(() => this.detail_save()).end() .find('#butBrow1').click(() => this.grup_form()).end() .find('#butBrow2').click(() => this.barang_form()); }); } }).send(); }, detail_tambah() { this.detail_show('insert', 0); }, detail_ubah(acell) { this.detail_show('update', acell[0]); }, detail_hapus(acell) { FoniaJS.showConfirm('Konfirmasi', 'Yakin akan hapus "'+acell[5]+'" ?', () => { new Request_JSF({ url: this.PHP + '/table_detail', sendParam: ['mode_detail=delete','PointID='+acell[0],'Cari_Skema'], onSuccess: () => FoniaJS.showInfo('Proses hapus data sukses!') }).send(); }, 'danger'); }, detail_save() { new Request_JSF({ url: this.PHP + '/table_detail', sendParam: ['mode_detail','PointID','Point_TipeID','KartuID','CabID','Grup_MemberID','Nilai_Jual','Grup_Barang','Kode_Barang','Tgl_Mulai','Aktif','Cari_Skema'], onSuccess: () => { FoniaJS.showInfo('Proses simpan data sukses!'); FoniaJS.closeWindow(this.winDetail); } }).send(); }, grup_form() { new Request({ url: this.PHP + '/form_grup', sendParam: ['Grup_Barang'], onSuccess: (ajson) => { this.winGrup = FoniaJS.showWindow('Grup', 'Daftar Grup Barang', ajson.html, 'lg', [{i:'butWSAll',v:'Cek Semua',c:'info'},{i:'butWCAll',v:'Hapus Semua',c:'info'},{},{i:'butTutup'},{i:'butWSimpan',v:'Simpan',c:'success'}], () => { $('#winGrup') .find('#butWSAll').click(() => this.grup_semua()).end() .find('#butWCAll').click(() => this.grup_clear()).end() .find('#butWSimpan').click(() => this.grup_save()); }); } }).send(); }, grup_semua() { $('#tabGrupList input.form-check-input[type=checkbox]').prop('checked', true); }, grup_clear() { $('#tabGrupList input.form-check-input[type=checkbox]').prop('checked', false); }, grup_save() { var alist = []; $('#tabGrupList tbody input.form-check-input[type=checkbox]:checked').map((i, b) => { alist.push($(b).val()); }); $('#Grup_Barang').val(alist.join()); FoniaJS.closeWindow(this.winGrup); }, barang_form() { new Request({ url: this.PHP + '/form_barang', sendParam: ['Kode_Barang'], onSuccess: (ajson) => { this.winBarang = FoniaJS.showWindow('Barang', 'Daftar Barang', ajson.html, 'lg', null, () => { FoniaJS.AutoComplete('#Nama_Produk', this.PHP + '/auto_produk', ['Kode_Barang'], {'selectFunc': this.Produk_Comp}); this.data_query("tabel-barang"); }); } }).send(); }, barang_hapus(acell) { FoniaJS.showConfirm('Konfirmasi', 'Yakin akan hapus "'+acell[1]+'" ?', () => { new Request_JSF({ url: this.PHP + '/table_barang', sendParam: ['mode_detail=delete','InvID='+acell[0],'Kode_Barang'], onSuccess: () => FoniaJS.showInfo('Proses hapus data sukses!') }).send(); }, 'danger'); }, data_query(tipe, mode) { if (tipe=="detail"){ new Request_JSF({ url: this.PHP + '/table_detail', sendParam: ['Cari_Skema'] }).send(); } else if (tipe=="tabel-barang"){ new Request_JSF({ url: this.PHP + '/table_barang', sendParam: ['Kode_Barang'], onSuccess: () => FoniaJS.setFocus('#Nama_Produk') }).send(); } }, Produk_Comp(item) { new Request_JSF({ url: PointSkemaJS.PHP + '/table_barang', sendParam: ['mode_detail=insert','Kode_Barang','InvID='+item.value] }).send(); $('#Nama_Produk').val('').focus(); } };