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
+448
View File
@@ -0,0 +1,448 @@
/*******************************************************************
App. Name : INVENTORY AND SALES SYSTEMS
Module : /apps/js/iss/beli.js
Desc. : JS - Transaksi Pembelian
Created By : Siau Pheng ([email protected]).
Created Date : May 22th, 2010.
Last Modified : October 19th, 2025.
(c) 2010 - 2025, 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
var BeliJS = {
PHP: '',
KODE: '',
loading: function(q){
$('#butTambah').click(function(){this.tx_tambah();}.bind(this));
$('#butUbah').click(function(){this.tx_ubah();}.bind(this));
$('#butHapus').click(function(){this.tx_hapus();}.bind(this));
$('#butPendingBrow').click(function(){this.pending_brow();}.bind(this));
$('#butPendingSimpan').click(function(){this.tx_simpan('pending');}.bind(this));
$('#butSimpan').click(function(){this.tx_simpan();}.bind(this));
$('#butBatal').click(function(){this.tx_batal();}.bind(this));
$('#butPrint').click(function(){this.tx_print();}.bind(this));
this.data_query('master', 'view', ((typeof(q)!=='undefined') ? q : ''));
},
tx_brow: function(){
var _isi = new String('<div class="row mb-1"><div class="col"><div class="input-group"><input class="form-control" id="Cari_TX" 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></div></div></div><div id="divBrowTX">&nbsp;</div>');
this.winBTX = FoniaJS.showWindow('BTX', 'Daftar Transaksi', _isi, 900, '', function(){
$('#winBTX').find('#Cari_TX').keydown(function(e){
var key = e.keyCode || e.which || 0;
if (key==13 && e.target.value!='') this.data_query('brow-tx');
}.bind(this));
$('#winBTX').find('#butSearch').click(function(e){
this.data_query('brow-tx');
}.bind(this));
$('#winBTX').find('#butAll').click(function(){
$('#winBTX').find('#Cari_TX').val('');
this.data_query('brow-tx');
}.bind(this));
this.data_query('brow-tx');
FoniaJS.setFocus('#Cari_TX');
}.bind(this));
},
tx_select: function(acell){
FoniaJS.closeWindow(this.winBTX);
$('#No_Beli').val(acell[0]);
this.data_query('master', 'view');
},
tx_tambah: function(){
this.data_query('master', 'add');
},
tx_ubah: function(){
if (!$('#No_Beli').val()){
FoniaJS.showError("Silakan masukkan Nomor Transaksi !");
return;
}
if (-1 !== $('#No_Beli').val().search(/BELI/i)){
this.data_query('master', 'pending-edit')
return;
}
FoniaJS.showAuth(function(){this.data_query('master', 'edit')}.bind(this), this, 'EDIT '+$('#No_Beli').val());
},
tx_hapus: function(){
if (!$('#No_Beli').val()){
FoniaJS.showError("Silakan masukkan Nomor Transaksi !");
return;
}
FoniaJS.showConfirm('Konfirmasi', 'Yakin akan hapus <strong>'+$('#No_Beli').val()+'</strong> ?', function(){
FoniaJS.showAuth(function(){
new Request.JSON({
url: this.PHP,
sendParam: ['data=delete','No_Beli'],
onSuccess: function(adata){
if (adata.status==true){
$('#No_Beli').val('');
this.data_query('master', 'view');
FoniaJS.showInfo('Proses hapus data sukses!');
}else{
FoniaJS.showInfo('Ada masalah dalam proses hapus data!');
}
}.bind(this)
}).send();
}.bind(this), this, 'DELETE '+$('#No_Beli').val());
}.bind(this), 'danger');
},
tx_simpan: function(mode){
if ($('#CabID').val()==0){
FoniaJS.showError("Silakan pilih Nama Cabang !");
return;
}
if ($('#SupID').val()==0){
FoniaJS.showError("Silakan pilih Nama Supplier !");
return;
}
if (mode == 'pending'){
this.data_query('master', 'pending-save');
return;
}
if (parseFloat($('#Total_Hutang').val())==0){
this.total_show();
return;
}
this.data_query('master', 'save');
},
tx_batal: function(){
FoniaJS.showConfirm('Konfirmasi', 'Yakin akan membatalkan ?', function(){
this.data_query('master', 'cancel');
$('#No_Beli').val('');
}.bind(this), 'danger');
},
tx_print: function(prt){
if ($('#No_Beli').val()) {
var cetak = new cPRINTER(FoniaJS.WEB_PATH+'apps/php/repo/nota.php');
cetak.add_param("data", "nota-beli");
cetak.add_param("Nomor_Cetak", $('#No_Beli').val());
if (prt) cetak.doPrint(); else cetak.doPreview();
return;
}
FoniaJS.showError("Silakan masukkan Nomor Transaksi !");
},
pending_brow: function(){
var _isi = new String('<div id="divBrowPending">&nbsp;</div>');
this.winBPending = FoniaJS.showWindow('BPending', 'Daftar Pending Pembelian', _isi, 900, '', function(){
this.data_query('brow-pending');
}.bind(this));
},
pending_select: function(acell){
FoniaJS.closeWindow(this.winBPending);
$('#No_Beli').val(acell[0]);
this.data_query('master', 'pending-edit');
},
pending_delete: function(acell){
FoniaJS.closeWindow(this.winBPending);
FoniaJS.showConfirm('Konfirmasi', 'Yakin akan hapus Transaksi Pending "'+acell[0]+'" ?', function(){
$('#No_Beli').val(acell[0]);
this.data_query('master', 'pending-delete');
}.bind(this), 'danger');
},
produk_brow: function(){
if ($('#SupID').val()==0){
FoniaJS.showError("Silakan pilih Nama Supplier !");
return;
}
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="Filter_Browse" value="all" /></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(){
if ($('#Filter_Browse').val()=='filter') {
$('#Filter_Browse').val('all');
$('#butAll').html('Semua');
} else {
$('#Filter_Browse').val('filter');
$('#butAll').html('Supplier');
}
$('#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);
this.detail_produk('insert', 0, acell[0], acell[1]);
},
detail_produk: function(mode, ID, InvID, SatuanID){
new Request.JSON({
url: this.PHP,
sendParam: ['data=detail-produk','No_Beli','mode','mode_detail='+mode,'ID='+ID,'InvID='+InvID,'SatuanID='+SatuanID],
onSuccess: function(a){
this.winDetail = FoniaJS.showWindow('Detail', 'Detail Barang', a.html, 700, [{},{i:'butTutup'},{i:'butWSimpan',v:'Simpan',c:'success'}], function(){
FoniaJS.AutoComplete('#Nama_Produk', this.PHP, ['data=auto-produk','No_Beli','CabID','SupID'], this.Produk_Comp);
$('#winDetail')
.find('#butWSimpan').click(function(){this.detail_simpan();}.bind(this)).end()
.find('#Nama_Produk').on('click', function(){
$('#Nama_Produk').select();
}).end()
.find('#Qty').keyup(function(e) {
this.Hitung_Detail();
if (e.which==13 && parseInt(e.target.value)>0) FoniaJS.setFocus('#Harga_Beli');
}.bind(this)).end()
.find('#Harga_Beli').keyup(function(e) {
this.Hitung_Detail();
if (e.which==13) FoniaJS.setFocus('#Disk_Rupiah');
}.bind(this)).end()
.find('#Disk_Rupiah').keyup(function(e) {
this.Hitung_Detail();
if (e.which==13) FoniaJS.setFocus('#Disk_Persen1');
}.bind(this)).end()
.find('#Disk_Persen1').keyup(function(e) {
this.Hitung_Detail();
if (e.which==13) FoniaJS.setFocus('#Disk_Persen2');
}.bind(this)).end()
.find('#Disk_Persen2').keyup(function(e) {
this.Hitung_Detail();
if (e.which==13) FoniaJS.setFocus('#Disk_Persen3');
}.bind(this)).end()
.find('#Disk_Persen3').keyup(function(e) {
this.Hitung_Detail();
if (e.which==13) FoniaJS.setFocus('#Disk_Persen4');
}.bind(this)).end()
.find('#Disk_Persen4').keyup(function(e) {
this.Hitung_Detail();
if (e.which==13) FoniaJS.setFocus('#Disk_Persen5');
}.bind(this)).end()
.find('#Disk_Persen5').keyup(function(e) {
this.Hitung_Detail();
if (e.which==13 && FoniaJS.StrToFloat($('#Jumlah').val())>0) this.detail_simpan();
}.bind(this));
if ($('#mode_detail').val() == 'insert' && $('#InvID').val() == 0) {
FoniaJS.setFocus('#Nama_Produk');
} else {
this.Hitung_Detail();
FoniaJS.setFocus('#Qty');
}
}.bind(this), false);
}.bind(this)
}).send();
},
detail_tambah: function(){
if ($('#SupID').val()==0){
FoniaJS.showError("Silakan pilih Nama Supplier !");
return;
}
this.detail_produk('insert', 0, 0, 0);
},
detail_ubah: function(acell){
this.detail_produk('update', acell[0], acell[1], acell[2]);
},
detail_hapus: function(acell){
FoniaJS.showConfirm('Konfirmasi', 'Hapus item <strong>"'+acell[4]+'"</strong> ?', function(){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=tabel-detail','mode','mode_detail=delete','No_Beli','ID='+acell[0]],
onSuccess: function(){
var _obtn = $('button:contains("Total")');
if (_obtn) _obtn.removeClass('btn-info').addClass('btn-secondary').attr('id','tombolTotal').html('Hutang : '+FoniaJS.FloatToStr($('#Total_Hutang').val(),2));
}
}).send();
}.bind(this), 'danger');
},
detail_simpan: function(){
if (parseInt($('#InvID').val())==0) {
FoniaJS.showError('Silakan masukkan Nama Barang !');
return;
}
var _mdetail = $('#mode_detail').val();
new Request.JSONF({
url: this.PHP,
sendParam: ['data=tabel-detail','mode','mode_detail','No_Beli','ID','InvID','SatuanID','Qty','Harga_Beli','Disk_Rupiah','Disk_Persen1','Disk_Persen2','Disk_Persen3','Disk_Persen4','Disk_Persen5'],
onSuccess: function(){
var _obtn = $('button:contains("Total")');
if (_obtn) _obtn.removeClass('btn-info').addClass('btn-secondary').attr('id','tombolTotal').html('Hutang : '+FoniaJS.FloatToStr($('#Total_Hutang').val(),2));
if (_mdetail=='insert') { this.detail_tambah(); } else FoniaJS.closeWindow(this.winDetail);
}.bind(this)
}).send();
},
total_show: function(){
if (['add','edit'].indexOf($('#mode').val()) == -1) return false;
new Request.JSON({
url: this.PHP,
sendParam: ['data=detail-total'],
onSuccess: function(a){
this.winTotal = FoniaJS.showWindow('Total', 'Informasi Transaksi', a.html, 500, [{},{i:'butTutup'},{i:'butWSimpan',v:'Simpan',c:'success'}], function(){
var dhutang = parseFloat($('#Total_Hutang').val());
if (dhutang==0) dhutang = parseFloat($('#Total_Beli').val());
$('#winTotal')
.find('#butWSimpan').click(function(){this.total_simpan();}.bind(this)).end()
.find('#popTotal_Bulat').keyup(function(e) {
this.Hitung_Total();
if (e.which==13) $('#butWSimpan').focus();
}.bind(this)).end()
.find('#popTotal_Bulat').val($('#Total_Bulat').val()).end()
.find('#popTotal_Hutang').val(dhutang);
FoniaJS.setFocus('#popTotal_Bulat');
}.bind(this), false);
}.bind(this)
}).send();
},
total_simpan: function(){
$('#Total_Bulat').val(FoniaJS.StrToFloat($('#popTotal_Bulat').val()));
$('#Total_Hutang').val(FoniaJS.StrToFloat($('#popTotal_Hutang').val()));
$('#tombolTotal').html('<i class="bi-wallet2 me-1"></i>Hutang : '+FoniaJS.FloatToStr($('#Total_Hutang').val(),2));
FoniaJS.closeWindow(this.winTotal);
},
data_query: function(tipe, mode, kd_tx){
if (tipe=="master"){
mode = (mode) ? mode : '';
var sparam = ['data=master','mode='+mode,'No_Beli'+((typeof(kd_tx)!=='undefined')?'='+kd_tx:'')];
if (-1 !== mode.search(/save/i)) sparam = ['data=master','mode='+mode,'No_Beli','Tgl_Beli','Tgl_Faktur','No_Faktur','CabID','SupID','Total_Bulat='+FoniaJS.StrToFloat($('#Total_Bulat').val()),'Total_Hutang='+FoniaJS.StrToFloat($('#Total_Hutang').val())];
new Request.JSON({
url: this.PHP,
sendParam: sparam,
onSuccess: function(ajson){
$('#divTXMaster').html(ajson.html);
$('#No_Beli').keyup(function(e){
if ((e.which || e.keyCode) == 13) {
if (($("#No_Beli")) && ($("#No_Beli").val() !== '')) this.data_query('master');
}
}.bind(this));
this.data_query('tabel-detail');
if ($.inArray($("#mode").val(),['add','edit']) !== -1) {
$('#butBrow').prop('disabled', true).removeClass('btn-info').addClass('btn-secondary');
$('#butTambah').addClass('d-none');
$('#butUbah').addClass('d-none');
$('#butHapus').addClass('d-none');
$('#butPrint').addClass('d-none');
$('#butSimpan').removeClass('d-none');
$('#butBatal').removeClass('d-none');
$('#butPendingBrow').addClass('d-none');
$('#butPendingSimpan').addClass('d-none');
if (-1 !== $('#No_Beli').val().search(/BELI/i)) $('#butPendingSimpan').removeClass('d-none');
} else {
$('#butBrow').prop('disabled', false).removeClass('btn-secondary').addClass('btn-info');
$('#butTambah').removeClass('d-none');
$('#butUbah').removeClass('d-none');
$('#butHapus').removeClass('d-none');
$('#butPrint').removeClass('d-none');
$('#butSimpan').addClass('d-none');
$('#butBatal').addClass('d-none');
$('#butPendingBrow').removeClass('d-none');
$('#butPendingSimpan').addClass('d-none');
}
$('#butUbah').prop('disabled', ($('#Lunas').val()==1 ? true : false));
$('#butHapus').prop('disabled', ($('#Lunas').val()==1 ? true : false));
if (ajson.error) {
FoniaJS.showError(ajson.error);
FoniaJS.setFocus('#No_Beli');
}
}.bind(this)
}).send();
} else if (tipe=="tabel-detail"){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=tabel-detail','mode','No_Beli'],
onSuccess: function(){
var _obtn = $('button:contains("Total")');
if (_obtn) _obtn.removeClass('btn-info').addClass('btn-secondary').attr('id','tombolTotal').html('<i class="bi-wallet2 me-1"></i>Hutang : '+FoniaJS.FloatToStr($('#Total_Hutang').val(),2));
}
}).send();
} else if (tipe=="brow-tx"){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=brow-tx','Cari_TX'],
onSuccess: function(){
FoniaJS.setFocus('#Cari_TX');
}
}).send();
} else if (tipe=="brow-pending"){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=brow-pending','Cari_Pending'],
onSuccess: function(){
FoniaJS.setFocus('#Cari_Pending');
}
}).send();
} else if (tipe=="brow-produk"){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=brow-produk','Cari_Produk','Filter_Browse','SupID'],
onSuccess: function(){
FoniaJS.setFocus('#Cari_Produk');
}
}).send();
}
},
Produk_Comp: function(item){
var adata = item.data.split(':');
$('#InvID').val(item.value);
$('#SatuanID').val(adata[0]);
$('#Nama_Satuan').val(adata[1]);
$('#Harga_Jual').val(FoniaJS.FloatToStr(adata[3]));
BeliJS.update_Items();
},
update_Items: function(){
new Request.JSON({
url: this.PHP,
sendParam: ['data=detail-item','InvID','SatuanID','SupID'],
onSuccess: function(adata){
if (!adata.data) {
$('#Harga_Beli').val(FoniaJS.FloatToStr(adata.Harga_Beli));
$('#Disk_Rupiah').val(adata.Disk_Rupiah);
$('#Disk_Persen1').val(adata.Disk_Persen1);
$('#Disk_Persen2').val(adata.Disk_Persen2);
$('#Disk_Persen3').val(adata.Disk_Persen3);
$('#Disk_Persen4').val(adata.Disk_Persen4);
$('#Disk_Persen5').val(adata.Disk_Persen5);
this.Hitung_Detail();
}
FoniaJS.setFocus('#Qty');
}.bind(this)
}).send();
},
Hitung_Detail: function(){
var dqty = FoniaJS.StrToFloat($('#Qty').val());
var dharga = FoniaJS.StrToFloat($('#Harga_Beli').val());
var ddiskrp = FoniaJS.StrToFloat($('#Disk_Rupiah').val());
var ddiskp1 = (100.0-FoniaJS.StrToFloat($('#Disk_Persen1').val())) / 100;
var ddiskp2 = (100.0-FoniaJS.StrToFloat($('#Disk_Persen2').val())) / 100;
var ddiskp3 = (100.0-FoniaJS.StrToFloat($('#Disk_Persen3').val())) / 100;
var ddiskp4 = (100.0-FoniaJS.StrToFloat($('#Disk_Persen4').val())) / 100;
var ddiskp5 = (100.0-FoniaJS.StrToFloat($('#Disk_Persen5').val())) / 100;
var dtot = ((dharga - ddiskrp) * ddiskp1 * ddiskp2 * ddiskp3 * ddiskp4 * ddiskp5) * dqty;
var ddis = (dharga * dqty) - dtot;
$('#Total_Diskon').val(FoniaJS.FloatToStr(ddis,2));
$('#Jumlah').val(FoniaJS.FloatToStr(dtot,2));
},
Hitung_Total: function(){
var dbeli = FoniaJS.StrToFloat($('#Total_Beli').val());
var dbulat = FoniaJS.StrToFloat($('#popTotal_Bulat').val());
$('#popTotal_Hutang').val(FoniaJS.FloatToStr(dbeli-dbulat,2));
}
};
+174
View File
@@ -0,0 +1,174 @@
/*******************************************************************
App. Name : INVENTORY AND SALES SYSTEMS
Module : /apps/js/iss/beli_lunas.js
Desc. : JS - Transaksi Pembayaran Pembelian
Created By : Siau Pheng ([email protected]).
Created Date : March 7th, 2011.
Last Modified : October 8th, 2025.
(c) 2011 - 2025, 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
var BeliLunasJS = {
PHP: '',
KODE: '',
loading: function(q){
$('#butMode').click(function(){this.tx_mode();}.bind(this));
$('#butBatal').click(function(){this.tx_batal();}.bind(this));
if (FoniaJS.User.Level>0) $('#butMode').hide();
this.data_query('master', 'view', ((typeof(q)!=='undefined') ? q : ''));
},
tx_mode: function(){
var mode = ($('#Mode_Tampil').val()==1) ? 0 : 1;
$('#Mode_Tampil').val(mode);
$('#butMode').html('<i class="bi-list me-2"></i>'+(mode==1?'Semua':'Normal'));
this.data_query('tabel-nota');
},
tx_batal: function(){
$('#divTXNota').removeClass('d-none');
$('#divDetailNota').addClass('d-none');
$('#divDetailBayar').addClass('d-none');
if (FoniaJS.User.Level==0) $('#butMode').removeClass('d-none');
$('#butBatal').addClass('d-none');
$('#butBrow').prop('disabled', false).removeClass('btn-secondary').addClass('btn-info');
$('#Nama_Sup').prop('disabled', false).removeClass('disabled').addClass('enabled');
this.data_query('tabel-nota');
},
sup_brow: function(){
var _isi = new String('<div class="row mb-1"><div class="col"><div class="input-group"><input class="form-control" id="Cari_Sup" 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></div></div></div><div id="divBrowSup">&nbsp;</div>');
this.winBSup = FoniaJS.showWindow('BSup', 'Daftar Supplier', _isi, 900, '', function(){
$('#winBSup').find('#Cari_Sup').keydown(function(e){
var key = e.keyCode || e.which || 0;
if (key==13 && e.target.value!='') this.data_query('brow-sup');
}.bind(this));
$('#winBSup').find('#butSearch').click(function(e){
this.data_query('brow-sup');
}.bind(this));
$('#winBSup').find('#butAll').click(function(){
$('#winBSup').find('#Cari_Sup').val('');
this.data_query('brow-sup');
}.bind(this));
this.data_query('brow-sup');
FoniaJS.setFocus('#Cari_Sup');
}.bind(this));
},
sup_select: function(acell){
FoniaJS.closeWindow(this.winBSup);
$('#SupID').val(acell[0]);
$('#Nama_Sup').val(acell[2]);
$('#Alamat_Sup').val(acell[4]);
this.data_query('tabel-nota');
},
nota_select: function(acell){
new Request.JSON({
url: this.PHP,
sendParam: ['data=detail-nota','No_Beli='+acell[1],'Tipe_Nota='+acell[0]],
onSuccess: function(ajson){
$('#divDetailNota').html(ajson.html);
$('#divTXNota').addClass('d-none');
$('#divDetailNota').removeClass('d-none');
$('#divDetailBayar').removeClass('d-none');
if (FoniaJS.User.Level==0) $('#butMode').addClass('d-none');
$('#butBatal').removeClass('d-none');
$('#butBrow').prop('disabled', true).removeClass('btn-info').addClass('btn-secondary');
$('#Nama_Sup').prop('disabled', true).removeClass('enabled').addClass('disabled');
this.data_query('tabel-bayar');
}.bind(this)
}).send();
},
bayar_show: function(){
new Request.JSON({
url: this.PHP,
sendParam: ['data=detail-bayar','No_Beli','Total_Sisa'],
onSuccess: function(ajson){
this.winBayar = FoniaJS.showWindow('Bayar', 'Detail Pembayaran', ajson.html, 500, [{},{i:'butTutup'},{i:'butWSimpan',v:'Simpan',c:'success'}], function(){
$('#winBayar').find('#butWSimpan').click(function(){this.bayar_simpan();}.bind(this));
this.Hitung_Detail();
FoniaJS.setFocus('#Total_Bayar');
}.bind(this), false);
}.bind(this)
}).send();
},
bayar_hapus: function(acell){
FoniaJS.showConfirm('Konfirmasi', 'Hapus item <strong>"'+acell[1]+'"</strong> ?', function(){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=tabel-bayar','mode_detail=delete','No_Beli','ID='+acell[0]]
}).send();
}.bind(this), 'danger');
},
bayar_simpan: function(){
if ((FoniaJS.StrToFloat($('#Total_Bayar').val()) + FoniaJS.StrToFloat($('#Total_Potong').val())) > $('#Total_Sisa').val()){
FoniaJS.showError("Jumlah pelunasan melebihi jumlah faktur!");
return;
}
new Request.JSONF({
url: this.PHP,
sendParam: ['data=tabel-bayar','mode_detail=insert','No_Beli','Tgl_Bayar','Total_Bayar','Total_Potong','Tipe_Nota'],
onSuccess: function(){
FoniaJS.closeWindow(this.winBayar);
}.bind(this)
}).send();
},
data_query: function(tipe, mode, kd_tx){
if (tipe=="master"){
new Request.JSON({
url: this.PHP,
sendParam: ['data=master','SupID'+((typeof(kd_tx)!=='undefined')?'='+kd_tx:'')],
onSuccess: function(ajson){
$('#divTXMaster').html(ajson.html);
this.tx_batal();
FoniaJS.AutoComplete('#Nama_Sup', this.PHP, ['data=auto-sup'], this.Sup_Comp);
$('#Nama_Sup').on('click', function(){
$('#Nama_Sup').select();
});
if (ajson.error) {
FoniaJS.showError(ajson.error);
}
FoniaJS.setFocus('#Nama_Sup');
}.bind(this)
}).send();
} else if (tipe=="tabel-nota"){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=tabel-nota','SupID','Mode_Tampil']
}).send();
} else if (tipe=="tabel-bayar"){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=tabel-bayar','No_Beli','Lunas','Mode_Tampil']
}).send();
} else if (tipe=="brow-sup"){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=brow-sup','Cari_Sup'],
onSuccess: function(){
FoniaJS.setFocus('#Cari_Sup');
}
}).send();
}
},
Sup_Comp: function(item){
$('#SupID').val(item.value);
$('#Alamat_Sup').val(item.data);
BeliLunasJS.data_query('tabel-nota');
},
Hitung_Detail: function(){
$('#Temp_Sisa').val(FoniaJS.FloatToStr(FoniaJS.StrToFloat($('#Temp_Total').val()) - FoniaJS.StrToFloat($('#Total_Bayar').val()) - FoniaJS.StrToFloat($('#Total_Potong').val()), 2));
}
};
+165
View File
@@ -0,0 +1,165 @@
/*******************************************************************
App. Name : INVENTORY AND SALES SYSTEMS
Module : /apps/js/iss/beli_lunas_sup.js
Desc. : JS - Transaksi Pelunasan Pembelian / Supplier
Created By : Siau Pheng ([email protected]).
Created Date : March 7th, 2011.
Last Modified : December 11th, 2025.
(c) 2011 - 2025, 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
var BeliLunasSupJS = {
PHP: '',
KODE: '',
loading: function(q){
$('#butSimpan').click(function(){this.tx_simpan();}.bind(this));
$('#butBatal').click(function(){this.tx_batal();}.bind(this));
this.data_query('master', 'view', ((typeof(q)!=='undefined') ? q : ''));
},
tx_simpan: function(mode){
FoniaJS.showConfirm("Konfirmasi", "Yakin akan proses Pelunasan ?", function(){
new Request({
url: this.PHP,
sendParam: ['data=proses-bayar','SupID','Tgl_Bayar'],
onSuccess: function(){
this.data_query('tabel-nota');
}.bind(this)
}).send();
}.bind(this), 'warning');
},
tx_batal: function(){
FoniaJS.showConfirm('Konfirmasi', 'Yakin akan membatalkan ?', function(){
this.data_query('master', 'cancel');
$('#SupID').val(0);
}.bind(this), 'danger');
},
sup_brow: function(){
var _isi = new String('<div class="row mb-1"><div class="col"><div class="input-group"><input class="form-control" id="Cari_Sup" 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></div></div></div><div id="divBrowSup">&nbsp;</div>');
this.winBSup = FoniaJS.showWindow('BSup', 'Daftar Supplier', _isi, 900, '', function(){
$('#winBSup').find('#Cari_Sup').keydown(function(e){
var key = e.keyCode || e.which || 0;
if (key==13 && e.target.value!='') this.data_query('brow-sup');
}.bind(this));
$('#winBSup').find('#butSearch').click(function(e){
this.data_query('brow-sup');
}.bind(this));
$('#winBSup').find('#butAll').click(function(){
$('#winBSup').find('#Cari_Sup').val('');
this.data_query('brow-sup');
}.bind(this));
this.data_query('brow-sup');
FoniaJS.setFocus('#Cari_Sup');
}.bind(this));
},
sup_select: function(acell){
FoniaJS.closeWindow(this.winBSup);
$('#SupID').val(acell[0]);
$('#Nama_Sup').val(acell[2]);
$('#Alamat_Sup').val(acell[4]);
this.data_query('tabel-nota');
},
bayar_tampil: function(acell){
new Request.JSON({
url: this.PHP,
sendParam: ['data=detail-bayar'],
onSuccess: function(ajson){
this.winBayar = FoniaJS.showWindow('Bayar', 'Detail Pembayaran', ajson.html, 600, [{},{i:'butTutup'},{i:'butWSimpan',v:'Simpan',c:'success'}], function(){
$('#winBayar')
.find('#butWSimpan').click(function(){this.bayar_simpan();}.bind(this)).end()
.find('#Jumlah_Bayar').keyup(function(e) {this.Hitung_Bayar();}.bind(this)).end()
.find('#Jumlah_Potong').keyup(function(e) {this.Hitung_Bayar();}.bind(this)).end()
.find('#No_Beli').val(acell[0]).end()
.find('#No_Faktur').val(acell[1]).end()
.find('#Tgl_Faktur').val(acell[2]).end()
.find('#Faktur').val(this.IDR_to_USD(acell[3])).end()
.find('#SBayar').val(this.IDR_to_USD(acell[4])).end()
.find('#Jumlah_Faktur').val(this.IDR_to_USD(acell[5])).end()
.find('#Jumlah_Bayar').val(this.IDR_to_USD((acell[6]==0?acell[5]:acell[6]))).end()
.find('#Jumlah_Potong').val(this.IDR_to_USD(acell[7]));
this.Hitung_Bayar();
FoniaJS.setFocus('#Jumlah_Bayar');
}.bind(this), false);
}.bind(this)
}).send();
},
bayar_simpan: function(){
var djumlah = FoniaJS.StrToFloat($('#Jumlah_Faktur').val());
var dbayar = FoniaJS.StrToFloat($('#Jumlah_Bayar').val());
var dpot = FoniaJS.StrToFloat($('#Jumlah_Potong').val());
if (djumlah<(dbayar+dpot)) {
FoniaJS.showError('Jumlah Pembayaran melebihi Jumlah Faktur !');
return;
}
new Request.JSONF({
url: this.PHP,
sendParam: ['data=tabel-nota','mode_detail','SupID','No_Beli','Jumlah_Bayar','Jumlah_Potong'],
onSuccess: function(){
FoniaJS.closeWindow(this.winBayar);
}.bind(this)
}).send();
},
data_query: function(tipe, mode, kd_tx){
if (tipe=="master"){
new Request.JSON({
url: this.PHP,
sendParam: ['data=master','mode='+mode,'SupID'+((typeof(kd_tx)!=='undefined')?'='+kd_tx:'')],
onSuccess: function(ajson){
$('#divTXMaster').html(ajson.html);
FoniaJS.AutoComplete('#Nama_Sup', this.PHP, ['data=auto-sup'], this.Sup_Comp);
$('#Nama_Sup').on('click', function(){
$('#Nama_Sup').select();
});
$('#Disp_Bayar').addClass('border-success');
if (ajson.error) {
FoniaJS.showError(ajson.error);
}
this.data_query('tabel-nota');
FoniaJS.setFocus('#Nama_Sup');
}.bind(this)
}).send();
} else if (tipe=="tabel-nota"){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=tabel-nota','SupID']
}).send();
} else if (tipe=="brow-sup"){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=brow-sup','Cari_Sup'],
onSuccess: function(){
FoniaJS.setFocus('#Cari_Sup');
}
}).send();
}
},
Sup_Comp: function(item){
$('#SupID').val(item.value);
$('#Alamat_Sup').val(item.data);
BeliLunasSupJS.data_query('tabel-nota');
},
Hitung_Bayar: function(){
var djumlah = FoniaJS.StrToFloat($('#Jumlah_Faktur').val());
var dbayar = FoniaJS.StrToFloat($('#Jumlah_Bayar').val());
var dpot = FoniaJS.StrToFloat($('#Jumlah_Potong').val());
$('#Sisa_Bayar').val(FoniaJS.FloatToStr(djumlah-dbayar-dpot, 2));
},
IDR_to_USD: function(value){
var nilai = value.replace(/\./g,'').replace(',','.');
return FoniaJS.FloatToStr(parseFloat(nilai));
}
};
+290
View File
@@ -0,0 +1,290 @@
/*******************************************************************
App. Name : INVENTORY AND SALES SYSTEMS
Module : /apps/js/iss/beli_retur.js
Desc. : JS - Transaksi Retur Pembelian
Created By : Siau Pheng ([email protected]).
Created Date : May 22th, 2010.
Last Modified : October 10th, 2025.
(c) 2010 - 2025, 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
var BeliReturJS = {
PHP: '',
KODE: '',
loading: function(q){
$('#butTambah').click(function(){this.tx_tambah();}.bind(this));
$('#butUbah').click(function(){this.tx_ubah();}.bind(this));
$('#butHapus').click(function(){this.tx_hapus();}.bind(this));
$('#butSimpan').click(function(){this.tx_simpan();}.bind(this));
$('#butBatal').click(function(){this.tx_batal();}.bind(this));
$('#butPrint').click(function(){this.tx_print();}.bind(this));
this.data_query('master', 'view', ((typeof(q)!=='undefined') ? q : ''));
},
tx_brow: function(){
var _isi = new String('<div class="row mb-1"><div class="col"><div class="input-group"><input class="form-control" id="Cari_TX" 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></div></div></div><div id="divBrowTX">&nbsp;</div>');
this.winBTX = FoniaJS.showWindow('BTX', 'Daftar Transaksi', _isi, 900, '', function(){
$('#winBTX')
.find('#Cari_TX').keydown(function(e){
var key = e.keyCode || e.which || 0;
if (key==13 && e.target.value!='') this.data_query('brow-tx');
}.bind(this)).end()
.find('#butSearch').click(function(e){
this.data_query('brow-tx');
}.bind(this)).end()
.find('#butAll').click(function(){
$('#winBTX').find('#Cari_TX').val('');
this.data_query('brow-tx');
}.bind(this));
this.data_query('brow-tx');
FoniaJS.setFocus('#Cari_TX');
}.bind(this));
},
tx_select: function(acell){
FoniaJS.closeWindow(this.winBTX);
$('#No_Beli').val(acell[0]);
this.data_query('master', 'view');
},
tx_tambah: function(){
this.data_query('master', 'add');
},
tx_ubah: function(){
if (!$('#No_Beli').val()){
FoniaJS.showError("Silakan masukkan Nomor Transaksi !");
return;
}
FoniaJS.showAuth(function(){this.data_query('master', 'edit')}.bind(this), this, 'EDIT '+$('#No_Beli').val());
},
tx_hapus: function(){
if (!$('#No_Beli').val()){
FoniaJS.showError("Silakan masukkan Nomor Transaksi !");
return;
}
FoniaJS.showConfirm('Konfirmasi', 'Yakin akan hapus <strong>'+$('#No_Beli').val()+'</strong> ?', function(){
FoniaJS.showAuth(function(){
new Request.JSON({
url: this.PHP,
sendParam: ['data=delete','No_Beli'],
onSuccess: function(adata){
if (adata.status==true){
$('#No_Beli').val('');
this.data_query('master', 'view');
FoniaJS.showInfo('Proses hapus data sukses!');
}else{
FoniaJS.showInfo('Ada masalah dalam proses hapus data!');
}
}.bind(this)
}).send();
}.bind(this), this, 'DELETE '+$('#No_Beli').val());
}.bind(this), 'danger');
},
tx_simpan: function(){
if ($('#CabID').val()==0){
FoniaJS.showError("Silakan pilih Nama Cabang !");
return;
}
if ($('#SupID').val()==0){
FoniaJS.showError("Silakan pilih Nama Supplier !");
return;
}
this.data_query('master', 'save');
},
tx_batal: function(){
FoniaJS.showConfirm('Konfirmasi', 'Yakin akan membatalkan ?', function(){
this.data_query('master', 'cancel');
$('#No_Beli').val('');
}.bind(this), 'danger');
},
tx_print: function(prt){
if ($('#No_Beli').val()) {
var cetak = new cPRINTER(FoniaJS.WEB_PATH+'apps/php/repo/nota.php');
cetak.add_param("data", "nota-beli-retur");
cetak.add_param("Nomor_Cetak", $('#No_Beli').val());
if (prt) cetak.doPrint(); else cetak.doPreview();
return;
}
FoniaJS.showError("Silakan masukkan Nomor Transaksi !");
},
produk_brow: function(){
if ($('#CabID').val()==0){
FoniaJS.showError("Silakan pilih Nama Cabang !");
return;
}
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></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)).end()
.find('#butSearch').click(function(e){
this.data_query('brow-produk');
}.bind(this)).end()
.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);
this.detail_produk('insert', 0, acell[0], acell[1]);
},
detail_produk: function(mode, ID, InvID, SatuanID){
new Request.JSON({
url: this.PHP,
sendParam: ['data=detail-produk','mode','mode_detail='+mode,'No_Beli','ID='+ID,'InvID='+InvID,'SatuanID='+SatuanID],
onSuccess: function(a){
this.winDetail = FoniaJS.showWindow('Detail', 'Detail Barang', a.html, 700, [{},{i:'butTutup'},{i:'butWSimpan',v:'Simpan',c:'success'}], function(){
FoniaJS.AutoComplete('#Nama_Produk', this.PHP, ['data=auto-produk','No_Beli','CabID','SupID'], {'selectFunc': BeliReturJS.Produk_Comp});
$('#winDetail')
.find('#butWSimpan').click(function(){this.detail_simpan();}.bind(this)).end()
.find('#Qty').keyup(function(e){
this.Hitung_Detail();
if (parseFloat(e.target.value) == 0) return false;
if (-1!==$.inArray(e.which, [13,9])) FoniaJS.setFocus('#Harga_Beli');
}.bind(this)).end()
.find('#Harga_Beli').keyup(function(e){
this.Hitung_Detail();
if (e.which==13 && FoniaJS.StrToFloat($('#Jumlah').val())>0) this.detail_simpan();
}.bind(this));
if (mode == 'insert' && InvID == 0) {
FoniaJS.setFocus('#Nama_Produk');
} else {
this.Hitung_Detail();
FoniaJS.setFocus('#Qty');
}
}.bind(this), false);
}.bind(this)
}).send();
},
detail_tambah: function(){
if ($('#SupID').val()==0){
FoniaJS.showError("Silakan pilih Nama Supplier !");
return;
}
this.detail_produk('insert', 0, 0, 0);
},
detail_ubah: function(acell){
this.detail_produk('update', acell[0], acell[1], acell[2]);
},
detail_hapus: function(acell){
FoniaJS.showConfirm('Konfirmasi', 'Hapus item <strong>"'+acell[2]+'"</strong> ?', function(){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=tabel-detail','mode','mode_detail=delete','No_Beli','ID='+acell[0]]
}).send();
}.bind(this), 'danger');
},
detail_simpan: function(){
if (parseInt($('#InvID').val())==0) {
FoniaJS.showError('Silakan masukkan Nama Barang !');
return;
}
var _mdetail = $('#mode_detail').val();
new Request.JSONF({
url: this.PHP,
sendParam: ['data=tabel-detail','mode','mode_detail','No_Beli','CabID','ID','InvID','SatuanID','Qty','Harga_Beli'],
onSuccess: function(){
if (_mdetail=='insert') { this.detail_tambah(); } else FoniaJS.closeWindow(this.winDetail);
}.bind(this)
}).send();
},
data_query: function(tipe, mode, kd_tx){
if (tipe=="master"){
var sparam = ['data=master','mode='+mode,'No_Beli'+((typeof(kd_tx)!=='undefined')?'='+kd_tx:'')];
if ((mode ?? '')=='save') sparam = ['data=master','mode=save','No_Beli','Tgl_Beli','CabID','SupID','No_Faktur'];
new Request.JSON({
url: this.PHP,
sendParam: sparam,
onSuccess: function(ajson){
$('#divTXMaster').html(ajson.html);
$('#No_Beli').keyup(function(e){
if ((e.which || e.keyCode) == 13) {
if (($("#No_Beli")) && ($("#No_Beli").val() !== '')) this.data_query('master');
}
}.bind(this));
this.data_query('tabel-detail');
if ($.inArray($("#mode").val(),['add','edit']) !== -1) {
$('#butBrow').prop('disabled', true).removeClass('btn-info').addClass('btn-secondary');
$('#butTambah').addClass('d-none');
$('#butUbah').addClass('d-none');
$('#butHapus').addClass('d-none');
$('#butPrint').addClass('d-none');
$('#butSimpan').removeClass('d-none');
$('#butBatal').removeClass('d-none');
} else {
$('#butBrow').prop('disabled', false).removeClass('btn-secondary').addClass('btn-info');
$('#butTambah').removeClass('d-none');
$('#butUbah').removeClass('d-none');
$('#butHapus').removeClass('d-none');
$('#butPrint').removeClass('d-none');
$('#butSimpan').addClass('d-none');
$('#butBatal').addClass('d-none');
}
if (ajson.error) {
FoniaJS.showError(ajson.error);
FoniaJS.setFocus('#No_Beli');
}
if ($('#mode').val()=='print') this.tx_print(true);
}.bind(this)
}).send();
} else if (tipe=="tabel-detail"){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=tabel-detail','mode','No_Beli']
}).send();
} else if (tipe=="brow-tx"){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=brow-tx','Cari_TX'],
onSuccess: function(){
FoniaJS.setFocus('#Cari_TX');
}
}).send();
} else if (tipe=="brow-produk"){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=brow-produk','CabID','Cari_Produk'],
onSuccess: function(){
FoniaJS.setFocus('#Cari_Produk');
}
}).send();
}
},
Produk_Comp: function(item){
var adata = item.data.split(':');
$('#InvID').val(item.value);
$('#SatuanID').val(adata[0]);
$('#Nama_Satuan').val(adata[1]);
$('#Harga_Beli').val(adata[2]);
FoniaJS.setFocus('#Qty');
},
Hitung_Detail: function(){
$('#Jumlah').val(FoniaJS.FloatToStr(FoniaJS.StrToFloat($('#Qty').val()) * FoniaJS.StrToFloat($('#Harga_Beli').val()), 2));
}
};
+113
View File
@@ -0,0 +1,113 @@
/*******************************************************************
App. Name : INVENTORY AND SALES SYSTEMS
Module : /apps/js/iss/cekharga.js
Desc. : JS - Informasi Barang & Harga Jual
Created By : Siau Pheng ([email protected]).
Created Date : October 22nd, 2014.
Last Modified : January 4th, 2025.
(c) 2014 - 2025, 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
var CekHargaJS = {
PHP: '',
KODE: '',
html5QrcodeScanner: null,
loading: function(){
$('#butBrow').click(function(){this.produk_brow();}.bind(this));
if (FoniaJS.WEB_MOBILE){
//html5QrcodeScanner = new Html5QrcodeScanner('qr-reader', { fps: 10, qrbox: 250, rememberLastUsedCamera: true, supportedScanTypes: [Html5QrcodeScanType.SCAN_TYPE_CAMERA] });
html5QrcodeScanner = new Html5Qrcode('qr-reader');
html5QrcodeScanner.start({ facingMode: 'environment' }, { fps: 10, qrbox: 250 }, CekHargaJS.ScanSukses);
} else {
FoniaJS.AutoComplete('#Nama_Produk', this.PHP, ['data=auto-produk'], {'selectFunc': CekHargaJS.Produk_Comp});
FoniaJS.setFocus('#Nama_Produk');
}
},
/* release QRScanner
if (FoniaJS.WEB_MOBILE){
this.html5QrcodeScanner.resume();
} else FoniaJS.setFocus('Nama_Produk');
*/
ScanSukses: function(decodedText, decodedResult){
new Request.JSON({
url: CekHargaJS.PHP,
sendParam: ['data=scan-produk','Cari_Produk='+decodedText],
onSuccess: function(ajson){
$('#InvID').val(ajson.InvID);
$('#Kode_Barang').val(ajson.Kode_Barang);
$('#Nama_Barang').val(ajson.Nama_Barang);
$('#Nama_Satuan').val(ajson.Nama_Satuan);
$('#Harga_Jual').val(ajson.Harga_Jual);
$('#Nama_Supplier').val(ajson.Nama_Supplier);
}
}).send();
//this.html5QrcodeScanner.pause();
},
produk_brow: function(){
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></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)).end()
.find('#butSearch').click(function(e){
this.data_query('brow-produk');
}.bind(this)).end()
.find('#butAll').click(function(){
$('#winBProduk').find('#Cari_Produk').val('');
this.data_query('brow-produk');
}.bind(this));
this.data_query('brow-produk');
}.bind(this));
},
produk_select: function(acell){
FoniaJS.closeWindow(this.winBProduk);
$('#InvID').val(acell[0]);
$('#Kode_Barang').val(acell[1]+' / '+acell[2]);
$('#Nama_Barang').val(acell[5]);
$('#Nama_Satuan').val(acell[6]);
$('#Harga_Jual').val(acell[4]);
this.update_Sup();
},
data_query: function(tipe){
if (tipe=="brow-produk"){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=brow-produk','Cari_Produk'],
onSuccess: function(){
FoniaJS.setFocus('#Cari_Produk');
}
}).send();
}
},
Produk_Comp: function(item){
var adata = item.data.split(':');
$('#InvID').val(item.value);
$('#Kode_Barang').val(adata[0]);
$('#Nama_Barang').val(adata[1]);
$('#Nama_Satuan').val(adata[2]);
$('#Harga_Jual').val(adata[3]);
$('#Nama_Produk').val('');
$('#Nama_Produk').focus();
CekHargaJS.update_Sup();
},
update_Sup: function(){
if ($('#InvID').val()==0) return false;
new Request.JSONF({
url: this.PHP,
sendParam: ['data=cek_supplier','InvID']
}).send();
}
};
+294
View File
@@ -0,0 +1,294 @@
/*******************************************************************
App. Name : INVENTORY AND SALES SYSTEMS
Module : /apps/js/iss/mutasi.js
Desc. : JS - Transaksi Mutasi Stok Cabang
Created By : Siau Pheng ([email protected]).
Created Date : February 28th, 2011.
Last Modified : December 10th, 2025.
(c) 2011 - 2025, 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
var MutasiJS = {
PHP: '',
KODE: '',
loading: function(q){
$('#butTambah').click(function(){this.tx_tambah();}.bind(this));
$('#butUbah').click(function(){this.tx_ubah();}.bind(this));
$('#butHapus').click(function(){this.tx_hapus();}.bind(this));
$('#butSimpan').click(function(){this.tx_simpan();}.bind(this));
$('#butBatal').click(function(){this.tx_batal();}.bind(this));
$('#butPrint').click(function(){this.tx_print();}.bind(this));
this.data_query('master', 'view', ((typeof(q)!=='undefined') ? q : ''));
},
tx_brow: function(){
var _isi = new String('<div class="row mb-1"><div class="col"><div class="input-group"><input class="form-control" id="Cari_TX" 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></div></div></div><div id="divBrowTX">&nbsp;</div>');
this.winBTX = FoniaJS.showWindow('BTX', 'Daftar Transaksi', _isi, 900, '', function(){
$('#winBTX')
.find('#Cari_TX').keydown(function(e){
var key = e.keyCode || e.which || 0;
if (key==13 && e.target.value!='') this.data_query('brow-tx');
}.bind(this)).end()
.find('#butSearch').click(function(e){
this.data_query('brow-tx');
}.bind(this)).end()
.find('#butAll').click(function(){
$('#winBTX').find('#Cari_TX').val('');
this.data_query('brow-tx');
}.bind(this));
this.data_query('brow-tx');
FoniaJS.setFocus('#Cari_TX');
}.bind(this));
},
tx_select: function(acell){
FoniaJS.closeWindow(this.winBTX);
$('#No_Mutasi').val(acell[0]);
this.data_query('master', 'view');
},
tx_tambah: function(){
this.data_query('master', 'add');
},
tx_ubah: function(){
if (!$('#No_Mutasi').val()){
FoniaJS.showError("Silakan masukkan Nomor Transaksi !");
return;
}
FoniaJS.showAuth(function(){this.data_query('master', 'edit')}.bind(this), this, 'EDIT '+$('#No_Mutasi').val());
},
tx_hapus: function(){
if (!$('#No_Mutasi').val()){
FoniaJS.showError("Silakan masukkan Nomor Transaksi !");
return;
}
FoniaJS.showConfirm('Konfirmasi', 'Yakin akan hapus <strong>'+$('#No_Mutasi').val()+'</strong> ?', function(){
FoniaJS.showAuth(function(){
new Request.JSON({
url: this.PHP,
sendParam: ['data=delete','No_Mutasi'],
onSuccess: function(adata){
if (adata.status==true){
$('#No_Mutasi').val('');
this.data_query('master', 'view');
FoniaJS.showInfo('Proses hapus data sukses!');
}else{
FoniaJS.showInfo('Ada masalah dalam proses hapus data!');
}
}.bind(this)
}).send();
}.bind(this), this, 'DELETE '+$('#No_Mutasi').val());
}.bind(this), 'danger');
},
tx_simpan: function(){
this.data_query('master', 'save');
},
tx_batal: function(){
FoniaJS.showConfirm('Konfirmasi', 'Yakin akan membatalkan ?', function(){
this.data_query('master', 'cancel');
$('#No_Mutasi').val('');
}.bind(this), 'danger');
},
tx_print: function(prt){
if ($('#No_Mutasi').val()) {
var cetak = new cPRINTER(FoniaJS.WEB_PATH+'apps/php/repo/nota.php');
cetak.add_param("data", "nota-mutasi");
cetak.add_param("Nomor_Cetak", $('#No_Mutasi').val());
if (prt) cetak.doPrint(); else cetak.doPreview();
return;
}
FoniaJS.showError("Silakan masukkan Nomor Transaksi !");
},
produk_brow: function(){
if ($('#Dari_CabID').val()==0){
FoniaJS.showError("Silakan pilih Dari Cabang !");
return;
}
if ($('#Ke_CabID').val()==0){
FoniaJS.showError("Silakan pilih Ke Cabang !");
return;
}
if ($('#Dari_CabID').val()==$('#Ke_CabID').val()){
FoniaJS.showError("Dari Cabang dan Ke Cabang tidak boleh sama !");
return;
}
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></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)).end()
.find('#butSearch').click(function(e){
this.data_query('brow-produk');
}.bind(this)).end()
.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);
this.detail_produk('insert', 0, acell[0], acell[1], acell[2]);
},
detail_produk: function(mode, ID, InvID, SatuanID, HPP){
new Request.JSON({
url: this.PHP,
sendParam: ['data=detail-produk','mode','mode_detail='+mode,'No_Mutasi','ID='+ID,'InvID='+InvID,'SatuanID='+SatuanID,'HPP='+HPP],
onSuccess: function(a){
this.winDetail = FoniaJS.showWindow('Detail', 'Detail Barang', a.html, 600, [{},{i:'butTutup'},{i:'butWSimpan',v:'Simpan',c:'success'}], function(){
FoniaJS.AutoComplete('#Nama_Produk', this.PHP, ['data=auto-produk','No_Mutasi','Dari_CabID'], {'selectFunc': MutasiJS.Produk_Comp});
$('#winDetail')
.find('#butWSimpan').click(function(){this.detail_simpan();}.bind(this)).end()
.find('#Qty').keyup(function(e){
this.Hitung_Detail();
if (parseFloat(e.target.value) == 0) return false;
if (-1!==$.inArray(e.which, [13,9])) this.detail_simpan();
}.bind(this));
if (mode == 'insert' && InvID == 0) {
FoniaJS.setFocus('#Nama_Produk');
} else {
this.Hitung_Detail();
FoniaJS.setFocus('#Qty');
}
}.bind(this), null, false);
}.bind(this)
}).send();
},
detail_tambah: function(){
if ($('#Dari_CabID').val()==0){
FoniaJS.showError("Silakan pilih Dari Cabang !");
return;
}
if ($('#Ke_CabID').val()==0){
FoniaJS.showError("Silakan pilih Ke Cabang !");
return;
}
if ($('#Dari_CabID').val()==$('#Ke_CabID').val()){
FoniaJS.showError("Dari Cabang dan Ke Cabang tidak boleh sama !");
return;
}
this.detail_produk('insert', 0, 0, 0, 0);
},
detail_ubah: function(acell){
this.detail_produk('update', acell[0], acell[1], acell[2], acell[3]);
},
detail_hapus: function(acell){
FoniaJS.showConfirm('Konfirmasi', 'Hapus item <strong>"'+acell[2]+'"</strong> ?', function(){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=tabel-detail','mode','mode_detail=delete','No_Mutasi','ID='+acell[0]]
}).send();
}.bind(this), 'danger');
},
detail_simpan: function(){
if (parseInt($('#InvID').val())==0) {
FoniaJS.showError('Silakan masukkan Nama Barang !');
return;
}
var _mdetail = $('#mode_detail').val();
new Request.JSONF({
url: this.PHP,
sendParam: ['data=tabel-detail','mode','mode_detail','No_Mutasi','Dari_CabID','Ke_CabID','ID','InvID','SatuanID','Qty','Harga_Beli'],
onSuccess: function(){
if (_mdetail=='insert') { this.detail_tambah(); } else FoniaJS.closeWindow(this.winDetail);
}.bind(this)
}).send();
},
data_query: function(tipe, mode, kd_tx){
if (tipe=="master"){
var sparam = ['data=master','mode='+mode,'No_Mutasi'+((typeof(kd_tx)!=='undefined')?'='+kd_tx:'')];
if ((mode ?? '')=='save') sparam = ['data=master','mode=save','No_Mutasi','Tgl_Mutasi','Dari_CabID','Ke_CabID','Catatan'];
new Request.JSON({
url: this.PHP,
sendParam: sparam,
onSuccess: function(ajson){
$('#divTXMaster').html(ajson.html);
$('#No_Mutasi').keyup(function(e){
if ((e.which || e.keyCode) == 13) {
if (($("#No_Mutasi")) && ($("#No_Mutasi").val() !== '')) this.data_query('master');
}
}.bind(this));
this.data_query('tabel-detail');
if ($.inArray($("#mode").val(),['add','edit']) !== -1) {
$('#butBrow').prop('disabled', true).removeClass('btn-info').addClass('btn-secondary');
$('#butTambah').addClass('d-none');
$('#butUbah').addClass('d-none');
$('#butHapus').addClass('d-none');
$('#butPrint').addClass('d-none');
$('#butSimpan').removeClass('d-none');
$('#butBatal').removeClass('d-none');
} else {
$('#butBrow').prop('disabled', false).removeClass('btn-secondary').addClass('btn-info');
$('#butTambah').removeClass('d-none');
$('#butUbah').removeClass('d-none');
$('#butHapus').removeClass('d-none');
$('#butPrint').removeClass('d-none');
$('#butSimpan').addClass('d-none');
$('#butBatal').addClass('d-none');
}
if (ajson.error) {
FoniaJS.showError(ajson.error);
FoniaJS.setFocus('#No_Mutasi');
}
}.bind(this)
}).send();
} else if (tipe=="tabel-detail"){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=tabel-detail','mode','No_Mutasi']
}).send();
} else if (tipe=="brow-tx"){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=brow-tx','Cari_TX'],
onSuccess: function(){
FoniaJS.setFocus('#Cari_TX');
}
}).send();
} else if (tipe=="brow-produk"){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=brow-produk','Dari_CabID','Cari_Produk'],
onSuccess: function(){
FoniaJS.setFocus('#Cari_Produk');
}
}).send();
}
},
Produk_Comp: function(item){
var adata = item.data.split(':');
$('#InvID').val(item.value);
$('#SatuanID').val(adata[3]);
$('#Kode_Barang').val(adata[0]);
$('#Nama_Satuan').val(adata[2]);
$('#Harga_Beli').val(adata[4]);
FoniaJS.setFocus('#Qty');
},
Hitung_Detail: function(){
$('#Jumlah').val(FoniaJS.FloatToStr(FoniaJS.StrToFloat($('#Qty').val()) * FoniaJS.StrToFloat($('#Harga_Beli').val()), 2));
}
};
+286
View File
@@ -0,0 +1,286 @@
/*******************************************************************
App. Name : INVENTORY AND SALES SYSTEMS
Module : /apps/js/iss/opname.js
Desc. : JS - Transaksi Opname Stok Barang
Created By : Siau Pheng ([email protected]).
Created Date : May 24th, 2010.
Last Modified : September 29th, 2025.
(c) 2010 - 2025, 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
var OpnameJS = {
PHP: '',
KODE: '',
loading: function(q){
$('#butTambah').click(function(){this.tx_tambah();}.bind(this));
$('#butUbah').click(function(){this.tx_ubah();}.bind(this));
$('#butHapus').click(function(){this.tx_hapus();}.bind(this));
$('#butSimpan').click(function(){this.tx_simpan();}.bind(this));
$('#butBatal').click(function(){this.tx_batal();}.bind(this));
$('#butPrint').click(function(){this.tx_print();}.bind(this));
this.data_query('master', 'view', ((typeof(q)!=='undefined') ? q : ''));
},
tx_brow: function(){
var _isi = new String('<div class="row mb-1"><div class="col"><div class="input-group"><input class="form-control" id="Cari_TX" 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></div></div></div><div id="divBrowTX">&nbsp;</div>');
this.winBTX = FoniaJS.showWindow('BTX', 'Daftar Transaksi', _isi, 900, '', function(){
$('#winBTX')
.find('#Cari_TX').keydown(function(e){
var key = e.keyCode || e.which || 0;
if (key==13 && e.target.value!='') this.data_query('brow-tx');
}.bind(this)).end()
.find('#butSearch').click(function(e){
this.data_query('brow-tx');
}.bind(this)).end()
.find('#butAll').click(function(){
$('#winBTX').find('#Cari_TX').val('');
this.data_query('brow-tx');
}.bind(this));
this.data_query('brow-tx');
FoniaJS.setFocus('#Cari_TX');
}.bind(this));
},
tx_select: function(acell){
FoniaJS.closeWindow(this.winBTX);
$('#No_Opname').val(acell[0]);
this.data_query('master', 'view');
},
tx_tambah: function(){
this.data_query('master', 'add');
},
tx_ubah: function(){
if (!$('#No_Opname').val()){
FoniaJS.showError("Silakan masukkan Nomor Transaksi !");
return;
}
FoniaJS.showAuth(function(){this.data_query('master', 'edit')}.bind(this), this, 'EDIT '+$('#No_Opname').val());
},
tx_hapus: function(){
if (!$('#No_Opname').val()){
FoniaJS.showError("Silakan masukkan Nomor Transaksi !");
return;
}
FoniaJS.showConfirm('Konfirmasi', 'Yakin akan hapus <strong>'+$('#No_Opname').val()+'</strong> ?', function(){
FoniaJS.showAuth(function(){
new Request.JSON({
url: this.PHP,
sendParam: ['data=delete','No_Opname'],
onSuccess: function(adata){
if (adata.status==true){
$('#No_Opname').val('');
this.data_query('master', 'view');
FoniaJS.showInfo('Proses hapus data sukses!');
}else{
FoniaJS.showInfo('Ada masalah dalam proses hapus data!');
}
}.bind(this)
}).send();
}.bind(this), this, 'DELETE '+$('#No_Opname').val());
}.bind(this), 'danger');
},
tx_simpan: function(){
if ($('#CabID').val()==0){
FoniaJS.showError("Silakan pilih Nama Cabang !");
return;
}
this.data_query('master', 'save');
},
tx_batal: function(){
FoniaJS.showConfirm('Konfirmasi', 'Yakin akan membatalkan ?', function(){
this.data_query('master', 'cancel');
$('#No_Opname').val('');
}.bind(this), 'danger');
},
tx_print: function(prt){
if ($('#No_Opname').val()) {
var cetak = new cPRINTER(FoniaJS.WEB_PATH+'apps/php/repo/nota.php');
cetak.add_param("data", "nota-opname");
cetak.add_param("Nomor_Cetak", $('#No_Opname').val());
if (prt) cetak.doPrint(); else cetak.doPreview();
return;
}
FoniaJS.showError("Silakan masukkan Nomor Transaksi !");
},
produk_brow: function(){
if ($('#CabID').val()==0){
FoniaJS.showError("Silakan pilih Nama Cabang !");
return;
}
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></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)).end()
.find('#butSearch').click(function(e){
this.data_query('brow-produk');
}.bind(this)).end()
.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);
this.detail_produk('insert', 0, acell[0], acell[1], acell[2]);
},
detail_produk: function(mode, ID, InvID, SatuanID, HPP){
new Request.JSON({
url: this.PHP,
sendParam: ['data=detail-produk','mode','mode_detail='+mode,'No_Opname','ID='+ID,'InvID='+InvID,'SatuanID='+SatuanID,'HPP='+HPP],
onSuccess: function(a){
this.winDetail = FoniaJS.showWindow('Detail', 'Detail Barang', a.html, 600, [{},{i:'butTutup'},{i:'butWSimpan',v:'Simpan',c:'success'}], function(){
FoniaJS.AutoComplete('#Nama_Produk', this.PHP, ['data=auto-produk','No_Opname','Tgl_Opname','CabID'], {'selectFunc': OpnameJS.Produk_Comp});
$('#winDetail')
.find('#butWSimpan').click(function(){this.detail_simpan();}.bind(this)).end()
.find('#Qty').keyup(function(e){
if (parseFloat(e.target.value) == 0) return false;
if (-1!==$.inArray(e.which, [13,9])) this.detail_simpan();
}.bind(this));
if (mode == 'insert' && InvID == 0) {
FoniaJS.setFocus('#Nama_Produk');
} else {
FoniaJS.setFocus('#Qty');
}
this.update_stok();
}.bind(this), null, false);
}.bind(this)
}).send();
},
detail_tambah: function(){
if ($('#CabID').val()==0){
FoniaJS.showError("Silakan pilih Nama Cabang !");
return;
}
this.detail_produk('insert', 0, 0, 0, 0);
},
detail_ubah: function(acell){
this.detail_produk('update', acell[0], acell[1], acell[2], acell[3]);
},
detail_hapus: function(acell){
FoniaJS.showConfirm('Konfirmasi', 'Hapus item <strong>"'+acell[2]+'"</strong> ?', function(){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=tabel-detail','mode','mode_detail=delete','No_Opname','ID='+acell[0]]
}).send();
}.bind(this), 'danger');
},
detail_simpan: function(){
if (parseInt($('#InvID').val())==0) {
FoniaJS.showError('Silakan masukkan Nama Barang !');
return;
}
var _mdetail = $('#mode_detail').val();
new Request.JSONF({
url: this.PHP,
sendParam: ['data=tabel-detail','mode','mode_detail','No_Opname','CabID','ID','InvID','SatuanID','Qty','Harga_Beli'],
onSuccess: function(){
if (_mdetail=='insert') { this.detail_tambah(); } else FoniaJS.closeWindow(this.winDetail);
}.bind(this)
}).send();
},
data_query: function(tipe, mode, kd_tx){
if (tipe=="master"){
var sparam = ['data=master','mode='+mode,'No_Opname'+((typeof(kd_tx)!=='undefined')?'='+kd_tx:'')];
if ((mode ?? '')=='save') sparam = ['data=master','mode=save','No_Opname','Tgl_Opname','CabID','Catatan'];
new Request.JSON({
url: this.PHP,
sendParam: sparam,
onSuccess: function(ajson){
$('#divTXMaster').html(ajson.html);
$('#No_Opname').keyup(function(e){
if ((e.which || e.keyCode) == 13) {
if (($("#No_Opname")) && ($("#No_Opname").val() !== '')) this.data_query('master');
}
}.bind(this));
this.data_query('tabel-detail');
if ($.inArray($("#mode").val(),['add','edit']) !== -1) {
$('#butBrow').prop('disabled', true).removeClass('btn-info').addClass('btn-secondary');
$('#butTambah').addClass('d-none');
$('#butUbah').addClass('d-none');
$('#butHapus').addClass('d-none');
$('#butPrint').addClass('d-none');
$('#butSimpan').removeClass('d-none');
$('#butBatal').removeClass('d-none');
} else {
$('#butBrow').prop('disabled', false).removeClass('btn-secondary').addClass('btn-info');
$('#butTambah').removeClass('d-none');
$('#butUbah').removeClass('d-none');
$('#butHapus').removeClass('d-none');
$('#butPrint').removeClass('d-none');
$('#butSimpan').addClass('d-none');
$('#butBatal').addClass('d-none');
}
if (ajson.error) {
FoniaJS.showError(ajson.error);
FoniaJS.setFocus('#No_Opname');
}
if ($('#mode').val()=='print') this.tx_print(true);
}.bind(this)
}).send();
} else if (tipe=="tabel-detail"){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=tabel-detail','mode','No_Opname']
}).send();
} else if (tipe=="brow-tx"){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=brow-tx','Cari_TX'],
onSuccess: function(){
FoniaJS.setFocus('#Cari_TX');
}
}).send();
} else if (tipe=="brow-produk"){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=brow-produk','CabID','Cari_Produk'],
onSuccess: function(){
FoniaJS.setFocus('#Cari_Produk');
}
}).send();
}
},
Produk_Comp: function(item){
var adata = item.data.split(':');
$('#InvID').val(item.value);
$('#SatuanID').val(adata[3]);
$('#Kode_Barang').val(adata[0]);
$('#Nama_Satuan').val(adata[2]);
$('#Harga_Beli').val(adata[4]);
OpnameJS.update_stok();
FoniaJS.setFocus('#Qty');
},
update_stok: function(){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=cek_stok','Tgl_Opname','CabID','InvID']
}).send();
}
};
+128
View File
@@ -0,0 +1,128 @@
/*******************************************************************
App. Name : INVENTORY AND SALES SYSTEMS
Module : /apps/js/iss/opname_barang.js
Desc. : JS - Transaksi Penyesuaian Stok Per Barang
Created By : Siau Pheng ([email protected]).
Created Date : October 22nd, 2014.
Last Modified : September 21st, 2025.
(c) 2014 - 2025, 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
var OpnameBarangJS = {
PHP: '',
KODE: '',
html5QrcodeScanner: null,
loading: function(){
$('#butSimpan').click(function(){this.proses_save();}.bind(this));
$('#butBrow').click(function(){this.produk_brow();}.bind(this));
if (FoniaJS.WEB_MOBILE){
//html5QrcodeScanner = new Html5QrcodeScanner('qr-reader', { fps: 10, qrbox: 250, rememberLastUsedCamera: true, supportedScanTypes: [Html5QrcodeScanType.SCAN_TYPE_CAMERA] });
html5QrcodeScanner = new Html5Qrcode('qr-reader');
html5QrcodeScanner.start({ facingMode: 'environment' }, { fps: 10, qrbox: 250 }, OpnameBarangJS.ScanSukses);
} else {
FoniaJS.AutoComplete('#Nama_Produk', this.PHP, ['data=auto-produk'], {'selectFunc': OpnameBarangJS.Produk_Comp});
FoniaJS.setFocus('#Nama_Produk');
}
},
proses_save: function(){
if ($('#InvID').val()==0) {
FoniaJS.showError('Silakan masukkan Nama Produk!');
return;
}
new Request.JSON({
url: this.PHP,
sendParam: ['data=simpan-opname','InvID','Stok_Fisik'],
onSuccess: function(ares){
if (ares.Status){
FoniaJS.showInfo('Sukses simpan penyesuaian Stok !');
$('#InvID').val(0);
$('.form-control').val('')
if (FoniaJS.WEB_MOBILE){
this.html5QrcodeScanner.resume();
} else FoniaJS.setFocus('Nama_Produk');
}
}.bind(this)
}).send();
},
ScanSukses: function(decodedText, decodedResult){
new Request.JSON({
url: OpnameBarangJS.PHP,
sendParam: ['data=scan-produk','Cari_Produk='+decodedText],
onSuccess: function(ajson){
$('#InvID').val(ajson.InvID);
$('#Kode_Barang').val(ajson.Kode_Barang);
$('#Nama_Barang').val(ajson.Nama_Barang);
$('#Nama_Satuan').val(ajson.Nama_Satuan);
$('#Stok_Sistem').val(ajson.Stok_Sistem);
FoniaJS.setFocus('#Stok_Fisik');
}
}).send();
this.html5QrcodeScanner.pause();
},
produk_brow: function(){
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></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)).end()
.find('#butSearch').click(function(e){
this.data_query('brow-produk');
}.bind(this)).end()
.find('#butAll').click(function(){
$('#winBProduk').find('#Cari_Produk').val('');
this.data_query('brow-produk');
}.bind(this));
this.data_query('brow-produk');
}.bind(this));
},
produk_select: function(acell){
FoniaJS.closeWindow(this.winBProduk);
$('#InvID').val(acell[0]);
$('#Kode_Barang').val(acell[1]+' / '+acell[2]);
$('#Nama_Barang').val(acell[5]);
$('#Nama_Satuan').val(acell[6]);
OpnameBarangJS.update_Stok();
},
data_query: function(tipe){
if (tipe=="brow-produk"){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=brow-produk','Cari_Produk'],
onSuccess: function(){
FoniaJS.setFocus('#Cari_Produk');
}
}).send();
}
},
Produk_Comp: function(item){
var adata = item.data.split(':');
$('#InvID').val(item.value);
$('#Kode_Barang').val(adata[0]);
$('#Nama_Barang').val(adata[1]);
$('#Nama_Satuan').val(adata[2]);
OpnameBarangJS.update_Stok();
},
update_Stok: function(){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=cek_stok','InvID'],
onSuccess: function(){
FoniaJS.setFocus('#Stok_Fisik');
}
}).send();
}
};
+348
View File
@@ -0,0 +1,348 @@
/*******************************************************************
App. Name : INVENTORY AND SALES SYSTEMS
Module : /apps/js/iss/po.js
Desc. : JS - Transaksi Pembuatan Purchase Order
Created By : Siau Pheng ([email protected]).
Created Date : May 22th, 2010.
Last Modified : January 19th, 2026.
(c) 2010 - 2026, 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
var POJS = {
PHP: '',
KODE: '',
loading: function(q){
$('#butTambah').click(function(){this.tx_tambah();}.bind(this));
$('#butUbah').click(function(){this.tx_ubah();}.bind(this));
$('#butHapus').click(function(){this.tx_hapus();}.bind(this));
$('#butSimpan').click(function(){this.tx_simpan();}.bind(this));
$('#butBatal').click(function(){this.tx_batal();}.bind(this));
$('#butPrint').click(function(){this.tx_print();}.bind(this));
$('#butShare').click(function(){this.tx_share();}.bind(this));
this.data_query('master', 'view', ((typeof(q)!=='undefined') ? q : ''));
},
tx_brow: function(){
var _isi = new String('<div class="row mb-1"><div class="col"><div class="input-group"><input class="form-control" id="Cari_TX" 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></div></div></div><div id="divBrowTX">&nbsp;</div>');
this.winBTX = FoniaJS.showWindow('BTX', 'Daftar Transaksi', _isi, 900, '', function(){
$('#winBTX').find('#Cari_TX').keydown(function(e){
var key = e.keyCode || e.which || 0;
if (key==13 && e.target.value!='') this.data_query('brow-tx');
}.bind(this));
$('#winBTX').find('#butSearch').click(function(e){
this.data_query('brow-tx');
}.bind(this));
$('#winBTX').find('#butAll').click(function(){
$('#winBTX').find('#Cari_TX').val('');
this.data_query('brow-tx');
}.bind(this));
this.data_query('brow-tx');
FoniaJS.setFocus('#Cari_TX');
}.bind(this));
},
tx_select: function(acell){
FoniaJS.closeWindow(this.winBTX);
$('#No_PO').val(acell[0]);
this.data_query('master', 'view');
},
tx_tambah: function(){
this.data_query('master', 'add');
},
tx_ubah: function(){
if (!$('#No_PO').val()){
FoniaJS.showError("Silakan masukkan Nomor Transaksi !");
return;
}
FoniaJS.showAuth(function(){this.data_query('master', 'edit')}.bind(this), this, 'EDIT '+$('#No_PO').val());
},
tx_hapus: function(){
if (!$('#No_PO').val()){
FoniaJS.showError("Silakan masukkan Nomor Transaksi !");
return;
}
FoniaJS.showConfirm('Konfirmasi', 'Yakin akan hapus <strong>'+$('#No_PO').val()+'</strong> ?', function(){
FoniaJS.showAuth(function(){
new Request.JSON({
url: this.PHP,
sendParam: ['data=delete','No_PO'],
onSuccess: function(adata){
if (adata.status==true){
$('#No_PO').val('');
this.data_query('master', 'view');
FoniaJS.showInfo('Proses hapus data sukses!');
}else{
FoniaJS.showInfo('Ada masalah dalam proses hapus data!');
}
}.bind(this)
}).send();
}.bind(this), this, 'DELETE '+$('#No_PO').val());
}.bind(this), 'danger');
},
tx_simpan: function(mode){
if ($('#CabID').val()==0){
FoniaJS.showError("Silakan pilih Nama Cabang !");
return;
}
if ($('#SupID').val()==0){
FoniaJS.showError("Silakan pilih Nama Supplier !");
return;
}
this.data_query('master', 'save');
},
tx_batal: function(){
FoniaJS.showConfirm('Konfirmasi', 'Yakin akan membatalkan ?', function(){
this.data_query('master', 'cancel');
$('#No_PO').val('');
}.bind(this), 'danger');
},
tx_print: function(){
if ($('#No_PO').val()) {
if (FoniaJS.WEB_MOBILE){
var dload = new cEXPORT({'url':FoniaJS.WEB_PATH+'apps/php/pdf/po.php'});
dload.add_param("data", "pdf-po");
dload.add_param("mode", "share");
dload.add_param("Nomor_Cetak", $('#No_PO').val());
dload.download();
} else {
var cetak = new cPDF(FoniaJS.WEB_PATH+'apps/php/pdf/po.php');
cetak.add_param("data", "pdf-po");
cetak.add_param("Nomor_Cetak", $('#No_PO').val());
cetak.showPDF();
}
return;
}
FoniaJS.showError("Silakan masukkan Nomor Transaksi !");
},
tx_share: function(){
if ($('#No_PO').val()) {
var dload = new cSHARE({'url':FoniaJS.WEB_PATH+'apps/php/pdf/po.php'});
dload.add_param("data", "pdf-po");
dload.add_param("mode", "share");
dload.add_param("Nomor_Cetak", $('#No_PO').val());
dload.share();
return;
}
FoniaJS.showError("Silakan masukkan Nomor Transaksi !");
},
produk_brow: function(){
if ($('#SupID').val()==0){
FoniaJS.showError("Silakan pilih Nama Supplier !");
return;
}
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="Filter_Browse" value="all" /></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(){
if ($('#Filter_Browse').val()=='filter') {
$('#Filter_Browse').val('all');
$('#butAll').html('Semua');
} else {
$('#Filter_Browse').val('filter');
$('#butAll').html('Supplier');
}
$('#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);
this.detail_produk('insert', 0, acell[0], acell[1]);
},
detail_produk: function(mode, ID, InvID, SatuanID){
new Request.JSON({
url: this.PHP,
sendParam: ['data=detail-produk','No_PO','mode','mode_detail='+mode,'ID='+ID,'InvID='+InvID,'SatuanID='+SatuanID],
onSuccess: function(a){
this.winDetail = FoniaJS.showWindow('Detail', 'Detail Barang', a.html, 700, [{},{i:'butTutup'},{i:'butWSimpan',v:'Simpan',c:'success'}], function(){
FoniaJS.AutoComplete('#Nama_Produk', this.PHP, ['data=auto-produk','No_PO','CabID','SupID'], this.Produk_Comp);
$('#winDetail')
.find('#butWSimpan').click(function(){this.detail_simpan();}.bind(this)).end()
.find('#Nama_Produk').on('click', function(){
$('#Nama_Produk').select();
}).end()
.find('#Qty').keyup(function(e) {
this.Hitung_Detail();
if (e.which==13 && parseInt(e.target.value)>0) FoniaJS.setFocus('#Harga_Beli');
}.bind(this)).end()
.find('#Harga_Beli').keyup(function(e) {
this.Hitung_Detail();
if (e.which==13 && FoniaJS.StrToFloat($('#Jumlah').val())>0) this.detail_simpan();
}.bind(this));
if ($('#mode_detail').val() == 'insert' && $('#InvID').val() == 0) {
FoniaJS.setFocus('#Nama_Produk');
} else {
if ($('#mode_detail').val() != 'insert') this.Hitung_Detail();
this.Update_Items();
}
}.bind(this), false);
}.bind(this)
}).send();
},
detail_tambah: function(){
if ($('#SupID').val()==0){
FoniaJS.showError("Silakan pilih Nama Supplier !");
return;
}
this.detail_produk('insert', 0, 0, 0);
},
detail_ubah: function(acell){
this.detail_produk('update', acell[0], acell[1], acell[2]);
},
detail_hapus: function(acell){
FoniaJS.showConfirm('Konfirmasi', 'Hapus item <strong>"'+acell[4]+'"</strong> ?', function(){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=tabel-detail','mode','mode_detail=delete','No_PO','ID='+acell[0]]
}).send();
}.bind(this), 'danger');
},
detail_simpan: function(){
if (parseInt($('#InvID').val())==0) {
FoniaJS.showError('Silakan masukkan Nama Barang !');
return;
}
var _mdetail = $('#mode_detail').val();
new Request.JSONF({
url: this.PHP,
sendParam: ['data=tabel-detail','mode','mode_detail','No_PO','ID','InvID','SatuanID','Qty','Harga_Beli','Harga_HPP'],
onSuccess: function(){
if (_mdetail=='insert') { this.detail_tambah(); } else FoniaJS.closeWindow(this.winDetail);
}.bind(this)
}).send();
},
data_query: function(tipe, mode, kd_tx){
if (tipe=="master"){
mode = (mode) ? mode : '';
var sparam = ['data=master','mode='+mode,'No_PO'+((typeof(kd_tx)!=='undefined')?'='+kd_tx:'')];
if (-1 !== mode.search(/save/i)) sparam = ['data=master','mode='+mode,'No_PO','Tgl_PO','CabID','SupID','Total_Beli'];
new Request.JSON({
url: this.PHP,
sendParam: sparam,
onSuccess: (ajson) => {
$('#divTXMaster').html(ajson.html);
$('#No_PO').keyup((e) => {
if ((e.which || e.keyCode) == 13) {
if (($("#No_PO")) && ($("#No_PO").val() !== '')) this.data_query('master');
}
});
this.data_query('tabel-detail');
if ($.inArray($("#mode").val(),['add','edit']) !== -1) {
$('#butBrow').prop('disabled', true).removeClass('btn-info').addClass('btn-secondary');
$('#butTambah').addClass('d-none');
$('#butUbah').addClass('d-none');
$('#butHapus').addClass('d-none');
$('#butPrint').addClass('d-none');
$('#butShare').addClass('d-none');
$('#butSimpan').removeClass('d-none');
$('#butBatal').removeClass('d-none');
} else {
$('#butBrow').prop('disabled', false).removeClass('btn-secondary').addClass('btn-info');
$('#butTambah').removeClass('d-none');
$('#butUbah').removeClass('d-none');
$('#butHapus').removeClass('d-none');
$('#butPrint').removeClass('d-none');
$('#butShare').removeClass('d-none');
$('#butSimpan').addClass('d-none');
$('#butBatal').addClass('d-none');
}
//$('#butUbah').prop('disabled', ($('#Lunas').val()==1 ? true : false));
//$('#butHapus').prop('disabled', ($('#Lunas').val()==1 ? true : false));
if (ajson.error) {
FoniaJS.showError(ajson.error);
FoniaJS.setFocus('#No_PO');
}
}
}).send();
} else if (tipe=="tabel-detail"){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=tabel-detail','mode','No_PO']
}).send();
} else if (tipe=="brow-tx"){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=brow-tx','Cari_TX'],
onSuccess: function(){
FoniaJS.setFocus('#Cari_TX');
}
}).send();
} else if (tipe=="brow-produk"){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=brow-produk','Cari_Produk','Filter_Browse','SupID','No_PO'],
onSuccess: function(){
FoniaJS.setFocus('#Cari_Produk');
}
}).send();
}
},
Produk_Comp: function(item){
var adata = item.data.split(':');
$('#InvID').val(item.value);
$('#SatuanID').val(adata[0]);
$('#Nama_Satuan1').val(adata[1]);
$('#Nama_Satuan2').val(adata[1]);
$('#Harga_Beli').val(FoniaJS.FloatToStr(adata[3]));
$('#Harga_HPP').val(FoniaJS.FloatToStr(adata[3]));
POJS.Update_Items();
},
oc_SupID: function(ob){
if (ob.value == 0) return false;
new Request.JSONF({
url: this.PHP,
sendParam: ['data=tabel-detail','mode','mode_detail=sup-baru','No_PO','SupID']
}).send();
},
Update_Items: function(){
new Request.JSON({
url: this.PHP,
sendParam: ['data=detail-item','InvID'],
onSuccess: function(adata){
if (!adata.data) {
$('#Stok').val(FoniaJS.FloatToStr(adata.Stok));
}
FoniaJS.setFocus('#Qty');
}.bind(this)
}).send();
},
Hitung_Detail: function(){
var dqty = FoniaJS.StrToFloat($('#Qty').val());
var dharga = FoniaJS.StrToFloat($('#Harga_Beli').val());
var dtot = dharga * dqty;
$('#Jumlah').val(FoniaJS.FloatToStr(dtot,2));
}
};
+525
View File
@@ -0,0 +1,525 @@
/*******************************************************************
App. Name : INVENTORY AND SALES SYSTEMS
Module : /apps/js/iss/pos.js
Desc. : JS - Transaksi Penjualan / Kasir POS
Created By : Siau Pheng ([email protected]).
Created Date : August 5th, 2012.
Last Modified : January 21st, 2026.
(c) 2012 - 2026, 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
var POSJS = {
PHP: '',
KODE: '',
POLE_DISP: null,
POLE_CONF: {},
loading: function(){
FoniaJS.AutoComplete('#Nama_Produk', this.PHP, ['data=auto-produk','No_Jual'], {'selectFunc': POSJS.Produk_Comp, 'keyFunc': POSJS.Produk_Key, 'breakValue': ['*9']});
$('#Nama_Produk').click(() => $('#Nama_Produk').select());
$('#POS_Qty').on({
keyup: (e) => {
(13 == e.which) && $('#Nama_Produk').focus();
},
click: () => $('#POS_Qty').select()
});
this.data_query('master');
//POLE DISPLAY
this.data_query('pole-config');
},
proses_oc: function(){
var cetak = new cPRINTERPOS(FoniaJS.WEB_PATH+'apps/php/repo/nota.php');
cetak.add_param("data", "opencash");
cetak.exec();
$('#Nama_Produk').focus();
},
proses_print: function(oc){
var _no_jual = $('#No_Cetak').val();
var cetak = new cPRINTERPOS(FoniaJS.WEB_PATH+'apps/php/repo/nota.php');
cetak.add_param("data", "nota-pos");
cetak.add_param("Nomor_Cetak", _no_jual);
cetak.add_param("Open_Cash", oc);
cetak.exec();
},
proses_cancel: function(){
if ($('#Total_Item').val()==0) {
FoniaJS.showInfo('Tidak ada item barang !');
return;
}
FoniaJS.showConfirm('Konfirmasi', 'Apakah Anda yakin ingin membatalkan ?<br>Semua item transaksi nota ini akan dihapus !', () => this.data_query('master','cancel'), 'danger');
},
nota_brow: function(){
var _isi = new String('<div class="row mb-1"><div class="col"><div class="input-group"><input class="form-control" id="Cari_Nota" 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></div></div></div><div id="divBrowNota">&nbsp;</div>');
this.winBNota = FoniaJS.showWindow('BNota', 'Daftar Transaksi', _isi, 900, '', () => {
$('#winBNota')
.find('#Cari_Nota').keydown((e) => {
var key = e.keyCode || e.which || 0;
if (key==13 && e.target.value!='') this.data_query('brow-nota');
}).end()
.find('#butSearch').click((e) => {
this.data_query('brow-nota');
}).end()
.find('#butAll').click(() => {
$('#winBNota').find('#Cari_Nota').val('');
this.data_query('brow-nota');
});
this.data_query('brow-nota');
});
},
nota_print: function(acell){
FoniaJS.closeWindow(this.winBNota);
FoniaJS.showConfirm('Konfirmasi', 'Yakin ingin cetak ulang Nota "'+acell[0]+'" ?', () => {
$('#No_Cetak').val(acell[0]);
this.proses_print(0);
}, 'info');
},
nota_select: function(acell){
FoniaJS.closeWindow(this.winBNota);
FoniaJS.showAuth(() => {
$('#No_Jual').val(acell[0]);
this.data_query('master', 'edit');
}, this, 'EDIT POS : '+acell[0]);
},
nota_delete: function(acell){
FoniaJS.closeWindow(this.winBNota);
FoniaJS.showConfirm('Konfirmasi', 'Yakin akan hapus Nota "'+acell[0]+'" ?', () => {
FoniaJS.showAuth(() => {
$('#No_Jual').val(acell[0]);
this.data_query('master', 'delete');
}, this, 'DELETE '+acell[0]);
}, 'danger');
},
pending_brow: function(){
this.winBPend = FoniaJS.showWindow('BPend', 'Daftar Transaksi Pending', '<div id="divBrowPending">&nbsp;</div>', 900, '', () => this.data_query('brow-pending'));
},
pending_select: function(acell){
$('#No_Jual').val(acell[0]);
FoniaJS.closeWindow(this.winBPend);
this.data_query('master', 'pending-edit');
},
pending_delete: function(acell){
FoniaJS.closeWindow(this.winBPend);
FoniaJS.showConfirm('Konfirmasi', 'Yakin akan hapus Transaksi Pending "'+acell[0]+'" ?', () => {
$('#No_Jual').val(acell[0]);
this.data_query('master', 'pending-delete');
}, 'danger');
},
produk_add: function(){
new Request({
url: this.PHP,
sendParam: ['data=info_produk'],
onSuccess: (txt) => {
this.winBarang = FoniaJS.showWindow('Barang', 'Penambahan Item Barang', txt, 600, [{},{i:'butBatal'},{i:'butSimpan',v:'Simpan',c:'success'}], () => {
$('#winBarang')
.find('#butSimpan').click(() => this.produk_simpan()).end()
.find('#butBatal').click(() => $('#Nama_Produk').focus()).end()
.find('#Kode_Barcode').keyup((e) => {
if (-1!==$.inArray(e.which, [13,9])) FoniaJS.setFocus('#Nama_Barang');
}).end()
.find('#Nama_Barang').keyup((e) => {
if (-1!==$.inArray(e.which, [13,9])) FoniaJS.setFocus('#Grup_InvID');
}).end()
.find('#Grup_InvID').keyup((e) => {
if (-1!==$.inArray(e.which, [13,9])) FoniaJS.setFocus('#StokID');
}).end()
.find('#StokID').keyup((e) => {
if (-1!==$.inArray(e.which, [13,9])) FoniaJS.setFocus('#Harga_Jual');
});
FoniaJS.setFocus('#Kode_Barcode');
});
}
}).send();
},
produk_simpan: function(){
new Request.JSON({
url: this.PHP,
sendParam: ['data=simpan_produk','Kode_Barcode','Nama_Barang','Grup_InvID','StokID','Harga_Jual'],
onSuccess: (ajson) => {
if (ajson.msg) FoniaJS.showInfo(ajson.msg);
FoniaJS.closeWindow(this.winBarang);
$('#Nama_Produk').val('').focus();
}
}).send();
},
produk_brow: function(){
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></div></div></div><div id="divBrowProduk">&nbsp;</div>');
this.winBProduk = FoniaJS.showWindow('BProduk', 'Daftar Barang', _isi, 900, '', () => {
$('#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((e) => {
this.data_query('brow-produk');
}).end()
.find('#butAll').click(() => {
$('#winBProduk').find('#Cari_Produk').val('');
this.data_query('brow-produk');
});
this.data_query('brow-produk');
});
},
produk_select: function(acell){
FoniaJS.closeWindow(this.winBProduk);
this.detail_produk('insert', 0, acell[0], acell[1]);
},
detail_produk: function(mode, ID, InvID, SatuanID){
new Request({
url: this.PHP,
sendParam: ['data=detail_produk','mode_detail='+mode,'No_Jual','ID='+ID,'InvID='+InvID,'SatuanID='+SatuanID],
onSuccess: (txt) => {
this.winDetail = FoniaJS.showWindow('Detail', 'Detail Barang', txt, 600, [{},{i:'butBatal'},{i:'butSimpan',v:'Simpan',c:'success'}], () => {
$('#winDetail')
.find('#butSimpan').click(() => this.detail_simpan()).end()
.find('#butBatal').click(() => $('#Nama_Produk').focus()).end()
.find('#Qty').keyup((e) => {
this.Hitung_Detail(1);
if (-1!==$.inArray(e.which, [13,9])) FoniaJS.setFocus('#Harga_Diskon');
}).end()
.find('#Harga_Diskon').keyup((e) => {
this.Hitung_Detail(1);
if (13==e.which) {
if (FoniaJS.StrToFloat($('#Qty').val())>0) this.detail_simpan();
}
}).end()
.find('#Persen_Diskon').keyup((e) => {
this.Hitung_Detail(2);
if (13==e.which) {
if (FoniaJS.StrToFloat($('#Qty').val())>0) this.detail_simpan();
}
});
this.Hitung_Detail(1);
FoniaJS.setFocus('#Qty');
});
}
}).send();
},
detail_ubah: function(acell){
if (parseInt(acell[3])==1){
this.detail_lain('update', acell[0]);
} else
this.detail_produk('update', acell[0], acell[1], acell[2]);
},
detail_hapus: function(acell){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=detail','mode_detail=delete','No_Jual','ID='+acell[0]],
onSuccess: () => {
$('#Nama_Produk').focus();
//POLE DISPLAY
if (this.POLE_CONF.ENABLE){
this.POLE_DISP.Send([{'t':'..','a':'L'},{'t':'Total '+$('#Total_Disp').html(),'a':'R'}]);
}
}
}).send();
},
detail_simpan: function(){
if (FoniaJS.StrToFloat($('#Persen_Diskon').val())>=100) {
FoniaJS.showInfo('Nilai Diskon diluar batas !');
return false;
}
new Request.JSONF({
url: this.PHP,
sendParam: ['data=detail','mode_detail','No_Jual','InvID','SatuanID','Qty','Harga_Beli','Harga_Jual','Harga_Diskon','ID','Ket'],
onSuccess: () => {
//POLE DISPLAY
if (this.POLE_CONF.ENABLE){
this.POLE_DISP.Send([{'t':$('#Nama_Lengkap').val(),'a':'L'},{'t':'Total '+$('#Total_Disp').html(),'a':'R'}]);
}
FoniaJS.closeWindow(this.winDetail);
$('#Nama_Produk').val('');
$('#Nama_Produk').focus();
}
}).send();
},
detail_lain: function(mode, ID){
new Request({
url: this.PHP,
sendParam: ['data=detail_lain','mode_detail='+mode,'No_Jual','ID='+ID],
onSuccess: (txt) => {
this.winDetail = FoniaJS.showWindow('Detail', 'Detail Barang', txt, 600, [{},{i:'butBatal'},{i:'butSimpan',v:'Simpan',c:'success'}], () => {
$('#winDetail')
.find('#butSimpan').click(() => this.detail_simpan()).end()
.find('#butBatal').click(() => $('#Nama_Produk').focus()).end()
.find('#Ket').keyup((e) => {
if ('' === e.target.value) return false;
if (-1!==$.inArray(e.which, [13,9])) FoniaJS.setFocus('#Qty');
}).end()
.find('#Qty').keyup((e) => {
this.Hitung_Detail(0);
if (-1!==$.inArray(e.which, [13,9])) FoniaJS.setFocus('#Harga_Jual');
}).end()
.find('#Harga_Jual').keyup((e) => {
this.Hitung_Detail(0);
if (13==e.which) {
if (FoniaJS.StrToFloat($('#Qty').val())>0 && FoniaJS.StrToFloat($('#Harga_Jual').val())>0) this.detail_simpan();
}
});
this.Hitung_Detail(0);
FoniaJS.setFocus('#Ket');
});
}
}).send();
},
kasir_show: function(){
//POLE DISPLAY
if (this.POLE_CONF.ENABLE){
this.POLE_DISP.Send([{'t':'Total '+$('#Total_Disp').html(),'a':'C'},{'t':'Tunai / Non Tunai ?','a':'C'}]);
}
if ($('#Total_Item').val()==0) {
FoniaJS.showInfo('Belum ada transaksi !');
return;
}
new Request.JSON({
url: this.PHP,
sendParam: ['data=info_kasir','No_Jual','Total_Nota'],
onSuccess: (adata) => {
this.winKasir = FoniaJS.showWindow('Kasir', 'Informasi Pembayaran', adata.html, 500, '', () => {
$('#butKPend').click(() => this.kasir_pending());
$('#butKBayar').click(() => this.kasir_simpan());
$('#butKBatal').click(() => $('#Nama_Produk').focus());
$('#popTotal_Tunai').keyup((e) => {
if (13 == e.which && parseFloat(e.target.value) == 0){
e.target.value = FoniaJS.FloatToStr($('#Total_Nota').val());
}
if (27 == e.which) {
FoniaJS.closeWindow(this.winKasir);
$('#Nama_Produk').focus();
}
this.kasir_hitung();
if (parseFloat(e.target.value) == 0) return false;
if (13 == e.which) $('#butKBayar').focus();
});
$('#popTotal_Kartu').keyup((e) => {
if (13 == e.which && $('#popKartuID').val() > 0 && parseFloat(e.target.value) == 0){
e.target.value = FoniaJS.FloatToStr($('#Total_Nota').val()-FoniaJS.StrToFloat($('#popTotal_Tunai').val()));
}
if (27 == e.which) {
FoniaJS.closeWindow(this.winKasir);
$('#Nama_Produk').focus();
}
this.kasir_hitung();
if (parseFloat(e.target.value) == 0) return false;
if (13 == e.which) $('#butKBayar').focus();
});
$('#popKartuID').change(() => {
if ($('#popKartuID').val() > 0){
if (parseFloat($('#popTotal_Kartu').val()) == 0) $('#popTotal_Kartu').val(FoniaJS.FloatToStr($('#Total_Nota').val()-FoniaJS.StrToFloat($('#popTotal_Tunai').val())));
$('.ckartu').removeClass('d-none');
} else {
$('#popTotal_Kartu').val('0.00');
$('.ckartu').addClass('d-none');
}
this.kasir_hitung();
FoniaJS.setFocus('#popTotal_Kartu');
});
$('#popTotal_Tunai').val(FoniaJS.FloatToStr($('#Total_Tunai').val()));
$('#popTotal_Kartu').val(FoniaJS.FloatToStr($('#Total_Kartu').val()));
$('#popTotal_Bayar').val($('#Total_Bayar').val());
$('#popKartuID').val($('#KartuID').val()).trigger('change');
$('#popNo_Kartu').val($('#No_Kartu').val());
$('#popNama_Kartu').val($('#Nama_Kartu').val());
$('#Total_Disp').html(adata.Total_Disp);
FoniaJS.setFocus('#popTotal_Tunai');
});
this.Simpan = false;
}
}).send();
},
kasir_hitung: function(){
const totBayar = FoniaJS.StrToFloat($('#popTotal_Tunai').val()) + FoniaJS.StrToFloat($('#popTotal_Kartu').val());
const totSisa = totBayar - FoniaJS.StrToFloat($('#popTotal_Jual').val());
$('#popTotal_Bayar').val(totBayar);
$('#popTotal_Sisa').val(FoniaJS.FloatToStr(totSisa, 2)).removeClass('border-danger border-success').addClass((totSisa < 0) ? 'border-danger' : 'border-success');
},
kasir_simpan: function(){
const totTunai = FoniaJS.StrToFloat($('#popTotal_Tunai').val());
const totKartu = FoniaJS.StrToFloat($('#popTotal_Kartu').val());
const jenKartu = $('#popKartuID').val();
if (jenKartu == 0 && totKartu > 0) {
FoniaJS.showInfo('Silakan pilih Jenis Pembayaran Non Tunai!');
FoniaJS.setFocus('#popKartuID');
return false;
} else if (jenKartu > 0 && totKartu == 0) {
FoniaJS.showInfo('Silakan masukkan Jumlah Pembayaran Non Tunai!');
FoniaJS.setFocus('#popKartuID');
return false;
}
if (FoniaJS.StrToFloat($('#popTotal_Sisa').val())<0) {
FoniaJS.showInfo('Pembayaran Transaksi tidak mencukupi!');
FoniaJS.setFocus('#popTotal_Bayar');
return false;
}
if (this.Simpan==true) {
FoniaJS.showError('Proses pembayaran sedang dilakukan!');
return;
}
this.Simpan = true;
$('#Total_Tunai').val(totTunai);
$('#Total_Kartu').val(totKartu);
$('#Total_Bayar').val($('#popTotal_Bayar').val());
$('#KartuID').val($('#popKartuID').val());
$('#No_Kartu').val($('#popNo_Kartu').val());
$('#Nama_Kartu').val($('#popNama_Kartu').val());
FoniaJS.closeWindow(this.winKasir);
this.data_query('master', 'save');
},
kasir_pending: function(){
FoniaJS.closeWindow(this.winKasir);
this.data_query('master', 'pending-save');
},
data_query: function(tipe, mode){
if (tipe=='master'){
mode = (mode) ? mode : '';
var sparam = ['data=master','mode='+mode,'No_Jual','No_Cetak'];
if (-1 !== mode.search(/save/i)) sparam = ['data=master','mode='+mode,'No_Jual','Tgl_Jual','Total_Tunai','Total_Kartu','Total_Bayar','KartuID','No_Kartu','Nama_Kartu'];
new Request({
url: this.PHP,
sendParam: sparam,
onSuccess: (txt) => {
$('#divPOS2').html(txt);
$('#posPEND').click(() =>this.pending_brow());
$('#posTAMBAH').click(() => this.produk_add());
$('#posBARANG').click(() => this.produk_brow());
$('#posNOTA').click(() => this.nota_brow());
$('#posSIMPAN').click(() => this.kasir_show());
$('#posBATAL').click(() => this.proses_cancel());
FoniaJS.User.Level>1 && $('#posBATAL').hide();
this.data_query('detail');
$('#Nama_Produk').focus();
if (-1!==$.inArray($('#mode').val(), ['print','opencd','saveonly'])){
if ($('#mode').val()=='print') this.proses_print(1);
if ($('#mode').val()=='opencd') this.proses_oc();
//POLE DISPLAY
if (this.POLE_CONF.ENABLE){
this.POLE_DISP.Send([{'t':this.POLE_CONF.END1,'a':'C'},{'t':this.POLE_CONF.END2,'a':'C'}]);
}
} else {
//POLE DISPLAY
if (this.POLE_CONF.ENABLE){
this.POLE_DISP.Send([{'t':this.POLE_CONF.START1,'a':'C'},{'t':this.POLE_CONF.START2,'a':'C'}]);
}
}
}
}).send();
} else if (tipe=='detail'){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=detail','No_Jual']
}).send();
} else if (tipe=='brow-produk'){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=brow-produk','Cari_Produk'],
onSuccess: () => {
FoniaJS.setFocus('#Cari_Produk');
}
}).send();
} else if (tipe=='brow-nota'){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=brow-nota','Cari_Nota'],
onSuccess: () => {
FoniaJS.setFocus('#Cari_Nota');
}
}).send();
} else if (tipe=='brow-pending'){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=brow-pending']
}).send();
} else if (tipe=='pole-config'){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=pole-config'],
onSuccess: (acfg) => {
if (typeof acfg.pole == 'object'){
this.POLE_CONF = acfg.pole;
if (this.POLE_CONF.ENABLE){
this.POLE_DISP = new cPOLEDISPLAY(this.POLE_CONF.PORT);
this.POLE_DISP.Open();
}
}
}
}).send();
}
},
Produk_Comp: function(item){
var _qty = $('#POS_Qty').val();
var adata = item.data.split(':');
//todo: jika stok kosong tidak simpan hanya utk glamore
//if (parseInt(adata[3])>0 || _qty<0){
new Request.JSONF({
url: POSJS.PHP,
sendParam: ['data=detail','mode_detail=insert','No_Jual','InvID='+item.value,'SatuanID='+adata[0],'Qty='+_qty,'Harga_Beli='+adata[1],'Harga_Jual='+adata[2]],
onSuccess: () => {
$('#POS_Qty').val('1.00');
//POLE DISPLAY
if (POSJS.POLE_CONF.ENABLE){
POSJS.POLE_DISP.Send([{'t':item.text,'a':'L'},{'t':'Total '+$('#Total_Disp').html(),'a':'R'}]);
}
}
}).send();
/*} else {
this.winPesan = FoniaJS.showWindow('Pesan', 'Informasi Barang', '<div class="fs-3 text-center text-danger">Barang tidak tersedia atau habis !</div>', 300, [{},{i:'butTutup'}], () => {
$('#winPesan').find('#butTutup').click(() => $('#Nama_Produk').focus()).focus();
});
}*/
$('#Nama_Produk').val('').focus();
},
Produk_Key: function(key, val){
if (val == '*9') {
if (key == 13) POSJS.detail_lain('insert', 0);
} else {
if (key == 13) {
POSJS.kasir_show();
} else if (key == 117) {//f6
POSJS.proses_oc();
} else if (key == 119) {//f8
POSJS.produk_add();
} else if (key == 120) {//f9
POSJS.produk_brow();
}
}
},
onblur_Qty: function(){
if ($('#POS_Qty').val()==0) $('#POS_Qty').val('1.00');
},
Hitung_Detail: function(tipe){
if (tipe==1) $('#Persen_Diskon').val(FoniaJS.FloatToStr((FoniaJS.StrToFloat($('#Harga_Diskon').val())*100) / FoniaJS.StrToFloat($('#Harga_Jual').val()), 2));
if (tipe==2) $('#Harga_Diskon').val(FoniaJS.FloatToStr(FoniaJS.StrToFloat($('#Harga_Jual').val()) * FoniaJS.StrToFloat($('#Persen_Diskon').val()) * 0.01, 2));
$('#Jumlah').val(FoniaJS.FloatToStr(FoniaJS.StrToFloat($('#Qty').val()) * (FoniaJS.StrToFloat($('#Harga_Jual').val()) - FoniaJS.StrToFloat($('#Harga_Diskon').val())), 2));
}
};