first commit
This commit is contained in:
@@ -0,0 +1,162 @@
|
||||
/*******************************************************************
|
||||
|
||||
PHP Class : /Controller/Gel/PiutangController
|
||||
Description : Transaksi Penerimaan Piutang Buyer / Member
|
||||
Created By : Siau Pheng ([email protected]).
|
||||
Created Date : March 7th, 2011.
|
||||
Last Modified : September 13th, 2026.
|
||||
|
||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
*******************************************************************/
|
||||
|
||||
var GELPiutangJS = {
|
||||
PHP: '',
|
||||
KODE: '',
|
||||
|
||||
index: function(q){
|
||||
$('#butMode').click(() => this.tx_mode());
|
||||
$('#butBatal').click(() => this.tx_batal());
|
||||
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_Member').prop('disabled', false).removeClass('disabled').addClass('enabled');
|
||||
this.data_query('tabel-nota');
|
||||
},
|
||||
|
||||
buyer_brow: function(){
|
||||
var _isi = new String('<div class="row mb-1"><div class="col"><div class="input-group"><input class="form-control" id="Cari_Buyer" 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="divBrowBuyer"> </div>');
|
||||
this.winBBuyer = FoniaJS.showWindow('BBuyer', 'Daftar Member', _isi, 'xl', '', () => {
|
||||
$('#winBBuyer')
|
||||
.find('#Cari_Buyer').keydown((e) => {
|
||||
var key = e.keyCode || e.which || 0;
|
||||
if (key==13 && e.target.value!='') this.data_query('brow-buyer');
|
||||
}).end()
|
||||
.find('#butSearch').click(() => this.data_query('brow-buyer')).end()
|
||||
.find('#butAll').click(() => {
|
||||
$('#winBBuyer').find('#Cari_Buyer').val('');
|
||||
this.data_query('brow-buyer');
|
||||
});
|
||||
this.data_query('brow-buyer');
|
||||
FoniaJS.setFocus('#Cari_Buyer');
|
||||
});
|
||||
},
|
||||
|
||||
buyer_select: function(acell){
|
||||
FoniaJS.closeWindow(this.winBBuyer);
|
||||
$('#MemberID').val(acell[0]);
|
||||
$('#Nama_Member').val(acell[2]);
|
||||
$('#Alamat_Member').val(acell[3]);
|
||||
this.data_query('tabel-nota');
|
||||
},
|
||||
|
||||
nota_select: function(acell){
|
||||
new Request({
|
||||
url: this.PHP + '/form_nota',
|
||||
sendParam: ['No_Jual='+acell[1],'Tipe_Nota='+acell[0]],
|
||||
onSuccess: (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_Member').prop('disabled', true).removeClass('enabled').addClass('disabled');
|
||||
this.data_query('tabel-bayar');
|
||||
}
|
||||
}).send();
|
||||
},
|
||||
|
||||
bayar_show: function(){
|
||||
new Request({
|
||||
url: this.PHP + '/form_bayar',
|
||||
sendParam: ['No_Jual','Total_Sisa'],
|
||||
onSuccess: (ajson) => {
|
||||
this.winBayar = FoniaJS.showWindow('Bayar', 'Detail Pembayaran', ajson.html, 'lg', [{},{i:'butTutup'},{i:'butWSimpan',v:'Simpan',c:'success'}], () => {
|
||||
$('#winBayar').find('#butWSimpan').click(() => this.bayar_simpan());
|
||||
FoniaJS.setFocus('#Total_Bayar');
|
||||
}, false);
|
||||
}
|
||||
}).send();
|
||||
},
|
||||
|
||||
bayar_hapus: function(acell){
|
||||
FoniaJS.showConfirm('Konfirmasi', 'Hapus item <strong>"'+acell[1]+'"</strong> ?', () => {
|
||||
new Request.JSONF({
|
||||
url: this.PHP + '/table_bayar',
|
||||
sendParam: ['mode_detail=delete','No_Jual','ID='+acell[0]]
|
||||
}).send();
|
||||
}, '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 + '/table_bayar',
|
||||
sendParam: ['mode_detail=insert','MemberID','No_Jual','Tgl_Bayar','Kode_Rek','Total_Bayar','Total_Potong','Tipe_Nota','Nama_Member'],
|
||||
onSuccess: () => FoniaJS.closeWindow(this.winBayar)
|
||||
}).send();
|
||||
},
|
||||
|
||||
data_query: function(tipe, mode, kd_tx){
|
||||
if (tipe=="master"){
|
||||
new Request({
|
||||
url: this.PHP + '/form_master',
|
||||
sendParam: ['MemberID'+((typeof(kd_tx)!=='undefined')?'='+kd_tx:'')],
|
||||
onSuccess: (ajson) => {
|
||||
$('#divTXMaster').html(ajson.html);
|
||||
this.tx_batal();
|
||||
FoniaJS.AutoComplete('#Nama_Member', this.PHP + '/auto_sup', [], {'selectFunc': this.Member_Comp});
|
||||
$('#Nama_Member').click(() => $('#Nama_Member').select());
|
||||
$('#butBrow').click(() => this.buyer_brow());
|
||||
if (ajson.error) {
|
||||
FoniaJS.showError(ajson.error);
|
||||
}
|
||||
FoniaJS.setFocus('#Nama_Member');
|
||||
}
|
||||
}).send();
|
||||
} else if (tipe=="tabel-nota"){
|
||||
new Request.JSONF({
|
||||
url: this.PHP + '/table_nota',
|
||||
sendParam: ['MemberID','Mode_Tampil']
|
||||
}).send();
|
||||
} else if (tipe=="tabel-bayar"){
|
||||
new Request.JSONF({
|
||||
url: this.PHP + '/table_bayar',
|
||||
sendParam: ['No_Jual','Lunas','Mode_Tampil']
|
||||
}).send();
|
||||
} else if (tipe=="brow-buyer"){
|
||||
new Request.JSONF({
|
||||
url: this.PHP + '/brow_buyer',
|
||||
sendParam: ['Cari_Buyer'],
|
||||
onSuccess: () => FoniaJS.setFocus('#Cari_Buyer')
|
||||
}).send();
|
||||
}
|
||||
},
|
||||
|
||||
Member_Comp: function(item){
|
||||
$('#MemberID').val(item.value);
|
||||
$('#Alamat_Member').val(item.data);
|
||||
GELPiutangJS.data_query('tabel-nota');
|
||||
}
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user