first commit

This commit is contained in:
2026-01-22 13:38:42 +07:00
commit ab311c5c95
91 changed files with 8064 additions and 0 deletions
+107
View File
@@ -0,0 +1,107 @@
/*******************************************************************
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 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');
}
},
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();
}
};
+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();
}
};
+127
View File
@@ -0,0 +1,127 @@
/*******************************************************************
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 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();
}
};
+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(':');
//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));
}
};