first commit

This commit is contained in:
2026-01-22 11:06:19 +07:00
commit c877faf5a0
168 changed files with 19843 additions and 0 deletions
+175
View File
@@ -0,0 +1,175 @@
/*******************************************************************
App. Name : INVENTORY AND SALES SYSTEMS
Module : /apps/js/promo/barang.js
Desc. : JS - Pengaturan Promo Penjualan Barang
Created By : Siau Pheng ([email protected]).
Created Date : September 28th, 2014.
Last Modified : December 9th, 2025.
(c) 2014 - 2025, 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
var PromoBarangJS = {
PHP: '',
KODE: '',
loading: function(){
this.data_query('detail');
$('#Cari_Promo').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_Promo').val('');
this.data_query('detail');
}.bind(this));
FoniaJS.setFocus('#Cari_Promo');
},
detail_show: function(mode, ID){
new Request({
url: this.PHP,
sendParam: ['data=promo-detail','mode_detail='+mode,'PromoID='+ID],
onSuccess: function(txt){
this.winDetail = FoniaJS.showWindow('Detail', 'Detail Promo', txt, 'xl', [{},{i:'butTutup'},{i:'butWSimpan',v:'Simpan',c:'success'}], function(){
$('#winDetail').find('#butWSimpan').click(function(){this.detail_save();}.bind(this));
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();
}
}.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 <b>"'+acell[2]+'"</b> ?', function(){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=detail','mode_detail=delete','PromoID='+acell[0],'Cari_Promo'],
onSuccess: function(){
FoniaJS.showInfo('Proses hapus data sukses!');
}.bind(this)
}).send();
}.bind(this), 'danger');
},
detail_save: function(){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=detail','mode_detail','PromoID','InvID','SatuanID','CabID','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: function(){
FoniaJS.showInfo('Proses simpan data sukses!');
FoniaJS.closeWindow(this.winDetail);
}.bind(this)
}).send();
},
produk_brow: function(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, 900, '', function(){
$('#winBProduk').find('#Cari_Produk').keydown(function(e){
var key = e.keyCode || e.which || 0;
if (key==13 && e.target.value!='') this.data_query('brow-produk');
}.bind(this));
$('#winBProduk').find('#butSearch').click(function(e){
this.data_query('brow-produk');
}.bind(this));
$('#winBProduk').find('#butAll').click(function(){
$('#winBProduk').find('#Cari_Produk').val('');
this.data_query('brow-produk');
}.bind(this));
this.data_query('brow-produk');
FoniaJS.setFocus('#Cari_Produk');
}.bind(this));
},
produk_select: function(acell){
FoniaJS.closeWindow(this.winBProduk);
var itipe = parseInt($('#Tipe_Brow').val());
if (itipe == 1){
$('#InvID').val(acell[0]);
$('#Nama_Produk').val(acell[2]);
this.update_Items(acell[0], 0, 1);
} else {
$('#Promo_InvID').val(acell[0]);
$('#Promo_Produk').val(acell[2]);
this.update_Items(acell[0], 0, 2);
}
},
data_query: function(tipe, mode){
if (tipe=="detail"){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=detail','Cari_Promo']
}).send();
} else if (tipe=="brow-produk"){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=brow-produk','Cari_Produk'],
onSuccess: function(){
FoniaJS.setFocus('#Cari_Produk');
}
}).send();
}
},
update_Items: function(InvID, SatuanID, Tipe){
const elSatuan = (Tipe==1) ? $('#SatuanID') : $('#Promo_SatuanID');
elSatuan.empty();
if (InvID==0) return false;
new Request.JSON({
url: this.PHP,
sendParam: ['data=detail_item','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: function(){
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: function(){
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);
}
}
};