Files
cmasa/app/Scripts/table/member/point_skema.js
T
2026-10-29 13:34:31 +07:00

154 lines
5.6 KiB
JavaScript

/*******************************************************************
PHP Class : /Controller/Table/Member/PointskemaController
Description : Master Skema Point Member
Created By : Siau Pheng ([email protected]).
Created Date : September 28th, 2014.
Last Modified : September 4th, 2026.
(c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
var PointSkemaJS = {
PHP: '',
KODE: '',
index: function(){
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: function(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: 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 <b>"'+acell[5]+'"</b> ?', () => {
new Request.JSONF({
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: function(){
new Request.JSONF({
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: function(){
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: function(){
$('#tabGrupList input.form-check-input[type=checkbox]').prop('checked', true);
},
grup_clear: function(){
$('#tabGrupList input.form-check-input[type=checkbox]').prop('checked', false);
},
grup_save: function(){
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: function(){
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: function(acell){
FoniaJS.showConfirm('Konfirmasi', 'Yakin akan hapus <b>"'+acell[1]+'"</b> ?', () => {
new Request.JSONF({
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: function(tipe, mode){
if (tipe=="detail"){
new Request.JSONF({
url: this.PHP + '/table_detail',
sendParam: ['Cari_Skema']
}).send();
} else if (tipe=="tabel-barang"){
new Request.JSONF({
url: this.PHP + '/table_barang',
sendParam: ['Kode_Barang'],
onSuccess: () => FoniaJS.setFocus('#Nama_Produk')
}).send();
}
},
Produk_Comp: function(item){
new Request.JSONF({
url: PointSkemaJS.PHP + '/table_barang',
sendParam: ['mode_detail=insert','Kode_Barang','InvID='+item.value]
}).send();
$('#Nama_Produk').val('').focus();
}
};