Files
cmasa/app/Scripts/report/inv/label.js
T
siaupheng dcd13bb9df Refactor printing logic across multiple scripts to use method chaining for improved readability and consistency
- Updated Printer and PrinterPos instantiation to use method chaining with addParam instead of add_param.
- Refactored print functions in various modules including opname.js, pos.js, tukar.js, ppobtx.js, prabayar.js, and multiple report scripts.
- Enhanced code clarity and maintainability by standardizing parameter addition for print jobs.
2026-11-02 14:03:32 +07:00

143 lines
6.0 KiB
JavaScript

/*******************************************************************
PHP Class : /Controller/Report/Inv/LabelController
Description : Cetak Label Harga
Created By : Siau Pheng ([email protected]).
Created Date : September 13th, 2014.
Last Modified : October 16th, 2026.
(c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
var RepoInvLabelJS = {
PHP: '',
KODE: '',
index(q) {
$('#butHapus').click(() => this.proses_empty());
$('#butPrint').click(() => this.proses_print(true));
$('#butPreview').click(() => this.proses_print());
this.data_query('tabel-detail', 'empty', ((typeof(q)!=='undefined') ? q : ''));
},
proses_empty() {
new Request_JSF({
url: this.PHP + '/table_detail',
sendParam: ['mode_detail=empty']
}).send();
},
proses_print(prt) {
let cetak = new Printer(this.PHP + '/print');
if (prt) cetak.doPrint(); else cetak.doPreview();
},
produk_brow() {
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, 'xl', [{},{i:'butTutup'},{i:'butWSimpan',v:'Simpan',c:'success'}], () => {
$('#winBProduk')
.find('#butWSimpan').click(() => this.produk_simpan()).end()
.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_simpan() {
new Request_JSF({
url: this.PHP + '/table_detail',
sendParam: ['mode_detail=simpan-produk'],
onSuccess: () => FoniaJS.closeWindow(this.winBProduk)
}).send();
},
grup_brow() {
var _isi = new String('<div class="row mb-1"><div class="col"><div class="input-group"><input class="form-control" id="Cari_Grup" 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="divBrowGrup">&nbsp;</div>');
this.winBGrup = FoniaJS.showWindow('BGrup', 'Daftar Grup Barang', _isi, 'xl', '', () => {
$('#winBGrup')
.find('#Cari_Grup').keydown((e) => {
var key = e.keyCode || e.which || 0;
if (key==13 && e.target.value!='') this.data_query('brow-grup');
}).end()
.find('#butSearch').click(() => this.data_query('brow-grup')).end()
.find('#butAll').click(() => {
$('#winBGrup').find('#Cari_Grup').val('');
this.data_query('brow-grup');
});
this.data_query('brow-grup');
});
},
grup_select(acell) {
new Request_JSF({
url: this.PHP + '/table_detail',
sendParam: ['mode_detail=simpan-grup','Grup_InvID='+acell[0]],
onSuccess: () => FoniaJS.closeWindow(this.winBGrup)
}).send();
},
detail_ubah(acell) {
new Request({
url: this.PHP + '/form_detail',
sendParam: ['mode_detail=update','ID='+acell[0]],
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())
.find('#Nama_Produk').keyup((e) => {
if (-1!==$.inArray(e.which, [13,9])) this.detail_simpan();
});
FoniaJS.setFocus('#Nama_Produk');
}, false);
}
}).send();
},
detail_hapus(acell) {
FoniaJS.showConfirm('Konfirmasi', 'Hapus item <strong>"'+acell[1]+'"</strong> ?', () => {
new Request_JSF({
url: this.PHP + '/table_detail',
sendParam: ['mode_detail=delete','ID='+acell[0]]
}).send();
}, 'danger');
},
detail_simpan() {
new Request_JSF({
url: this.PHP + '/table_detail',
sendParam: ['mode_detail=update','ID='+$('#ID').val(),'Nama_Produk='+encodeURIComponent($('#Nama_Produk').val())],
onSuccess: () => FoniaJS.closeWindow(this.winDetail)
}).send();
},
data_query(tipe, mode, kd_tx) {
if (tipe=="tabel-detail"){
new Request_JSF({
url: this.PHP + '/table_detail',
sendParam: ['mode_detail='+mode,'No_Label'+((typeof(kd_tx)!=='undefined')?'='+kd_tx:'')]
}).send();
} else if (tipe=="brow-produk"){
new Request_JSF({
url: this.PHP + '/brow_produk',
sendParam: ['Cari_Produk'],
onSuccess: () => FoniaJS.setFocus('#Cari_Produk')
}).send();
} else if (tipe=="brow-grup"){
new Request_JSF({
url: this.PHP + '/brow_grup',
sendParam: ['Cari_Grup'],
onSuccess: () => FoniaJS.setFocus('#Cari_Grup')
}).send();
}
}
};