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