Compare commits
9
Commits
bc95edbc0f
...
v1.0.11
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
11e17bd978 | ||
|
|
929f3af79a | ||
|
|
cf100a86e2 | ||
|
|
a538cc0cc5 | ||
|
|
4c8399cf64 | ||
|
|
2be02c36ec | ||
|
|
0a47ddc422 | ||
|
|
17188f6134 | ||
|
|
8a758e5875 |
Vendored
+1
-1
@@ -1882,7 +1882,7 @@ progress {
|
||||
.table > :not(caption) > * > * {
|
||||
padding: 0.5rem 0.5rem;
|
||||
color: var(--bs-table-color-state, var(--bs-table-color-type, var(--bs-table-color)));
|
||||
background-color: var(--bs-table-bg);
|
||||
/*background-color: var(--bs-table-bg);*/
|
||||
border-bottom-width: var(--bs-border-width);
|
||||
box-shadow: inset 0 0 0 9999px var(--bs-table-bg-state, var(--bs-table-bg-type, var(--bs-table-accent-bg)));
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
Desc. : CSS Default Configuration
|
||||
Created By : Siau Pheng ([email protected]).
|
||||
Created Date : December 20th, 2007.
|
||||
Last Modified : February 7th, 2026.
|
||||
Last Modified : September 27th, 2026.
|
||||
|
||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
@@ -343,6 +343,14 @@ ul.dtr-details li.hidden { visibility: hidden !important; display: none !importa
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.bootstrap-autocomplete.dropdown-menu .dropdown-item.active .text-primary {
|
||||
color: #93f6c5 !important;
|
||||
}
|
||||
|
||||
.bootstrap-autocomplete.dropdown-menu .dropdown-item.active .text-danger {
|
||||
color: #f4c8d2 !important;
|
||||
}
|
||||
|
||||
/******************************** text field ********************************/
|
||||
|
||||
input.double, input.integer, input.number {
|
||||
|
||||
+235
-351
@@ -1,84 +1,52 @@
|
||||
var __extends = (undefined && undefined.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var BaseResolver = (function () {
|
||||
function BaseResolver(options) {
|
||||
var AjaxResolver = class {
|
||||
constructor(options) {
|
||||
this._settings = $.extend(true, {}, this.getDefaults(), options);
|
||||
}
|
||||
BaseResolver.prototype.getDefaults = function () {
|
||||
return {};
|
||||
};
|
||||
BaseResolver.prototype.getResults = function (limit, start, end) {
|
||||
return this.results;
|
||||
};
|
||||
BaseResolver.prototype.search = function (q, cbk) {
|
||||
cbk(this.getResults());
|
||||
};
|
||||
return BaseResolver;
|
||||
}());
|
||||
|
||||
var AjaxResolver = (function (_super) {
|
||||
__extends(AjaxResolver, _super);
|
||||
function AjaxResolver(options) {
|
||||
return _super.call(this, options) || this;
|
||||
}
|
||||
AjaxResolver.prototype.getDefaults = function () {
|
||||
getDefaults() {
|
||||
return {
|
||||
url: '',
|
||||
method: 'post',
|
||||
queryKey: 'Auto_Query',
|
||||
extraData: {},
|
||||
param: [],
|
||||
timeout: 0,
|
||||
requestThrottling: 500
|
||||
};
|
||||
};
|
||||
AjaxResolver.prototype.search = function (q, cbk) {
|
||||
var _this = this;
|
||||
if (this.jqXHR != null) {
|
||||
this.jqXHR.abort();
|
||||
}
|
||||
search(q, cbk) {
|
||||
if (this.jqXHR != null) this.jqXHR.abort();
|
||||
|
||||
var data = {};
|
||||
data[this._settings.queryKey] = q;
|
||||
$.extend(data, this._settings.extraData);
|
||||
if (this.requestTID) {
|
||||
window.clearTimeout(this.requestTID);
|
||||
if (this._settings.param.length > 0) {
|
||||
$.extend(data, FoniaJS.RequestParam(this._settings.param));
|
||||
}
|
||||
this.requestTID = window.setTimeout(function () {
|
||||
_this.jqXHR = $.ajax(_this._settings.url, {
|
||||
method: _this._settings.method,
|
||||
|
||||
if (this.requestTID) window.clearTimeout(this.requestTID);
|
||||
|
||||
this.requestTID = window.setTimeout(() => {
|
||||
this.jqXHR = $.ajax(this._settings.url, {
|
||||
method: this._settings.method,
|
||||
data: data,
|
||||
timeout: _this._settings.timeout
|
||||
timeout: this._settings.timeout
|
||||
});
|
||||
_this.jqXHR.done(function (result) {
|
||||
//gnips: result in object
|
||||
cbk((undefined !== result.autodata) ? result.autodata : result);
|
||||
|
||||
this.jqXHR.done(result => {
|
||||
cbk(result.autodata !== undefined ? result.autodata : result);
|
||||
});
|
||||
_this.jqXHR.fail(function (err) {
|
||||
var _a;
|
||||
(_a = _this._settings) === null || _a === void 0 ? void 0 : _a.fail(err);
|
||||
|
||||
this.jqXHR.fail(err => {
|
||||
this._settings.fail?.(err);
|
||||
});
|
||||
_this.jqXHR.always(function () {
|
||||
_this.jqXHR = null;
|
||||
|
||||
this.jqXHR.always(() => {
|
||||
this.jqXHR = null;
|
||||
});
|
||||
}, this._settings.requestThrottling);
|
||||
};
|
||||
return AjaxResolver;
|
||||
}(BaseResolver));
|
||||
}
|
||||
};
|
||||
|
||||
var DropdownV5 = (function () {
|
||||
function DropdownV5(e, formatItemCbk, autoSelect, noResultsText) {
|
||||
var DropdownV5 = class {
|
||||
constructor(e, formatItemCbk, autoSelect, noResultsText) {
|
||||
this.initialized = false;
|
||||
this.shown = false;
|
||||
this.items = [];
|
||||
@@ -88,85 +56,67 @@ var DropdownV5 = (function () {
|
||||
this.autoSelect = autoSelect;
|
||||
this.noResultsText = noResultsText;
|
||||
}
|
||||
DropdownV5.prototype.getElPos = function () {
|
||||
var pos = $.extend({}, this._$el.position(), {
|
||||
height: this._$el[0].offsetHeight
|
||||
});
|
||||
return pos;
|
||||
};
|
||||
DropdownV5.prototype.init = function () {
|
||||
var _this = this;
|
||||
|
||||
getElPos() {
|
||||
return $.extend({}, this._$el.position(), { height: this._$el[0].offsetHeight });
|
||||
}
|
||||
|
||||
init() {
|
||||
var pos = this.getElPos();
|
||||
this._dd = $('<div />');
|
||||
this._dd.addClass('bootstrap-autocomplete dropdown-menu');
|
||||
this._dd.insertAfter(this._$el);
|
||||
this._dd.css({ top: pos.top + this._$el.outerHeight(), left: pos.left, width: this._$el.outerWidth() });
|
||||
this._dd.on('click', '.dropdown-item', function (evt) {
|
||||
//console.log('clicked', evt.currentTarget);
|
||||
//console.log($(evt.currentTarget));
|
||||
var fontsize = this._$el.css('font-size');
|
||||
|
||||
this._dd = $('<div />')
|
||||
.addClass('bootstrap-autocomplete dropdown-menu')
|
||||
.insertAfter(this._$el)
|
||||
.css({
|
||||
top: pos.top + this._$el.outerHeight(),
|
||||
left: pos.left,
|
||||
width: this._$el.outerWidth(),
|
||||
'font-size': fontsize
|
||||
});
|
||||
|
||||
this._dd.on('click', '.dropdown-item', evt => {
|
||||
var item = $(evt.currentTarget).data('item');
|
||||
_this.itemSelectedLaunchEvent(item);
|
||||
this.itemSelectedLaunchEvent(item);
|
||||
evt.preventDefault();
|
||||
});
|
||||
this._dd.on('keyup', function (evt) {
|
||||
if (_this.shown) {
|
||||
switch (evt.which) {
|
||||
case 27:
|
||||
_this.hide();
|
||||
_this._$el.focus();
|
||||
break;
|
||||
}
|
||||
|
||||
this._dd.on('keyup', evt => {
|
||||
if (this.shown && evt.which === 27) {
|
||||
this.hide();
|
||||
this._$el.focus();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
this._dd.on('mouseenter', function (evt) {
|
||||
_this.ddMouseover = true;
|
||||
});
|
||||
this._dd.on('mouseleave', function (evt) {
|
||||
_this.ddMouseover = false;
|
||||
});
|
||||
this._dd.on('mouseenter', '.dropdown-item', function (evt) {
|
||||
if (_this.haveResults) {
|
||||
|
||||
this._dd.on('mouseenter', () => { this.ddMouseover = true; });
|
||||
this._dd.on('mouseleave', () => { this.ddMouseover = false; });
|
||||
|
||||
this._dd.on('mouseenter', '.dropdown-item', evt => {
|
||||
if (this.haveResults) {
|
||||
$(evt.currentTarget).closest('div').find('.dropdown-item.active').removeClass('active');
|
||||
$(evt.currentTarget).addClass('active');
|
||||
_this.mouseover = true;
|
||||
this.mouseover = true;
|
||||
}
|
||||
});
|
||||
this._dd.on('mouseleave', '.dropdown-item', function (evt) {
|
||||
_this.mouseover = false;
|
||||
});
|
||||
|
||||
this._dd.on('mouseleave', '.dropdown-item', () => { this.mouseover = false; });
|
||||
this.initialized = true;
|
||||
};
|
||||
DropdownV5.prototype.checkInitialized = function () {
|
||||
if (!this.initialized) {
|
||||
this.init();
|
||||
}
|
||||
};
|
||||
Object.defineProperty(DropdownV5.prototype, "isMouseOver", {
|
||||
get: function () {
|
||||
return this.mouseover;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(DropdownV5.prototype, "isDdMouseOver", {
|
||||
get: function () {
|
||||
return this.ddMouseover;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(DropdownV5.prototype, "haveResults", {
|
||||
get: function () {
|
||||
return (this.items.length > 0);
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
DropdownV5.prototype.focusNextItem = function (reversed) {
|
||||
if (this.haveResults) {
|
||||
|
||||
checkInitialized() {
|
||||
if (!this.initialized) this.init();
|
||||
}
|
||||
|
||||
get isMouseOver() { return this.mouseover; }
|
||||
get isDdMouseOver() { return this.ddMouseover; }
|
||||
get haveResults() { return this.items.length > 0; }
|
||||
|
||||
focusNextItem(reversed) {
|
||||
if (!this.haveResults) return;
|
||||
var currElem = this._dd.find('.dropdown-item.active');
|
||||
var nextElem = reversed ? currElem.prev() : currElem.next();
|
||||
|
||||
if (nextElem.length === 0) {
|
||||
nextElem = reversed ? this._dd.find('.dropdown-item').last() : this._dd.find('.dropdown-item').first();
|
||||
}
|
||||
@@ -174,111 +124,92 @@ var DropdownV5 = (function () {
|
||||
nextElem.addClass('active');
|
||||
this.scrollTo(nextElem);
|
||||
}
|
||||
};
|
||||
DropdownV5.prototype.focusPreviousItem = function () {
|
||||
this.focusNextItem(true);
|
||||
};
|
||||
DropdownV5.prototype.selectFocusItem = function () {
|
||||
this._dd.find('.dropdown-item.active').trigger('click');
|
||||
};
|
||||
Object.defineProperty(DropdownV5.prototype, "isItemFocused", {
|
||||
get: function () {
|
||||
if (this._dd && this.isShown() && (this._dd.find('.dropdown-item.active').length > 0)) {
|
||||
return true;
|
||||
|
||||
focusPreviousItem() { this.focusNextItem(true); }
|
||||
selectFocusItem() { this._dd.find('.dropdown-item.active').trigger('click'); }
|
||||
|
||||
get isItemFocused() {
|
||||
return !!(this._dd && this.isShown() && this._dd.find('.dropdown-item.active').length > 0);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
DropdownV5.prototype.show = function () {
|
||||
|
||||
show() {
|
||||
if (!this.shown) {
|
||||
this._dd.addClass('show');
|
||||
this.shown = true;
|
||||
this._$el.trigger('autocomplete.dd.shown');
|
||||
}
|
||||
};
|
||||
DropdownV5.prototype.isShown = function () {
|
||||
return this.shown;
|
||||
};
|
||||
DropdownV5.prototype.hide = function () {
|
||||
}
|
||||
|
||||
isShown() { return this.shown; }
|
||||
|
||||
hide() {
|
||||
if (this.shown) {
|
||||
this._dd.removeClass('show');
|
||||
this.shown = false;
|
||||
this._$el.trigger('autocomplete.dd.hidden');
|
||||
}
|
||||
};
|
||||
DropdownV5.prototype.updateItems = function (items, searchText) {
|
||||
}
|
||||
|
||||
updateItems(items, searchText) {
|
||||
this.items = items;
|
||||
this.searchText = searchText;
|
||||
this.refreshItemList();
|
||||
};
|
||||
DropdownV5.prototype.showMatchedText = function (text, qry) {
|
||||
}
|
||||
|
||||
showMatchedText(text, qry) {
|
||||
var startIndex = text.toLowerCase().indexOf(qry.toLowerCase());
|
||||
if (startIndex > -1) {
|
||||
var endIndex = startIndex + qry.length;
|
||||
return text.slice(0, startIndex) + '<b>'
|
||||
+ text.slice(startIndex, endIndex) + '</b>'
|
||||
+ text.slice(endIndex);
|
||||
return text.slice(0, startIndex) + '<b>' + text.slice(startIndex, endIndex) + '</b>' + text.slice(endIndex);
|
||||
}
|
||||
return text;
|
||||
};
|
||||
DropdownV5.prototype.refreshItemList = function () {
|
||||
var _this = this;
|
||||
}
|
||||
|
||||
refreshItemList() {
|
||||
this.checkInitialized();
|
||||
this._dd.empty();
|
||||
var liList = [];
|
||||
|
||||
if (this.items.length > 0) {
|
||||
this.items.forEach(function (item) {
|
||||
var itemFormatted = _this.formatItem(item);
|
||||
if (typeof itemFormatted === 'string') {
|
||||
itemFormatted = { text: itemFormatted };
|
||||
}
|
||||
var itemText;
|
||||
var itemHtml;
|
||||
itemText = _this.showMatchedText(itemFormatted.text, _this.searchText);
|
||||
if (itemFormatted.html !== undefined) {
|
||||
itemHtml = itemFormatted.html;
|
||||
}
|
||||
else {
|
||||
itemHtml = itemText;
|
||||
}
|
||||
var disabledItem = itemFormatted.disabled;
|
||||
var li = $('<a >');
|
||||
li.addClass('dropdown-item')
|
||||
//css bisa dimasukkan ke style default + cursor select
|
||||
//.css({ 'overflow': 'hidden', 'text-overflow': 'ellipsis' })
|
||||
this.items.forEach(item => {
|
||||
var itemFormatted = this.formatItem(item);
|
||||
if (typeof itemFormatted === 'string') itemFormatted = { text: itemFormatted };
|
||||
|
||||
var itemText = this.showMatchedText(itemFormatted.text, this.searchText);
|
||||
var itemHtml = itemFormatted.html !== undefined ? itemFormatted.html : itemText;
|
||||
|
||||
var li = $('<a />')
|
||||
.addClass('dropdown-item')
|
||||
.html(itemHtml)
|
||||
.data('item', item);
|
||||
if (disabledItem) {
|
||||
li.addClass('disabled');
|
||||
}
|
||||
|
||||
if (itemFormatted.disabled) li.addClass('disabled');
|
||||
liList.push(li);
|
||||
});
|
||||
this._dd.append(liList);
|
||||
this.show();
|
||||
}
|
||||
else {
|
||||
if (this.noResultsText === '') {
|
||||
this.hide();
|
||||
}
|
||||
else {
|
||||
var li = $('<a >');
|
||||
li.addClass('dropdown-item disabled')
|
||||
.html(this.noResultsText);
|
||||
} else if (this.noResultsText !== '') {
|
||||
var li = $('<a />').addClass('dropdown-item disabled').html(this.noResultsText);
|
||||
liList.push(li);
|
||||
this._dd.append(liList);
|
||||
this.show();
|
||||
} else {
|
||||
this.hide();
|
||||
}
|
||||
}
|
||||
};
|
||||
DropdownV5.prototype.itemSelectedLaunchEvent = function (item) {
|
||||
|
||||
itemSelectedLaunchEvent(item) {
|
||||
this._$el.trigger('autocomplete.select', item);
|
||||
};
|
||||
DropdownV5.prototype.scrollTo = function (el) {
|
||||
var _he = this._dd.height(), _to = this._dd.scrollTop(), _ito = el.position().top, _ihe = el.outerHeight(),
|
||||
}
|
||||
|
||||
scrollTo(el) {
|
||||
var _he = this._dd.height(),
|
||||
_to = this._dd.scrollTop(),
|
||||
_ito = el.position().top,
|
||||
_ihe = el.outerHeight(),
|
||||
_nto = _to, _wra = false;
|
||||
if (_ito < 0){
|
||||
|
||||
if (_ito < 0) {
|
||||
_wra = el.is(':first-child');
|
||||
_nto = _wra ? 0 : _to - _he / 2;
|
||||
} else if (_ito > _he - _ihe) {
|
||||
@@ -286,12 +217,11 @@ var DropdownV5 = (function () {
|
||||
_nto = _wra ? (_ito + _ihe - _he) : _to + _he / 2;
|
||||
}
|
||||
this._dd.scrollTop(_nto);
|
||||
};
|
||||
return DropdownV5;
|
||||
}());
|
||||
}
|
||||
};
|
||||
|
||||
var AutoComplete = (function () {
|
||||
function AutoComplete(element, options) {
|
||||
var AutoComplete = class {
|
||||
constructor(element, options) {
|
||||
this._selectedItem = null;
|
||||
this._defaultValue = null;
|
||||
this._defaultText = null;
|
||||
@@ -304,235 +234,189 @@ var AutoComplete = (function () {
|
||||
autoSelect: true,
|
||||
noResultsText: 'Pencarian Tidak Ketemu',
|
||||
preventEnter: false,
|
||||
events: {
|
||||
typed: null,
|
||||
searchPre: null,
|
||||
search: null,
|
||||
searchPost: null,
|
||||
select: null,
|
||||
focus: null,
|
||||
},
|
||||
//gnips: adding callback, keyfunc and breakvalue
|
||||
selectFunc: function(){},
|
||||
keyFunc: function(){},
|
||||
events: { typed: null, searchPre: null, search: null, searchPost: null, select: null, focus: null },
|
||||
selectFunc: () => {},
|
||||
keyFunc: () => {},
|
||||
breakFocus: false,
|
||||
breakValue: []
|
||||
};
|
||||
this._el = element;
|
||||
this._$el = $(this._el);
|
||||
this.manageInlineDataAttributes();
|
||||
|
||||
if (typeof options === 'object') {
|
||||
this._settings = $.extend(true, {}, this.getSettings(), options);
|
||||
}
|
||||
this.init();
|
||||
}
|
||||
AutoComplete.prototype.manageInlineDataAttributes = function () {
|
||||
|
||||
manageInlineDataAttributes() {
|
||||
var s = this.getSettings();
|
||||
if (this._$el.data('url')) {
|
||||
s.resolverSettings.url = this._$el.data('url');
|
||||
if (this._$el.data('url')) s.resolverSettings.url = this._$el.data('url');
|
||||
if (this._$el.data('default-value')) this._defaultValue = this._$el.data('default-value');
|
||||
if (this._$el.data('default-text')) this._defaultText = this._$el.data('default-text');
|
||||
if (this._$el.data('noresults-text') !== undefined) s.noResultsText = this._$el.data('noresults-text');
|
||||
}
|
||||
if (this._$el.data('default-value')) {
|
||||
this._defaultValue = this._$el.data('default-value');
|
||||
}
|
||||
if (this._$el.data('default-text')) {
|
||||
this._defaultText = this._$el.data('default-text');
|
||||
}
|
||||
if (this._$el.data('noresults-text') !== undefined) {
|
||||
s.noResultsText = this._$el.data('noresults-text');
|
||||
}
|
||||
};
|
||||
AutoComplete.prototype.getSettings = function () {
|
||||
return this._settings;
|
||||
};
|
||||
AutoComplete.prototype.init = function () {
|
||||
|
||||
getSettings() { return this._settings; }
|
||||
|
||||
init() {
|
||||
this.bindDefaultEventListeners();
|
||||
if (this._settings.resolver === 'ajax') {
|
||||
this.resolver = new AjaxResolver(this._settings.resolverSettings);
|
||||
}
|
||||
this._dd = new DropdownV5(this._$el, this._settings.formatResult, this._settings.autoSelect, this._settings.noResultsText);
|
||||
};
|
||||
AutoComplete.prototype.bindDefaultEventListeners = function () {
|
||||
var _this = this;
|
||||
this._$el.on('keydown', function (evt) {
|
||||
//gnips: check breakValue and call keydown function
|
||||
(('' == _this._$el.val() || ((_this._settings.breakValue.length > 0) && (_this._settings.breakValue.indexOf(_this._$el.val()) != -1))) && _this._settings.keyFunc(evt.which, _this._$el.val()));
|
||||
}
|
||||
|
||||
bindDefaultEventListeners() {
|
||||
this._$el.on('keydown', evt => {
|
||||
var val = this._$el.val();
|
||||
if ((val === '' || (this._settings.breakValue.length > 0 && this._settings.breakValue.indexOf(val) !== -1))) {
|
||||
this._settings.keyFunc(evt.which, val);
|
||||
}
|
||||
|
||||
switch (evt.which) {
|
||||
case 9:
|
||||
if (_this._dd.isItemFocused) {
|
||||
_this._dd.selectFocusItem();
|
||||
if (!this._settings.breakFocus) {
|
||||
if (this._dd.isItemFocused) this._dd.selectFocusItem();
|
||||
this._dd.hide();
|
||||
}
|
||||
_this._dd.hide();
|
||||
break;
|
||||
case 13:
|
||||
if (_this._dd.isItemFocused) {
|
||||
_this._dd.selectFocusItem();
|
||||
}
|
||||
_this._dd.hide();
|
||||
if (_this._settings.preventEnter) {
|
||||
evt.preventDefault();
|
||||
}
|
||||
if (this._dd.isItemFocused) this._dd.selectFocusItem();
|
||||
this._dd.hide();
|
||||
if (this._settings.preventEnter) evt.preventDefault();
|
||||
break;
|
||||
case 40:
|
||||
_this._dd.focusNextItem();
|
||||
this._dd.focusNextItem();
|
||||
break;
|
||||
case 38:
|
||||
_this._dd.focusPreviousItem();
|
||||
this._dd.focusPreviousItem();
|
||||
break;
|
||||
}
|
||||
});
|
||||
this._$el.on('keyup', function (evt) {
|
||||
|
||||
this._$el.on('keyup', evt => {
|
||||
switch (evt.which) {
|
||||
case 16:
|
||||
case 17:
|
||||
case 18:
|
||||
case 39:
|
||||
case 37:
|
||||
case 36:
|
||||
case 35:
|
||||
case 16: case 17: case 18: case 39: case 37: case 36: case 35: case 40: case 38:
|
||||
break;
|
||||
case 13:
|
||||
_this._dd.hide();
|
||||
break;
|
||||
case 27:
|
||||
_this._dd.hide();
|
||||
break;
|
||||
case 40:
|
||||
break;
|
||||
case 38:
|
||||
case 13: case 27:
|
||||
this._dd.hide();
|
||||
break;
|
||||
default:
|
||||
_this._selectedItem = null;
|
||||
var newValue = _this._$el.val();
|
||||
_this.handlerTyped(newValue);
|
||||
this._selectedItem = null;
|
||||
this.handlerTyped(this._$el.val());
|
||||
}
|
||||
});
|
||||
this._$el.on('blur', function (evt) {
|
||||
if (!_this._dd.isMouseOver && _this._dd.isDdMouseOver && _this._dd.isShown()) {
|
||||
setTimeout(function () { _this._$el.focus(); });
|
||||
_this._$el.focus();
|
||||
}
|
||||
else if (!_this._dd.isMouseOver) {
|
||||
_this._dd.hide();
|
||||
|
||||
this._$el.on('blur', () => {
|
||||
if (this._settings.breakFocus) return;
|
||||
if (!this._dd.isMouseOver && this._dd.isDdMouseOver && this._dd.isShown()) {
|
||||
setTimeout(() => { this._$el.focus(); });
|
||||
this._$el.focus();
|
||||
} else if (!this._dd.isMouseOver) {
|
||||
this._dd.hide();
|
||||
}
|
||||
});
|
||||
this._$el.on('autocomplete.select', function (evt, item) {
|
||||
_this._selectedItem = item;
|
||||
_this.itemSelectedDefaultHandler(item);
|
||||
|
||||
this._$el.on('autocomplete.select', (evt, item) => {
|
||||
this._selectedItem = item;
|
||||
this.itemSelectedDefaultHandler(item);
|
||||
});
|
||||
this._$el.on('paste', function (evt) {
|
||||
setTimeout(function () {
|
||||
_this._$el.trigger('keyup', evt);
|
||||
}, 0);
|
||||
|
||||
this._$el.on('paste', evt => {
|
||||
setTimeout(() => { this._$el.trigger('keyup', evt); }, 0);
|
||||
});
|
||||
};
|
||||
AutoComplete.prototype.handlerTyped = function (newValue) {
|
||||
}
|
||||
|
||||
handlerTyped(newValue) {
|
||||
if (this._settings.events.typed !== null) {
|
||||
newValue = this._settings.events.typed(newValue, this._$el);
|
||||
if (!newValue) {
|
||||
return;
|
||||
}
|
||||
if (!newValue) return;
|
||||
}
|
||||
if (newValue.length >= this._settings.minLength) {
|
||||
this._searchText = newValue;
|
||||
this.handlerPreSearch();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this._dd.hide();
|
||||
}
|
||||
};
|
||||
AutoComplete.prototype.handlerPreSearch = function () {
|
||||
}
|
||||
|
||||
handlerPreSearch() {
|
||||
if (this._settings.events.searchPre !== null) {
|
||||
var newValue = this._settings.events.searchPre(this._searchText, this._$el);
|
||||
if (!newValue)
|
||||
return;
|
||||
if (!newValue) return;
|
||||
this._searchText = newValue;
|
||||
}
|
||||
this.handlerDoSearch();
|
||||
};
|
||||
AutoComplete.prototype.handlerDoSearch = function () {
|
||||
var _this = this;
|
||||
if (this._settings.events.search !== null) {
|
||||
this._settings.events.search(this._searchText, function (results) {
|
||||
_this.postSearchCallback(results);
|
||||
}, this._$el);
|
||||
}
|
||||
else {
|
||||
if (this.resolver) {
|
||||
this.resolver.search(this._searchText, function (results) {
|
||||
_this.postSearchCallback(results);
|
||||
|
||||
handlerDoSearch() {
|
||||
if (this._settings.events.search !== null) {
|
||||
this._settings.events.search(this._searchText, results => {
|
||||
this.postSearchCallback(results);
|
||||
}, this._$el);
|
||||
} else if (this.resolver) {
|
||||
this.resolver.search(this._searchText, results => {
|
||||
this.postSearchCallback(results);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
AutoComplete.prototype.postSearchCallback = function (results) {
|
||||
|
||||
postSearchCallback(results) {
|
||||
if (this._settings.events.searchPost) {
|
||||
results = this._settings.events.searchPost(results, this._$el);
|
||||
if ((typeof results === 'boolean') && !results)
|
||||
return;
|
||||
if (typeof results === 'boolean' && !results) return;
|
||||
}
|
||||
this.handlerStartShow(results);
|
||||
};
|
||||
AutoComplete.prototype.handlerStartShow = function (results) {
|
||||
//gnips: adding auto select when barcode result of 1 item only
|
||||
if (1 == results.length && 1 == (void 0 !== results[0].bc ? results[0].bc : 0)) {
|
||||
this._$el.trigger('autocomplete.select', results[0]),
|
||||
}
|
||||
|
||||
handlerStartShow(results) {
|
||||
var bcVal = results[0]?.bc ?? 0;
|
||||
if (results.length === 1 && bcVal === 1) {
|
||||
this._$el.trigger('autocomplete.select', results[0]);
|
||||
this._dd.hide();
|
||||
} else this._dd.updateItems(results, this._searchText);
|
||||
};
|
||||
AutoComplete.prototype.itemSelectedDefaultHandler = function (item) {
|
||||
} else {
|
||||
this._dd.updateItems(results, this._searchText);
|
||||
}
|
||||
}
|
||||
|
||||
itemSelectedDefaultHandler(item) {
|
||||
if (item != null) {
|
||||
var itemFormatted = this._settings.formatResult(item);
|
||||
if (typeof itemFormatted === 'string') {
|
||||
itemFormatted = { text: itemFormatted };
|
||||
}
|
||||
if (typeof itemFormatted === 'string') itemFormatted = { text: itemFormatted };
|
||||
this._$el.val(itemFormatted.text);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this._$el.val('');
|
||||
}
|
||||
this._selectedItem = item;
|
||||
//gnips: callback with selected item
|
||||
this._settings.selectFunc(item);
|
||||
this._dd.hide();
|
||||
};
|
||||
AutoComplete.prototype.defaultFormatResult = function (item) {
|
||||
if (typeof item === 'string') {
|
||||
return { text: item };
|
||||
}
|
||||
else if (item.text) {
|
||||
return item;
|
||||
}
|
||||
else {
|
||||
|
||||
defaultFormatResult(item) {
|
||||
if (typeof item === 'string') return { text: item };
|
||||
if (item.text) return item;
|
||||
return { text: item.toString() };
|
||||
}
|
||||
};
|
||||
AutoComplete.prototype.manageAPI = function (APICmd, params) {
|
||||
if (APICmd === 'set') {
|
||||
this.itemSelectedDefaultHandler(params);
|
||||
}
|
||||
else if (APICmd === 'clear') {
|
||||
this.itemSelectedDefaultHandler(null);
|
||||
}
|
||||
else if (APICmd === 'show') {
|
||||
this._$el.trigger('keyup');
|
||||
}
|
||||
else if (APICmd === 'updateResolver') {
|
||||
this.resolver = new AjaxResolver(params);
|
||||
}
|
||||
};
|
||||
AutoComplete.NAME = 'autoComplete';
|
||||
return AutoComplete;
|
||||
}());
|
||||
|
||||
(function ($, window, document) {
|
||||
$.fn[AutoComplete.NAME] = function (optionsOrAPI, optionalParams) {
|
||||
manageAPI(APICmd, params) {
|
||||
if (APICmd === 'set') this.itemSelectedDefaultHandler(params);
|
||||
else if (APICmd === 'clear') this.itemSelectedDefaultHandler(null);
|
||||
else if (APICmd === 'show') this._$el.trigger('keyup');
|
||||
else if (APICmd === 'updateResolver') this.resolver = new AjaxResolver(params);
|
||||
}
|
||||
};
|
||||
AutoComplete.NAME = 'autoComplete';
|
||||
|
||||
// jQuery plugin wrapper
|
||||
$.fn[AutoComplete.NAME] = function (optionsOrAPI, optionalParams) {
|
||||
return this.each(function () {
|
||||
var pluginClass;
|
||||
pluginClass = $(this).data(AutoComplete.NAME);
|
||||
var pluginClass = $(this).data(AutoComplete.NAME);
|
||||
if (!pluginClass) {
|
||||
pluginClass = new AutoComplete(this, optionsOrAPI);
|
||||
$(this).data(AutoComplete.NAME, pluginClass);
|
||||
}
|
||||
pluginClass.manageAPI(optionsOrAPI, optionalParams);
|
||||
});
|
||||
};
|
||||
})(jQuery, window, document);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
/*******************************************************************
|
||||
|
||||
Module : /assets/js/download.js
|
||||
Desc. : Fungsi-fungsi download data & laporan
|
||||
Created By : Siau Pheng ([email protected]).
|
||||
Created Date : April 1st, 2011.
|
||||
Last Modified : November 2nd, 2026.
|
||||
|
||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
*******************************************************************
|
||||
*
|
||||
* Class Download
|
||||
*
|
||||
* Download atau Share file.
|
||||
*
|
||||
* @license MIT, https://www.3fonia.com
|
||||
* @copyright Copyright (c) 2008-2026, Siau Pheng <[email protected]>
|
||||
*
|
||||
* @param {object} options
|
||||
* @param {string} options.url - Endpoint URL File
|
||||
* @param {string} [options.filename='file.bin'] - Default file name for download is header is missing
|
||||
* @param {string} [options.title] - Title for share file
|
||||
* @param {string} [options.text] - Text for share file
|
||||
* @param {Array} [options.params] - Request payload
|
||||
*/
|
||||
|
||||
class Download {
|
||||
constructor(options = {}) {
|
||||
this.url = typeof options === 'string' ? options : options.url || '';
|
||||
this.filename = options.filename || 'file.bin';
|
||||
this.title = options.title || '';
|
||||
this.text = options.text || '';
|
||||
this.params = options.params || [];
|
||||
}
|
||||
|
||||
addParam(id, val) {
|
||||
this.params.push(val !== undefined ? `${id}=${encodeURIComponent(val)}` : id);
|
||||
return this;
|
||||
}
|
||||
|
||||
async _exec(isShare = false) {
|
||||
if (!this.url) {
|
||||
console.warn('Url File Download dibutuhkan!');
|
||||
return;
|
||||
}
|
||||
await $.ajax({
|
||||
type: 'POST',
|
||||
url: this.url,
|
||||
data: FoniaJS.RequestParam(this.params),
|
||||
xhrFields: { responseType: 'blob' }
|
||||
})
|
||||
.done((blob, status, xhr) => {
|
||||
let filename = this.filename;
|
||||
const disposition = xhr.getResponseHeader('Content-Disposition');
|
||||
const match = disposition?.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/);
|
||||
if (match?.[1]) filename = match[1].replace(/['"]/g, '');
|
||||
|
||||
if (!isShare) {
|
||||
const url = URL.createObjectURL(blob);
|
||||
const link = Object.assign(document.createElement('a'), {
|
||||
href: url,
|
||||
download: filename
|
||||
});
|
||||
link.click();
|
||||
URL.revokeObjectURL(url);
|
||||
} else {
|
||||
const file = new File([blob], filename, { type: blob.type });
|
||||
if (isShare && navigator.canShare?.({ files: [file] })) {
|
||||
navigator.share({
|
||||
files: [file],
|
||||
title: this.title || filename,
|
||||
text: this.text
|
||||
});
|
||||
}
|
||||
file = null;
|
||||
}
|
||||
})
|
||||
.fail((xhr, status, err) => console.error('Gagal download File karena : ', err));
|
||||
}
|
||||
|
||||
share() {
|
||||
return this._exec(true);
|
||||
}
|
||||
|
||||
download() {
|
||||
return this._exec(false);
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
/*******************************************************************
|
||||
|
||||
Module : /assets/js/export.js
|
||||
Desc. : Fungsi-fungsi export data & laporan
|
||||
Created By : Siau Pheng ([email protected]).
|
||||
Created Date : April 1st, 2011.
|
||||
Last Modified : January 19th, 2026.
|
||||
|
||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
*******************************************************************/
|
||||
|
||||
var cEXPORT = function(url, options){
|
||||
var _options = {
|
||||
'url': '',
|
||||
'filename': ''
|
||||
};
|
||||
var _params = [];
|
||||
|
||||
this.construct = function(url, options){
|
||||
if (typeof url == 'object') {
|
||||
$.extend(_options, url);
|
||||
} else {
|
||||
$.extend(_options, options);
|
||||
_options.url = url;
|
||||
}
|
||||
};
|
||||
this.set_url = function (url){
|
||||
_options.url = url;
|
||||
};
|
||||
this.add_param = function (par_id, par_val){
|
||||
var _getvalue = (par_val) ? par_id + "=" + escape(par_val) : par_id;
|
||||
_params.push(_getvalue);
|
||||
},
|
||||
this.download = async function(){
|
||||
if (!_options.url) {
|
||||
console.warn('cek url !');
|
||||
return false;
|
||||
}
|
||||
var _pro = (window.location.protocol=='https:') ? 'https://' : 'http://';
|
||||
var _src = _pro+FoniaJS.WEB_HOST + _options.url + '?' + (FoniaJS.RequestParam(_params)).join('&');
|
||||
|
||||
try {
|
||||
const response = await fetch(_src)
|
||||
.then(response => {
|
||||
const cDispo = response.headers.get('Content-Disposition');
|
||||
if (cDispo && cDispo.indexOf('filename=') !== -1) {
|
||||
_options.filename = cDispo.split('filename=')[1].split(';')[0].replace(/"/g, '');
|
||||
}
|
||||
return response;
|
||||
})
|
||||
const blob = await response.blob();
|
||||
const link = document.createElement('a');
|
||||
link.href = URL.createObjectURL(blob);
|
||||
link.download = _options.filename;
|
||||
link.click();
|
||||
} catch (error) {
|
||||
console.error('Download gagal:', error);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
this.construct(url, options);
|
||||
};
|
||||
+648
-710
File diff suppressed because it is too large
Load Diff
+113
-53
@@ -4,63 +4,123 @@
|
||||
Desc. : JS - Cetak Laporan PDF
|
||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||
Created Date : April 6th, 2015.
|
||||
Last Modified : October 18th, 2020.
|
||||
Last Modified : November 2nd, 2026.
|
||||
|
||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
*******************************************************************/
|
||||
*******************************************************************
|
||||
*
|
||||
* Class Pdf
|
||||
*
|
||||
* Preview dan download file pdf.
|
||||
*
|
||||
* @license MIT, https://www.3fonia.com
|
||||
* @copyright Copyright (c) 2008-2026, Siau Pheng <siaupheng@3fonia.com>
|
||||
*
|
||||
* @param {object} options
|
||||
* @param {string} options.url - Endpoint PDF File URL
|
||||
* @param {number} [options.zoom=80] - Zoom percentage in PDF viewer
|
||||
* @param {string} [options.filename='report.pdf'] - Default file name for download is header is missing
|
||||
* @param {Array} [options.params] - Request payload
|
||||
*/
|
||||
|
||||
var cPDF = function(url, options){
|
||||
var vars = {
|
||||
'url': '',
|
||||
'zoom': 80,
|
||||
'param': []
|
||||
};
|
||||
this.construct = function(url, options){
|
||||
$.extend(vars, options);
|
||||
vars.url = url;
|
||||
};
|
||||
this.set_url = function (url){
|
||||
vars.url = url;
|
||||
};
|
||||
this.set_zoom = function (zoom){
|
||||
if (zoom) vars.zoom = zoom;
|
||||
},
|
||||
this.add_param = function (par_id, par_val){
|
||||
var _getvalue = (par_val) ? par_id + "=" + escape(par_val) : par_id;
|
||||
vars.param.push(_getvalue);
|
||||
},
|
||||
this.downloadPDF = function(){
|
||||
if (!vars.url) {
|
||||
console.warn(vars.param + ", cek url php!");
|
||||
return false;
|
||||
class Pdf {
|
||||
constructor(options = {}) {
|
||||
this.url = typeof options === 'string' ? options : options.url || '';
|
||||
this.zoom = options.zoom || 80;
|
||||
this.filename = options.filename || 'report.pdf';
|
||||
this.params = options.params || [];
|
||||
}
|
||||
vars.data = FoniaJS.RequestParam(vars.param);
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: vars.url,
|
||||
data: (vars.data).join('&'),
|
||||
success: (typeof vars.onSuccess === "function") ? vars.onSuccess : null,
|
||||
error: (typeof vars.onFailure === "function") ? vars.onFailure : null,
|
||||
}).always(FoniaJS.FormDecorated);
|
||||
|
||||
addParam(id, val) {
|
||||
this.params.push(val !== undefined ? `${id}=${encodeURIComponent(val)}` : id);
|
||||
return this;
|
||||
};
|
||||
this.showPDF = function(){
|
||||
var _proto = window.location.protocol + '//';
|
||||
var _src = _proto + FoniaJS.WEB_HOST + vars.url + '?' + (FoniaJS.RequestParam(vars.param)).join('&') + '#zoom='+vars.zoom+',0,0&page=1';
|
||||
var _wtxt =
|
||||
'<div class="modal fade" id="winAPPPDF" tabindex="-1" role="dialog" data-bs-keyboard="false" data-bs-show="false" data-bs-backdrop="static" aria-labelledby="winAPPPDFLabel" aria-hidden="true">'+
|
||||
'<div class="modal-dialog modal-dialog-centered modal-fs" role="document">'+
|
||||
'<div class="modal-content">'+
|
||||
'<div class="modal-header"><h5 class="modal-title" id="winAPPPDFLabel">Preview PDF</h5><button class="btn-close" type="button" data-bs-dismiss="modal" aria-label="Close"></button></div>'+
|
||||
'<div class="modal-body mb-0 p-0"><div class="ratio ratio-21x9"><object type="application/pdf" data="'+_src+'"><p>Tidak Mendukung Preview PDF</p></object></div></div>'+
|
||||
'</div></div></div>';
|
||||
if ($('#winAPPPDF')) $('#winAPPPDF').modal('dispose').remove();
|
||||
$(_wtxt).on('shown.bs.modal', function(e){
|
||||
FoniaJS.FormDecorated();
|
||||
}).on('hidden.bs.modal', function(e){
|
||||
}
|
||||
|
||||
async downloadPdf() {
|
||||
if (!this.url) {
|
||||
console.warn('Url PDF dibutuhkan!');
|
||||
return;
|
||||
}
|
||||
await $.ajax({
|
||||
type: 'POST',
|
||||
url: this.url,
|
||||
data: FoniaJS.RequestParam(this.params),
|
||||
xhrFields: { responseType: 'blob' }
|
||||
})
|
||||
.done((blob, status, xhr) => {
|
||||
let filename = this.filename;
|
||||
const disposition = xhr.getResponseHeader('Content-Disposition');
|
||||
const match = disposition?.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/);
|
||||
if (match?.[1]) filename = match[1].replace(/['"]/g, '');
|
||||
const url = URL.createObjectURL(blob);
|
||||
const link = Object.assign(document.createElement('a'), {
|
||||
href: url,
|
||||
download: filename
|
||||
});
|
||||
link.click();
|
||||
URL.revokeObjectURL(url);
|
||||
})
|
||||
.fail((xhr, status, err) => console.error('Gagal proses download PDF karena : ', err));
|
||||
}
|
||||
|
||||
async showPdf() {
|
||||
if (!this.url) {
|
||||
console.warn('Url PDF dibutuhkan!');
|
||||
return;
|
||||
}
|
||||
await $.ajax({
|
||||
type: 'POST',
|
||||
url: this.url,
|
||||
data: FoniaJS.RequestParam(this.params),
|
||||
xhrFields: { responseType: 'blob' }
|
||||
})
|
||||
.done((blob, status, xhr) => {
|
||||
let filename = this.filename;
|
||||
const disposition = xhr.getResponseHeader('Content-Disposition');
|
||||
const match = disposition?.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/);
|
||||
if (match?.[1]) filename = match[1].replace(/['"]/g, '');
|
||||
|
||||
const objectUrl = URL.createObjectURL(blob);
|
||||
const pdfSrc = `${objectUrl}#zoom=${zoom}&page=1`;
|
||||
|
||||
const modalHtml = `
|
||||
<div class="modal fade" id="winAPPPDF" tabindex="-1" data-bs-backdrop="static" aria-labelledby="winAPPPDFLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered modal-xl" style="height: 90vh;">
|
||||
<div class="modal-content h-100">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="winAPPPDFLabel">${filename}</h5>
|
||||
<div class="ms-auto d-flex align-items-center gap-2">
|
||||
<a href="${objectUrl}" download="${filename}" class="btn btn-sm btn-outline-primary">
|
||||
<i class="bi bi-download"></i> Download
|
||||
</a>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-body p-0 h-100">
|
||||
<object data="${pdfSrc}" type="application/pdf" class="w-100 h-100">
|
||||
<iframe src="${pdfSrc}" class="w-100 h-100" style="border: none;">
|
||||
<p class="p-3">Ada kendala dalam Preview PDF di browser Anda.
|
||||
<a href="${objectUrl}" download="${filename}">Unduh ${filename}</a> instead.
|
||||
</p>
|
||||
</iframe>
|
||||
</object>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
$('#winAPPPDF').modal('dispose').remove();
|
||||
$(modalHtml)
|
||||
.appendTo('body')
|
||||
//.on('shown.bs.modal', () => FoniaJS.FormDecorated())
|
||||
.on('hidden.bs.modal', function () {
|
||||
URL.revokeObjectURL(objectUrl);
|
||||
$(this).remove();
|
||||
}).modal('show');
|
||||
};
|
||||
this.construct(url, options);
|
||||
};
|
||||
})
|
||||
.modal('show');
|
||||
})
|
||||
.fail((xhr, status, err) => console.error('Gagal proses preview PDF karena : ', err));
|
||||
}
|
||||
}
|
||||
|
||||
+57
-61
@@ -4,90 +4,86 @@
|
||||
Desc. : JS Class Tampil Data di Pole Display POS
|
||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||
Created Date : October 12th, 2025.
|
||||
Last Modified : November 1st, 2026.
|
||||
|
||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
*******************************************************************/
|
||||
|
||||
var cPOLEDISPLAY = function(port, options){
|
||||
var _cd_port = '';
|
||||
var _cd_pole = '';
|
||||
var _options = {
|
||||
class PoleDisplay {
|
||||
constructor(port, options = {}) {
|
||||
this.port = port;
|
||||
this.pole = '';
|
||||
this.options = Object.assign({
|
||||
rx: { start: '\x02', end: '\x0D', width: null },
|
||||
baudRate: 9600,
|
||||
dataBits: 8,
|
||||
stopBits: 1,
|
||||
parity: 'NONE',
|
||||
flowControl: 'NONE'
|
||||
};
|
||||
|
||||
this.construct = function (port, options){
|
||||
$.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);
|
||||
}, options);
|
||||
}
|
||||
};
|
||||
|
||||
this.Close = function (){
|
||||
qz.serial.closePort(_cd_port).then(() => {
|
||||
_cd_pole = '';
|
||||
this.cd_Error(_cd_port+' closed');
|
||||
}).catch(this.cd_Error);
|
||||
};
|
||||
Open() {
|
||||
if (this.pole) return;
|
||||
|
||||
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());
|
||||
qz.serial.openPort(this.port, this.options)
|
||||
.then(() => {
|
||||
this.pole = this.port;
|
||||
this._conerr(`${this.port} opened`);
|
||||
return qz.serial.sendData(this.pole, { type: 'HEX', data: 'x1Bx40' }, this.options);
|
||||
})
|
||||
.catch(this._conerr);
|
||||
}
|
||||
return 'x' + arr1.join('x');
|
||||
};
|
||||
var _txt = txt;
|
||||
|
||||
Close() {
|
||||
if (!this.pole) return;
|
||||
|
||||
qz.serial.closePort(this.port)
|
||||
.then(() => {
|
||||
this.pole = '';
|
||||
this._conerr(`${this.port} closed`);
|
||||
})
|
||||
.catch(this._conerr);
|
||||
}
|
||||
|
||||
Send(txt) {
|
||||
if (!this.pole) return false;
|
||||
|
||||
// Convert string to ASCII hex format
|
||||
const asciiToHex = str =>
|
||||
Array.from(str, char => char.charCodeAt(0).toString(16).padStart(2, '0').toUpperCase())
|
||||
.join('x');
|
||||
|
||||
let textToSend = txt;
|
||||
if (Array.isArray(txt)) {
|
||||
_txt = '';
|
||||
txt.forEach((ele) => {
|
||||
_txt += this.cd_Text(ele['t'], ele['a']);
|
||||
});
|
||||
textToSend = txt.map(ele => this._aligntext(ele.t, ele.a)).join('');
|
||||
}
|
||||
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 hexData = `x10C${asciiToHex(textToSend)}`;
|
||||
qz.serial.sendData(this.pole, { type: 'HEX', data: hexData }, this.options)
|
||||
.catch(this._conerr);
|
||||
}
|
||||
const padding = totWidth - txtLength;
|
||||
var lPadding = 0;
|
||||
var rPadding = padding;
|
||||
if (align === null) align = 'L';
|
||||
if (align == 'C'){
|
||||
|
||||
_aligntext(text, align = 'L') {
|
||||
const totWidth = 20;
|
||||
if (text.length >= totWidth) return text.substring(0, totWidth);
|
||||
|
||||
const padding = totWidth - text.length;
|
||||
let lPadding = 0, rPadding = padding;
|
||||
|
||||
if (align === 'C') {
|
||||
lPadding = Math.floor(padding / 2);
|
||||
rPadding = Math.ceil(padding / 2);
|
||||
} else if (align == 'R'){
|
||||
} else if (align === 'R') {
|
||||
lPadding = padding;
|
||||
rPadding = 0;
|
||||
}
|
||||
return " ".repeat(lPadding) + text + " ".repeat(rPadding);
|
||||
};
|
||||
|
||||
this.cd_Error = function (err){
|
||||
return ' '.repeat(lPadding) + text + ' '.repeat(rPadding);
|
||||
}
|
||||
|
||||
_conerr(err) {
|
||||
console.error(err);
|
||||
};
|
||||
|
||||
this.construct(port, options);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
+202
-168
@@ -4,231 +4,265 @@
|
||||
Desc. : JS Class Printer & Printer POS
|
||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||
Created Date : May 27th, 2007.
|
||||
Last Modified : August 21st, 2026.
|
||||
Last Modified : November 2nd, 2026.
|
||||
|
||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
*******************************************************************/
|
||||
*******************************************************************
|
||||
*
|
||||
* Class Printer
|
||||
*
|
||||
* Standard Web Document Printing & Report Preview Class
|
||||
*
|
||||
* @license MIT, https://www.3fonia.com
|
||||
* @copyright Copyright (c) 2008-2026, Siau Pheng <siaupheng@3fonia.com>
|
||||
*
|
||||
* @param {object} options
|
||||
* @param {string} options.url - Endpoint URL Print Page
|
||||
* @param {number} [options.zoom=90] - Zoom percentage in viewer
|
||||
* @param {Array} [options.params] - Request payload
|
||||
*/
|
||||
|
||||
var cPRINTER = function(url, options){
|
||||
var vars = {
|
||||
'url': '',
|
||||
'zoom': 90,
|
||||
'param': []
|
||||
};
|
||||
this.construct = function(url, options){
|
||||
$.extend(vars, options);
|
||||
vars.url = url;
|
||||
};
|
||||
this.set_url = function (url){
|
||||
vars.url = url;
|
||||
};
|
||||
this.set_zoom = function (zoom){
|
||||
if (zoom) vars.zoom = zoom;
|
||||
},
|
||||
this.add_param = function (par_id, par_val){
|
||||
var _getvalue = (par_val) ? par_id + "=" + escape(par_val) : par_id;
|
||||
vars.param.push(_getvalue);
|
||||
},
|
||||
this.doPrint = function(){
|
||||
if (!vars.url) {
|
||||
console.warn(vars.param + ", cek url php!");
|
||||
return false;
|
||||
class Printer {
|
||||
constructor(options = {}) {
|
||||
this.url = typeof options === 'string' ? options : options.url || '';
|
||||
this.zoom = options.zoom || 90;
|
||||
this.params = options.params || [];
|
||||
}
|
||||
|
||||
addParam(id, val) {
|
||||
this.params.push(val !== undefined ? `${id}=${encodeURIComponent(val)}` : id);
|
||||
return this;
|
||||
}
|
||||
|
||||
doPrint() {
|
||||
if (!this.url) {
|
||||
console.warn('Url Laporan dibutuhkan!');
|
||||
return;
|
||||
}
|
||||
vars.data = FoniaJS.RequestParam(vars.param);
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: vars.url,
|
||||
data: (vars.data).join('&'),
|
||||
url: this.url,
|
||||
data: FoniaJS.RequestParam(this.params),
|
||||
success: (txt) => {
|
||||
var $printData = $('#dataPrint');
|
||||
let $printData = $('#dataPrint');
|
||||
if (!$printData.length) {
|
||||
$printData = $('<div/>', {id:'dataPrint','class':'d-none d-print-block print-body'}).appendTo('body');
|
||||
$printData = $('<div/>', {
|
||||
id: 'dataPrint',
|
||||
class: 'd-none d-print-block print-body'
|
||||
}).appendTo('body');
|
||||
}
|
||||
$printData.html(txt);
|
||||
window.print();
|
||||
},
|
||||
error: (typeof vars.onFailure === "function") ? vars.onFailure : null,
|
||||
error: typeof this.onFailure === 'function' ? this.onFailure : null
|
||||
});
|
||||
return this;
|
||||
};
|
||||
this.doPreview = function(){
|
||||
if (!vars.url) console.warn(vars.param + ", cek url php!");
|
||||
vars.data = FoniaJS.RequestParam(vars.param);
|
||||
}
|
||||
|
||||
doPreview() {
|
||||
if (!this.url) {
|
||||
console.warn('Url Laporan dibutuhkan!');
|
||||
return;
|
||||
}
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: vars.url,
|
||||
data: (vars.data).join('&'),
|
||||
url: this.url,
|
||||
data: FoniaJS.RequestParam(this.params),
|
||||
success: (txt) => {
|
||||
if ('' == txt) {
|
||||
if (!txt) {
|
||||
FoniaJS.showInfo('Tidak ada data untuk pembuatan laporan !');
|
||||
return false;
|
||||
}
|
||||
var _wtxt =
|
||||
'<div class="modal fade" id="winAPPPrint" tabindex="-1" role="dialog" data-bs-keyboard="false" data-bs-show="false" data-bs-backdrop="static" aria-labelledby="winAPPPrintLabel" aria-hidden="true">'+
|
||||
'<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable modal-fs" role="document">'+
|
||||
'<div class="modal-content">'+
|
||||
'<div class="modal-header"><h5 class="modal-title" id="winAPPPrintLabel">Preview Laporan</h5><div class="ms-auto"><button class="btn me-2" id="tombCetak" type="button" aria-label="Cetak"><i class="bi-printer me-2"></i><span aria-hidden="true">Cetak</span></button><button class="btn" type="button" data-bs-dismiss="modal" aria-label="Tutup"><i class="bi-x-lg me-2"></i><span aria-hidden="true">Tutup</span></button></div></div>'+
|
||||
'<div class="modal-body print-body" id="divPrintP">'+txt+'</div>'+
|
||||
'</div></div></div>';
|
||||
if ($('#winAPPPrint')) $('#winAPPPrint').modal('dispose').remove();
|
||||
$(_wtxt).on('shown.bs.modal', (e) => {
|
||||
$('#winAPPPrint').find('#tombCetak').click(() => {
|
||||
var $printData = $('#dataPrint');
|
||||
const modalHtml = `
|
||||
<div class="modal fade" id="winAPPPrint" tabindex="-1" role="dialog" data-bs-keyboard="false" data-bs-show="false" data-bs-backdrop="static" aria-labelledby="winAPPPrintLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable modal-fs" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="winAPPPrintLabel">Preview Laporan</h5>
|
||||
<div class="ms-auto">
|
||||
<button class="btn me-2" id="tombCetak" type="button" aria-label="Cetak">
|
||||
<i class="bi-printer me-2"></i><span aria-hidden="true">Cetak</span>
|
||||
</button>
|
||||
<button class="btn" type="button" data-bs-dismiss="modal" aria-label="Tutup">
|
||||
<i class="bi-x-lg me-2"></i><span aria-hidden="true">Tutup</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-body print-body" id="divPrintP">${txt}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
$('#winAPPPrint').modal('dispose').remove();
|
||||
$(modalHtml)
|
||||
.on('shown.bs.modal', () => {
|
||||
$('#winAPPPrint #tombCetak').off('click').on('click', () => {
|
||||
let $printData = $('#dataPrint');
|
||||
if (!$printData.length) {
|
||||
$printData = $('<div/>', {id:'dataPrint','class':'d-none d-print-block print-body'}).appendTo('body');
|
||||
$printData = $('<div/>', {
|
||||
id: 'dataPrint',
|
||||
class: 'd-none d-print-block print-body'
|
||||
}).appendTo('body');
|
||||
}
|
||||
$printData.html($('#divPrintP').html());
|
||||
FoniaJS.closeWindow($('#winAPPPrint'));
|
||||
window.print();
|
||||
});
|
||||
}).on('hidden.bs.modal', (e) => {
|
||||
})
|
||||
.on('hidden.bs.modal', function () {
|
||||
$(this).remove();
|
||||
}).modal('show');
|
||||
})
|
||||
.modal('show');
|
||||
},
|
||||
error: (typeof vars.onFailure === "function") ? vars.onFailure : null,
|
||||
error: typeof this.onFailure === 'function' ? this.onFailure : null
|
||||
});
|
||||
};
|
||||
this.construct(url, options);
|
||||
};
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
var cPRINTERPOS = function(url, options) {
|
||||
var b_default = false;
|
||||
var _options = {
|
||||
'url': '',
|
||||
'param': [],
|
||||
'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;
|
||||
};
|
||||
this.detectPrinter = function() {
|
||||
if (!qz.websocket.isActive()) {
|
||||
/**
|
||||
* Class PrinterPos
|
||||
*
|
||||
* Direct Thermal POS Printer Class (via QZ Tray API)
|
||||
*
|
||||
* @license MIT, https://www.3fonia.com
|
||||
* @copyright Copyright (c) 2008-2026, Siau Pheng <siaupheng@3fonia.com>
|
||||
*
|
||||
* @param {object} options
|
||||
* @param {string} options.url - Endpoint URL Print Page
|
||||
* @param {number} [options.printer=FoniaJS._def_printer] - Printer Name
|
||||
* @param {Array} [options.params] - Request payload
|
||||
*/
|
||||
|
||||
class PrinterPos {
|
||||
constructor(options = {}) {
|
||||
this.url = typeof options === 'string' ? options : options.url || '';
|
||||
this.printer = options.printer || (FoniaJS._def_printer ?? null);
|
||||
this.cut_paper = options.cut_paper || '\x1D\x56\x41';
|
||||
this.open_draw = options.open_draw || '\x1B\x70\x30\x19\x19';
|
||||
this.chr_norm = options.chr_norm || '\x1B\x21\x01';
|
||||
this.chr_bold = options.chr_bold || '\x1B\x21\x10';
|
||||
this.chr_sbold = options.chr_sbold || '\x1B\x21\x31';
|
||||
this.chr_uline = options.chr_uline || '\x1B\x21\x80';
|
||||
this.params = options.params || [];
|
||||
}
|
||||
|
||||
_detectPrinter() {
|
||||
if (!qz?.websocket?.isActive?.()) {
|
||||
FoniaJS.showInfo('Status Printer belum Active !');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
this.getPrinters = function() {
|
||||
return [];
|
||||
};
|
||||
this.setPrinter = function(nprint) {
|
||||
(nprint != null) && (_options.printer = nprint);
|
||||
};
|
||||
this.useDefaultPrinter = function() {
|
||||
b_default = true;
|
||||
};
|
||||
this.set_url = function(url) {
|
||||
_options.url = url;
|
||||
};
|
||||
this.add_param = function(par_id, par_val) {
|
||||
var _getvalue = (par_val) ? par_id + '=' + escape(par_val) : par_id;
|
||||
_options.param.push(_getvalue);
|
||||
};
|
||||
this.exec = function() {
|
||||
if (!this.detectPrinter()) return;
|
||||
if (this.b_default) {
|
||||
var parent = this;
|
||||
qz.printers.getDefault().then(function(data) {
|
||||
var nama_p = data;
|
||||
if (data.name != undefined) {
|
||||
nama_p = data.name;
|
||||
}
|
||||
parent._options.param.push('Printer='+nama_p);
|
||||
return parent.do_print(nama_p, parent._options.url, parent._options.param);
|
||||
}, function(data) {
|
||||
FoniaJS.showInfo(data);
|
||||
});
|
||||
} else {
|
||||
var _nprinter = _options.printer;
|
||||
if (typeof _nprinter === 'object' && _nprinter.name == undefined) {
|
||||
if (_nprinter.file != undefined) _nprinter = _nprinter.file;
|
||||
if (_nprinter.host != undefined) _nprinter = _nprinter.host + ":" + _nprinter.port;
|
||||
} else {
|
||||
if (_nprinter.name != undefined) _nprinter = _nprinter.name;
|
||||
if (_nprinter== undefined) _nprinter = 'None';
|
||||
|
||||
setPrinter(nprint) {
|
||||
if (nprint != null) this.printer = nprint;
|
||||
return this;
|
||||
}
|
||||
_options.param.push('Printer='+_nprinter);
|
||||
this.do_print(_options.printer, _options.url, _options.param);
|
||||
|
||||
addParam(id, val) {
|
||||
this.params.push(val !== undefined ? `${id}=${encodeURIComponent(val)}` : id);
|
||||
return this;
|
||||
}
|
||||
};
|
||||
this.do_print = function(nama_p, url, params) {
|
||||
var qzcfg = qz.configs.create(nama_p);
|
||||
new Request.JSON({
|
||||
url: url,
|
||||
|
||||
async exec() {
|
||||
if (!this._detectPrinter()) return;
|
||||
|
||||
let printerName = this.printer;
|
||||
if (typeof printerName === 'object' && printerName !== null) {
|
||||
if (printerName.name !== undefined) {
|
||||
printerName = printerName.name;
|
||||
} else if (printerName.file !== undefined) {
|
||||
printerName = printerName.file;
|
||||
} else if (printerName.host !== undefined) {
|
||||
printerName = `${printerName.host}:${printerName.port}`;
|
||||
}
|
||||
}
|
||||
printerName = printerName ?? 'None';
|
||||
this.params.push(`Printer=${printerName}`);
|
||||
this.doPrint(this.printer, this.url, this.params);
|
||||
}
|
||||
|
||||
doPrint(printerName, url, params) {
|
||||
const qzcfg = qz.configs.create(printerName);
|
||||
new Request({
|
||||
url,
|
||||
sendParam: params,
|
||||
onSuccess: (ajson) => {
|
||||
if (typeof ajson === "object") {
|
||||
var hasil_cetak = (ajson.type == "escp") ? this.gen_escp(ajson) : this.gen_epl(ajson);
|
||||
qz.print(qzcfg, hasil_cetak);
|
||||
if (typeof ajson === 'object' && ajson !== null) {
|
||||
const printPayload = ajson.type === 'escp' ? this.genEscp(ajson) : this.genEpl(ajson);
|
||||
qz.print(qzcfg, printPayload);
|
||||
} else {
|
||||
FoniaJS.showInfo('Error dalam proses Cetak.');
|
||||
}
|
||||
}
|
||||
}).send();
|
||||
};
|
||||
this.gen_escp = function(adata) {
|
||||
var ohead = [];
|
||||
var osheet = [], ocetak = [];
|
||||
ohead.push("\x1B\x40");
|
||||
ohead.push("\x1B\x61\x01");
|
||||
if (adata.config.logo != null) {
|
||||
ohead.push({type:'raw',format:'image',data:adata.config.logo,options:{language:'ESCPOS',dotDensity:'double'}});
|
||||
ohead.push("\x1B\x32");
|
||||
}
|
||||
if (parseInt(adata.config.fontsize) == 2) {
|
||||
_options.chr_norm = "\x1B\x21\x02";
|
||||
|
||||
genEscp(adata) {
|
||||
const ohead = ['\x1B\x40', '\x1B\x61\x01'];
|
||||
if (adata.config?.logo) {
|
||||
ohead.push({
|
||||
type: 'raw',
|
||||
format: 'image',
|
||||
flavor: 'base64',
|
||||
data: adata.config.logo,
|
||||
options: { language: 'ESCPOS', dotDensity: 'double' }
|
||||
});
|
||||
ohead.push('\x1B\x32');
|
||||
}
|
||||
if (adata.header.length > 0) {
|
||||
for (i = 0; i < adata.header.length; i++) {
|
||||
if (i==0 && adata.config.logo==null) ohead.push(_options.chr_bold);
|
||||
ohead.push(adata.header[i] + "\x0A");
|
||||
if (i==0 && adata.config.logo==null) ohead.push(_options.chr_norm);
|
||||
if (parseInt(adata.config?.fontsize, 10) === 2) {
|
||||
this.chr_norm = '\x1B\x21\x02';
|
||||
}
|
||||
if (Array.isArray(adata.header)) {
|
||||
adata.header.forEach((headerLine, index) => {
|
||||
if (index === 0 && !adata.config?.logo) ohead.push(this.chr_bold);
|
||||
ohead.push(`${headerLine}\x0A`);
|
||||
if (index === 0 && !adata.config?.logo) ohead.push(this.chr_norm);
|
||||
});
|
||||
}
|
||||
for (s = 0; s < adata.content.length; s++) {
|
||||
if (adata.content[s].length == 0) continue;
|
||||
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_', _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(_options.cut_paper + "\x0A");
|
||||
|
||||
let ocetak = [];
|
||||
if (Array.isArray(adata.content)) {
|
||||
adata.content.forEach((sheetContent) => {
|
||||
if (!sheetContent?.length) return;
|
||||
const osheet = [...ohead];
|
||||
sheetContent.forEach((line) => {
|
||||
const formattedLine = line
|
||||
.replace('_SBOLD_', this.chr_sbold)
|
||||
.replace('_BOLD_', this.chr_bold)
|
||||
.replace('_NORM_', this.chr_norm)
|
||||
.replace('_ULINE_', this.chr_uline);
|
||||
osheet.push(`${formattedLine}\x0A`);
|
||||
});
|
||||
if (adata.config?.cutpaper) {
|
||||
osheet.push(`${this.cut_paper}\x0A`);
|
||||
}
|
||||
ocetak = ocetak.concat(osheet);
|
||||
});
|
||||
}
|
||||
var notaout = [];
|
||||
if (adata.config.opendraw) {
|
||||
notaout.push(_options.open_draw);
|
||||
|
||||
let notaout = [];
|
||||
if (adata.config?.opendraw) {
|
||||
notaout.push(this.open_draw);
|
||||
}
|
||||
for (i = 0; i < adata.config.times; i++) {
|
||||
const times = adata.config?.times || 1;
|
||||
for (let i = 0; i < times; i++) {
|
||||
notaout = notaout.concat(ocetak);
|
||||
}
|
||||
return notaout;
|
||||
};
|
||||
this.gen_epl = function(adata) {
|
||||
var cetak = [];
|
||||
for (i = 0; i < adata.content.length; i++) {
|
||||
cetak.push(adata.content[i] + "\r\n");
|
||||
}
|
||||
var notaout = [];
|
||||
for (i = 0; i < adata.config.times; i++) {
|
||||
|
||||
genEpl(adata) {
|
||||
const cetak = (adata.content || []).map((line) => `${line}\r\n`);
|
||||
let notaout = [];
|
||||
const times = adata.config?.times || 1;
|
||||
|
||||
for (let i = 0; i < times; i++) {
|
||||
notaout = notaout.concat(cetak);
|
||||
}
|
||||
return notaout;
|
||||
};
|
||||
this.construct(url, options);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
/*******************************************************************
|
||||
|
||||
Module : /assets/js/share.js
|
||||
Desc. : JS Class Share File Cross Browser
|
||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||
Created Date : May 27th, 2007.
|
||||
Last Modified : January 19th, 2026.
|
||||
|
||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
*******************************************************************/
|
||||
|
||||
var cSHARE = function(url, options) {
|
||||
var _options = {
|
||||
'url': '',
|
||||
'filename': '',
|
||||
'title': '',
|
||||
'text': 'share dari aplikasi'
|
||||
};
|
||||
var _params = [];
|
||||
this.construct = function(url, options){
|
||||
if (typeof url == 'object') {
|
||||
$.extend(_options, url);
|
||||
} else {
|
||||
$.extend(_options, options);
|
||||
_options.url = url;
|
||||
}
|
||||
};
|
||||
this.set_url = function (url){
|
||||
_options.url = url;
|
||||
};
|
||||
this.add_param = function(par_id, par_val) {
|
||||
var _getvalue = (par_val) ? par_id + '=' + escape(par_val) : par_id;
|
||||
_params.push(_getvalue);
|
||||
};
|
||||
this.share = async function() {
|
||||
if (!_options.url) {
|
||||
console.warn('cek url !');
|
||||
return false;
|
||||
}
|
||||
var _pro = (window.location.protocol=='https:') ? 'https://' : 'http://';
|
||||
var _src = _pro+FoniaJS.WEB_HOST + _options.url + '?' + (FoniaJS.RequestParam(_params)).join('&');
|
||||
|
||||
try {
|
||||
const response = await fetch(_src)
|
||||
.then(response => {
|
||||
const cDispo = response.headers.get('Content-Disposition');
|
||||
if (cDispo && cDispo.indexOf('filename=') !== -1) {
|
||||
_options.filename = cDispo.split('filename=')[1].split(';')[0].replace(/"/g, '');
|
||||
}
|
||||
return response;
|
||||
});
|
||||
const blob = await response.blob();
|
||||
const file = new File([blob], _options.filename, { type: blob.type });
|
||||
|
||||
if (navigator.canShare && navigator.canShare({ files: [file] })) {
|
||||
await navigator.share({
|
||||
files: [file],
|
||||
title: _options.title ?? _options.filename,
|
||||
text: _options.text
|
||||
});
|
||||
} else {
|
||||
const link = document.createElement('a');
|
||||
link.href = URL.createObjectURL(blob);
|
||||
link.download = _options.filename;
|
||||
link.click();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Sharing gagal:', error);
|
||||
}
|
||||
};
|
||||
this.construct(url, options);
|
||||
};
|
||||
+80
-53
@@ -1,60 +1,87 @@
|
||||
/*******************************************************************
|
||||
|
||||
Module : /assets/js/simulator.js
|
||||
Desc. : JS Class Simulator Data dalam Code
|
||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||
Created Date : March 18th, 2021.
|
||||
Last Modified : December 26th, 2025.
|
||||
Last Modified : November 2nd, 2026.
|
||||
|
||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||
*******************************************************************
|
||||
*
|
||||
* Class Simulator
|
||||
*
|
||||
* Simulator Data untuk sinkron data dengan JSON
|
||||
*
|
||||
* @license MIT, https://www.3fonia.com
|
||||
* @copyright Copyright (c) 2008-2026, Siau Pheng <siaupheng@3fonia.com>
|
||||
*
|
||||
* @param {object} options
|
||||
* @param {string} options.url - Endpoint URL Print Page
|
||||
* @param {Array} [options.params] - Request payload
|
||||
*/
|
||||
|
||||
*******************************************************************/
|
||||
class Simulator {
|
||||
constructor(options = {}) {
|
||||
this.url = typeof options === 'string' ? options : options.url || '';
|
||||
this.params = options.params || [];
|
||||
}
|
||||
|
||||
var cSIMULATOR = function(url, options){
|
||||
var vars = {
|
||||
'url': '',
|
||||
'param': []
|
||||
};
|
||||
this.construct = function(url, options){
|
||||
$.extend(vars, options);
|
||||
vars.url = url;
|
||||
};
|
||||
this.set_url = function (url){
|
||||
vars.url = url;
|
||||
};
|
||||
this.add_param = function (par_id, par_val){
|
||||
var _getvalue = (par_val) ? par_id + "=" + escape(par_val) : par_id;
|
||||
vars.param.push(_getvalue);
|
||||
},
|
||||
this.doPreview = function(){
|
||||
if (!vars.url) console.warn(vars.param + ", cek url php!");
|
||||
vars.data = FoniaJS.RequestParam(vars.param);
|
||||
addParam(id, val) {
|
||||
this.params.push(val !== undefined ? `${id}=${encodeURIComponent(val)}` : id);
|
||||
return this;
|
||||
}
|
||||
|
||||
doPreview() {
|
||||
if (!this.url) {
|
||||
console.warn('Url Simulator dibutuhkan!');
|
||||
return;
|
||||
}
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: vars.url,
|
||||
data: (vars.data).join('&'),
|
||||
success: function(data){
|
||||
if (data.length == 0) {
|
||||
url: this.url,
|
||||
data: FoniaJS.RequestParam(this.params),
|
||||
dataType: 'json',
|
||||
error: typeof onFailure === 'function' ? onFailure : null,
|
||||
success: (data) => {
|
||||
if (!data || data.length === 0) {
|
||||
FoniaJS.showInfo('Tidak ada data !');
|
||||
return false;
|
||||
}
|
||||
var _divd = '';
|
||||
for (var no = 0; no < data.length; no++) {
|
||||
_divd += '<div class="sim-code px-2 py-2 mb-1 border border-info">' + data[no] + '</div>';
|
||||
}
|
||||
var _wtxt =
|
||||
'<div class="modal fade" id="winAPPSim" tabindex="-1" role="dialog" data-bs-keyboard="false" data-bs-show="false" data-bs-backdrop="static" aria-labelledby="winAPPSimLabel" aria-hidden="true">'+
|
||||
'<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable modal-fs" role="document">'+
|
||||
'<div class="modal-content">'+
|
||||
'<div class="modal-header"><h5 class="modal-title" id="winAPPSimLabel">Code Simulator</h5><div class="ms-auto"><button class="btn me-2" id="tombSalin" type="button" aria-label="Salin Semua"><i class="bi-copy me-2"></i><span aria-hidden="true">Salin Semua</span></button><button class="btn" type="button" data-bs-dismiss="modal" aria-label="Tutup"><i class="bi-x-lg me-2"></i><span aria-hidden="true">Tutup</span></button></div></div>'+
|
||||
'<div class="modal-body">'+_divd+'</div>'+
|
||||
'</div></div></div>';
|
||||
if ($('#winAPPSim')) $('#winAPPSim').modal('dispose').remove();
|
||||
$(_wtxt).on('shown.bs.modal', function(e){
|
||||
$('#winAPPSim').find('#tombSalin').click(function(){
|
||||
|
||||
const divContent = data
|
||||
.map(item => `<div class="sim-code px-2 py-2 mb-1 border border-info">${item}</div>`)
|
||||
.join('');
|
||||
|
||||
const modalHtml = `
|
||||
<div class="modal fade" id="winAPPSim" tabindex="-1" role="dialog" data-bs-keyboard="false" data-bs-show="false" data-bs-backdrop="static" aria-labelledby="winAPPSimLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable modal-fs" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="winAPPSimLabel">Code Simulator</h5>
|
||||
<div class="ms-auto">
|
||||
<button class="btn me-2" id="tombSalin" type="button" aria-label="Salin Semua">
|
||||
<i class="bi-copy me-2"></i><span aria-hidden="true">Salin Semua</span>
|
||||
</button>
|
||||
<button class="btn" type="button" data-bs-dismiss="modal" aria-label="Tutup">
|
||||
<i class="bi-x-lg me-2"></i><span aria-hidden="true">Tutup</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-body">${divContent}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
$('#winAPPSim').modal('dispose').remove();
|
||||
$(modalHtml)
|
||||
.on('shown.bs.modal', function () {
|
||||
const $modal = $(this);
|
||||
|
||||
// Copy all code blocks
|
||||
$modal.find('#tombSalin').on('click', () => {
|
||||
window.getSelection().removeAllRanges();
|
||||
$('.sim-code').each(function(i, ele) {
|
||||
var range = document.createRange();
|
||||
$('.sim-code').each((_, ele) => {
|
||||
const range = document.createRange();
|
||||
range.selectNode(ele);
|
||||
window.getSelection().addRange(range);
|
||||
});
|
||||
@@ -62,23 +89,23 @@ var cSIMULATOR = function(url, options){
|
||||
window.getSelection().removeAllRanges();
|
||||
FoniaJS.showInfo('Sukses salin semua Kode !');
|
||||
});
|
||||
$('#winAPPSim').find('.sim-code').click(function(){
|
||||
var range = document.createRange();
|
||||
|
||||
// Copy individual code block and hide it
|
||||
$modal.find('.sim-code').on('click', function () {
|
||||
const range = document.createRange();
|
||||
range.selectNode(this);
|
||||
window.getSelection().removeAllRanges();
|
||||
window.getSelection().addRange(range);
|
||||
document.execCommand('copy');
|
||||
window.getSelection().removeAllRanges();
|
||||
//$(this).addClass('bg-success');
|
||||
$(this).addClass('d-none');
|
||||
});
|
||||
}).on('hidden.bs.modal', function(e){
|
||||
})
|
||||
.on('hidden.bs.modal', function () {
|
||||
$(this).remove();
|
||||
}).modal('show');
|
||||
},
|
||||
error: (typeof vars.onFailure === "function") ? vars.onFailure : null,
|
||||
dataType: 'json'
|
||||
})
|
||||
.modal('show');
|
||||
}
|
||||
});
|
||||
};
|
||||
this.construct(url, options);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
+5
-6
@@ -18,13 +18,12 @@
|
||||
],
|
||||
"require": {
|
||||
"php": ">=8.3",
|
||||
"flightphp/core": "^3.18",
|
||||
"flightphp/core": "^3.19",
|
||||
"flightphp/session": "^0.3",
|
||||
"mpdf/mpdf": ">=8.0",
|
||||
"matthiasmullie/minify": ">=1.3",
|
||||
"endroid/qr-code": ">=4.4",
|
||||
"phpoffice/phpspreadsheet": ">=1.29",
|
||||
"shuchkin/simplexlsxgen": "^1.3"
|
||||
"mpdf/mpdf": "^8.3",
|
||||
"avadim/fast-excel-writer": "^6.19",
|
||||
"matthiasmullie/minify": "^1.3",
|
||||
"endroid/qr-code": "^6.1"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": ["src/"],
|
||||
|
||||
+27
-37
@@ -5,7 +5,7 @@
|
||||
Module : /App/Auth.php
|
||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||
Created Date : March 16th, 2008.
|
||||
Last Modified : September 10th, 2026.
|
||||
Last Modified : October 31st, 2026.
|
||||
|
||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
@@ -43,73 +43,51 @@ final class Auth {
|
||||
$this->app = $app;
|
||||
$this->db = $app->db();
|
||||
$this->session = $app->session();
|
||||
$this->id_reg = (int) $this->session->get('WEB_APP', ['REG_ID'=>0])['REG_ID'];
|
||||
}
|
||||
|
||||
public function set_id_reg(int|string $id = 0): void {
|
||||
if ((int) $id > 0) $this->id_reg = (int) $id;
|
||||
$this->id_reg = (int) $this->session->get('WEB_APP', ['PARENT_CODE'=>0])['PARENT_CODE'];
|
||||
}
|
||||
|
||||
public function user_check(string $user, string $pass): bool {
|
||||
$i_hasil = (int) $this->db->fetchField('SELECT COUNT(*) FROM app_operator WHERE Username=? AND Password=MD5(?) AND Aktif=1', [$user, $pass]);
|
||||
$i_hasil = (int) $this->db->fetchField('SELECT COUNT(*) FROM app_operator WHERE Username=? AND Password=MD5(?) AND Aktif=1', [$user, $pass]) ?? 0;
|
||||
return ($i_hasil > 0 ? true : false);
|
||||
}
|
||||
|
||||
public function user_data(string $user): array {
|
||||
public function user_data(string $user, bool $gen_module=true): array {
|
||||
$adata = [ 'Grup_MenuID' => 0 ];
|
||||
$xdata = $this->db->fetchRow('SELECT *,DECODE(Menu,?) Menu2 FROM app_operator WHERE Username=?', [$this->id_reg, $user]);
|
||||
if ($xdata) {
|
||||
$adata = $xdata->getData();
|
||||
$adata['Menu'] = $adata['Menu2'];
|
||||
unset($adata['Menu2'], $adata['Password']);
|
||||
}
|
||||
$xdata = $this->db->fetchRow('SELECT UserID,Grup_MenuID,Username,Nama,Posisi,Email,HP,Level,Last_IP,Last_Date FROM app_operator WHERE Username=?', [$user]);
|
||||
if ($xdata) $adata = $xdata->getData();
|
||||
|
||||
if (empty($this->session->get('APP_TOKEN'))) {
|
||||
$_token = $this->genToken(60);
|
||||
$this->session->set('APP_TOKEN', $_token);
|
||||
$this->db->insert('app_token', [ 'Token' => $_token, 'UserID' => $adata['UserID'], 'IP' => $this->app->request()->ip ]);
|
||||
}
|
||||
if ((int) $adata['Grup_MenuID'] > 0) $adata['Menu_Grup'] = $this->user_allmenu((int) $adata['Grup_MenuID']);
|
||||
$adata['UNIX'] = time();
|
||||
$adata['LOCALE'] = $this->session->get('WEB_APP', ['DEF_LOCALE'=>'id'])['DEF_LOCALE'];
|
||||
$adata['MENU_MODUL'] = [];
|
||||
return $adata;
|
||||
}
|
||||
|
||||
public function gen_module_menu(): void {
|
||||
$amodul = []; $aallow = []; $tallow = '';
|
||||
if ($this->session->get('WEB_APP', ['APP_MODULE'=>0])['APP_MODULE']) {
|
||||
$tallow = $this->db->fetchField('SELECT Modul_Akses FROM app_menu_grup WHERE Grup_MenuID=?', [$this->session->get('WEB_USER', ['Grup_MenuID'=>0])['Grup_MenuID']]);
|
||||
if ($gen_module === true && !empty($this->session->get('WEB_APP')['APP_MODULE'])) {
|
||||
$tallow = $this->db->fetchField('SELECT Modul_Akses FROM app_menu_grup WHERE Grup_MenuID=?', [$adata['Grup_MenuID']]) ?? '';
|
||||
$aallow = explode(",", $tallow);
|
||||
|
||||
if (count($aallow) > 0) {
|
||||
$stat = $this->db->runQuery('SELECT * FROM (SELECT APP_MODULE,APP_PATH FROM app_config) A LEFT JOIN (SELECT Modul,Urut,Judul,Icon FROM app_menu WHERE Level=0) B ON (A.APP_MODULE=B.Modul) ORDER BY B.Urut');
|
||||
while ($row = $stat->fetch()) {
|
||||
if (!in_array($row['Modul'], $aallow) || $row['Modul']==$this->session->get('WEB_APP')['APP_MODULE']) continue;
|
||||
$amodul[] = $row;
|
||||
if (!in_array($row['Modul'], $aallow) || $row['Modul'] === $this->session->get('WEB_APP')['APP_MODULE']) continue;
|
||||
$adata['MENU_MODUL'][] = $row;
|
||||
}
|
||||
}
|
||||
}
|
||||
$auser = $this->session->get('WEB_USER', []);
|
||||
$auser['MENU_MODUL'] = $amodul;
|
||||
$this->session->set('WEB_USER', $auser);
|
||||
}
|
||||
|
||||
public function user_allmenu(int $id_grup = 0): string {
|
||||
$allmenu = $this->db->fetchField('SELECT DECODE(Menu,?) MenuX FROM app_menu_grup WHERE Grup_MenuID=?', [$this->id_reg, $id_grup]);
|
||||
return $allmenu;
|
||||
return $adata;
|
||||
}
|
||||
|
||||
public function user_check_level(string $user, int $level = 9): bool {
|
||||
$i_hasil = (int)$this->db->fetchField('SELECT COUNT(*) FROM app_operator WHERE Username=? AND Level<=? AND Aktif=1', [$user, $level]);
|
||||
$i_hasil = (int) $this->db->fetchField('SELECT COUNT(*) FROM app_operator WHERE Username=? AND Level<=? AND Aktif=1', [$user, $level]);
|
||||
return ($i_hasil > 0 ? true : false);
|
||||
}
|
||||
|
||||
public function user_log(): void {
|
||||
$_user_id = $this->session->get('WEB_USER')['UserID'] ?? 0;
|
||||
if ($_user_id === 0) return;
|
||||
$a_hasil = $this->db->fetchRow('SELECT * FROM app_logs WHERE UserID=? ORDER BY Last_Date DESC LIMIT 1', [$_user_id])->getData();
|
||||
if (count($a_hasil) > 0) {
|
||||
$a_hasil = $this->db->fetchRow('SELECT * FROM app_logs WHERE UserID=? ORDER BY Last_Date DESC LIMIT 1', [$_user_id]);
|
||||
if ($a_hasil) {
|
||||
$this->db->update('app_operator', [ 'Last_IP' => $a_hasil['Last_IP'], 'Last_Date' => $a_hasil['Last_Date'] ], 'UserID=?', [$_user_id]);
|
||||
}
|
||||
$this->db->runQuery('INSERT IGNORE INTO app_logs SELECT UserID,Token,IP,DateStamp FROM app_token WHERE Token=?', [$this->session->get('APP_TOKEN')]);
|
||||
@@ -143,9 +121,21 @@ final class Auth {
|
||||
}
|
||||
|
||||
public function getUserByToken(string $token): string {
|
||||
$hasil = $this->db->fetchField('SELECT Username FROM app_operator WHERE UserID IN (SELECT UserID FROM app_token WHERE Token=?) LIMIT 1', [$token ?? $this->session->get('APP_TOKEN')]);
|
||||
$hasil = $this->db->fetchField('SELECT Username FROM app_operator WHERE UserID IN (SELECT UserID FROM app_token WHERE Token=?) LIMIT 1', [$token ?? $this->session->get('APP_TOKEN')]) ?? '';
|
||||
return $hasil;
|
||||
}
|
||||
|
||||
public function pos_login(int $id_cab, int $id_user, int $unix, string $ip): void {
|
||||
if (empty($id_cab) || empty($id_user) || empty($ip)) return;
|
||||
$this->db->delete('disp_login', 'CabID=? AND UserID=?', [$id_cab, $id_user]);
|
||||
$this->db->runQuery('INSERT INTO disp_login (IP, CabID, UserID, Unix, Date) VALUES (?, ?, ?, ?, NOW())', [ $ip, $id_cab, $id_user, $unix ?? 0 ]);
|
||||
}
|
||||
|
||||
public function pos_logout(int $id_cab, int $id_user, int $unix, string $ip): void {
|
||||
if (empty($id_cab) || empty($id_user) || empty($ip)) return;
|
||||
$this->db->delete('disp_login', 'CabID=? AND UserID=? AND IP=? AND Unix=?', [$id_cab, $id_user, $ip, $unix ?? 0 ]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
+5
-4
@@ -5,7 +5,7 @@
|
||||
Module : /DB/SQL.php
|
||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||
Created Date : February 2nd, 2007.
|
||||
Last Modified : August 21st, 2026.
|
||||
Last Modified : September 11th, 2026.
|
||||
|
||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
@@ -15,6 +15,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Webapp\DB;
|
||||
|
||||
use ErrorException;
|
||||
use \flight\Engine;
|
||||
use \flight\Session;
|
||||
use \flight\database\SimplePdo;
|
||||
@@ -68,7 +69,7 @@ final class SQL {
|
||||
public function add_param_date(string $param = "", string|null $value = null): void {
|
||||
$this->_afield[] = [
|
||||
'field' => $param,
|
||||
'value' => tgl_sql2str(is_null($value) ? Param::Get($param) : $value),
|
||||
'value' => tgl_sql2str(is_null($value) ? Param::Get($param, '00-00-0000') : $value),
|
||||
'numbe' => false,
|
||||
];
|
||||
}
|
||||
@@ -185,8 +186,8 @@ final class SQL {
|
||||
$this->db->runQuery($tsql, $__aexec);
|
||||
}
|
||||
|
||||
public function LastInsertID(): int {
|
||||
return $this->db->lastInsertId();
|
||||
public function LastInsertID(?string $name = null): mixed {
|
||||
return $this->db->lastInsertId($name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -2,7 +2,7 @@
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
Module : /Data/CSV.php
|
||||
Module : /Data/Csv.php
|
||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||
Created Date : April 2rd, 2011.
|
||||
Last Modified : August 21st, 2026.
|
||||
@@ -19,9 +19,9 @@ define( DELI_CSV, ";" );
|
||||
define( CRLF_CSV, "\r\n" );
|
||||
|
||||
/**
|
||||
* Class CSV
|
||||
* Class Csv
|
||||
*
|
||||
* Membuat file CSV.
|
||||
* Membuat file Csv.
|
||||
*
|
||||
* @license MIT, https://www.3fonia.com
|
||||
* @copyright Copyright (c) 2008-2026, Siau Pheng <siaupheng@3fonia.com>
|
||||
@@ -29,7 +29,7 @@ define( CRLF_CSV, "\r\n" );
|
||||
* @package Webapp\Data
|
||||
*/
|
||||
|
||||
final class CSV {
|
||||
final class Csv {
|
||||
private $__avalue = [];
|
||||
private $__atabel = [];
|
||||
|
||||
|
||||
+14
-11
@@ -5,7 +5,7 @@
|
||||
Module : /Data/Cache.php
|
||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||
Created Date : March 16th, 2008.
|
||||
Last Modified : September 3rd, 2026.
|
||||
Last Modified : October 12th, 2026.
|
||||
|
||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
@@ -43,6 +43,7 @@ final class Cache {
|
||||
private array $ini;
|
||||
private array $web_app;
|
||||
private array $web_user;
|
||||
private array $my_menu = [];
|
||||
private bool $is_login;
|
||||
private bool $IS_DEV = false;
|
||||
protected Engine $app;
|
||||
@@ -72,7 +73,7 @@ final class Cache {
|
||||
$this->ini = [
|
||||
'login' => [ 'css' => "", 'js' => "", 'app' => "", ],
|
||||
'index' => [ 'css' => "", 'js' => "", 'app' => "", ],
|
||||
'display' => [ 'css' => "", 'js' => "", 'app' => "", ],
|
||||
'monitor' => [ 'css' => "", 'js' => "", 'app' => "", ],
|
||||
];
|
||||
$this->save_ini();
|
||||
} else $this->ini = parse_ini_file($this->cachedir . "cache.ini", true);
|
||||
@@ -134,16 +135,15 @@ final class Cache {
|
||||
}
|
||||
if ($mode === 'index') {
|
||||
$_ajs = ['system/profile', 'system/chpasswd'];
|
||||
$amenu = array_values($this->web_user['Merge_Menu'] ?? []);
|
||||
$amenu = array_values($this->my_menu ?? []);
|
||||
$_ops = $this->db->fetchColumn("SELECT Link FROM app_menu WHERE Kode IN (?) AND Link<>'' ORDER BY Kode", [$amenu]);
|
||||
if ($_ops) $_ajs += $_ops;
|
||||
|
||||
if ($_ops) $_ajs = array_merge($_ajs, $_ops);
|
||||
$dirIterator = new \RecursiveDirectoryIterator($this->jsapp, \RecursiveDirectoryIterator::SKIP_DOTS);
|
||||
$dirFilter = new \RecursiveCallbackFilterIterator($dirIterator, fn($curr, $key, $iter) => !($curr->isDir() && in_array($curr->getFilename(), ['locale'])));
|
||||
$iterator = new \RecursiveIteratorIterator($dirFilter);
|
||||
foreach ($iterator as $_file) {
|
||||
if ($_file->isFile() &&
|
||||
!in_array($_file->getFilename(), ['login.js','index.js','display.js']) &&
|
||||
!in_array($_file->getFilename(), ['login.js','index.js','monitor.js']) &&
|
||||
array_any($_ajs, fn($js) => str_ends_with(str_replace(['_','\\'],['','/'],$_file->getRealPath()), $js.'.js'))) {
|
||||
$afile[] = $_file->getRealPath();
|
||||
$itime += $_file->getMTime();
|
||||
@@ -195,7 +195,10 @@ final class Cache {
|
||||
public function Cache(string $mode = "index"): array {
|
||||
if ($mode === 'index') {
|
||||
$this->ini['index']['app'] = (string) $this->db->fetchField("SELECT JS FROM app_operator_profile WHERE UserID=?", [$this->web_user['UserID']]) ?? '';
|
||||
$this->web_user['Merge_Menu'] = array_filter(array_unique(explode(",", $this->web_user['Menu_Grup'] .",". $this->web_user['Menu'])));
|
||||
$_menu = $this->db->fetchField("SELECT CONVERT(DECODE(Menu,?) USING UTF8MB4) Menu FROM app_operator WHERE UserID=?", [$this->web_app['PARENT_CODE'], $this->web_user['UserID']]) ?? '';
|
||||
$_gmenu = '';
|
||||
if ($this->web_user['Grup_MenuID'] > 0) $_gmenu = $this->db->fetchField('SELECT CONVERT(DECODE(Menu,?) USING UTF8MB4) Menu FROM app_menu_grup WHERE Grup_MenuID=?', [$this->web_app['PARENT_CODE'], $this->web_user['Grup_MenuID']]) ?? '';
|
||||
$this->my_menu = array_filter(array_unique(explode(",", $_gmenu .",". $_menu)));
|
||||
}
|
||||
|
||||
$is_modif = false;
|
||||
@@ -236,7 +239,7 @@ final class Cache {
|
||||
return $acache;
|
||||
}
|
||||
|
||||
public function Make_Cache(array $amode = ['login', 'index', 'display']): array {
|
||||
public function Make_Cache(array $amode = ['login', 'index', 'monitor']): array {
|
||||
$is_modif = false;
|
||||
foreach ($amode as $mode) {
|
||||
foreach (['css','js','app'] as $type) {
|
||||
@@ -253,11 +256,11 @@ final class Cache {
|
||||
if ($is_modif === true) $this->save_ini();
|
||||
|
||||
if (in_array('index', $amode)) {
|
||||
$agrup = $this->db->fetchAll('SELECT Grup_MenuID,DECODE(Menu,?) Menu FROM app_menu_grup', [$this->web_app['PARENT_CODE']]);
|
||||
$auser = $this->db->fetchAll("SELECT A.*,IFNULL(B.JS,'') JS FROM (SELECT UserID,Grup_MenuID,DECODE(Menu,?) Menu FROM app_operator) A LEFT JOIN app_operator_profile B ON (A.UserID=B.UserID)", [$this->web_app['PARENT_CODE']]);
|
||||
$agrup = $this->db->fetchAll('SELECT Grup_MenuID,CONVERT(DECODE(Menu,?) USING UTF8MB4) Menu FROM app_menu_grup', [$this->web_app['PARENT_CODE']]);
|
||||
$auser = $this->db->fetchAll("SELECT A.*,IFNULL(B.JS,'') JS FROM (SELECT UserID,Grup_MenuID,CONVERT(DECODE(Menu,?) USING UTF8MB4) Menu FROM app_operator) A LEFT JOIN app_operator_profile B ON (A.UserID=B.UserID)", [$this->web_app['PARENT_CODE']]);
|
||||
foreach ($auser as $user) {
|
||||
if (empty($user['JS']) || !file_exists($this->cachedir . $user['JS'])) {
|
||||
$this->web_user['Merge_Menu'] = array_filter(array_unique(explode(",", $user['Menu'] .",". ($agrup[$user['Grup_MenuID']]['Menu'] ?? ''))));
|
||||
$this->my_menu = array_filter(array_unique(explode(",", $user['Menu'] .",". ($agrup[$user['Grup_MenuID']]['Menu'] ?? ''))));
|
||||
|
||||
[ $afile, $lastmod ] = $this->gen_file('index', 'app');
|
||||
$cachefile = md5('index-app-' . (string) $user['UserID'] . $lastmod) . '.js';
|
||||
|
||||
+26
-26
@@ -2,7 +2,7 @@
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
Module : /Data/PDF.php
|
||||
Module : /Data/Pdf.php
|
||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||
Created Date : April 18th, 2015.
|
||||
Last Modified : August 21st, 2026.
|
||||
@@ -19,9 +19,9 @@ use \flight\Engine;
|
||||
use \Mpdf;
|
||||
|
||||
/**
|
||||
* Class PDF
|
||||
* Class Pdf
|
||||
*
|
||||
* Membuat file PDF.
|
||||
* Membuat file Pdf.
|
||||
*
|
||||
* @license MIT, https://www.3fonia.com
|
||||
* @copyright Copyright (c) 2008-2026, Siau Pheng <siaupheng@3fonia.com>
|
||||
@@ -29,11 +29,11 @@ use \Mpdf;
|
||||
* @package Webapp\Data
|
||||
*/
|
||||
|
||||
final class PDF {
|
||||
private $__avalue = [];
|
||||
private $__atabel = [];
|
||||
private $__theader = "";
|
||||
private $__tcolname = "";
|
||||
final class Pdf {
|
||||
private array $avalue = [];
|
||||
private array $atabel = [];
|
||||
private string $__theader = "";
|
||||
private string $__tcolname = "";
|
||||
protected array $webapp;
|
||||
protected array $webuser;
|
||||
|
||||
@@ -47,21 +47,21 @@ final class PDF {
|
||||
}
|
||||
|
||||
public function add_field(string $nama, string|int $lebar=0, string $align="L", string $func="", int $kol=1): void {
|
||||
$this->__atabel[] = [ $nama, (string)$lebar.'%', $func, $align, $kol ];
|
||||
$this->atabel[] = [ $nama, (string)$lebar.'%', $func, $align, $kol ];
|
||||
}
|
||||
|
||||
public function show_fields(): void {
|
||||
$tmp_out = "<thead><tr>";
|
||||
for ($i=0; $i<count($this->__atabel); $i++) {
|
||||
if ($this->__atabel[$i][4]==0) continue;
|
||||
$tmp_out .= $this->set_align($this->__atabel[$i][0], $this->__atabel[$i][1], "C", false, true, $this->__atabel[$i][4]);
|
||||
for ($i=0; $i<count($this->atabel); $i++) {
|
||||
if ($this->atabel[$i][4]==0) continue;
|
||||
$tmp_out .= $this->set_align($this->atabel[$i][0], $this->atabel[$i][1], "C", false, true, $this->atabel[$i][4]);
|
||||
}
|
||||
$tmp_out .= "</tr></thead>";
|
||||
$this->__tcolname = $tmp_out;
|
||||
}
|
||||
|
||||
public function clear(): void {
|
||||
$this->__avalue = [];
|
||||
$this->avalue = [];
|
||||
$this->__theader = "";
|
||||
$this->__tcolname = "";
|
||||
}
|
||||
@@ -78,18 +78,18 @@ final class PDF {
|
||||
$tmp_arr = func_get_args();
|
||||
if (is_array($tmp_arr[0])) $tmp_arr = $tmp_arr[0];
|
||||
$tmp_out = "<tr>";
|
||||
for ($i=0; $i<count($this->__atabel); $i++) {
|
||||
for ($i=0; $i<count($this->atabel); $i++) {
|
||||
$tmp_val = $tmp_arr[$i];
|
||||
if (is_array($this->__atabel[$i][2]) && trim($tmp_val)<>"") {
|
||||
$tmp_val = $this->__atabel[$i][2][$tmp_val];
|
||||
} else if (function_exists($this->__atabel[$i][2]) && trim($tmp_val)<>"") {
|
||||
$tmp_val = call_user_func($this->__atabel[$i][2], $tmp_val);
|
||||
if (is_array($this->atabel[$i][2]) && trim($tmp_val)<>"") {
|
||||
$tmp_val = $this->atabel[$i][2][$tmp_val];
|
||||
} else if (function_exists($this->atabel[$i][2]) && trim($tmp_val)<>"") {
|
||||
$tmp_val = call_user_func($this->atabel[$i][2], $tmp_val);
|
||||
}
|
||||
$tmp_val = $this->set_align($tmp_val, $this->__atabel[$i][1], $this->__atabel[$i][3]);
|
||||
$tmp_val = $this->set_align($tmp_val, $this->atabel[$i][1], $this->atabel[$i][3]);
|
||||
$tmp_out .= $tmp_val;
|
||||
}
|
||||
$tmp_out .= "</tr>";
|
||||
$this->__avalue[] = $tmp_out;
|
||||
$this->avalue[] = $tmp_out;
|
||||
}
|
||||
|
||||
public function add_span(): void {
|
||||
@@ -104,15 +104,15 @@ final class PDF {
|
||||
$tmp_out .= $tmp_val;
|
||||
}
|
||||
$tmp_out .= "</tr>";
|
||||
$this->__avalue[] = $tmp_out;
|
||||
$this->avalue[] = $tmp_out;
|
||||
}
|
||||
|
||||
public function add_empty(): void {
|
||||
$this->__avalue[] = $this->set_align(" ", 0, "L,NB", true);
|
||||
$this->avalue[] = $this->set_align(" ", 0, "L,NB", true);
|
||||
}
|
||||
|
||||
public function add_stamp(int $ctk_ke=1, bool $tampil_nama=false): void {
|
||||
$this->__avalue[] = $this->set_align($this->get_stamp($ctk_ke, $tampil_nama), 0, "L,NB", true);
|
||||
$this->avalue[] = $this->set_align($this->get_stamp($ctk_ke, $tampil_nama), 0, "L,NB", true);
|
||||
}
|
||||
|
||||
public function get_stamp(int $ctk_ke=1, bool $tampil_nama=false): string {
|
||||
@@ -163,8 +163,8 @@ final class PDF {
|
||||
$html .= '<tbody>';
|
||||
|
||||
// content out
|
||||
for ($i=0; $i<count($this->__avalue); $i++) {
|
||||
$html .= $this->__avalue[$i];
|
||||
for ($i=0; $i<count($this->avalue); $i++) {
|
||||
$html .= $this->avalue[$i];
|
||||
}
|
||||
$html .= '</tbody></table></div></div></body>';
|
||||
$mpdf = new mPDF('c', 'A4'.($orien==="L"?"-L":""), $fontz, '', 5, 5, 5, 10, 5, 5);
|
||||
@@ -177,7 +177,7 @@ final class PDF {
|
||||
$tstyle = $this->create_style($dir);
|
||||
if (strpos(strtolower($text), "<tr>")===false) {
|
||||
if ($line===true) {
|
||||
return '<tr><td colspan="'.count($this->__atabel).'" class="'.$tstyle.'">'.$text."</td></tr>";
|
||||
return '<tr><td colspan="'.count($this->atabel).'" class="'.$tstyle.'">'.$text."</td></tr>";
|
||||
} else {
|
||||
return (($head===true)?"<th":"<td").(($col>1)?' colspan="'.(string)$col.'"':"").' class="'.$tstyle.'" '.(($head===true)?'width="'.(string)$width.'"':"").">".$text.(($head===true)?"</th>":"</td>");
|
||||
}
|
||||
|
||||
@@ -1,164 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
Module : /Data/SimpleXLS.php
|
||||
Desc. : Class pembuatan file Simple XLS
|
||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||
Created Date : November 18th, 2012.
|
||||
Last Modified : September 30th, 2025.
|
||||
|
||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
*******************************************************************/
|
||||
|
||||
//todo: deprecated
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webapp\Data;
|
||||
|
||||
final class SimpleXLS {
|
||||
private $__wbook = null;
|
||||
private $__atabel = [];
|
||||
private $__astyle = [];
|
||||
private $__aheader = [];
|
||||
private $__amerge = [];
|
||||
private $__avalue = [];
|
||||
private $__tsheet = null;
|
||||
|
||||
public function __construct($oprop=[]) {
|
||||
$this->__wbook = new \Shuchkin\SimpleXLSXGen();
|
||||
$this->__wbook
|
||||
->setAuthor($_SESSION['WEB_APP']['APP_NAME']." v".$_SESSION['WEB_APP']['APP_VER'])
|
||||
->setLastModifiedBy($_SESSION['WEB_APP']['APP_NAME']." v".$_SESSION['WEB_APP']['APP_VER'])
|
||||
->setTitle($oprop['title'] ?? "")
|
||||
->setSubject($oprop['subject'] ?? $_SESSION['WEB_APP']['REG_NAME'])
|
||||
->setDescription($oprop['desc'] ?? "")
|
||||
->setCompany($_SESSION['WEB_APP']['REG_NAME'])
|
||||
->setDefaultFont("Calibri")
|
||||
->setDefaultFontSize(11);
|
||||
}
|
||||
|
||||
private function coord2cell($x, $y) {
|
||||
$c = '';
|
||||
for ($i = $x; $i >= 0; $i = ((int)($i / 26)) - 1) {
|
||||
$c = chr(ord('A') + $i % 26) . $c;
|
||||
}
|
||||
return $c . ($y + 1);
|
||||
}
|
||||
|
||||
private function create_style($tstyle="L") {
|
||||
$_astyle = explode(",", $tstyle);
|
||||
$_s_style = ""; $_e_style = "";
|
||||
foreach ($_astyle as $_key => $_val) {
|
||||
if ($_val == "L") {$_s_style .= '<left>'; $_e_style .= '</left>';}
|
||||
if ($_val == "R") {$_s_style .= '<right>'; $_e_style .= '</right>';}
|
||||
if ($_val == "C") {$_s_style .= '<center>'; $_e_style .= '</center>';}
|
||||
if ($_val == "W") {$_s_style .= '<wraptext>'; $_e_style .= '</wraptext>';}
|
||||
if ($_val == "B") {$_s_style .= '<b>'; $_e_style .= '</b>';}
|
||||
if ($_val == "I") {$_s_style .= '<i>'; $_e_style .= '</i>';}
|
||||
if ($_val == "S") {$_s_style .= "\0"; $_e_style .= '';}
|
||||
if ($_val == "N") {$_s_style .= '<style nf="#,##0.00">'; $_e_style .= '</style>';}
|
||||
if ($_val == "N0") {$_s_style .= '<style nf="#,##0">'; $_e_style .= '</style>';}
|
||||
}
|
||||
return ['s'=>$_s_style, 'e'=>$_e_style];
|
||||
}
|
||||
|
||||
public function clear_field() {
|
||||
$this->__atabel = [];
|
||||
}
|
||||
|
||||
public function add_header($tjudul="") {
|
||||
if ($tjudul=="") return;
|
||||
$this->__aheader[] = $tjudul;
|
||||
}
|
||||
|
||||
public function add_empty_row($nrow=1) {
|
||||
$_jkolom = count($this->__atabel);
|
||||
for ($i=0; $i<$nrow; $i++) {
|
||||
$this->__avalue[] = array_fill(0,$_jkolom,"");
|
||||
}
|
||||
}
|
||||
|
||||
public function add_field($tnama="", $nlebar=0, $talign="L", $ffunc="") {
|
||||
$this->__atabel[] = [$tnama, $nlebar, $ffunc];
|
||||
$this->__astyle[] = $this->create_style($talign);
|
||||
}
|
||||
|
||||
public function add_sheet($tnama_sheet="BARU", $bw_header=true) {
|
||||
$this->__tsheet = $tnama_sheet;
|
||||
$_jkolom = count($this->__atabel);
|
||||
foreach ($this->__aheader as $_key => $_val) {
|
||||
$a_out = ['<style font-size="12"><center>'.$_val."</center></style>"];
|
||||
$this->__amerge[] = $this->coord2cell(0, count($this->__avalue)) . ":" . $this->coord2cell($_jkolom-1, count($this->__avalue));
|
||||
$this->__avalue[] = $a_out;
|
||||
}
|
||||
if ($bw_header==true) $this->show_headers();
|
||||
}
|
||||
|
||||
public function add_value() {
|
||||
$tmp_arr = func_get_args();
|
||||
if (is_array($tmp_arr[0])) $tmp_arr = $tmp_arr[0];
|
||||
$a_out = [];
|
||||
for ($i=0; $i<count($this->__atabel); $i++) {
|
||||
$tmp_val = $tmp_arr[$i];
|
||||
if (is_array($this->__atabel[$i][2]) && trim($tmp_val)<>"") {
|
||||
$tmp_val = $this->__atabel[$i][2][$tmp_val];
|
||||
} else if (function_exists($this->__atabel[$i][2]) && trim($tmp_val)<>"") {
|
||||
$tmp_val = call_user_func($this->__atabel[$i][2], $tmp_val);
|
||||
}
|
||||
$a_out[] = $this->__astyle[$i]['s'] . $tmp_val . $this->__astyle[$i]['e'];
|
||||
}
|
||||
$this->__avalue[] = $a_out;
|
||||
}
|
||||
|
||||
public function add_span() {
|
||||
$tmp_arr = func_get_args();
|
||||
$a_out = [];
|
||||
for ($i=0; $i<count($tmp_arr); $i++) {
|
||||
$tmp_val = $tmp_arr[$i]; // CONTENT, COLSPAN=1, L, FUNC
|
||||
if (!isset($tmp_val[1])) $tmp_val[1] = 1;
|
||||
if (!isset($tmp_val[2])) $tmp_val[2] = "L";
|
||||
if (isset($tmp_val[3])) {
|
||||
if (function_exists($tmp_val[3]) && trim("".$tmp_val[0])<>"") {
|
||||
$tmp_val[0] = call_user_func($tmp_val[3], $tmp_val[0]);
|
||||
}
|
||||
}
|
||||
$tmp_style = $this->create_style($tmp_val[2]);
|
||||
if ($tmp_val[1]>1) $this->__amerge[] = $this->coord2cell(count($a_out), count($this->__avalue)) . ":" . $this->coord2cell((count($a_out)+$tmp_val[1])-1, count($this->__avalue));
|
||||
$a_out[] = $tmp_style['s'] . $tmp_val[0] . $tmp_style['e'];
|
||||
for ($k=1; $k<$tmp_val[1]; $k++) $a_out[] = null;
|
||||
}
|
||||
$this->__avalue[] = $a_out;
|
||||
}
|
||||
|
||||
public function add_stamp($ctk_ke=1, $bnama=false) {
|
||||
$this->__avalue[] = ["<i>".$_SESSION['WEB_APP']['APP_NAME']."v".$_SESSION['WEB_APP']['APP_VER'].date("\@ymd.His")."-".user_id(3).(($bnama==true)?"/".strtoupper(user_user()):"").(($ctk_ke>0)?"#".isi_nol($ctk_ke,2):"")."</i>"];
|
||||
}
|
||||
|
||||
public function get_stamp($ctk_ke=1, $bnama=false) {
|
||||
return $_SESSION['WEB_APP']['APP_NAME']."v".$_SESSION['WEB_APP']['APP_VER'].date("\@ymd.His")."-".user_id(3).(($bnama==true)?"/".strtoupper(user_user()):"").(($ctk_ke>0)?"#".isi_nol($ctk_ke,2):"");
|
||||
}
|
||||
|
||||
public function show_headers() {
|
||||
$a_out = [];
|
||||
for ($i=0; $i<count($this->__atabel); $i++) {
|
||||
$a_out[] = '<style bgcolor="#D0D0D0"><center>'.$this->__atabel[$i][0].'</center></style>';
|
||||
}
|
||||
$this->__avalue[] = $a_out;
|
||||
}
|
||||
|
||||
public function send($tnama_file="File_Excel") {
|
||||
$this->__wbook->addSheet($this->__avalue, $this->__tsheet);
|
||||
for ($i=0; $i<count($this->__atabel); $i++) {
|
||||
$this->__wbook->setColWidth(($i+1), $this->__atabel[$i][1]);
|
||||
}
|
||||
for ($i=0; $i<count($this->__amerge); $i++) {
|
||||
$this->__wbook->mergeCells($this->__amerge[$i]);
|
||||
}
|
||||
$this->__wbook->downloadAs($tnama_file);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,156 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
Module : /Data/XLS.php
|
||||
Desc. : Class pembuatan file XLS
|
||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||
Created Date : November 18th, 2012.
|
||||
Last Modified : October 26th, 2023.
|
||||
|
||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
*******************************************************************/
|
||||
|
||||
//todo: deprecated
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webapp\Data;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
|
||||
final class XLS {
|
||||
private $__tnamafile = null;
|
||||
private $__bline = true;
|
||||
private $__wbook = null;
|
||||
private $__wsheet = null;
|
||||
private $__baris = 0;
|
||||
private $__kolom = 0;
|
||||
private $__atabel = [];
|
||||
private $__astyle =[];
|
||||
private $__aheader = [];
|
||||
private $__fhead = null;
|
||||
private $__isheet = 0;
|
||||
|
||||
public function __construct($tnama_file="", $oprop=[]) {//oke
|
||||
\PhpOffice\PhpSpreadsheet\Cell\Cell::setValueBinder( new \PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder() );
|
||||
$this->__tnamafile = $tnama_file;
|
||||
$this->__wbook = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$this->__wbook->getProperties()
|
||||
->setCreator($_SESSION['WEB_APP']['APP_NAME']." v".$_SESSION['WEB_APP']['APP_VER'])
|
||||
->setLastModifiedBy($_SESSION['WEB_APP']['APP_NAME']." v".$_SESSION['WEB_APP']['APP_VER'])
|
||||
->setTitle($oprop['title'] ?? "")
|
||||
->setSubject($oprop['subject'] ?? "")
|
||||
->setDescription($oprop['desc'] ?? "")
|
||||
->setCompany($_SESSION['WEB_APP']['REG_NAME']);
|
||||
$this->__wsheet = $this->__wbook->getActiveSheet();
|
||||
$this->__fhead = [
|
||||
'font' => ['bold' => true],
|
||||
'alignment' => ['horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER, 'vertical' => \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER, 'wrapText' => true],
|
||||
'fill' => ['fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID, 'startColor' => ['rgb'=>"D0D0D0"]],
|
||||
'borders' => ['allBorders' => ['borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN, 'color' => ['rgb'=>"C0C0C0"]]]
|
||||
];
|
||||
}
|
||||
|
||||
public function create_style($tstyle="L") {//oke
|
||||
$_astyle = explode(",", $tstyle);
|
||||
$_tmp_style = [];
|
||||
$_bline = $this->__bline;
|
||||
foreach ($_astyle as $_key => $_val) {
|
||||
if ($_val == "L") $_tmp_style['alignment'] = ['horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_LEFT];
|
||||
if ($_val == "R") $_tmp_style['alignment'] = ['horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_RIGHT];
|
||||
if ($_val == "C") $_tmp_style['alignment'] = ['horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER];
|
||||
if ($_val == "W") $_tmp_style['alignment'] = ['wrapText' => true];
|
||||
if ($_val == "B") $_tmp_style['font'] = ['bold' => true];
|
||||
if ($_val == "S") $_tmp_style['numberFormat'] = ['formatCode' => \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_TEXT];
|
||||
if ($_val == "N") $_tmp_style['numberFormat'] = ['formatCode' => \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED2];
|
||||
if ($_val == "N0") $_tmp_style['numberFormat'] = ['formatCode' => \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED2];
|
||||
if ($_val == "NL") $_bline = false;
|
||||
if ($_val == "H") {
|
||||
$_bline = false;
|
||||
$_tmp_style = $this->__fhead;
|
||||
}
|
||||
}
|
||||
return $_tmp_style;
|
||||
}
|
||||
|
||||
public function clear_field() {//up : 2014-06-19
|
||||
$this->__atabel = [];
|
||||
$this->__astyle = [];
|
||||
}
|
||||
|
||||
public function set_pos($nbaris=0, $nkolom=0) {
|
||||
$this->__baris = $nbaris;
|
||||
$this->__kolom = $nkolom;
|
||||
}
|
||||
|
||||
public function set_garis_bawah($bgaris=true) {}//todo: deleted
|
||||
|
||||
public function add_header($tjudul="") {//oke
|
||||
if ($tjudul=="") return;
|
||||
$this->__aheader[] = $tjudul;
|
||||
}
|
||||
|
||||
public function add_empty_row($nrow=1) {//oke
|
||||
$this->__baris += $nrow;
|
||||
}
|
||||
|
||||
public function add_field($tnama="", $nlebar=0, $talign="L", $ffunc="") {//oke
|
||||
$this->__atabel[] = [$tnama, $nlebar, $ffunc];
|
||||
$this->__astyle[] = $this->create_style($talign);
|
||||
}
|
||||
|
||||
public function add_sheet($tnama_sheet="BARU", $bw_header=true) {//not yet !!!
|
||||
if ($this->__isheet > 0) {
|
||||
$this->__wbook->createSheet();
|
||||
$this->__wsheet = $this->__wbook->setActiveSheetIndex(++$this->__isheet);
|
||||
}
|
||||
$this->__wsheet->setTitle($tnama_sheet);
|
||||
for ($i=0; $i<count($this->__atabel); $i++) {
|
||||
//sampai disini dulu !!
|
||||
$this->__wsheet->getColumnDimension($this->__kolom+$i)->setWidth($this->__atabel[$i][1]);
|
||||
}
|
||||
$_fjudul = $this->__wbook->addFormat();
|
||||
$_fjudul->setBold();
|
||||
$_fjudul->setAlign("center");
|
||||
$_jkolom = count($this->__atabel);
|
||||
if ($_jkolom>0) $_jkolom--;
|
||||
foreach ($this->__aheader as $_key => $_val) {
|
||||
$this->__wsheet->write($this->__baris,$this->__kolom,$_val,$_fjudul);
|
||||
$this->__wsheet->setMerge($this->__baris,$this->__kolom,$this->__baris,$this->__kolom+$_jkolom);
|
||||
$this->__baris++;
|
||||
}
|
||||
$this->__baris++;
|
||||
if ($bw_header==true) $this->show_headers();
|
||||
}
|
||||
|
||||
public function add_value() {
|
||||
$tmp_arr = func_get_args();
|
||||
if (is_array($tmp_arr[0])) $tmp_arr = $tmp_arr[0];
|
||||
$tmp_out = "";
|
||||
for ($i=0; $i<count($this->__atabel); $i++) {
|
||||
$tmp_val = $tmp_arr[$i];
|
||||
if (is_array($this->__atabel[$i][1]) && trim($tmp_val)<>"") {
|
||||
$tmp_val = $this->__atabel[$i][1][$tmp_val];
|
||||
} else if (function_exists($this->__atabel[$i][1]) && trim($tmp_val)<>"") {
|
||||
$tmp_val = call_user_func($this->__atabel[$i][1], $tmp_val);
|
||||
}
|
||||
$tmp_out .= DELI_CSV . $tmp_val;
|
||||
}
|
||||
$tmp_out = substr($tmp_out, 1);
|
||||
$this->__avalue[] = $tmp_out;
|
||||
}
|
||||
|
||||
public function send($tnama_file="File_Excel") {//oke
|
||||
$this->__wsheet->setActiveSheetIndex(0);
|
||||
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
||||
header('Content-Disposition: attachment;filename="'.$tnama_file.'"');
|
||||
header('Cache-Control: max-age=0');
|
||||
$writer = IOFactory::createWriter($this->__wsheet, 'Xlsx');
|
||||
$writer->save('php://output');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
PHP Class : /Data/Xlsx.php
|
||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||
Created Date : November 18th, 2012.
|
||||
Last Modified : October 24th, 2026.
|
||||
|
||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
*******************************************************************/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webapp\Data;
|
||||
|
||||
use \flight\Engine;
|
||||
use \avadim\FastExcelWriter\Excel;
|
||||
use \avadim\FastExcelWriter\Options;
|
||||
use \avadim\FastExcelWriter\Sheet;
|
||||
use \avadim\FastExcelWriter\Style\Style;
|
||||
|
||||
/**
|
||||
* Class Xlsx
|
||||
*
|
||||
* Membuat file Excel XLSX
|
||||
*
|
||||
* @license MIT, https://www.3fonia.com
|
||||
* @copyright Copyright (c) 2008-2026, Siau Pheng <siaupheng@3fonia.com>
|
||||
*
|
||||
* @package Webapp\Data
|
||||
*/
|
||||
|
||||
final class Xlsx {
|
||||
|
||||
private Options $options;
|
||||
private Excel $excel;
|
||||
private Sheet $sheet;
|
||||
private array $webapp;
|
||||
private array $webuser;
|
||||
private array $meta = [];
|
||||
private array $titles = [];
|
||||
private array $subtitles = [];
|
||||
private array $atabel = [];
|
||||
private int $baris = 1;
|
||||
|
||||
/**
|
||||
* @param Engine $app
|
||||
*/
|
||||
|
||||
public function __construct(Engine $app) {
|
||||
$this->webapp = (array) $app->session()->get('WEB_APP', ['REG_NAME'=>'', 'APP_NAME'=>'', 'APP_VER'=>'']);
|
||||
$this->webuser = (array) $app->session()->get('WEB_USER', ['UserID'=>0, 'Username'=>'']);
|
||||
$this->meta = [
|
||||
'company' => $this->webapp['REG_NAME'],
|
||||
'subject' => $this->webapp['REG_NAME'],
|
||||
'author' => $this->webapp['APP_NAME'].' v'.$this->webapp['APP_VER'],
|
||||
];
|
||||
$this->options = Options::create()
|
||||
->DefaultFont([ Style::FONT_NAME => "Calibri", Style::FONT_SIZE => 11 ])
|
||||
->defaultDateFormat('DD-MM-YYYY')
|
||||
->defaultTimeFormat('HH:MM')
|
||||
->defaultDateTimeFormat('DD-MM-YYYY HH:MM');
|
||||
}
|
||||
|
||||
public function set_meta(array $meta): void {
|
||||
if (!empty($meta)) $this->meta = array_merge($this->meta, $meta);
|
||||
}
|
||||
|
||||
public function add_title(string|array $judul): void {
|
||||
if (empty($judul)) return;
|
||||
if (is_array($judul)) {
|
||||
$this->titles = $judul;
|
||||
} else array_push($this->titles, $judul);
|
||||
}
|
||||
|
||||
public function add_sub_title(string|array $judul): void {
|
||||
if (empty($judul)) return;
|
||||
if (is_array($judul)) {
|
||||
$this->subtitles = $judul;
|
||||
} else array_push($this->subtitles, $judul);
|
||||
}
|
||||
|
||||
public function add_field(string $nama="", int $lebar=0, string $style="@text", ?callable $func=null): void {
|
||||
$this->atabel[] = ['n' => $nama, 'l' => $lebar, 's' => $style, 'f' => $func];
|
||||
}
|
||||
|
||||
public function add_sheet(string $nama_sheet="BARU", bool $show_header=false): void {
|
||||
if (empty($this->excel)) {
|
||||
$this->excel = Excel::create([$nama_sheet], $this->options)
|
||||
->setCompany($this->meta['company'] ?? "")
|
||||
->setAuthor($this->meta['author'] ?? "")
|
||||
->setTitle($this->meta['title'] ?? "")
|
||||
->setDescription($this->meta['desc'] ?? "")
|
||||
->setSubject($this->meta['subject'] ?? "");
|
||||
$this->sheet = $this->excel->sheet(); //getSheet();
|
||||
} else {
|
||||
$this->sheet = $this->excel->makeSheet($nama_sheet);
|
||||
}
|
||||
if ($show_header === true) {
|
||||
$this->show_titles();
|
||||
$this->show_headers();
|
||||
}
|
||||
}
|
||||
|
||||
public function add_row(array $row): void {
|
||||
if (is_array($row) && !empty($row)) $this->sheet->writeRow($row);
|
||||
}
|
||||
|
||||
public function add_row_bold(array $row): void {
|
||||
if (is_array($row) && !empty($row)) $this->sheet->writeRow($row)->applyFontStyleBold();
|
||||
}
|
||||
|
||||
public function show_titles(): void {
|
||||
$this->baris = $this->sheet->getCurrentRow();
|
||||
$jum_kolom = count($this->atabel);
|
||||
foreach ($this->titles as $title) {
|
||||
$this->sheet->writeTo('A'.(string) $this->baris.':'.$this->excel->colLetter($jum_kolom).(string) $this->baris, $title)
|
||||
->applyFontStyleBold()
|
||||
->applyTextCenter();
|
||||
$this->baris++;
|
||||
}
|
||||
if (count($this->subtitles) > 0) {
|
||||
$this->baris++;
|
||||
foreach ($this->subtitles as $title) {
|
||||
$this->sheet->writeTo('A'.(string) $this->baris++, $title);
|
||||
}
|
||||
} else
|
||||
$this->sheet->writeTo('A'.(string) $this->baris, '');
|
||||
}
|
||||
|
||||
public function show_headers(bool $is_hide=false): void {
|
||||
if (!$is_hide) $this->sheet->writeHeader(array_column($this->atabel, 'n'))
|
||||
->applyFontStyleBold()
|
||||
->applyTextCenter()
|
||||
->applyBorder(Style::BORDER_STYLE_THIN);
|
||||
$this->sheet->setColFormats(array_column($this->atabel, 's'))
|
||||
->setColWidths(array_column($this->atabel, 'l'));
|
||||
}
|
||||
|
||||
public function add_stamp(int $ctk_ke=1, bool $tampil_nama=false): void {
|
||||
$this->sheet->nextRow();
|
||||
$this->sheet->writeCell($this->get_stamp($ctk_ke, $tampil_nama), ['font-size' => 8, 'font-style' => 'italic']);
|
||||
}
|
||||
|
||||
public function get_stamp(int $ctk_ke=1, bool $tampil_nama=false): string {
|
||||
return $this->webapp['APP_NAME']."v".$this->webapp['APP_VER'].date("\@ymd.His")."-".isi_nol($this->webuser['UserID'], 3).(($tampil_nama)?"/".strtoupper($this->webuser['Username']):"").(($ctk_ke>0)?"#".isi_nol($ctk_ke,2):"");
|
||||
}
|
||||
|
||||
public function download(string $nama_file="File_Excel.xlsx"): void {
|
||||
$this->excel->download($nama_file);
|
||||
}
|
||||
|
||||
}
|
||||
+39
-1
@@ -6,7 +6,7 @@
|
||||
Desc. : Fungsi Custom Lain Lain
|
||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||
Created Date : January 27th, 2008.
|
||||
Last Modified : August 21st, 2026.
|
||||
Last Modified : October 27th, 2026.
|
||||
|
||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
@@ -362,3 +362,41 @@ if (!function_exists('random_color')) {
|
||||
return "rgba(".$col_r.",".$col_g.",".$col_b.",".$trans.")";
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('gen_uuidv4')) {
|
||||
function gen_uuidv4(): string {
|
||||
$data = random_bytes(16);
|
||||
// Set version to 0100 (UUID v4)
|
||||
$data[6] = chr(ord($data[6]) & 0x0f | 0x40);
|
||||
// Set bits 6-7 to 10
|
||||
$data[8] = chr(ord($data[8]) & 0x3f | 0x80);
|
||||
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('gen_uuidv7')) {
|
||||
function gen_uuidv7(int $time=0): string {
|
||||
// Get timestamp in milliseconds (48 bits)
|
||||
if (empty($time)) $time = (int) floor(microtime(true) * 1000);
|
||||
// Generate 16 bytes of random data
|
||||
$randomBytes = random_bytes(16);
|
||||
// Pack the 48-bit timestamp into the first 6 bytes
|
||||
$timeHex = str_pad(dechex($time), 12, '0', STR_PAD_LEFT);
|
||||
$bytes = hex2bin($timeHex);
|
||||
// Append 10 bytes of randomness (we need 16 total bytes)
|
||||
$bytes .= substr($randomBytes, 0, 10);
|
||||
// Apply the version bits (Version 7 -> 0b0111) onto byte 6
|
||||
$bytes[6] = chr((ord($bytes[6]) & 0x0f) | 0x70);
|
||||
// Apply the variant bits (Variant 1 -> 0b10xx) onto byte 8
|
||||
$bytes[8] = chr((ord($bytes[8]) & 0x3f) | 0x80);
|
||||
// Unpack to hex string and format with hyphens
|
||||
$hex = bin2hex($bytes);
|
||||
return sprintf('%08s-%04s-%04s-%04s-%012s',
|
||||
substr($hex, 0, 8),
|
||||
substr($hex, 8, 4),
|
||||
substr($hex, 12, 4),
|
||||
substr($hex, 16, 4),
|
||||
substr($hex, 20, 12)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+91
-74
@@ -5,7 +5,7 @@
|
||||
Module : /Printer/PrintHTML.php
|
||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||
Created Date : June 15th, 2008.
|
||||
Last Modified : August 26th, 2026.
|
||||
Last Modified : October 24th, 2026.
|
||||
|
||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
@@ -29,10 +29,12 @@ use \flight\Engine;
|
||||
*/
|
||||
|
||||
final class PrintHTML {
|
||||
private $__avalue = [];
|
||||
private $__atabel = [];
|
||||
private $__css = "table";
|
||||
private $__tstamp = "";
|
||||
private array $avalue = [];
|
||||
private array $atabel = [];
|
||||
private string $css = "table";
|
||||
private string $stamp = "";
|
||||
private array $titles = [];
|
||||
private array $subtitles = [];
|
||||
protected array $webapp;
|
||||
protected array $webuser;
|
||||
|
||||
@@ -40,98 +42,116 @@ final class PrintHTML {
|
||||
* @param Engine $app
|
||||
*/
|
||||
public function __construct(Engine $app) {
|
||||
$this->webapp = $app->session()->get('WEB_APP', ['APP_NAME'=>'', 'APP_VER'=>'']);
|
||||
$this->webuser = $app->session()->get('WEB_USER', ['UserID'=>0, 'Username'=>'']);
|
||||
$this->webapp = (array) $app->session()->get('WEB_APP', ['APP_NAME'=>'', 'APP_VER'=>'']);
|
||||
$this->webuser = (array) $app->session()->get('WEB_USER', ['UserID'=>0, 'Username'=>'']);
|
||||
}
|
||||
|
||||
public function set_css(string $style): void {
|
||||
if (!empty($style)) $this->__css = $style;
|
||||
if (!empty($style)) $this->css = $style;
|
||||
}
|
||||
|
||||
public function add_field(string $nama, int $lebar=0, string $align="L", string $func="", int $kol=1): void {
|
||||
$this->__atabel[] = [ $nama, $lebar, $func, $align, $kol ];
|
||||
public function add_title(string|array $judul): void {
|
||||
if (empty($judul)) return;
|
||||
if (is_array($judul)) {
|
||||
$this->titles = $judul;
|
||||
} else array_push($this->titles, $judul);
|
||||
}
|
||||
|
||||
public function clear(): void {
|
||||
$this->__avalue = [];
|
||||
public function add_sub_title(string|array $judul): void {
|
||||
if (empty($judul)) return;
|
||||
if (is_array($judul)) {
|
||||
$this->subtitles = $judul;
|
||||
} else array_push($this->subtitles, $judul);
|
||||
}
|
||||
|
||||
public function add_value(): void {
|
||||
$tmp_arr = func_get_args();
|
||||
if (is_array($tmp_arr[0])) $tmp_arr = $tmp_arr[0];
|
||||
$tmp_out = "<tr>";
|
||||
for ($i=0; $i<count($this->__atabel); $i++) {
|
||||
$tmp_val = $tmp_arr[$i];
|
||||
if (is_array($this->__atabel[$i][2]) && trim("".$tmp_val)<>"") {
|
||||
$tmp_val = $this->__atabel[$i][2][$tmp_val];
|
||||
} else if (function_exists($this->__atabel[$i][2]) && trim("".$tmp_val)<>"") {
|
||||
$tmp_val = call_user_func($this->__atabel[$i][2], $tmp_val);
|
||||
}
|
||||
$tmp_val = $this->set_align((string) $tmp_val, $this->__atabel[$i][1], $this->__atabel[$i][3]);
|
||||
$tmp_out .= $tmp_val;
|
||||
}
|
||||
$tmp_out .= "</tr>";
|
||||
$this->__avalue[] = $tmp_out;
|
||||
public function add_field(string $nama, int $lebar=0, string $align="L", callable|array|null $func=null, int $kol=1): void {
|
||||
$this->atabel[] = [ 'n' => $nama, 'l' => $lebar, 'f' => $func, 'a' => $align, 'k' => $kol ];
|
||||
}
|
||||
|
||||
public function add_span(): void {
|
||||
$tmp_arr = func_get_args();
|
||||
$tmp_out = "<tr>";
|
||||
for ($i=0; $i<count($tmp_arr); $i++) {
|
||||
$tmp_val = $tmp_arr[$i];// CONTENT, COLSPAN=1, L, FUNC, EXTRA
|
||||
if (!isset($tmp_val[1])) $tmp_val[1] = 1;
|
||||
if (!isset($tmp_val[2])) $tmp_val[2] = "L";
|
||||
if (!isset($tmp_val[4])) $tmp_val[4] = "";
|
||||
if (isset($tmp_val[3])) {
|
||||
if (function_exists($tmp_val[3]) && trim("".$tmp_val[0])<>"") {
|
||||
$tmp_val[0] = call_user_func($tmp_val[3], $tmp_val[0]);
|
||||
public function add_row(array $row): void {
|
||||
if (!is_array($row) || empty($row)) return;
|
||||
$row_out = "<tr>";
|
||||
foreach ($this->atabel as $i => $tabel) {
|
||||
$col_val = $row[$i] ?? '';
|
||||
if (!empty($col_val)) {
|
||||
if (is_array($tabel['f'])) {
|
||||
$col_val = $tabel['f'][$col_val];
|
||||
} else if (is_callable($tabel['f'])) {
|
||||
$col_val = call_user_func($tabel['f'], $col_val);
|
||||
}
|
||||
}
|
||||
$tmp_val = $this->set_align($tmp_val[0], 0, $tmp_val[2], false, false, $tmp_val[1], $tmp_val[4]);
|
||||
$tmp_out .= $tmp_val;
|
||||
$row_out .= $this->set_align((string) $col_val, $tabel['l'], $tabel['a']);
|
||||
}
|
||||
$tmp_out .= "</tr>";
|
||||
$this->__avalue[] = $tmp_out;
|
||||
$row_out .= "</tr>";
|
||||
echo $row_out;
|
||||
}
|
||||
|
||||
public function add_stamp(int $ctk_ke=1, bool $cetak_nama=false): void {
|
||||
$this->__tstamp = $this->get_stamp($ctk_ke, $cetak_nama);
|
||||
public function add_span(array $span): void {
|
||||
if (!is_array($span) || empty($span)) return;
|
||||
$row_out = "<tr>";
|
||||
foreach ($span as $col) {
|
||||
// CONTENT, COLSPAN=1, L, FUNC, EXTRA
|
||||
if (!isset($col[1])) $col[1] = 1;
|
||||
if (!isset($col[2])) $col[2] = "L";
|
||||
if (!isset($col[4])) $col[4] = "";
|
||||
if (isset($col[3]) && is_callable($col[3])) {
|
||||
if (function_exists($col[3]) && !empty($col[0])) {
|
||||
$col[0] = call_user_func($col[3], $col[0]);
|
||||
}
|
||||
}
|
||||
$row_out .= $this->set_align($col[0], 0, $col[2], false, false, $col[1], $col[4]);
|
||||
}
|
||||
$row_out .= "</tr>";
|
||||
echo $row_out;
|
||||
}
|
||||
|
||||
public function get_stamp(int $ctk_ke=1, bool $cetak_nama=false): string {
|
||||
return $this->webapp['APP_NAME']."v".$this->webapp['APP_VER'].date("\@ymd.His")."-".isi_nol($this->webuser['UserID'], 3).(($cetak_nama)?"/".strtoupper($this->webuser['Username']):"").(($ctk_ke>0)?"#".isi_nol($ctk_ke,2):"");
|
||||
public function show_titles(): void {
|
||||
$_afs = [0=>"4", 1=>"5", 2=>"6"];
|
||||
foreach ($this->titles as $i => $title) {
|
||||
vprintf('<div class="fs-%s text-center">%s</div>', [($_afs[$i] ?? '6'), $title]);
|
||||
|
||||
}
|
||||
if (count($this->subtitles) > 0) {
|
||||
foreach ($this->subtitles as $title) {
|
||||
vprintf('<div>%s</div>', [$title]);
|
||||
}
|
||||
} else
|
||||
echo '<br />';
|
||||
}
|
||||
|
||||
public function show(int $jumlah_ctk=1) {
|
||||
$out = "<table class=\"".$this->__css."\"><thead>";
|
||||
|
||||
// header out
|
||||
$tmp_out = "<tr>";
|
||||
for ($i=0; $i<count($this->__atabel); $i++) {
|
||||
if ($this->__atabel[$i][4]==0) continue;
|
||||
$tmp_out .= $this->set_align($this->__atabel[$i][0], $this->__atabel[$i][1], "C", false, true, $this->__atabel[$i][4]);
|
||||
public function show_headers(bool $is_hide=false): void {
|
||||
vprintf('<table class="%s"><thead>', [$this->css]);
|
||||
// 0-n, 1=l, 2-f, 3-a, 4-k
|
||||
$head_out = "<tr>";
|
||||
foreach ($this->atabel as $tabel) {
|
||||
if ($tabel['k'] === 0) continue;
|
||||
$head_out .= $this->set_align($tabel['n'], $tabel['l'], "C", false, true, $tabel['k'], ($is_hide?'d-none':''));
|
||||
}
|
||||
$tmp_out .= "</tr>";
|
||||
$out .= "</thead>".$tmp_out."<tbody>";
|
||||
|
||||
// content out
|
||||
for ($i=0; $i<count($this->__avalue); $i++) {
|
||||
$tmp_str = $this->__avalue[$i];
|
||||
if (strpos($tmp_str, "_LINE")>0) $tmp_str = "<hr />";
|
||||
$out .= $tmp_str;
|
||||
}
|
||||
$out .= "</tbody></table>";
|
||||
$out .= $this->__tstamp;
|
||||
|
||||
for ($i=1; $i<=$jumlah_ctk; $i++) echo $out;
|
||||
$head_out .= "</tr>";
|
||||
echo $head_out."</thead><tbody>";
|
||||
// start content row
|
||||
}
|
||||
|
||||
public function set_align(string $text, int $width=0, string $dir="L", bool $line=false, bool $head=false, int $col=1, string $extra=""): string {
|
||||
public function add_stamp(int $ctk_ke=1, bool $tampil_nama=false): void {
|
||||
$this->stamp = $this->get_stamp($ctk_ke, $tampil_nama);
|
||||
}
|
||||
|
||||
public function get_stamp(int $ctk_ke=1, bool $tampil_nama=false): string {
|
||||
return $this->webapp['APP_NAME']."v".$this->webapp['APP_VER'].date("\@ymd.His")."-".isi_nol($this->webuser['UserID'], 3).(($tampil_nama)?"/".strtoupper($this->webuser['Username']):"").(($ctk_ke>0)?"#".isi_nol($ctk_ke,2):"");
|
||||
}
|
||||
|
||||
public function show() {
|
||||
// end content row
|
||||
echo "</tbody></table>";
|
||||
if (!empty($this->stamp)) vprintf('<span class="small fst-italic">%s</span>', [$this->stamp]);
|
||||
}
|
||||
|
||||
public function set_align(mixed $text, int $width=0, string $dir="L", bool $line=false, bool $head=false, int $col=1, string $extra=""): string {
|
||||
$tstyle = $this->create_style($dir);
|
||||
if ($line===true) {
|
||||
return "<tr><td colspan=\"".count($this->__atabel)."\" class=\"".$tstyle." ".$extra."\">".$text."</td></tr>";
|
||||
return "<tr><td colspan=\"".count($this->atabel)."\" class=\"".$tstyle." ".$extra."\">".$text."</td></tr>";
|
||||
} else {
|
||||
return (($head===true)?"<th":"<td").(($col>1)?" colspan=\"".(string)$col."\"":"")." class=\"".$tstyle." ".$extra."\" ".(($head===true)?"width=\"".(string)$width."\"":"").">".$text.(($head===true)?"</th>":"</td>");
|
||||
return (($head===true)?"<th":"<td").(($col>1)?" colspan=\"".(string) $col."\"":"")." class=\"".$tstyle." ".$extra."\" ".(($head===true)?"width=\"".(string) $width."\"":"").">".$text.(($head===true)?"</th>":"</td>");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,9 +166,6 @@ final class PrintHTML {
|
||||
return implode(' ', $ahasil);
|
||||
}
|
||||
|
||||
//todo: deprecated
|
||||
public function show_fields() {}
|
||||
public function add_pagebreak() {}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
+28
-45
@@ -5,7 +5,7 @@
|
||||
Module : /Printer/PrintPOS.php
|
||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||
Created Date : June 15th, 2008.
|
||||
Last Modified : August 21st, 2026.
|
||||
Last Modified : October 3rd, 2026.
|
||||
|
||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
@@ -29,12 +29,11 @@ use \flight\Engine;
|
||||
*/
|
||||
|
||||
class PrintPOS {
|
||||
private $_header = [];
|
||||
private $_avalue = [];
|
||||
private $_astyle = [];
|
||||
private $_ncont = 0;
|
||||
private $_maxchr = 40;
|
||||
private $_config = [
|
||||
private int $sheet = 0;
|
||||
private int $maxchr = 40;
|
||||
private array $header = [];
|
||||
private array $acontent = [];
|
||||
private array $config = [
|
||||
'fontsize' => 1,
|
||||
'opendraw' => false,
|
||||
'cutpaper' => false,
|
||||
@@ -54,52 +53,52 @@ class PrintPOS {
|
||||
}
|
||||
|
||||
public function set_opendrawer(): void {
|
||||
$this->_config['opendraw'] = true;
|
||||
$this->config['opendraw'] = true;
|
||||
}
|
||||
|
||||
public function set_cutpaper(): void {
|
||||
$this->_config['cutpaper'] = true;
|
||||
$this->config['cutpaper'] = true;
|
||||
}
|
||||
|
||||
public function set_maxchr(int $max = 0): void {
|
||||
if ($max > 0) $this->_maxchr = $max;
|
||||
if ($max > 0) $this->maxchr = $max;
|
||||
}
|
||||
|
||||
public function set_fontsize(int $size = 1): void {
|
||||
if ($size > 0) $this->_config['fontsize'] = $size;
|
||||
if ($size > 0) $this->config['fontsize'] = $size;
|
||||
}
|
||||
|
||||
public function set_header_logo(string $logo_file = ""): void {
|
||||
if (!empty($logo_file) && file_exists(PROJECT_ROOT."assets/images/".$logo_file)) {
|
||||
$this->_config['logo'] = PROJECT_BASE."assets/images/".$logo_file;
|
||||
if (!empty($logo_file) && file_exists(PROJECT_ROOT."public/assets/images/".$logo_file)) {
|
||||
//$this->config['logo'] = PROJECT_BASE."assets/images/".$logo_file;
|
||||
$this->config['logo'] = base64_encode(file_get_contents(PROJECT_ROOT."public/assets/images/".$logo_file));
|
||||
}
|
||||
}
|
||||
|
||||
public function add_header(): void {
|
||||
$extra = func_get_args();
|
||||
if (count($extra) > 0) {
|
||||
foreach ($extra as $_val) {
|
||||
$this->_header[] = $_val;
|
||||
}
|
||||
}
|
||||
if (count($extra) > 0) $this->header = $extra;
|
||||
}
|
||||
|
||||
public function add_sheet(): void {
|
||||
$this->_ncont++;
|
||||
$this->sheet++;
|
||||
}
|
||||
|
||||
public function add(): void {
|
||||
$val_arr = func_get_args(); $ttext = ""; $tstyle = "L";
|
||||
if (is_array($val_arr[0])) {
|
||||
foreach($val_arr as $aval) {
|
||||
$ttext .= $this->set_align((isset($aval[0])?$aval[0]:""), (isset($aval[1])?$aval[1]:0), (isset($aval[2])?$aval[2]:$tstyle));
|
||||
foreach ($val_arr as $aval) {
|
||||
$ttext .= $this->set_align(($aval[0] ?? ""), ($aval[1] ?? 0), ($aval[2] ?? $tstyle));
|
||||
}
|
||||
} else {
|
||||
$ttext = (isset($val_arr[0])) ? $val_arr[0] : "";
|
||||
$tstyle = (isset($val_arr[1])) ? $val_arr[1] : $tstyle;
|
||||
$ttext = $val_arr[0] ?? "";
|
||||
$tstyle = $val_arr[1] ?? $tstyle;
|
||||
}
|
||||
$this->_avalue[$this->_ncont][] = $ttext;
|
||||
$this->_astyle[$this->_ncont][] = $tstyle;
|
||||
if (str_contains($ttext, "_LINE")) {
|
||||
$tmp_arr = explode(" ", $ttext);
|
||||
$ttext = str_pad($tmp_arr[1], $this->maxchr, $tmp_arr[1]);
|
||||
}
|
||||
$this->acontent[$this->sheet][] = ($tstyle === "X") ? $ttext : $this->set_align($ttext, $this->maxchr, $tstyle);
|
||||
}
|
||||
|
||||
public function addl(string $text = ""): void {
|
||||
@@ -127,25 +126,11 @@ class PrintPOS {
|
||||
}
|
||||
|
||||
public function show(int $jumlah_ctk=1): void {
|
||||
$acontent = [];
|
||||
$nmax = $this->_maxchr;
|
||||
|
||||
for ($s=0; $s<count($this->_avalue); $s++) {
|
||||
for ($i=0; $i<count($this->_avalue[$s]); $i++) {
|
||||
$tmp_str = $this->_avalue[$s][$i];
|
||||
if (strpos($tmp_str, "_LINE")>0) {
|
||||
$tmp_arr = explode(" ", $tmp_str);
|
||||
$tmp_str = str_pad($tmp_arr[1], $nmax, $tmp_arr[1]);
|
||||
}
|
||||
$acontent[$s][] = ($this->_astyle[$s][$i]=="X") ? $tmp_str : $this->set_align($tmp_str, $nmax, $this->_astyle[$s][$i]);
|
||||
}
|
||||
}
|
||||
|
||||
$this->_config['times'] = $jumlah_ctk;
|
||||
$this->config['times'] = $jumlah_ctk;
|
||||
$aout = ['type' => "escp"];
|
||||
$aout['config'] = $this->_config;
|
||||
$aout['header'] = $this->_header;
|
||||
$aout['content'] = $acontent;
|
||||
$aout['config'] = $this->config;
|
||||
$aout['header'] = $this->header;
|
||||
$aout['content'] = $this->acontent;
|
||||
$this->app->json($aout);
|
||||
}
|
||||
|
||||
@@ -156,8 +141,6 @@ class PrintPOS {
|
||||
return str_pad($text, $len, " ", $apad[$dir]);
|
||||
}
|
||||
|
||||
//todo: deprecated
|
||||
public function set_printnv_logo() {}//delete
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
+24
-23
@@ -5,7 +5,7 @@
|
||||
Module : /Web/Menu.php
|
||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||
Created Date : January 16th, 2008.
|
||||
Last Modified : August 22nd, 2026.
|
||||
Last Modified : October 30th, 2026.
|
||||
|
||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
@@ -31,8 +31,9 @@ use \flight\database\SimplePdo;
|
||||
*/
|
||||
|
||||
final class Menu {
|
||||
private array $webapp;
|
||||
private array $webuser;
|
||||
private array $web_app;
|
||||
private array $web_user;
|
||||
private array $my_menu;
|
||||
protected Engine $app;
|
||||
protected SimplePdo $db;
|
||||
protected Session $session;
|
||||
@@ -44,27 +45,28 @@ final class Menu {
|
||||
$this->app = $app;
|
||||
$this->db = $app->db();
|
||||
$this->session = $app->session();
|
||||
$this->webapp = $this->session->get('WEB_APP', ['APP_MODULE'=>'', 'PARENT_SITE'=>'', 'PARENT_SUB'=>false]);
|
||||
$this->webuser = $this->session->get('WEB_USER', ['Menu'=>'', 'Menu_Grup'=>'', 'MENU_MODUL'=>[]]);
|
||||
$this->web_app = $this->session->get('WEB_APP', ['APP_MODULE'=>'', 'PARENT_SITE'=>'', 'PARENT_SUB'=>false]);
|
||||
$this->web_user = $this->session->get('WEB_USER', ['Menu'=>'', 'Menu_Grup'=>'', 'MENU_MODUL'=>[]]);
|
||||
$_gmenu = '';
|
||||
$_umenu = $this->db->fetchField("SELECT CONVERT(DECODE(Menu,?) USING UTF8MB4) Menu FROM app_operator WHERE UserID=?", [$this->web_app['PARENT_CODE'], $this->web_user['UserID']]) ?? '';
|
||||
if ($this->web_user['Grup_MenuID'] > 0) $_gmenu = $this->db->fetchField('SELECT CONVERT(DECODE(Menu,?) USING UTF8MB4) Menu FROM app_menu_grup WHERE Grup_MenuID=?', [$this->web_app['PARENT_CODE'], $this->web_user['Grup_MenuID']]) ?? '';
|
||||
$this->my_menu = array_unique(array_filter(explode(",", $_gmenu.",".$_umenu)));
|
||||
}
|
||||
|
||||
public function Sidebar(): string {
|
||||
$a_modul = [];
|
||||
$is_modul = ($this->webapp['APP_MODULE'] !== '') ? true : false;
|
||||
if ($is_modul == true) {
|
||||
$a_modul[] = $this->webapp['APP_MODULE'];
|
||||
$is_modul = !empty($this->web_app['APP_MODULE']);
|
||||
if ($is_modul === true) {
|
||||
$a_modul[] = $this->web_app['APP_MODULE'];
|
||||
} else {
|
||||
$atmp = $this->db->fetchAll('SELECT * FROM app_menu WHERE Level=0 AND Aktif=1 AND Modul<>"IND" ORDER BY Urut');
|
||||
foreach ($atmp as $tmp) {
|
||||
$a_modul[] = $tmp['Modul'];
|
||||
}
|
||||
foreach ($atmp as $tmp) $a_modul[] = $tmp['Modul'];
|
||||
}
|
||||
|
||||
$my_menu = array_unique(array_filter(explode(",", $this->webuser['Menu_Grup'].",".$this->webuser['Menu'])));
|
||||
$tsql = 'SELECT * FROM app_menu WHERE Aktif=1 AND Modul IN (?) AND Kode IN (?)';
|
||||
if ($is_modul == true) $tsql .= ' AND Level>0';
|
||||
|
||||
$amodul = $this->db->fetchAll($tsql . ' ORDER BY Kode', [$a_modul, $my_menu]);
|
||||
$amodul = $this->db->fetchAll($tsql . ' ORDER BY Kode', [$a_modul, $this->my_menu]);
|
||||
$thasil = '';
|
||||
|
||||
$last_level = 0;
|
||||
@@ -88,10 +90,10 @@ final class Menu {
|
||||
|
||||
public function Header(): string {
|
||||
$a_modul = [];
|
||||
$is_modul = ($this->webapp['APP_MODULE'] !== '') ? true : false;
|
||||
$is_modul = !empty($this->web_app['APP_MODULE']);
|
||||
$mulai_level = 0;
|
||||
if ($is_modul == true) {
|
||||
$a_modul[] = $this->webapp['APP_MODULE'];
|
||||
if ($is_modul === true) {
|
||||
$a_modul[] = $this->web_app['APP_MODULE'];
|
||||
$mulai_level = 1;
|
||||
} else {
|
||||
$atmp = $this->db->fetchAll('SELECT * FROM app_menu WHERE Level=0 AND Aktif=1 AND Modul<>"IND" ORDER BY Urut');
|
||||
@@ -100,11 +102,10 @@ final class Menu {
|
||||
}
|
||||
}
|
||||
|
||||
$my_menu = array_unique(array_filter(explode(",", $this->webuser['Menu_Grup'].",".$this->webuser['Menu'])));
|
||||
$tsql = 'SELECT * FROM app_menu WHERE Aktif=1 AND Modul IN (?) AND Kode IN (?)';
|
||||
if ($is_modul == true) $tsql .= ' AND Level>0';
|
||||
|
||||
$amodul = $this->db->fetchAll($tsql . ' ORDER BY Kode', [$a_modul, $my_menu]);
|
||||
$amodul = $this->db->fetchAll($tsql . ' ORDER BY Kode', [$a_modul, $this->my_menu]);
|
||||
$thasil = '';
|
||||
|
||||
$last_level = 0;
|
||||
@@ -134,15 +135,15 @@ final class Menu {
|
||||
|
||||
public function Modul(): string {
|
||||
$t_modul = '';
|
||||
if (is_array($this->webuser['MENU_MODUL']) && count($this->webuser['MENU_MODUL'])>0) {
|
||||
if (is_array($this->web_user['MENU_MODUL']) && count($this->web_user['MENU_MODUL'])>0) {
|
||||
$t_modul = '<div class="dropdown-divider"></div>';
|
||||
if ($this->app->request()->getVar('SERVER_ADDR') === '127.0.0.1') {
|
||||
$href1 = '//127.0.0.1/';
|
||||
$href2 = "";
|
||||
} else {
|
||||
$_host = $this->app->request()->getVar('HTTP_ORIGIN') ?? $this->app->request()->getVar('HTTP_HOST') ?? $this->webapp['PARENT_SITE'];
|
||||
$_host = $_SERVER['HTTP_ORIGIN'] ?? $_SERVER['HTTP_HOST'] ?? $this->web_app['PARENT_SITE'];
|
||||
$_host = str_replace(['http://','https://'], "", $_host);
|
||||
if ($this->webapp['PARENT_SUB'] === true) {
|
||||
if ($this->web_app['PARENT_SUB'] === true) {
|
||||
$_subs = explode('.', $_host);
|
||||
if (count($_subs) > 2) array_shift($_subs);
|
||||
$href1 = "//";
|
||||
@@ -152,7 +153,7 @@ final class Menu {
|
||||
$href2 = "";
|
||||
}
|
||||
}
|
||||
foreach ($this->webuser['MENU_MODUL'] as $modul) {
|
||||
foreach ($this->web_user['MENU_MODUL'] as $modul) {
|
||||
$href = $href1 . $modul['APP_PATH'] . $href2 . '/' . $this->session->get('APP_TOKEN');
|
||||
$t_modul .= '<a class="dropdown-item slink" href="'.$href.'"><i class="'.$modul['Icon'].' me-2"></i> '.$modul['Judul'].'</a>';
|
||||
}
|
||||
@@ -173,7 +174,7 @@ final class Menu {
|
||||
$apage = $acus_page[$page];
|
||||
} else if ($page <> "") {
|
||||
$apage = $db->fetchRow('SELECT * FROM app_menu WHERE Kode=?', [$page]);
|
||||
$apage['Width'] = (int)$apage['Width'];
|
||||
$apage['Width'] = (int) $apage['Width'];
|
||||
}
|
||||
|
||||
$ajson['iswindow'] = ($apage['Width'] > 0) ? true : false;
|
||||
|
||||
+19
-18
@@ -5,7 +5,7 @@
|
||||
Module : /Web/Param.php
|
||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||
Created Date : November 14th, 2013.
|
||||
Last Modified : August 22nd, 2026.
|
||||
Last Modified : October 16th, 2026.
|
||||
|
||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
@@ -38,42 +38,43 @@ final class Param {
|
||||
private static function __data(): void {
|
||||
global $app;
|
||||
if (empty($app)) $app = \Flight::app();
|
||||
//$_asumber = array_merge($app->request()->query->getData(), $app->request()->data->getData());
|
||||
$_asumber = $app->request()->query->getData() + $app->request()->data->getData();
|
||||
foreach ($_asumber as $__key => $__val) {
|
||||
self::$__ahasil[$__key] = is_string($__val) ? self::safeSQL($__val) : $__val;
|
||||
if (in_array($__val, ['true','false'])) { $__val = ($__val === 'true'); }
|
||||
else if (is_string($__val)) $__val = urldecode(self::safeSQL($__val));
|
||||
self::$__ahasil[$__key] = $__val;
|
||||
}
|
||||
}
|
||||
|
||||
public static function safeSQL(string $str = ""): string {
|
||||
$_se = array("\\","\0","\n","\r","\x1a","'",'"');
|
||||
$_re = array("\\\\","\\0","\\n","\\r","\Z","\'",'\"');
|
||||
$_se = ["\\","\0","\n","\r","\x1a","'",'"'];
|
||||
$_re = ["\\\\","\\0","\\n","\\r","\Z","\'",'\"'];
|
||||
return str_replace($_se, $_re, $str);
|
||||
}
|
||||
|
||||
public static function Get(string $key = "", mixed $def = null): mixed {
|
||||
if (count(self::$__ahasil)==0) self::__data();
|
||||
if (isset(self::$__ahasil[$key]) && self::$__ahasil[$key]) return self::$__ahasil[$key];
|
||||
if (empty(self::$__ahasil)) self::__data();
|
||||
if (isset(self::$__ahasil[$key])) return self::$__ahasil[$key];
|
||||
return $def;
|
||||
}
|
||||
|
||||
public static function Get_Text(string $key, mixed $def = null): mixed {
|
||||
if (count(self::$__ahasil)==0) self::__data();
|
||||
$_str = (isset(self::$__ahasil[$key])) ? self::$__ahasil[$key] : $def;
|
||||
$_str = str_replace("\\r", "", $_str);
|
||||
$_str = str_replace("\\n", " ", $_str);
|
||||
$_str = str_replace("\\t", " ", $_str);
|
||||
return (trim($_str));
|
||||
public static function Int(string $key = "", int $def = 0): int {
|
||||
if (empty(self::$__ahasil)) self::__data();
|
||||
if (isset(self::$__ahasil[$key])) return (int) self::$__ahasil[$key];
|
||||
return $def;
|
||||
}
|
||||
|
||||
public static function Get_Array(): array {
|
||||
public static function Float(string $key = "", float $def = 0): float {
|
||||
if (empty(self::$__ahasil)) self::__data();
|
||||
if (isset(self::$__ahasil[$key])) return (float) self::$__ahasil[$key];
|
||||
return $def;
|
||||
}
|
||||
|
||||
public static function Get_All(): array {
|
||||
if (count(self::$__ahasil)==0) self::__data();
|
||||
return self::$__ahasil;
|
||||
}
|
||||
|
||||
public static function Get_ArrayCBOX() {//delete
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
+11
-1
@@ -5,7 +5,7 @@
|
||||
Module : /Web/Table.php
|
||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||
Created Date : January 16th, 2008.
|
||||
Last Modified : August 27th, 2026.
|
||||
Last Modified : September 16th, 2026.
|
||||
|
||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
@@ -208,6 +208,11 @@ final class Table {
|
||||
$tval = $row[$col['a']];
|
||||
if (is_array($col['f'])) {
|
||||
$tval = $col['f'][$tval];
|
||||
} else if (!is_null($col['f']) && str_contains($col['f'], '::')) {
|
||||
$tclass = explode("::", $col['f']);
|
||||
if (class_exists($tclass[0]) && method_exists($tclass[0], $tclass[1])) {
|
||||
$tval = call_user_func($col['f'], $tval);
|
||||
}
|
||||
} else if (!is_null($col['f']) && function_exists($col['f'])) {
|
||||
$tval = call_user_func($col['f'], $tval);
|
||||
} else if (is_string($tval)) {
|
||||
@@ -291,6 +296,11 @@ final class Table {
|
||||
$tval = $row[$col['a']];
|
||||
if (is_array($col['f'])) {
|
||||
$tval = $col['f'][$tval];
|
||||
} else if (!is_null($col['f']) && str_contains($col['f'], '::')) {
|
||||
$tclass = explode("::", $col['f']);
|
||||
if (class_exists($tclass[0]) && method_exists($tclass[0], $tclass[1])) {
|
||||
$tval = call_user_func($col['f'], $tval);
|
||||
}
|
||||
} else if (!is_null($col['f']) && function_exists($col['f'])) {
|
||||
$tval = call_user_func($col['f'], $tval);
|
||||
} else if (is_string($tval)) {
|
||||
|
||||
Reference in New Issue
Block a user