first commit
This commit is contained in:
@@ -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"> </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"> </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));
|
||||
}
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user