Files
siaupheng aaaf0a9215 Refactor member and product scripts to use concise method definitions
- Updated all function declarations to use ES6 shorthand method syntax in member.js, member_grup.js, point_barang.js, point_skema.js, point_tipe.js, kategori.js, operator.js, produk.js, produk_grup.js, rekpos.js, satuan.js, supplier.js, and varian.js.
2026-11-01 14:57:54 +07:00

171 lines
6.5 KiB
JavaScript

/*******************************************************************
PHP Class : /Controller/Promo/BarangController
Description : Konfigurasi Promo Penjualan Barang
Created By : Siau Pheng ([email protected]).
Created Date : September 28th, 2014.
Last Modified : September 2nd, 2026.
(c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
var PromoBarangJS = {
PHP: '',
KODE: '',
index() {
this.data_query('detail');
$('#Cari_Promo').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_Promo').val('');
this.data_query('detail');
});
FoniaJS.setFocus('#Cari_Promo');
},
detail_show(mode, ID) {
new Request({
url: this.PHP + '/form_promo',
sendParam: ['mode_detail='+mode,'PromoID='+ID],
onSuccess: (ajson) => {
this.winDetail = FoniaJS.showWindow('Detail', 'Detail Promo', ajson.html, 'xl', [{},{i:'butTutup'},{i:'butWSimpan',v:'Simpan',c:'success'}], () => {
$('#winDetail')
.find('#butWSimpan').click(() => this.detail_save()).end()
.find('#butBrow1').click(() => this.produk_brow(1)).end()
.find('#butBrow2').click(() => this.produk_brow(2));
if ($.inArray($("#mode_detail").val(),['insert','update']) !== -1) {
this.update_Items($('#InvID').val(), $('#SatuanID').val(), 1);
this.update_Items($('#Promo_InvID').val(), $('#Promo_SatuanID').val(), 2);
this.oc_PilihQ();
this.oc_PilihP();
}
});
}
}).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 <b>"'+acell[2]+'"</b> ?', () => {
new Request_JSF({
url: this.PHP + '/table_promo',
sendParam: ['mode_detail=delete','PromoID='+acell[0],'Cari_Promo'],
onSuccess: () => FoniaJS.showInfo('Proses hapus data sukses!')
}).send();
}, 'danger');
},
detail_save() {
new Request_JSF({
url: this.PHP + '/table_promo',
sendParam: ['mode_detail','PromoID','InvID','SatuanID','CabID','Grup_MemberID','Pilih_Qty','Qty_Min','Qty_Kali','Tipe_Promo','Promo_Disc','Promo_InvID','Promo_SatuanID','Promo_Qty','Jumlah_Promo','Tgl_Mulai','Tgl_Akhir','Aktif','Cari_Promo'],
onSuccess: () => {
FoniaJS.showInfo('Proses simpan data sukses!');
FoniaJS.closeWindow(this.winDetail);
}
}).send();
},
produk_brow(tipe) {
var _isi = new String('<div class="row mb-1"><div class="col"><div class="input-group"><input class="form-control" id="Cari_Produk" placeholder="Kunci Pencarian" type="text"><button class="btn btn-info shadow-none" type="button" id="butSearch">Cari</button><button class="btn btn-secondary shadow-none" type="button" id="butAll">Semua</button><input type="hidden" id="Tipe_Brow" value="'+tipe+'" /></div></div></div><div id="divBrowProduk">&nbsp;</div>');
this.winBProduk = FoniaJS.showWindow('BProduk', 'Daftar Barang', _isi, 'lg', '', () => {
$('#winBProduk')
.find('#Cari_Produk').keydown((e) => {
var key = e.keyCode || e.which || 0;
if (key==13 && e.target.value!='') this.data_query('brow-produk');
}).end()
.find('#butSearch').click(() => this.data_query('brow-produk')).end()
.find('#butAll').click(() => {
$('#winBProduk').find('#Cari_Produk').val('');
this.data_query('brow-produk');
});
this.data_query('brow-produk');
FoniaJS.setFocus('#Cari_Produk');
});
},
produk_select(acell) {
FoniaJS.closeWindow(this.winBProduk);
var itipe = parseInt($('#Tipe_Brow').val());
if (itipe == 1){
$('#InvID').val(acell[0]);
$('#Nama_Produk').val(acell[1]);
this.update_Items(acell[0], 0, 1);
} else {
$('#Promo_InvID').val(acell[0]);
$('#Promo_Produk').val(acell[1]);
this.update_Items(acell[0], 0, 2);
}
},
data_query(tipe, mode) {
if (tipe=="detail"){
new Request_JSF({
url: this.PHP + '/table_promo',
sendParam: ['Cari_Promo']
}).send();
} else if (tipe=="brow-produk"){
new Request_JSF({
url: this.PHP + '/brow_produk',
sendParam: ['Cari_Produk'],
onSuccess: () => FoniaJS.setFocus('#Cari_Produk')
}).send();
}
},
update_Items(InvID, SatuanID, Tipe) {
const elSatuan = (Tipe==1) ? $('#SatuanID') : $('#Promo_SatuanID');
elSatuan.empty();
if (InvID==0) return false;
new Request({
url: this.PHP + '/item_detail',
sendParam: ['InvID='+InvID],
onSuccess: (adata) => {
adata.map((val) => {
elSatuan.append(new Option(val['label'],val['value'],false,(val['value']==SatuanID?true:false)))
});
elSatuan.trigger('change');
}
}).send();
},
oc_PilihQ() {
var i = parseInt($('#Pilih_Qty').val());
if (i == 1){
$('#Qty_Min').prop('disabled', false);
$('#Qty_Kali').prop('disabled', true).val(0);
} else {
$('#Qty_Min').prop('disabled', true).val(0);
$('#Qty_Kali').prop('disabled', false);
}
},
oc_PilihP() {
var i = parseInt($('#Tipe_Promo').val());
if (i == 1){
$('.promo1').removeClass('d-none');
$('.promo2').addClass('d-none');
$('#Promo_SatuanID').val(0);
$('#Promo_Qty').val(0);
$('#Promo_InvID').val(0);
} else {
$('.promo1').addClass('d-none');
$('.promo2').removeClass('d-none');
$('#Promo_Disc').val(0);
}
}
};