- Updated all function declarations to use ES6 shorthand method syntax in member.js, member_grup.js, point_barang.js, point_skema.js, point_tipe.js, kategori.js, operator.js, produk.js, produk_grup.js, rekpos.js, satuan.js, supplier.js, and varian.js.
292 lines
12 KiB
JavaScript
292 lines
12 KiB
JavaScript
/*******************************************************************
|
|
|
|
PHP Class : /Controller/Inv/MutasiController
|
|
Description : Transaksi Mutasi Stok Antar Cabang
|
|
Created By : Siau Pheng ([email protected]).
|
|
Created Date : February 28th, 2011.
|
|
Last Modified : September 28th, 2026.
|
|
|
|
(c) 3FONIA Software; WWW.3FONIA.COM.
|
|
|
|
*******************************************************************/
|
|
|
|
var MutasiJS = {
|
|
PHP: '',
|
|
KODE: '',
|
|
|
|
index(q) {
|
|
$('#butTambah').click(() => this.tx_tambah());
|
|
$('#butUbah').click(() => this.tx_ubah());
|
|
$('#butHapus').click(() => this.tx_hapus());
|
|
$('#butSimpan').click(() => this.tx_simpan());
|
|
$('#butBatal').click(() => this.tx_batal());
|
|
$('#printNota').click(() => this.tx_print());
|
|
$('#printPOS').click(() => this.tx_print_pos());
|
|
this.data_query('master', 'view', ((typeof(q)!=='undefined') ? q : ''));
|
|
},
|
|
|
|
tx_brow() {
|
|
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, 'xl', '', () => {
|
|
$('#winBTX')
|
|
.find('#Cari_TX').keydown((e) => {
|
|
var key = e.keyCode || e.which || 0;
|
|
if (key==13 && e.target.value!='') this.data_query('brow-tx');
|
|
}).end()
|
|
.find('#butSearch').click(() => this.data_query('brow-tx')).end()
|
|
.find('#butAll').click(() => {
|
|
$('#winBTX').find('#Cari_TX').val('');
|
|
this.data_query('brow-tx');
|
|
});
|
|
this.data_query('brow-tx');
|
|
});
|
|
},
|
|
|
|
tx_select(acell) {
|
|
FoniaJS.closeWindow(this.winBTX);
|
|
$('#No_Mutasi').val(acell[0]);
|
|
this.data_query('master', 'view');
|
|
},
|
|
|
|
tx_tambah() {
|
|
this.data_query('master', 'add');
|
|
},
|
|
|
|
tx_ubah() {
|
|
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() {
|
|
if (!$('#No_Mutasi').val()){
|
|
FoniaJS.showError("Silakan masukkan Nomor Transaksi !");
|
|
return;
|
|
}
|
|
FoniaJS.showConfirm('Konfirmasi', 'Yakin akan hapus <strong>'+$('#No_Mutasi').val()+'</strong> ?', () => {
|
|
FoniaJS.showAuth(() => {
|
|
new Request({
|
|
url: this.PHP + '/proses_delete',
|
|
sendParam: ['No_Mutasi'],
|
|
onSuccess: (ajson) => {
|
|
if (ajson.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!');
|
|
}
|
|
}
|
|
}).send();
|
|
}, this, 'DELETE '+$('#No_Mutasi').val());
|
|
}, 'danger');
|
|
},
|
|
|
|
tx_simpan() {
|
|
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.data_query('master', 'save');
|
|
},
|
|
|
|
tx_batal() {
|
|
FoniaJS.showConfirm('Konfirmasi', 'Yakin akan membatalkan ?', () => {
|
|
this.data_query('master', 'cancel');
|
|
$('#No_Mutasi').val('');
|
|
}, 'danger');
|
|
},
|
|
|
|
tx_print(prt) {
|
|
if ($('#No_Mutasi').val()) {
|
|
var cetak = new Printer('report/nota/mutasi');
|
|
cetak.add_param("Nomor_Cetak", $('#No_Mutasi').val());
|
|
if (prt) cetak.doPrint(); else cetak.doPreview();
|
|
return;
|
|
}
|
|
FoniaJS.showError("Silakan masukkan Nomor Transaksi !");
|
|
},
|
|
|
|
tx_print_pos() {
|
|
if ($('#No_Mutasi').val()) {
|
|
var cetak = new PrinterPos('report/nota/mutasi_pos');
|
|
cetak.add_param("Nomor_Cetak", $('#No_Mutasi').val());
|
|
cetak.exec();
|
|
return;
|
|
}
|
|
FoniaJS.showError("Silakan masukkan Nomor Transaksi !");
|
|
},
|
|
|
|
produk_brow() {
|
|
if ($('#Dari_CabID').val()==0){
|
|
FoniaJS.showError("Silakan pilih Dari 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, 'xl', '', () => {
|
|
$('#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(() => 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(acell) {
|
|
FoniaJS.closeWindow(this.winBProduk);
|
|
this.detail_produk('insert', 0, acell[0], acell[1], acell[2]);
|
|
},
|
|
|
|
detail_produk(mode, ID, InvID, SatuanID, VarianID) {
|
|
new Request({
|
|
url: this.PHP + '/form_produk',
|
|
sendParam: ['mode','mode_detail='+mode,'No_Mutasi','ID='+ID,'InvID='+InvID,'SatuanID='+SatuanID,'VarianID='+VarianID],
|
|
onSuccess: (ajson) => {
|
|
this.winDetail = FoniaJS.showWindow('Detail', 'Detail Barang', ajson.html, 'lg', [{},{i:'butTutup'},{i:'butWSimpan',v:'Simpan',c:'success'}], () => {
|
|
$('#winDetail')
|
|
.find('#butWSimpan').click(() => this.detail_simpan()).end()
|
|
.find('#butBatal').click(() => $('#Nama_Produk').focus()).end()
|
|
.find('#Qty').keyup((e) => {
|
|
this.Hitung_Detail();
|
|
if (parseFloat(e.target.value) == 0) return false;
|
|
if (-1!==$.inArray(e.which, [13,9])) this.detail_simpan();
|
|
});
|
|
this.Hitung_Detail();
|
|
FoniaJS.setFocus('#Qty');
|
|
});
|
|
}
|
|
}).send();
|
|
},
|
|
|
|
detail_ubah(acell) {
|
|
this.detail_produk('update', acell[0], acell[1], acell[2], acell[3]);
|
|
},
|
|
|
|
detail_hapus(acell) {
|
|
FoniaJS.showConfirm('Konfirmasi', 'Hapus item <strong>"'+acell[5]+'"</strong> ?', () => {
|
|
new Request_JSF({
|
|
url: this.PHP + '/table_detail',
|
|
sendParam: ['mode','mode_detail=delete','No_Mutasi','ID='+acell[0]],
|
|
onSuccess: () => $('#Nama_Produk').focus()
|
|
}).send();
|
|
}, 'danger');
|
|
},
|
|
|
|
detail_simpan() {
|
|
new Request_JSF({
|
|
url: this.PHP + '/table_detail',
|
|
sendParam: ['mode','mode_detail','No_Mutasi','ID','InvID','SatuanID','VarianID','Qty','Harga_Beli','Dari_CabID','Ke_CabID'],
|
|
onSuccess: () => {
|
|
FoniaJS.closeWindow(this.winDetail);
|
|
$('#Nama_Produk').val('').focus();
|
|
}
|
|
}).send();
|
|
},
|
|
|
|
data_query(tipe, mode, kd_tx) {
|
|
if (tipe=="master"){
|
|
var sparam = ['mode='+mode,'No_Mutasi'+((typeof(kd_tx)!=='undefined')?'='+kd_tx:'')];
|
|
if ((mode ?? '')=='save') sparam = ['mode='+mode,'No_Mutasi','Tgl_Mutasi','Dari_CabID','Ke_CabID','Catatan'];
|
|
new Request({
|
|
url: this.PHP + '/form_master',
|
|
sendParam: sparam,
|
|
onSuccess: (ajson) => {
|
|
$('#divTXMaster').html(ajson.html);
|
|
FoniaJS.AutoComplete('#Nama_Produk', this.PHP + '/auto_produk', ['No_Mutasi','Dari_CabID'], {'selectFunc':this.Produk_Comp});
|
|
$('#Nama_Produk').click(() => $('#Nama_Produk').select());
|
|
$('#POS_Qty').on({
|
|
keyup: (e) => {
|
|
(13 == e.which) && $('#Nama_Produk').focus();
|
|
},
|
|
blur: (e) => {
|
|
if (parseInt(e.target.value) == 0) e.target.value = '1.00';
|
|
},
|
|
click: () => $('#POS_Qty').select()
|
|
});
|
|
$('#No_Mutasi').keyup((e) => {
|
|
if ((e.which || e.keyCode) == 13) {
|
|
if (($("#No_Mutasi")) && ($("#No_Mutasi").val() !== '')) this.data_query('master');
|
|
}
|
|
});
|
|
$('#butBrow').click(() => this.tx_brow());
|
|
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');
|
|
FoniaJS.setFocus('#Nama_Produk');
|
|
} 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');
|
|
FoniaJS.setFocus('#No_Mutasi');
|
|
}
|
|
if (ajson.error) FoniaJS.showError(ajson.error);
|
|
}
|
|
}).send();
|
|
} else if (tipe=="tabel-detail"){
|
|
new Request_JSF({
|
|
url: this.PHP + '/table_detail',
|
|
sendParam: ['mode','No_Mutasi']
|
|
}).send();
|
|
} else if (tipe=="brow-tx"){
|
|
new Request_JSF({
|
|
url: this.PHP + '/brow_tx',
|
|
sendParam: ['Cari_TX'],
|
|
onSuccess: () => FoniaJS.setFocus('#Cari_TX')
|
|
}).send();
|
|
} else if (tipe=="brow-produk"){
|
|
new Request_JSF({
|
|
url: this.PHP + '/brow_produk',
|
|
sendParam: ['Cari_Produk','Dari_CabID'],
|
|
onSuccess: () => FoniaJS.setFocus('#Cari_Produk')
|
|
}).send();
|
|
}
|
|
},
|
|
|
|
Produk_Comp(item) {
|
|
if ($('#Dari_CabID').val()==0){
|
|
FoniaJS.showError("Silakan pilih Dari Cabang !");
|
|
return;
|
|
}
|
|
var _qty = FoniaJS.StrToFloat($('#POS_Qty').val());
|
|
var adata = item.data.split(':');
|
|
// Satuan : Varian : Harga_Pokok
|
|
new Request_JSF({
|
|
url: MutasiJS.PHP + '/table_detail',
|
|
sendParam: ['mode','mode_detail=insert','No_Mutasi','InvID='+item.value,'SatuanID='+adata[0],'VarianID='+adata[1],'Qty='+_qty,'Harga_Beli='+adata[2]],
|
|
onSuccess: () => $('#POS_Qty').val('1.00')
|
|
}).send();
|
|
$('#Nama_Produk').val('').focus();
|
|
},
|
|
|
|
Hitung_Detail() {
|
|
$('#Jumlah').val(FoniaJS.FloatToStr(FoniaJS.StrToFloat($('#Qty').val()) * FoniaJS.StrToFloat($('#Harga_Beli').val()), 2));
|
|
}
|
|
|
|
};
|