table css-row, on-close showWindow event, redirect parent on exit, open cash-drawer always on start printing, pole-display fixed bug.

This commit is contained in:
2025-12-03 14:28:39 +07:00
parent 8890739e45
commit 8864811189
6 changed files with 168 additions and 127 deletions
+40 -41
View File
@@ -4,7 +4,7 @@
Desc. : JS - Fonia Custom Class v3
Created By : Siau Pheng ([email protected]).
Created Date : June 19th, 2009.
Last Modified : September 21st, 2025.
Last Modified : December 3rd, 2025.
(c) 2009 - 2025, 3FONIA Software; WWW.3FONIA.COM.
@@ -13,7 +13,7 @@
'use strict';
var FoniaJS = {
version: "3.0.0",
version: "3.0.1",
APP_ID: 0,
APP_SID: "",
WEB_HOST: "",
@@ -21,7 +21,7 @@ var FoniaJS = {
WEB_FULLPATH: "",
WEB_MOBILE: 0,
AUTH_LEVEL: 9,
User: {ID:null, UID:null, GID:0, Level:0},
User: {ID:null, UID:0, GID:0, Level:0},
phpversion: "",
locales: [],
deflocal: "",
@@ -486,9 +486,10 @@ var FoniaJS = {
});
}).modal('show');
},
showWindow: function(id_wind, s_judul, s_isi, i_width, s_toolb, f_onload, b_scroll) {//oke
showWindow: function(id_wind, s_judul, s_isi, i_width, s_toolb, f_onload, f_offload, b_scroll) {//oke
var t_width = '', t_toolb = '', t_scroll = (typeof b_scroll == 'boolean' && b_scroll == false) ? '' : 'modal-dialog-scrollable';
var f_oncall = (typeof f_onload == "function") ? f_onload : function(){};
var f_offcall = (typeof f_offload == "function") ? f_offload : function(){};
if (typeof i_width == 'string') { t_width = 'modal-'+i_width; } else
if (i_width <= 300) { t_width = 'modal-sm'; } else
if (i_width <= 400) { t_width = 'modal-400'; } else
@@ -513,6 +514,7 @@ var FoniaJS = {
f_oncall();
FoniaJS.FormDecorated();
}).on('hidden.bs.modal', function(e){
f_offcall();
$(this).remove();
}).modal('show');
return '#win'+id_wind;
@@ -721,9 +723,6 @@ Request.JSONF = function(options){//oke
};
var make_option = function(ini){//oke
var optIni = $('#'+ini.id);
/*if (ini.css) {
optIni.prop('disabled', ini.css=='disabled');
}*/
if (!optIni) return;
if (ini.avalue) {
optIni.empty();
@@ -764,6 +763,9 @@ Request.JSONF = function(options){//oke
});
strHead += '<th data-class-name="c">'+strAksi+'</th>';
aSortCol.push(null);
} else {
strHead += '<th data-class-name="hid">&nbsp;</th>';
aSortCol.push(null);
}
strHead += '</tr></thead>';
@@ -791,11 +793,11 @@ Request.JSONF = function(options){//oke
if (keyi == 0) return;
strBody += '<td>' + vali + '</td>';
});
var _tbtn1 = "", _tbtn2 = "";
if (val[0].rowcss) {
_tbtn1 += '<span class="rowcss '+val[0].rowcss+'"></span>';
}
if (ini.option.length > 0) {
var _tbtn1 = "", _tbtn2 = "";
if (val[0].rowcss) {
_tbtn1 += '<span class="rowcss '+val[0].rowcss+'"></span>';
}
if (val[0].button.length > 0) {
$.each(val[0].button, function(keyb, valb){
var _icon = (valb[0]=='fon-tabel-dt') ? 'pencil' : valb[0];
@@ -812,9 +814,8 @@ Request.JSONF = function(options){//oke
if (val[0].checkbox) {
_tbtn1 += '<div><input class="form-check-input" type="checkbox" id="'+ChkField+'_cbox_'+val[0].checkbox.field+'" value="'+val[0].checkbox.value+'"></div>';
}
strBody += '<td class="">'+_tbtn1+_tbtn2+'</td>';
}
strBody += '</tr>';
strBody += '<td class="">'+_tbtn1+_tbtn2+'</td></tr>';
});
strBody += '</tbody>';
@@ -850,11 +851,11 @@ Request.JSONF = function(options){//oke
$.each(jsono.data, function(key, val){
var optval = val[0]; jsono.data[key].shift();
var _tbtn1 = "", _tbtn2 = "";
if (optval.rowcss) {
_tbtn1 += '<span class="rowcss '+optval.rowcss+'"></span>';
}
if (ini.option.length > 0) {
var _tbtn1 = "", _tbtn2 = "";
if (optval.rowcss) {
_tbtn1 += '<span class="rowcss '+optval.rowcss+'"></span>';
}
if (optval.button.length > 0) {
$.each(optval.button, function(keyb, valb){
var _icon = (valb[0]=='fon-tabel-dt') ? 'pencil' : valb[0];
@@ -871,8 +872,8 @@ Request.JSONF = function(options){//oke
if (optval.checkbox) {
_tbtn1 += '<div><input class="form-check-input" type="checkbox" id="'+ChkField+'_cbox_'+optval.checkbox.field+'" value="'+optval.checkbox.value+'"></div>';
}
jsono.data[key].push(_tbtn1+_tbtn2);
}
jsono.data[key].push(_tbtn1+_tbtn2);
});
return JSON.stringify(jsono);
}
@@ -988,29 +989,27 @@ Request.JSONF = function(options){//oke
}
});
}
//if (ini.config.live){
$('#'+ini.id+'Tabel tbody').on('click', 'td.dtr-control', function(){
var tr = $(this).closest('tr');
var row = otabel.row(tr);
if (row.child.isShown()){
row.child.hide();
tr.removeClass('dt-hasChild parent');
}else{
var ind = 0;
var tampil = '<ul class="list-unstyled">';
api.columns().every(function() {
var kol = this.header();
if (kol.className.indexOf('dtr-hidden') != -1){
tampil += '<li class="py-1"><span class="d-inline-block" style="min-width:100px;">' + kol.textContent + '</span><span class="text-break">' + row.data()[ind] + '</span></li>';
}
ind++;
})
tampil += '</ul>';
row.child(tampil).show();
tr.addClass('dt-hasChild parent');
}
});
//}
$('#'+ini.id+'Tabel tbody').on('click', 'td.dtr-control', function(){
var tr = $(this).closest('tr');
var row = otabel.row(tr);
if (row.child.isShown()){
row.child.hide();
tr.removeClass('dt-hasChild parent');
}else{
var ind = 0;
var tampil = '<ul class="list-unstyled">';
api.columns().every(function() {
var kol = this.header();
if (kol.className.indexOf('dtr-hidden') != -1){
tampil += '<li class="py-1"><span class="d-inline-block" style="min-width:100px;">' + kol.textContent + '</span><span class="text-break">' + row.data()[ind] + '</span></li>';
}
ind++;
})
tampil += '</ul>';
row.child(tampil).show();
tr.addClass('dt-hasChild parent');
}
});
}
var otabel = $('#'+ini.id+'Tabel').DataTable(opsi);
};
+93
View File
@@ -0,0 +1,93 @@
/*******************************************************************
Module : /assets/js/pole-display.js
Desc. : JS Class Tampil Data di Pole Display POS
Created By : Siau Pheng ([email protected]).
Created Date : October 12th, 2025.
(c) 2025, 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
var cPOLEDISPLAY = function(port, options){
var _cd_port = '';
var _cd_pole = '';
var _options = {
rx: { start: '\x02', end: '\x0D', width: null },
baudRate: 9600,
dataBits: 8,
stopBits: 1,
parity: 'NONE',
flowControl: 'NONE'
};
this.construct = function (port, options){//oke
$.extend(_options, options);
_cd_port = port;
};
this.Open = function (){
if (_cd_pole === '') {
qz.serial.openPort(_cd_port, _options).then(() => {
_cd_pole = _cd_port;
this.cd_Error(_cd_port+' opened');
}).then(() => {
qz.serial.sendData(_cd_pole, {type:'HEX',data:'x1Bx40'}, _options).catch(this.cd_Error);
}).catch(this.cd_Error);
}
};
this.Close = function (){
qz.serial.closePort(_cd_port).then(() => {
_cd_pole = '';
this.cd_Error(_cd_port+' closed');
}).catch(this.cd_Error);
};
this.Send = function (txt){
if (_cd_pole === '') return false;
var ascii_to_hexa = function(str) {
var arr1 = [];
for (var n = 0, l = str.length; n < l; n++) {
var hex = Number(str.charCodeAt(n)).toString(16);
if (hex.length==1) hex = '0' + hex;
arr1.push(hex.toUpperCase());
}
return 'x' + arr1.join('x');
};
var _txt = txt;
if (Array.isArray(txt)) {
_txt = '';
txt.forEach((ele) => {
_txt += this.cd_Text(ele['t'], ele['a']);
});
}
qz.serial.sendData(_cd_pole, {type:'HEX',data:'x10C'+ascii_to_hexa(_txt)}, _options).catch(this.cd_Error);
};
this.cd_Text = function (text, align){
const totWidth = 20;
const txtLength = text.length;
if (txtLength >= totWidth) {
return text.substring(0, totWidth);
}
const padding = totWidth - txtLength;
var lPadding = 0;
var rPadding = padding;
if (align === null) align = 'L';
if (align == 'C'){
lPadding = Math.floor(padding / 2);
rPadding = Math.ceil(padding / 2);
} else if (align == 'R'){
lPadding = padding;
rPadding = 0;
}
return " ".repeat(lPadding) + text + " ".repeat(rPadding);
};
this.cd_Error = function (err){//oke
console.error(err);
};
this.construct(port, options);
};
+19 -65
View File
@@ -4,9 +4,9 @@
Desc. : JS Class Printer & Printer POS
Created By : Siau Pheng ([email protected]).
Created Date : May 27th, 2007.
Last Modified : January 26th, 2021.
Last Modified : December 3rd, 2025.
(c) 2008 - 2021, 3FONIA Software; WWW.3FONIA.COM.
(c) 2007 - 2025, 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
@@ -92,51 +92,23 @@ var cPRINTER = function(url, options){
this.construct(url, options);
};
/*
showPreview: function() {
toolbar: true,
toolbarPosition: "top",
toolbarHeight: 35,
toolbarMenu: "PP,_,PS,PN,PB",
toolbarOnload: function() {
$("butPPrint").addEvent("click", function() {
if (this.winPreview) {
this.winPreview.close();
}
window.print();
}.bind(this));
$("butPNormal").addEvent("click", function() {
this.winPreview.options.zoomfont = 100;
$("winPreview_content").setStyle("font-size", this.winPreview.options.zoomfont + "%");
}.bind(this));
$("butPSmall").addEvent("click", function() {
this.winPreview.options.zoomfont -= 10;
$("winPreview_content").setStyle("font-size", this.winPreview.options.zoomfont + "%");
}.bind(this));
$("butPBig").addEvent("click", function() {
this.winPreview.options.zoomfont += 10;
$("winPreview_content").setStyle("font-size", this.winPreview.options.zoomfont + "%");
}.bind(this));
$("winPreview_content").setStyle("font-size", this.options.zoom + "%");
}.bind(this)
});
},
});*/
var cPRINTERPOS = function(url, options) {
var b_default = false;
var _options = {
'url': '',
'param': [],
'printer': null
'printer': null,
'cut_paper': "\x1D\x56\x41",
'open_draw': "\x1B\x70\x30\x19\x19",
'chr_norm': "\x1B\x21\x01",
'chr_bold': "\x1B\x21\x10",
'chr_sbold': "\x1B\x21\x31",
'chr_uline': "\x1B\x21\x80"
};
this.construct = function(url, options) {
$.extend(_options, options);
_options.url = url;
if (FoniaJS._def_printer) _options.printer = FoniaJS._def_printer;
/*if ($('#configPrinter')) {
_options.printer = $('#configPrinter').html();
}*/
};
this.detectPrinter = function() {
if (!qz.websocket.isActive()) {
@@ -170,9 +142,6 @@ var cPRINTERPOS = function(url, options) {
if (data.name != undefined) {
nama_p = data.name;
}
/*if ($('#configPrinter')) {
$('#configPrinter').html(nama_p);
}*/
parent._options.param.push('Printer='+nama_p);
return parent.do_print(nama_p, parent._options.url, parent._options.param);
}, function(data) {
@@ -207,13 +176,6 @@ var cPRINTERPOS = function(url, options) {
}).send();
};
this.gen_escp = function(adata) {
var cut_paper = "\x1D\x56\x41";
var open_draw = "\x1B\x70\x30\x19\x19";
var nv_image = "\x1D\x28\x4C\x06\x00\x30\x45\x30\x30\x01\x01";
var chr_norm = "\x1B\x21\x01";
var chr_bold = "\x1B\x21\x10";
var chr_sbold = "\x1B\x21\x31";
var chr_uline = "\x1B\x21\x80";
var ohead = [];
var osheet = [], ocetak = [];
ohead.push("\x1B\x40");
@@ -223,17 +185,13 @@ var cPRINTERPOS = function(url, options) {
ohead.push("\x1B\x32");
}
if (parseInt(adata.config.fontsize) == 2) {
chr_norm = "\x1B\x21\x02";
}
if (adata.config.nvlogo) {
ohead.push((this.options.nv_cmd?this.options.nv_cmd:nv_image));
ohead.push(chr_norm);
_options.chr_norm = "\x1B\x21\x02";
}
if (adata.header.length > 0) {
for (i = 0; i < adata.header.length; i++) {
if (i==0 && !adata.config.nvlogo && adata.config.logo==null) ohead.push(chr_bold);
if (i==0 && adata.config.logo==null) ohead.push(_options.chr_bold);
ohead.push(adata.header[i] + "\x0A");
if (i==0 && !adata.config.nvlogo && adata.config.logo==null) ohead.push(chr_norm);
if (i==0 && adata.config.logo==null) ohead.push(_options.chr_norm);
}
}
for (s = 0; s < adata.content.length; s++) {
@@ -241,28 +199,24 @@ var cPRINTERPOS = function(url, options) {
osheet = ohead.slice(0);
for (i = 0; i < adata.content[s].length; i++) {
var tmp_cont = adata.content[s][i];
tmp_cont = tmp_cont.replace('_SBOLD_', chr_sbold)
.replace('_BOLD_', chr_bold)
.replace('_NORM_', chr_norm)
.replace('_ULINE_', chr_uline);
tmp_cont = tmp_cont.replace('_SBOLD_', _options.chr_sbold)
.replace('_BOLD_', _options.chr_bold)
.replace('_NORM_', _options.chr_norm)
.replace('_ULINE_', _options.chr_uline);
osheet.push(tmp_cont + "\x0A");
}
if (adata.config.cutpaper) {
osheet.push(cut_paper + "\x0A");
osheet.push(_options.cut_paper + "\x0A");
}
//osheet.push("\x1B\x65\x02");//feed up 2row
ocetak = ocetak.concat(osheet);
}
var notaout = [];
if (adata.config.opendraw && adata.config.opendrawbegin) {
notaout.push(open_draw);
if (adata.config.opendraw) {
notaout.push(_options.open_draw);
}
for (i = 0; i < adata.config.times; i++) {
notaout = notaout.concat(ocetak);
}
if (adata.config.opendraw && adata.config.opendrawbegin == false) {
notaout.push(open_draw);
}
return notaout;
};
this.gen_epl = function(adata) {