2 Commits
34 changed files with 543 additions and 484 deletions
+1 -1
View File
@@ -6,7 +6,7 @@
Created Date : December 20th, 2007. Created Date : December 20th, 2007.
Last Modified : February 7th, 2026. Last Modified : February 7th, 2026.
(c) 2009 - 2026, 3FONIA Software; WWW.3FONIA.COM. (c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/ *******************************************************************/
+1 -1
View File
@@ -6,7 +6,7 @@
Created Date : October 7th, 2008. Created Date : October 7th, 2008.
Last Modified : November 24th, 2020. Last Modified : November 24th, 2020.
(c) 2008 - 2020, 3FONIA Software; WWW.3FONIA.COM. (c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/ *******************************************************************/
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -1,12 +1,12 @@
/******************************************************************* /*******************************************************************
Module : /modules/js/export.js Module : /assets/js/export.js
Desc. : Fungsi-fungsi export data & laporan Desc. : Fungsi-fungsi export data & laporan
Created By : Siau Pheng ([email protected]). Created By : Siau Pheng ([email protected]).
Created Date : April 1st, 2011. Created Date : April 1st, 2011.
Last Modified : January 19th, 2026. Last Modified : January 19th, 2026.
(c) 2011 - 2026, 3FONIA Software; WWW.3FONIA.COM. (c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/ *******************************************************************/
+1 -1
View File
@@ -6,7 +6,7 @@
Created Date : June 19th, 2009. Created Date : June 19th, 2009.
Last Modified : February 10th, 2026. Last Modified : February 10th, 2026.
(c) 2009 - 2026, 3FONIA Software; WWW.3FONIA.COM. (c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/ *******************************************************************/
+1 -1
View File
@@ -6,7 +6,7 @@
Created Date : April 6th, 2015. Created Date : April 6th, 2015.
Last Modified : October 18th, 2020. Last Modified : October 18th, 2020.
(c) 2015 - 2020, 3FONIA Software; WWW.3FONIA.COM. (c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/ *******************************************************************/
+1 -1
View File
@@ -5,7 +5,7 @@
Created By : Siau Pheng ([email protected]). Created By : Siau Pheng ([email protected]).
Created Date : October 12th, 2025. Created Date : October 12th, 2025.
(c) 2025, 3FONIA Software; WWW.3FONIA.COM. (c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/ *******************************************************************/
+11 -11
View File
@@ -4,9 +4,9 @@
Desc. : JS Class Printer & Printer POS Desc. : JS Class Printer & Printer POS
Created By : Siau Pheng ([email protected]). Created By : Siau Pheng ([email protected]).
Created Date : May 27th, 2007. Created Date : May 27th, 2007.
Last Modified : December 26th, 2025. Last Modified : August 21st, 2026.
(c) 2007 - 2025, 3FONIA Software; WWW.3FONIA.COM. (c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/ *******************************************************************/
@@ -40,10 +40,10 @@ var cPRINTER = function(url, options){
type: 'POST', type: 'POST',
url: vars.url, url: vars.url,
data: (vars.data).join('&'), data: (vars.data).join('&'),
success: function(txt){ success: (txt) => {
var $printData = $('#dataPrint'); var $printData = $('#dataPrint');
if (!$printData.length) { if (!$printData.length) {
var $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); $printData.html(txt);
window.print(); window.print();
@@ -59,7 +59,7 @@ var cPRINTER = function(url, options){
type: 'POST', type: 'POST',
url: vars.url, url: vars.url,
data: (vars.data).join('&'), data: (vars.data).join('&'),
success: function(txt){ success: (txt) => {
if ('' == txt) { if ('' == txt) {
FoniaJS.showInfo('Tidak ada data untuk pembuatan laporan !'); FoniaJS.showInfo('Tidak ada data untuk pembuatan laporan !');
return false; return false;
@@ -72,17 +72,17 @@ var cPRINTER = function(url, options){
'<div class="modal-body print-body" id="divPrintP">'+txt+'</div>'+ '<div class="modal-body print-body" id="divPrintP">'+txt+'</div>'+
'</div></div></div>'; '</div></div></div>';
if ($('#winAPPPrint')) $('#winAPPPrint').modal('dispose').remove(); if ($('#winAPPPrint')) $('#winAPPPrint').modal('dispose').remove();
$(_wtxt).on('shown.bs.modal', function(e){ $(_wtxt).on('shown.bs.modal', (e) => {
$('#winAPPPrint').find('#tombCetak').click(function(){ $('#winAPPPrint').find('#tombCetak').click(() => {
var $printData = $('#dataPrint'); var $printData = $('#dataPrint');
if (!$printData.length) { if (!$printData.length) {
var $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()); $printData.html($('#divPrintP').html());
FoniaJS.closeWindow($('#winAPPPrint')); FoniaJS.closeWindow($('#winAPPPrint'));
window.print(); window.print();
}); });
}).on('hidden.bs.modal', function(e){ }).on('hidden.bs.modal', (e) => {
$(this).remove(); $(this).remove();
}).modal('show'); }).modal('show');
}, },
@@ -165,14 +165,14 @@ var cPRINTERPOS = function(url, options) {
new Request.JSON({ new Request.JSON({
url: url, url: url,
sendParam: params, sendParam: params,
onSuccess: function(ajson) { onSuccess: (ajson) => {
if (typeof ajson === "object") { if (typeof ajson === "object") {
var hasil_cetak = (ajson.type == "escp") ? this.gen_escp(ajson) : this.gen_epl(ajson); var hasil_cetak = (ajson.type == "escp") ? this.gen_escp(ajson) : this.gen_epl(ajson);
qz.print(qzcfg, hasil_cetak); qz.print(qzcfg, hasil_cetak);
} else { } else {
FoniaJS.showInfo('Error dalam proses Cetak.'); FoniaJS.showInfo('Error dalam proses Cetak.');
} }
}.bind(this) }
}).send(); }).send();
}; };
this.gen_escp = function(adata) { this.gen_escp = function(adata) {
+37 -35
View File
@@ -1,19 +1,43 @@
/******************************************************************* /*******************************************************************
Module : /js/qz/qz-start.js Module : /assets/js/qz/qz-start.js
Desc. : JS Setup QZ Connection Desc. : Setup QZ Connection
Created By : Siau Pheng ([email protected]). Created By : Siau Pheng ([email protected]).
Created Date : May 27th, 2007. Created Date : May 27th, 2007.
Last Modified : February 8th, 2026. Last Modified : August 22nd, 2026.
(c) 2008 - 2026, 3FONIA Software; WWW.3FONIA.COM. (c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/ *******************************************************************/
function launchQZ() { const _divStatus = '#divQZStatus';
if (typeof qz !== 'undefined') {
qz.security.setSignatureAlgorithm("SHA512");
qz.security.setCertificatePromise((resolve, reject) => {
jQuery.ajax({url:'qz/cert', cache:false, dataType:'text'}).then(resolve, reject);
});
qz.security.setSignaturePromise((toSign) => {
return (resolve, reject) => {
jQuery.ajax('qz/sign/'+toSign).then(resolve, reject);
};
});
qz.websocket.setClosedCallbacks((evt) => {
_updateState('Inactive');
if (evt.reason) console.info("Connection closed: " + evt.reason);
});
qz.websocket.setErrorCallbacks((evt) => {
_updateState('Error');
if (evt.target != undefined) {
var err = (evt.target.readyState >= 2) ? "Connection to QZ Tray was closed" : "A connection error occurred, check log for details";
console.info(err)
}
});
}
function launchQZ() {
if (!qz.websocket.isActive()) { if (!qz.websocket.isActive()) {
window.location.assign("qz:launch"); window.location.assign("qz:launch");
//Retry 5 times, pausing 1 second between each attempt
startConnection({ retries: 5, delay: 1 }); startConnection({ retries: 5, delay: 1 });
} }
} }
@@ -22,10 +46,10 @@ function startConnection(config) {
config = config ? config : {}; config = config ? config : {};
if (!qz.websocket.isActive()) { if (!qz.websocket.isActive()) {
_updateState('Waiting'); _updateState('Waiting');
qz.websocket.connect(config).then(() => { qz.websocket.connect({...config, host: 'localhost'}).then(() => {
_updateState('Active'); _updateState('Active');
_findDefaultPrinter(); _findDefaultPrinter();
}); }).catch(() => _updateState('Error'));
} else { } else {
console.info('An active connection with QZ already exists.'); console.info('An active connection with QZ already exists.');
} }
@@ -35,7 +59,7 @@ function endConnection(){
if (qz.websocket.isActive()) { if (qz.websocket.isActive()) {
qz.websocket.disconnect().then(() => { qz.websocket.disconnect().then(() => {
_updateState('Inactive'); _updateState('Inactive');
}); }).catch(() => _updateState('Error'));
} else { } else {
console.info('No active connection with QZ exists.'); console.info('No active connection with QZ exists.');
} }
@@ -64,30 +88,8 @@ function _updateState(text){
} else { } else {
$(_divStatus).addClass('border-warning'); $(_divStatus).addClass('border-warning');
} }
} $('li#qzL, li#qzS, li#qzZ').removeClass('d-none');
if (text !== "Error") {
const _divStatus = '#divQZStatus'; $('li#qzL').addClass('d-none');
} else $('li#qzS, li#qzZ').addClass('d-none');
if (typeof qz !== 'undefined') {
qz.security.setSignatureAlgorithm("SHA512");
qz.security.setCertificatePromise((resolve, reject) => {
jQuery.ajax({url:'qz/cert', cache:false, dataType:'text'}).then(resolve, reject);
});
qz.security.setSignaturePromise((toSign) => {
return (resolve, reject) => {
jQuery.ajax('qz/sign/'+toSign).then(resolve, reject);
};
});
qz.websocket.setClosedCallbacks((evt) => {
_updateState('Inactive');
if (evt.reason) console.info("Connection closed: " + evt.reason);
});
qz.websocket.setErrorCallbacks((evt) => {
_updateState('Error');
if (evt.target != undefined) {
var err = (evt.target.readyState >= 2) ? "Connection to QZ Tray was closed" : "A connection error occurred, check log for details";
console.info(err)
}
});
startConnection();
} }
+1 -1
View File
@@ -6,7 +6,7 @@
Created Date : May 27th, 2007. Created Date : May 27th, 2007.
Last Modified : January 19th, 2026. Last Modified : January 19th, 2026.
(c) 2007 - 2026, 3FONIA Software; WWW.3FONIA.COM. (c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/ *******************************************************************/
+1 -1
View File
@@ -6,7 +6,7 @@
Created Date : March 18th, 2021. Created Date : March 18th, 2021.
Last Modified : December 26th, 2025. Last Modified : December 26th, 2025.
(c) 2021 - 2025, 3FONIA Software; WWW.3FONIA.COM. (c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/ *******************************************************************/
+1 -1
View File
@@ -17,7 +17,7 @@
} }
], ],
"require": { "require": {
"php" : "^8.3", "php" : ">=8.3",
"mpdf/mpdf": ">=8.0", "mpdf/mpdf": ">=8.0",
"matthiasmullie/minify": ">=1.3", "matthiasmullie/minify": ">=1.3",
"endroid/qr-code": ">=4.4", "endroid/qr-code": ">=4.4",
+18 -21
View File
@@ -6,31 +6,28 @@
Desc. : Class Check SQL / Repair Database Desc. : Class Check SQL / Repair Database
Created By : Siau Pheng ([email protected]). Created By : Siau Pheng ([email protected]).
Created Date : May 11th, 2011. Created Date : May 11th, 2011.
Last Modified : August 13th, 2026. Last Modified : August 21st, 2026.
(c) 2011 - 2026, 3FONIA Software; WWW.3FONIA.COM. (c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/ *******************************************************************/
//OK
declare(strict_types=1); declare(strict_types=1);
namespace siaupheng\webapp\DB; namespace siaupheng\webapp\DB;
use Exception; use \Exception;
use flight\Engine; use \flight\Engine;
use flight\Session; use \flight\database\SimplePdo;
use flight\database\SimplePdo;
final class CheckSQL { final class CheckSQL {
private Array $__atabel = []; private Array $__atabel = [];
protected Engine $app; protected Engine $app;
protected SimplePdo $db; protected SimplePdo $db;
public function __construct(?Engine $app = null){ public function __construct(Engine $app, SimplePdo $db) {
$this->app = (empty($app) === true) ? \Flight::app() : $app; $this->app = $app;
$this->db = $this->app->db(); $this->db = $db;
$nama_db = $this->db->fetchField('SELECT DATABASE()'); $nama_db = $this->db->fetchField('SELECT DATABASE()');
$arow = $this->db->fetchAll("SELECT TABLE_NAME,ENGINE,TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='".$nama_db."' AND TABLE_TYPE='BASE TABLE'"); $arow = $this->db->fetchAll("SELECT TABLE_NAME,ENGINE,TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='".$nama_db."' AND TABLE_TYPE='BASE TABLE'");
foreach ($arow as $row) { foreach ($arow as $row) {
@@ -38,14 +35,14 @@ final class CheckSQL {
} }
} }
public function ignore_table() { public function ignore_table(): void {
$tmp_arr = func_get_args(); $tmp_arr = func_get_args();
if (is_array($tmp_arr[0])) $tmp_arr = $tmp_arr[0]; if (is_array($tmp_arr[0])) $tmp_arr = $tmp_arr[0];
$farray = array_filter($this->__atabel, fn($child) => !in_array($child[0], $tmp_arr)); $farray = array_filter($this->__atabel, fn($child) => !in_array($child[0], $tmp_arr));
$this->__atabel = array_values($farray); $this->__atabel = array_values($farray);
} }
private function _check_db(array $atabel=[]) { private function _check_db(array $atabel=[]): string {
$pesan = '<span style="color:blue;">OK</span>'; $pesan = '<span style="color:blue;">OK</span>';
$row = $this->db->runQuery('CHECK TABLE '.$atabel[0].' QUICK')->fetch(SimplePdo::FETCH_ASSOC); $row = $this->db->runQuery('CHECK TABLE '.$atabel[0].' QUICK')->fetch(SimplePdo::FETCH_ASSOC);
if (($row['Msg_text'] ?? '') !== 'OK') { if (($row['Msg_text'] ?? '') !== 'OK') {
@@ -57,24 +54,24 @@ final class CheckSQL {
$pesan .= ' -> Auto Repair <span style="color:red;">' . $e->getMessage() . '</span>'; $pesan .= ' -> Auto Repair <span style="color:red;">' . $e->getMessage() . '</span>';
} }
} }
return $atabel[0] . $atabel[3] ." ... ". $pesan ."<br>"; return $atabel[0] . $atabel[3] ." ... ". $pesan;
} }
private function _opti_db(array $atabel=[]) { private function _opti_db(array $atabel=[]): string {
$pesan = '<span style="color:orange;">SKIP</span>'; $pesan = '<span style="color:orange;">SKIP</span>';
if ($atabel[1] === 'MyISAM') { if ($atabel[1] === 'MyISAM') {
$pesan = '<span style="color:blue;">OK</span>'; $pesan = '<span style="color:blue;">OK</span>';
$row = $this->db->runQuery('OPTIMIZE TABLE '.$atabel[0])->fetch(SimplePdo::FETCH_ASSOC); $row = $this->db->runQuery('OPTIMIZE TABLE '.$atabel[0])->fetch(SimplePdo::FETCH_ASSOC);
if (!in_array(strtoupper($row['Msg_text'] ?? ''), ['OK','TABLE IS ALREADY UP TO DATE'])) $pesan = '<span style="color:red;">ERROR</span>'; if (!in_array(strtoupper($row['Msg_text'] ?? ''), ['OK','TABLE IS ALREADY UP TO DATE'])) $pesan = '<span style="color:red;">ERROR</span>';
} }
return $atabel[0] . $atabel[2] ." ... ". $pesan ."<br>"; return $atabel[0] . $atabel[2] ." ... ". $pesan;
} }
public function count_db() { public function count_db(): int {
return count($this->__atabel); return count($this->__atabel);
} }
public function check_db() { public function check_db(): string {
$hasil = "=== CEK DATABASE ===<br>"; $hasil = "=== CEK DATABASE ===<br>";
for ($n=0; $n<count($this->__atabel); $n++) { for ($n=0; $n<count($this->__atabel); $n++) {
$hasil .= $this->_check_db($this->__atabel[$n]); $hasil .= $this->_check_db($this->__atabel[$n]);
@@ -82,11 +79,11 @@ final class CheckSQL {
return $hasil; return $hasil;
} }
public function check_db_step($n) { public function check_db_step(int $n): string {
return $this->_check_db($this->__atabel[$n]); return $this->_check_db($this->__atabel[$n]);
} }
public function optimize_db() { public function optimize_db(): string {
$hasil = "=== OPTIMALISASI DATABASE ===<br>"; $hasil = "=== OPTIMALISASI DATABASE ===<br>";
for ($n=0;$n<count($this->__atabel);$n++) { for ($n=0;$n<count($this->__atabel);$n++) {
$hasil .= $this->_opti_db($this->__atabel[$n]); $hasil .= $this->_opti_db($this->__atabel[$n]);
@@ -94,7 +91,7 @@ final class CheckSQL {
return $hasil; return $hasil;
} }
public function optimize_db_step($n) { public function optimize_db_step(int $n): string {
return $this->_opti_db($this->__atabel[$n]); return $this->_opti_db($this->__atabel[$n]);
} }
} }
+2 -1
View File
@@ -8,10 +8,11 @@
Created Date : May 11th, 2011. Created Date : May 11th, 2011.
Last Modified : May 8th, 2021. Last Modified : May 8th, 2021.
(c) 2011 - 2021, 3FONIA Software; WWW.3FONIA.COM. (c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/ *******************************************************************/
//todo: deprecated
declare(strict_types=1); declare(strict_types=1);
namespace siaupheng\webapp\DB; namespace siaupheng\webapp\DB;
+21 -16
View File
@@ -6,20 +6,19 @@
Desc. : Class Query database Desc. : Class Query database
Created By : Siau Pheng ([email protected]). Created By : Siau Pheng ([email protected]).
Created Date : February 2nd, 2007. Created Date : February 2nd, 2007.
Last Modified : August 14th, 2026. Last Modified : August 21st, 2026.
(c) 2008 - 2026, 3FONIA Software; WWW.3FONIA.COM. (c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/ *******************************************************************/
//OK
declare(strict_types=1); declare(strict_types=1);
namespace siaupheng\webapp\DB; namespace siaupheng\webapp\DB;
use flight\Engine; use \flight\Engine;
use flight\Session; use \flight\Session;
use flight\database\SimplePdo; use \flight\database\SimplePdo;
use siaupheng\webapp\Web\Param; use siaupheng\webapp\Web\Param;
final class SQL { final class SQL {
@@ -28,13 +27,16 @@ final class SQL {
private array $_awhere = []; private array $_awhere = [];
protected Engine $app; protected Engine $app;
protected SimplePdo $db; protected SimplePdo $db;
protected array webuser;
public function __construct(?Engine $app = null){ public function __construct(Engine $app, Ssssion $session, SimplePdo $db){
$this->app = (empty($app) === true) ? \Flight::app() : $app; $this->app = $app;
$this->db = $this->app->db(); $this->db = $db;
$this->webuser = $session->get('__WEB_USER', ['UserID'=>0, 'UNIX'=>0]);
} }
public function SafeSQL($ttext = "") {//delete //todo: deprecated
public function SafeSQL($ttext = "") {
return $ttext; return $ttext;
} }
@@ -43,17 +45,19 @@ final class SQL {
} }
public function add_param(string $param = "", string|int|null $value = null, bool $nomor = false): void { public function add_param(string $param = "", string|int|null $value = null, bool $nomor = false): void {
$req = Param::Get($param);
$this->_afield[] = [ $this->_afield[] = [
'field' => $param, 'field' => $param,
'value' => (is_null($value) && !empty(Param::Get($param))) ? Param::Get($param) : $value, 'value' => (is_null($value) && !empty($req)) ? $req : $value,
'numbe' => $nomor, 'numbe' => $nomor,
]; ];
} }
public function add_param_date(string $param = "", string|null $value = null): void { public function add_param_date(string $param = "", string|null $value = null): void {
$req = Param::Get($param);
$this->_afield[] = [ $this->_afield[] = [
'field' => $param, 'field' => $param,
'value' => tgl_sql2str((is_null($value) && !empty(Param::Get($param))) ? Param::Get($param) : $value), 'value' => tgl_sql2str((is_null($value) && !empty($req)) ? $req : $value),
'numbe' => false, 'numbe' => false,
]; ];
} }
@@ -69,7 +73,7 @@ final class SQL {
public function add_param_unix(): void { public function add_param_unix(): void {
$this->_afield[] = [ $this->_afield[] = [
'field' => 'Unix', 'field' => 'Unix',
'value' => user_unix(), 'value' => $this->webuser['UNIX'],
'numbe' => false, 'numbe' => false,
]; ];
} }
@@ -77,7 +81,7 @@ final class SQL {
public function add_param_userid(string $param = "UserID"): void { public function add_param_userid(string $param = "UserID"): void {
$this->_afield[] = [ $this->_afield[] = [
'field' => $param, 'field' => $param,
'value' => user_id(), 'value' => $this->webuser['UserID'],
'numbe' => false, 'numbe' => false,
]; ];
} }
@@ -85,7 +89,7 @@ final class SQL {
public function add_where_unix(): void { public function add_where_unix(): void {
$this->_awhere[] = [ $this->_awhere[] = [
'field' => 'Unix', 'field' => 'Unix',
'value' => user_id(), 'value' => $this->webuser['UNIX'],
'numbe' => false, 'numbe' => false,
]; ];
} }
@@ -99,9 +103,10 @@ final class SQL {
} }
public function add_where(string $field = "", string|int|null $value = null, bool $nomor = false): void { public function add_where(string $field = "", string|int|null $value = null, bool $nomor = false): void {
$req = Param::Get($param);
$this->_awhere[] = [ $this->_awhere[] = [
'field' => $field, 'field' => $field,
'value' => (is_null($value) && !empty(Param::Get($field))) ? Param::Get($field) : $value, 'value' => (is_null($value) && !empty($req)) ? $req : $value,
'numbe' => $nomor, 'numbe' => $nomor,
]; ];
} }
+6 -6
View File
@@ -6,9 +6,9 @@
Desc. : Class pembuatan file CSV Desc. : Class pembuatan file CSV
Created By : Siau Pheng ([email protected]). Created By : Siau Pheng ([email protected]).
Created Date : April 2rd, 2011. Created Date : April 2rd, 2011.
Last Modified : July 25th, 2026. Last Modified : August 21st, 2026.
(c) 2011 - 2026, 3FONIA Software; WWW.3FONIA.COM. (c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/ *******************************************************************/
@@ -23,11 +23,11 @@ final class CSV {
private $__avalue = []; private $__avalue = [];
private $__atabel = []; private $__atabel = [];
public function add_field($tnama="", $ffunc="") { public function add_field(string $nama, string $func=""): void {
$this->__atabel[] = [$tnama, $ffunc]; $this->__atabel[] = [ $nama, $func ];
} }
public function add_value() { public function add_value(): void {
$tmp_arr = func_get_args(); $tmp_arr = func_get_args();
if (is_array($tmp_arr[0])) $tmp_arr = $tmp_arr[0]; if (is_array($tmp_arr[0])) $tmp_arr = $tmp_arr[0];
$tmp_out = ""; $tmp_out = "";
@@ -44,7 +44,7 @@ final class CSV {
$this->__avalue[] = $tmp_out; $this->__avalue[] = $tmp_out;
} }
public function download($nama_file="export.csv") { public function download(string $nama_file="export.csv"): void {
$out = ""; $tmp_out = ""; $out = ""; $tmp_out = "";
// add header // add header
for ($i=0; $i<count($this->__atabel); $i++) { for ($i=0; $i<count($this->__atabel); $i++) {
+32 -26
View File
@@ -6,21 +6,21 @@
Desc. : Class cache css dan js aplikasi Desc. : Class cache css dan js aplikasi
Created By : Siau Pheng ([email protected]). Created By : Siau Pheng ([email protected]).
Created Date : March 16th, 2008. Created Date : March 16th, 2008.
Last Modified : August 19th, 2026. Last Modified : August 21st, 2026.
(c) 2008 - 2026, 3FONIA Software; WWW.3FONIA.COM. (c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/ *******************************************************************/
//OK
declare(strict_types=1); declare(strict_types=1);
namespace siaupheng\webapp\Data; namespace siaupheng\webapp\Data;
use flight\Engine; use \flight\Engine;
use FilesystemIterator; use \flight\Session;
use MatthiasMullie\Minify; use \FilesystemIterator;
use SplFileInfo; use \MatthiasMullie\Minify;
use \SplFileInfo;
final class Cache { final class Cache {
private $__cachedir = ""; private $__cachedir = "";
@@ -31,15 +31,16 @@ final class Cache {
private $__rootdir = ""; private $__rootdir = "";
private $__ini = []; private $__ini = [];
protected Engine $app; protected Engine $app;
protected Session $session;
protected array $__asset = []; protected array $__asset = [];
public function __construct(?Engine $app = null, array $asset = []) { public function __construct(Engine $app, Session $session) {
$this->app = (empty($app) === true) ? Flight::app() : $app; $this->app = $app;
$this->__asset = $asset; $this->session = $session;
$rootdir = (defined('PROJECT_ROOT')) ? PROJECT_ROOT : $this->app->get('flight.root_dir'); $rootdir = (defined('PROJECT_ROOT')) ? PROJECT_ROOT : $this->app->get('app.project_root');
$this->__cachedir = $rootdir . '/public/chunks/'; $this->__cachedir = $rootdir . '/public/chunks/';
$this->__localedir = $rootdir . '/app/locale/'; $this->__localedir = $rootdir . '/app/Scripts/locale/';
$this->__jsapp = $rootdir . '/app/scripts/'; $this->__jsapp = $rootdir . '/app/Scripts/';
$this->__cssdir = __DIR__ . '/../../assets/css/'; $this->__cssdir = __DIR__ . '/../../assets/css/';
$this->__jsdir = __DIR__ . '/../../assets/js/'; $this->__jsdir = __DIR__ . '/../../assets/js/';
$this->__rootdir = $rootdir . '/'; $this->__rootdir = $rootdir . '/';
@@ -54,7 +55,11 @@ final class Cache {
} else $this->__ini = parse_ini_file($this->__cachedir . "cache.ini", true); } else $this->__ini = parse_ini_file($this->__cachedir . "cache.ini", true);
} }
private function gen_file($mode = "index", $type = "css") { public function set_asset(array $asset = []): void {
$this->__asset = $asset;
}
private function gen_file(string $mode = "index", string $type = "css"): array {
$itime = 0; $itime = 0;
$afile = []; $afile = [];
if ($type == "css") { if ($type == "css") {
@@ -65,8 +70,8 @@ final class Cache {
$afile[] = $_file->getRealPath(); $afile[] = $_file->getRealPath();
$itime += $_file->getMTime(); $itime += $_file->getMTime();
} }
if (is_dir($this->__rootdir . 'app/css/')) { if (is_dir($this->__rootdir . 'app/Styles/')) {
$iterator = new FilesystemIterator($this->__rootdir . 'app/css/', FilesystemIterator::SKIP_DOTS); $iterator = new FilesystemIterator($this->__rootdir . 'app/Styles/', FilesystemIterator::SKIP_DOTS);
foreach ($iterator as $_file) { foreach ($iterator as $_file) {
if ($_file->isFile()) { if ($_file->isFile()) {
$afile[] = $_file->getRealPath(); $afile[] = $_file->getRealPath();
@@ -83,7 +88,7 @@ final class Cache {
$itime += $_file->getMTime(); $itime += $_file->getMTime();
} }
// add locale file // add locale file
$ljs = ($this->app->session()->get('__WEB_USER')['LOCALE'] ?? $this->app->session()->get('__WEB_APP')['DEF_LOCALE']).'.js'; $ljs = ($this->session->get('__WEB_USER')['LOCALE'] ?? $this->session->get('__WEB_APP')['DEF_LOCALE']).'.js';
if (is_dir($this->__localedir)) { if (is_dir($this->__localedir)) {
$iterator = new \FilesystemIterator($this->__localedir, \FilesystemIterator::SKIP_DOTS); $iterator = new \FilesystemIterator($this->__localedir, \FilesystemIterator::SKIP_DOTS);
foreach ($iterator as $_file) { foreach ($iterator as $_file) {
@@ -97,7 +102,8 @@ final class Cache {
if ($mode === 'index') { if ($mode === 'index') {
if (is_dir($this->__jsapp)) { if (is_dir($this->__jsapp)) {
$dirIterator = new \RecursiveDirectoryIterator($this->__jsapp, \RecursiveDirectoryIterator::SKIP_DOTS); $dirIterator = new \RecursiveDirectoryIterator($this->__jsapp, \RecursiveDirectoryIterator::SKIP_DOTS);
$iterator = new \RecursiveIteratorIterator($dirIterator); $dirFilter = new \RecursiveCallbackFilterIterator($dirIterator, fn($curr, $key, $iter) => !($curr->isDir() && in_array($curr->getFilename(), ['locale'])));
$iterator = new \RecursiveIteratorIterator($dirFilter);
foreach ($iterator as $_file) { foreach ($iterator as $_file) {
if ($_file->isFile() && !in_array($_file->getFilename(), ['login.js','display.js'])) { if ($_file->isFile() && !in_array($_file->getFilename(), ['login.js','display.js'])) {
$afile[] = $_file->getRealPath(); $afile[] = $_file->getRealPath();
@@ -116,7 +122,7 @@ final class Cache {
return [ $afile, $itime ]; return [ $afile, $itime ];
} }
private function create_cache($type = "css", $afile = [], $cachefile = "") { private function create_cache(string $type = "css", array $afile = [], string $cachefile = ""): void {
$contents = ''; $smini = null; $contents = ''; $smini = null;
$bpublic = ($this->app->request()->ip === '127.0.0.1') ? false : true; $bpublic = ($this->app->request()->ip === '127.0.0.1') ? false : true;
if ($bpublic == true) { if ($bpublic == true) {
@@ -139,7 +145,7 @@ final class Cache {
file_put_contents($this->__cachedir . $cachefile, $contents); file_put_contents($this->__cachedir . $cachefile, $contents);
} }
private function save_ini() { private function save_ini(): void {
$content = ""; $content = "";
foreach ($this->__ini as $key => $elem) { foreach ($this->__ini as $key => $elem) {
$content .= ($content==""?"":"\n"). "[".$key."]\n"; $content .= ($content==""?"":"\n"). "[".$key."]\n";
@@ -151,7 +157,7 @@ final class Cache {
file_put_contents($this->__cachedir . "cache.ini", $content); file_put_contents($this->__cachedir . "cache.ini", $content);
} }
public function Cache($mode = "index") { public function Cache(string $mode = "index"): array {
$is_modif = false; $is_modif = false;
foreach (['css','js','app'] as $type) { foreach (['css','js','app'] as $type) {
[ $afile, $lastmod ] = $this->gen_file($mode, $type); [ $afile, $lastmod ] = $this->gen_file($mode, $type);
@@ -174,17 +180,17 @@ final class Cache {
} }
} }
$session = $this->app->session(); $aoption = $this->session->get('__WEB_APP');
$aoption = $session->get('__WEB_APP'); $auser = $this->session->get('__WEB_USER');
$auser = $session->get('__WEB_USER');
$nonce = $this->app->get('csp_nonce'); $nonce = $this->app->get('csp_nonce');
$islog = user_logged($this->session);
$_secret = $aoption['APP_CODE'] .";". $aoption['APP_SID'] .";". $this->app->request()->getVar('HTTP_HOST') .";". "http://".$this->app->request()->getVar('HTTP_HOST') .";". isMobile() .";". ($aoption['AUTH_LEVEL']?$aoption['AUTH_LEVEL']:0); $_secret = $aoption['APP_CODE'] .";". $aoption['APP_SID'] .";". $this->app->request()->getVar('HTTP_HOST') .";". "http://".$this->app->request()->getVar('HTTP_HOST') .";". isMobile() .";". ($aoption['AUTH_LEVEL']?$aoption['AUTH_LEVEL']:0);
$_suser = (user_logged()) ? $auser['Username'] .";". $auser['UserID'] .";". $auser['Grup_MenuID'] .";". $auser['Level'] : "nobody;999;999;9"; $_suser = ($islog) ? $auser['Username'] .";". $auser['UserID'] .";". $auser['Grup_MenuID'] .";". $auser['Level'] : "nobody;999;999;9";
$acache['JSX'][] = '<script nonce="'.$nonce.'" type="text/javascript">'; $acache['JSX'][] = '<script nonce="'.$nonce.'" type="text/javascript">';
$acache['JSX'][] = 'FoniaJS.setConfig("'.base64_encode($_secret).'", "'.base64_encode($_suser).'");'; $acache['JSX'][] = 'FoniaJS.setConfig("'.base64_encode($_secret).'", "'.base64_encode($_suser).'");';
$acache['JSX'][] = '$(document).ready(function(){'; $acache['JSX'][] = '$(document).ready(function(){';
if (user_logged()) $acache['JSX'][] = 'FoniaJS.loadMenu();'; if ($islog) $acache['JSX'][] = 'FoniaJS.loadMenu();';
$acache['JSX'][] = '});'; $acache['JSX'][] = '});';
$acache['JSX'][] = '</script>'; $acache['JSX'][] = '</script>';
+38 -33
View File
@@ -6,9 +6,9 @@
Desc. : Class pembuatan file PDF Desc. : Class pembuatan file PDF
Created By : Siau Pheng ([email protected]). Created By : Siau Pheng ([email protected]).
Created Date : April 18th, 2015. Created Date : April 18th, 2015.
Last Modified : July 25th, 2026. Last Modified : August 21st, 2026.
(c) 2015 - 2026, 3FONIA Software; WWW.3FONIA.COM. (c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/ *******************************************************************/
@@ -16,22 +16,27 @@ declare(strict_types=1);
namespace siaupheng\webapp\Data; namespace siaupheng\webapp\Data;
use Mpdf; use \flight\Session;
use \Mpdf;
final class PDF { final class PDF {
private $__avalue = []; private $__avalue = [];
private $__atabel = []; private $__atabel = [];
private $__theader = ""; private $__theader = "";
private $__tcolname = ""; private $__tcolname = "";
protected array $webapp;
protected array $webuser;
public function __construct() { public function __construct(Session $session) {
$this->webapp = $session->get('__WEB_APP', ['REG_NAME'=>'', 'APP_NAME'=>'', 'APP_VER'=>'']);
$this->webuser = $session->get('__WEB_USER', ['UserID'=>0, 'Username'=>'']);
} }
public function add_field($tnama="", $nlebar=0, $talign="L", $ffunc="", $nkol=1) { public function add_field(string $nama, string|int $lebar=0, string $align="L", string $func="", int $kol=1): void {
$this->__atabel[] = array($tnama, $nlebar.'%', $ffunc, $talign, $nkol); $this->__atabel[] = [ $nama, (string)$lebar.'%', $func, $align, $kol ];
} }
public function show_fields() { public function show_fields(): void {
$tmp_out = "<thead><tr>"; $tmp_out = "<thead><tr>";
for ($i=0; $i<count($this->__atabel); $i++) { for ($i=0; $i<count($this->__atabel); $i++) {
if ($this->__atabel[$i][4]==0) continue; if ($this->__atabel[$i][4]==0) continue;
@@ -41,21 +46,21 @@ final class PDF {
$this->__tcolname = $tmp_out; $this->__tcolname = $tmp_out;
} }
public function clear() { public function clear(): void {
$this->__avalue = []; $this->__avalue = [];
$this->__theader = ""; $this->__theader = "";
$this->__tcolname = ""; $this->__tcolname = "";
} }
public function set_header($tlapor="", $tperiod="") { public function set_header(string $lapor, string $period): void {
$thasil = '<div style="text-align:center;font-size:12pt;"><b>'.strtoupper($_SESSION['__WEB_APP']['REG_NAME']); $thasil = '<div style="text-align:center;font-size:12pt;"><b>'.strtoupper($this->webapp['REG_NAME']);
$thasil .= (($tlapor=="") ? "" : '<br>'.$tlapor) . '</b>'; $thasil .= (($lapor=="") ? "" : '<br>'.$lapor) . '</b>';
$thasil .= ($tperiod=="") ? "" : '<br><span style="font-size:11pt;">'.$tperiod.'</span>'; $thasil .= ($period=="") ? "" : '<br><span style="font-size:11pt;">'.$period.'</span>';
$thasil .= '</div><br>'; $thasil .= '</div><br>';
$this->__theader = $thasil; $this->__theader = $thasil;
} }
public function add_value() { public function add_value(): void {
$tmp_arr = func_get_args(); $tmp_arr = func_get_args();
if (is_array($tmp_arr[0])) $tmp_arr = $tmp_arr[0]; if (is_array($tmp_arr[0])) $tmp_arr = $tmp_arr[0];
$tmp_out = "<tr>"; $tmp_out = "<tr>";
@@ -73,7 +78,7 @@ final class PDF {
$this->__avalue[] = $tmp_out; $this->__avalue[] = $tmp_out;
} }
public function add_span() { public function add_span(): void {
$tmp_arr = func_get_args(); $tmp_arr = func_get_args();
$tmp_out = "<tr>"; $tmp_out = "<tr>";
for ($i=0; $i<count($tmp_arr); $i++) { for ($i=0; $i<count($tmp_arr); $i++) {
@@ -88,19 +93,19 @@ final class PDF {
$this->__avalue[] = $tmp_out; $this->__avalue[] = $tmp_out;
} }
public function add_empty() { public function add_empty(): void {
$this->__avalue[] = $this->set_align("&nbsp;", 0, "L,NB", true); $this->__avalue[] = $this->set_align("&nbsp;", 0, "L,NB", true);
} }
public function add_stamp($ctk_ke=1, $bnama=false) { public function add_stamp(int $ctk_ke=1, bool $tampil_nama=false): void {
$this->__avalue[] = $this->set_align($_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):""), 0, "L,NB", true); $this->__avalue[] = $this->set_align($this->get_stamp($ctk_ke, $tampil_nama), 0, "L,NB", true);
} }
public function get_stamp($ctk_ke=1, $bnama=false) { public function get_stamp(int $ctk_ke=1, bool $tampil_nama=false): string {
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):""); 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 createPDF($nama_file = "Nama_File.pdf", $nfontz = 8, $orien = "P") { public function createPDF(string $nama_file = "Nama_File.pdf", int $fontz = 8, string $orien = "P"): void {
$html = ' $html = '
<style> <style>
#pdf_area { #pdf_area {
@@ -148,33 +153,33 @@ final class PDF {
$html .= $this->__avalue[$i]; $html .= $this->__avalue[$i];
} }
$html .= '</tbody></table></div></div></body>'; $html .= '</tbody></table></div></div></body>';
$mpdf = new mPDF('c', 'A4'.($orien=="L"?"-L":""), $nfontz, '', 5, 5, 5, 10, 5, 5); $mpdf = new mPDF('c', 'A4'.($orien==="L"?"-L":""), $fontz, '', 5, 5, 5, 10, 5, 5);
$mpdf->useSubstitutions = false; $mpdf->useSubstitutions = false;
$mpdf->WriteHTML($html); $mpdf->WriteHTML($html);
$mpdf->Output($nama_file.".pdf", "I"); $mpdf->Output($nama_file.".pdf", "I");
} }
public function set_align($ttext, $nlen, $tdir="L", $bline=false, $bhead=false, $ncol=1) { public function set_align(string $text, string|int $width, string $dir="L", bool $line=false, bool $head=false, int $col=1): string {
$tstyle = $this->create_style($tdir); $tstyle = $this->create_style($dir);
if (strpos(strtolower($ttext), "<tr>")===false) { //jika tidak ada <tr> up 2011-04-14 if (strpos(strtolower($text), "<tr>")===false) {
if ($bline===true) { if ($line===true) {
return '<tr><td colspan="'.count($this->__atabel).'" class="'.$tstyle.'">'.$ttext."</td></tr>"; return '<tr><td colspan="'.count($this->__atabel).'" class="'.$tstyle.'">'.$text."</td></tr>";
} else { } else {
return (($bhead===true)?"<th":"<td").(($ncol>1)?' colspan="'.$ncol.'"':"").' class="'.$tstyle.'" '.(($bhead===true)?'width="'.$nlen.'"':"").">".$ttext.(($bhead===true)?"</th>":"</td>"); return (($head===true)?"<th":"<td").(($col>1)?' colspan="'.(string)$col.'"':"").' class="'.$tstyle.'" '.(($head===true)?'width="'.(string)$width.'"':"").">".$text.(($head===true)?"</th>":"</td>");
} }
} else { } else {
return (($bline===true) ? $ttext : (($bhead===true)?"<th":"<td").(($ncol>1)?" colspan=\"".$ncol."\"":"")." class=\"".$tstyle." \" ".(($bhead===true)?"width=\"".$nlen."\"":"").">".$ttext.(($bhead===true)?"</th>":"</td>")); return (($line===true) ? $text : (($head===true)?"<th":"<td").(($col>1)?" colspan=\"".(string)$col."\"":"")." class=\"".$tstyle." \" ".(($head===true)?"width=\"".(string)$width."\"":"").">".$text.(($head===true)?"</th>":"</td>"));
} }
} }
private function create_style($tstyle="L") { private function create_style(string $style="L"): string {
$apad = ["L"=>"left", "R"=>"right", "C"=>"center", "NB"=>"nb", "NL"=>"noleft", "NR"=>"noright", "B"=>"bold", "I"=>"italic"]; $apad = ["L"=>"left", "R"=>"right", "C"=>"center", "NB"=>"nb", "NL"=>"noleft", "NR"=>"noright", "B"=>"bold", "I"=>"italic"];
$_astyle = explode(",", $tstyle); $_astyle = explode(",", $style);
$thasil = ""; $ahasil = [];
foreach ($_astyle as $_key => $_val) { foreach ($_astyle as $_key => $_val) {
$thasil .= " ".$apad[$_val]; $ahasil[] = $apad[$_val];
} }
return substr($thasil,1); return implode(' ', $ahasil);
} }
} }
+2 -1
View File
@@ -8,10 +8,11 @@
Created Date : November 18th, 2012. Created Date : November 18th, 2012.
Last Modified : September 30th, 2025. Last Modified : September 30th, 2025.
(c) 2012 - 2025, 3FONIA Software; WWW.3FONIA.COM. (c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/ *******************************************************************/
//todo: deprecated
declare(strict_types=1); declare(strict_types=1);
namespace siaupheng\webapp\Data; namespace siaupheng\webapp\Data;
+2 -1
View File
@@ -8,10 +8,11 @@
Created Date : November 18th, 2012. Created Date : November 18th, 2012.
Last Modified : October 26th, 2023. Last Modified : October 26th, 2023.
(c) 2012 - 2023, 3FONIA Software; WWW.3FONIA.COM. (c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/ *******************************************************************/
//todo: deprecated
declare(strict_types=1); declare(strict_types=1);
namespace siaupheng\webapp\Data; namespace siaupheng\webapp\Data;
+18 -17
View File
@@ -8,55 +8,56 @@
Created Date : January 27th, 2008. Created Date : January 27th, 2008.
Last Modified : January 21st, 2024. Last Modified : January 21st, 2024.
(c) 2008 - 2024, 3FONIA Software; WWW.3FONIA.COM. (c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/ *******************************************************************/
//OK
declare(strict_types=1); declare(strict_types=1);
use \flight\Session;
if (!function_exists('user_level')) { if (!function_exists('user_level')) {
function user_level($level = 9) { function user_level(Session $session, int $level = 9): bool {
if (Flight::session()->get('__WEB_USER', ['Level'=>9]) <= $level) return true; if ($session->get('__WEB_USER', ['Level'=>9]) <= $level) return true;
return false; return false;
} }
} }
if (!function_exists('user_level_not')) { if (!function_exists('user_level_not')) {
function user_level_not($level = 9) { function user_level_not(Session $session, int $level = 9): bool {
if (Flight::session()->get('__WEB_USER', ['Level'=>9]) !== $level) return true; if ($session->get('__WEB_USER', ['Level'=>9]) !== $level) return true;
return false; return false;
} }
} }
if (!function_exists('user_logged')) { if (!function_exists('user_logged')) {
function user_logged() { function user_logged(Session $session): bool {
return !empty(Flight::session()->get('__WEB_USER')); return !empty($session->get('__WEB_USER'));
} }
} }
if (!function_exists('user_id')) { if (!function_exists('user_id')) {
function user_id($idigit = 0) { function user_id(Session $session, int $digit = 0): string|int {
if ($idigit > 0) return isi_nol((int)Flight::session()->get('__WEB_USER', ['UserID'=>0])['UserID'], $idigit); if ($digit > 0) return isi_nol($session->get('__WEB_USER', ['UserID'=>0])['UserID'], $digit);
return (int)Flight::session()->get('__WEB_USER', ['UserID'=>0])['UserID']; return (int)$session->get('__WEB_USER', ['UserID'=>0])['UserID'];
} }
} }
if (!function_exists('user_user')) { if (!function_exists('user_user')) {
function user_user() { function user_user(Session $session): string {
return (string)Flight::session()->get('__WEB_USER', ['Username'=>''])['Username']; return (string)$session->get('__WEB_USER', ['Username'=>''])['Username'];
} }
} }
if (!function_exists('user_unix')) { if (!function_exists('user_unix')) {
function user_unix() { function user_unix(Session $session): string {
return (string)Flight::session()->get('__WEB_USER', ['UNIX'=>'0'])['UNIX']; return (string)$session->get('__WEB_USER', ['UNIX'=>'0'])['UNIX'];
} }
} }
if (!function_exists('user_nama')) { if (!function_exists('user_nama')) {
function user_nama() { function user_nama(Session $session): string {
return (string)Flight::session()->get('__WEB_USER', ['Nama'=>''])['Nama']; return (string)$session->get('__WEB_USER', ['Nama'=>''])['Nama'];
} }
} }
+12 -11
View File
@@ -6,9 +6,9 @@
Desc. : Fungsi Custom Lain Lain Desc. : Fungsi Custom Lain Lain
Created By : Siau Pheng ([email protected]). Created By : Siau Pheng ([email protected]).
Created Date : January 27th, 2008. Created Date : January 27th, 2008.
Last Modified : December 26th, 2025. Last Modified : August 21st, 2026.
(c) 2008 - 2025, 3FONIA Software; WWW.3FONIA.COM. (c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/ *******************************************************************/
@@ -17,24 +17,25 @@ declare(strict_types=1);
/*************************** FORMAT ANGKA / CURRENCY *****************************/ /*************************** FORMAT ANGKA / CURRENCY *****************************/
if (!function_exists('rupiah')) {//oke if (!function_exists('rupiah')) {//oke
function rupiah(string|float $angka = 0, int $desi = 0) { function rupiah(string|float $angka = 0, int $desi = 0): string {
return number_format((float)$angka, $desi, ",", "."); return number_format((float)$angka, $desi, ",", ".");
} }
} }
if (!function_exists('rupiah2')) { if (!function_exists('rupiah2')) {//oke
function rupiah2($angka = 0) { function rupiah2($angka = 0): string {
return rupiah($angka, 2); return rupiah($angka, 2);
} }
} }
if (!function_exists('rupiah30')) { //todo: deprecated
function rupiah30($angka = 0) { /*if (!function_exists('rupiah30')) {
function rupiah30($angka = 0): string {
$nilai = explode(".", $angka); $nilai = explode(".", $angka);
$hasil = (intval($nilai[1])==0) ? rupiah($angka, 0) : rupiah($angka, 3); $hasil = (intval($nilai[1])==0) ? rupiah($angka, 0) : rupiah($angka, 3);
return $hasil; return $hasil;
} }
} }*/
if (!function_exists('kurung_rup')) { if (!function_exists('kurung_rup')) {
function kurung_rup($angka = 0, $desi = 0) { function kurung_rup($angka = 0, $desi = 0) {
@@ -284,9 +285,9 @@ if (!function_exists('br2nl')) {
} }
} }
if (!function_exists('isi_nol')) { if (!function_exists('isi_nol')) {//oke
function isi_nol($nilai = "0", $panjang = 1) { function isi_nol(string|int $nilai = 0, int $panjang = 1): string {
$nilai = strval($nilai); $nilai = (string)$nilai;
return ($panjang>strlen($nilai) ? str_repeat("0", $panjang-strlen($nilai)):'').$nilai; return ($panjang>strlen($nilai) ? str_repeat("0", $panjang-strlen($nilai)):'').$nilai;
} }
} }
+37 -33
View File
@@ -2,13 +2,13 @@
/******************************************************************* /*******************************************************************
Module : /Printing/PrintHTML.php Module : /Printer/PrintHTML.php
Desc. : Class cetak HTML Desc. : Class cetak HTML
Created By : Siau Pheng ([email protected]). Created By : Siau Pheng ([email protected]).
Created Date : June 15th, 2008. Created Date : June 15th, 2008.
Last Modified : September 30th, 2025. Last Modified : August 21st, 2026.
(c) 2008 - 2025, 3FONIA Software; WWW.3FONIA.COM. (c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/ *******************************************************************/
@@ -16,38 +16,40 @@ declare(strict_types=1);
namespace siaupheng\webapp\Printer; namespace siaupheng\webapp\Printer;
use \flight\Session;
final class PrintHTML { final class PrintHTML {
private $__avalue = []; private $__avalue = [];
private $__atabel = []; private $__atabel = [];
private $__css = "table"; private $__css = "table";
private $__tstamp = ""; private $__tstamp = "";
protected array $webapp;
protected array $webuser;
public function __construct() { public function __construct(Session $session) {
$this->webapp = $session->get('__WEB_APP', ['APP_NAME'=>'', 'APP_VER'=>'']);
$this->webuser = $session->get('__WEB_USER', ['UserID'=>0, 'Username'=>'']);
} }
public function set_css($style = "") { public function set_css(string $style): void {
if ($style=="") return; if (!empty($style)) $this->__css = $style;
$this->__css = $style;
} }
public function add_field($tnama="", $nlebar=0, $talign="L", $ffunc="", $nkol=1) {//up 2012-03-07 public function add_field(string $nama, int $lebar=0, string $align="L", string $func="", int $kol=1): void {
$this->__atabel[] = [$tnama, $nlebar, $ffunc, $talign, $nkol]; $this->__atabel[] = [ $nama, $lebar, $func, $align, $kol ];
} }
public function show_fields() {//todo: deleted public function clear(): void {
}
public function clear() {
$this->__avalue = []; $this->__avalue = [];
} }
public function add_value() { public function add_value(): void {
$tmp_arr = func_get_args(); $tmp_arr = func_get_args();
if (is_array($tmp_arr[0])) $tmp_arr = $tmp_arr[0]; //up 2009-09-27 if (is_array($tmp_arr[0])) $tmp_arr = $tmp_arr[0];
$tmp_out = "<tr>"; $tmp_out = "<tr>";
for ($i=0; $i<count($this->__atabel); $i++) { for ($i=0; $i<count($this->__atabel); $i++) {
$tmp_val = $tmp_arr[$i]; $tmp_val = $tmp_arr[$i];
if (is_array($this->__atabel[$i][2]) && trim("".$tmp_val)<>"") { //up 2010-05-28 if (is_array($this->__atabel[$i][2]) && trim("".$tmp_val)<>"") {
$tmp_val = $this->__atabel[$i][2][$tmp_val]; $tmp_val = $this->__atabel[$i][2][$tmp_val];
} else if (function_exists($this->__atabel[$i][2]) && trim("".$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 = call_user_func($this->__atabel[$i][2], $tmp_val);
@@ -59,7 +61,7 @@ final class PrintHTML {
$this->__avalue[] = $tmp_out; $this->__avalue[] = $tmp_out;
} }
public function add_span() { public function add_span(): void {
$tmp_arr = func_get_args(); $tmp_arr = func_get_args();
$tmp_out = "<tr>"; $tmp_out = "<tr>";
for ($i=0; $i<count($tmp_arr); $i++) { for ($i=0; $i<count($tmp_arr); $i++) {
@@ -79,15 +81,15 @@ final class PrintHTML {
$this->__avalue[] = $tmp_out; $this->__avalue[] = $tmp_out;
} }
public function add_stamp($ctk_ke=1, $bnama=false) {//up 2023-10-13 public function add_stamp(int $ctk_ke=1, bool $cetak_nama=false): void {
$this->__tstamp = $this->get_stamp($ctk_ke, $bnama); $this->__tstamp = $this->get_stamp($ctk_ke, $cetak_nama);
} }
public function get_stamp($ctk_ke=1, $bnama=false) {//up 2012-10-11 public function get_stamp(int $ctk_ke=1, bool $cetak_nama=false): string {
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):""); 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($jumlah_ctk=1) {//up 2012-10-11 public function show(int $jumlah_ctk=1) {
$out = "<table class=\"".$this->__css."\"><thead>"; $out = "<table class=\"".$this->__css."\"><thead>";
// header out // header out
@@ -111,27 +113,29 @@ final class PrintHTML {
for ($i=1; $i<=$jumlah_ctk; $i++) echo $out; for ($i=1; $i<=$jumlah_ctk; $i++) echo $out;
} }
public function set_align($ttext, $nlen, $tdir="L", $bline=false, $bhead=false, $ncol=1, $textra="") {//up 2011-04-14 public function set_align(string $text, int $width=0, string $dir="L", bool $line=false, bool $head=false, int $col=1, string $extra=""): string {
$tstyle = $this->create_style($tdir); $tstyle = $this->create_style($dir);
if ($bline===true) { if ($line===true) {
return "<tr><td colspan=\"".count($this->__atabel)."\" class=\"".$tstyle." ".$textra."\">".$ttext."</td></tr>"; return "<tr><td colspan=\"".count($this->__atabel)."\" class=\"".$tstyle." ".$extra."\">".$text."</td></tr>";
} else { } else {
return (($bhead===true)?"<th":"<td").(($ncol>1)?" colspan=\"".$ncol."\"":"")." class=\"".$tstyle." ".$textra."\" ".(($bhead===true)?"width=\"".$nlen."\"":"").">".$ttext.(($bhead===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>");
} }
} }
private function create_style($tstyle="L") { //up 2014-10-12 private function create_style(string $style="L"): string {
// style = Left Right Center No-Border No-Left No-Right Bold Italic // style = Left Right Center No-Border No-Left No-Right Bold Italic
$apad = ["L"=>"l", "R"=>"r", "C"=>"c", "NB"=>"nb", "NL"=>"noleft", "NR"=>"noright", "B"=>"b", "I"=>"i"]; $apad = ["L"=>"l", "R"=>"r", "C"=>"c", "NB"=>"nb", "NL"=>"noleft", "NR"=>"noright", "B"=>"b", "I"=>"i"];
$_astyle = explode(",", $tstyle); $_astyle = explode(",", $style);
$thasil = ""; $ahasil = [];
foreach ($_astyle as $_key => $_val) { foreach ($_astyle as $_key => $_val) {
$thasil .= " ".$apad[$_val]; $ahasil[] = $apad[$_val];
} }
return substr($thasil,1); return implode(' ', $ahasil);
} }
public function add_pagebreak() {}//delete: not used anymore //todo: deprecated
public function show_fields() {}
public function add_pagebreak() {}
} }
?> ?>
+52 -47
View File
@@ -2,13 +2,13 @@
/******************************************************************* /*******************************************************************
Module : /Printing/PrintPOS.php Module : /Printer/PrintPOS.php
Desc. : Class cetak POS Desc. : Class cetak POS
Created By : Siau Pheng ([email protected]). Created By : Siau Pheng ([email protected]).
Created Date : June 15th, 2008. Created Date : June 15th, 2008.
Last Modified : December 3rd, 2025. Last Modified : August 21st, 2026.
(c) 2008 - 2025, 3FONIA Software; WWW.3FONIA.COM. (c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/ *******************************************************************/
@@ -16,8 +16,10 @@ declare(strict_types=1);
namespace siaupheng\webapp\Printer; namespace siaupheng\webapp\Printer;
/* VERSI BARU DENGAN MULTI SHEET */ use \flight\Engine;
class PrintPOS {//up: 20251203 use \flight\Session;
class PrintPOS {
private $_header = []; private $_header = [];
private $_avalue = []; private $_avalue = [];
private $_astyle = []; private $_astyle = [];
@@ -27,37 +29,41 @@ class PrintPOS {//up: 20251203
'fontsize' => 1, 'fontsize' => 1,
'opendraw' => false, 'opendraw' => false,
'cutpaper' => false, 'cutpaper' => false,
'logo' => null ]; 'logo' => null,
];
private array $webapp;
private array $webuser;
protected Engine $app;
public function __construct() { public function __construct(Engine $app, Session $session) {
$this->app = $app;
$this->webapp = $session->get('__WEB_APP', ['APP_NAME'=>'', 'APP_VER'=>'', 'REAL_PATH'=>'']);
$this->webuser = $session->get('__WEB_USER', ['UserID'=>0, 'Username'=>'']);
} }
public function set_opendrawer() { public function set_opendrawer(): void {
$this->_config['opendraw'] = true; $this->_config['opendraw'] = true;
} }
public function set_cutpaper() { public function set_cutpaper(): void {
$this->_config['cutpaper'] = true; $this->_config['cutpaper'] = true;
} }
public function set_maxchr($nmax = 0) {//up: 2015-03-22 public function set_maxchr(int $max = 0): void {
if ($nmax > 0) $this->_maxchr = $nmax; if ($max > 0) $this->_maxchr = $max;
} }
public function set_fontsize($nsize = 1) {//up: 2015-09-30 public function set_fontsize(int $size = 1): void {
if ($nsize > 0) $this->_config['fontsize'] = $nsize; if ($size > 0) $this->_config['fontsize'] = $size;
} }
public function set_printnv_logo() {}//delete public function set_header_logo(string $logo_file = ""): void {
if (!empty($logo_file) && file_exists($this->webapp['REAL_PATH']."assets/images/".$logo_file)) {
public function set_header_logo($logo_file = "") {//up: 2019-01-08 $this->_config['logo'] = $this->webapp['WEB_PATH']."assets/images/".$logo_file;
if ($logo_file=="") return;
if (file_exists($_SESSION['__WEB_APP']['REAL_PATH']."assets/images/".$logo_file)) {
$this->_config['logo'] = $_SESSION['__WEB_APP']['WEB_PATH']."assets/images/".$logo_file;
} }
} }
public function add_header() {//up: 2025-12-03 public function add_header(): void {
$extra = func_get_args(); $extra = func_get_args();
if (count($extra) > 0) { if (count($extra) > 0) {
foreach ($extra as $_val) { foreach ($extra as $_val) {
@@ -66,11 +72,11 @@ class PrintPOS {//up: 20251203
} }
} }
public function add_sheet() {//up: 20170321 public function add_sheet(): void {
$this->_ncont++; $this->_ncont++;
} }
public function add() {//up: 20180524 public function add(): void {
$val_arr = func_get_args(); $ttext = ""; $tstyle = "L"; $val_arr = func_get_args(); $ttext = ""; $tstyle = "L";
if (is_array($val_arr[0])) { if (is_array($val_arr[0])) {
foreach($val_arr as $aval) { foreach($val_arr as $aval) {
@@ -84,32 +90,32 @@ class PrintPOS {//up: 20251203
$this->_astyle[$this->_ncont][] = $tstyle; $this->_astyle[$this->_ncont][] = $tstyle;
} }
public function addl($ttext = "") { public function addl(string $text = ""): void {
$this->add($ttext); $this->add($text);
} }
public function addr($ttext = "") { public function addr(string $text = ""): void {
$this->add($ttext, "R"); $this->add($text, "R");
} }
public function addc($ttext = "") { public function addc(string $text = ""): void {
$this->add($ttext, "C"); $this->add($text, "C");
} }
public function add_line($tmp = "-") { public function add_line(string $line = "-"): void {
$this->add("__LINE ".$tmp); $this->add("__LINE ".$line);
} }
public function add_empty($nrep = 1) { public function add_empty(int $baris = 1): void {
for ($i=0;$i<$nrep;$i++) $this->add(""); for ($i=0; $i<$baris; $i++) $this->add("");
} }
public function add_stamp($ctk_ke=1, $bnama=false) { public function add_stamp(int $ctk_ke=1, bool $cetak_nama=false): void {
$this->add($_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):"")); $this->add($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):""));
} }
private function _json_out() {//up: 2016-11-12 public function show(int $jumlah_ctk=1): void {
$acontent = array(); $acontent = [];
$nmax = $this->_maxchr; $nmax = $this->_maxchr;
for ($s=0; $s<count($this->_avalue); $s++) { for ($s=0; $s<count($this->_avalue); $s++) {
@@ -123,24 +129,23 @@ class PrintPOS {//up: 20251203
} }
} }
$aout = array('type' => "escp"); $this->_config['times'] = $jumlah_ctk;
$aout = ['type' => "escp"];
$aout['config'] = $this->_config; $aout['config'] = $this->_config;
$aout['header'] = $this->_header; $aout['header'] = $this->_header;
$aout['content'] = $acontent; $aout['content'] = $acontent;
send_json($aout); $this->app->json($aout);
} }
public function show($jumlah_ctk=1) { public function set_align(string $text, int $len=0, string $dir="L"): string {
$this->_config['times'] = $jumlah_ctk; $apad = ["L"=>STR_PAD_RIGHT, "R"=>STR_PAD_LEFT, "C"=>STR_PAD_BOTH];
$this->_json_out(); $nlen = ($len==0) ? strlen($text) : $len;
$ttext = (strlen($text)>$len) ? substr($text, 0, $len) : $text;
return str_pad($text, $len, " ", $apad[$dir]);
} }
public function set_align($ttext, $nlen=0, $tdir="L") {//up: 20180524 //todo: deprecated
$apad = array("L"=>STR_PAD_RIGHT, "R"=>STR_PAD_LEFT, "C"=>STR_PAD_BOTH); public function set_printnv_logo() {}//delete
$nlen = ($nlen==0) ? strlen($ttext) : $nlen;
$ttext = (strlen($ttext)>$nlen) ? substr($ttext, 0, $nlen) : $ttext;
return str_pad($ttext, $nlen, " ", $apad[$tdir]);
}
} }
?> ?>
+46 -45
View File
@@ -2,13 +2,13 @@
/******************************************************************* /*******************************************************************
Module : /Printing/PrintRAW.php Module : /Printer/PrintRAW.php
Desc. : Class cetak RAW Desc. : Class cetak RAW
Created By : Siau Pheng ([email protected]). Created By : Siau Pheng ([email protected]).
Created Date : June 15th, 2008. Created Date : June 15th, 2008.
Last Modified : November 1st, 2023. Last Modified : November 1st, 2023.
(c) 2008 - 2023, 3FONIA Software; WWW.3FONIA.COM. (c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/ *******************************************************************/
@@ -16,6 +16,9 @@ declare(strict_types=1);
namespace siaupheng\webapp\Printer; namespace siaupheng\webapp\Printer;
use \flight\Engine;
use \flight\Session;
class PrintRAW { class PrintRAW {
private $_header = []; private $_header = [];
private $_avalue = []; private $_avalue = [];
@@ -27,54 +30,56 @@ class PrintRAW {
'fontsize' => "01", 'fontsize' => "01",
'nvlogo' => false, 'nvlogo' => false,
'opendraw' => false, 'opendraw' => false,
'opendrawbegin' => false, 'cutpaper' => false,
'cutpaper' => false ]; ];
protected Engine $app;
protected array $webapp;
protected array $webuser;
public function __construct() { public function __construct(Engine $app, Session $session) {
$this->app = $app;
$this->webapp = $session->get('__WEB_APP', ['APP_NAME'=>'', 'APP_VER'=>'', 'REAL_PATH'=>'']);
$this->webuser = $session->get('__WEB_USER', ['UserID'=>0, 'Username'=>'']);
} }
public function set_opendrawer($bbegin = true) { public function set_opendrawer(): void {
$this->_config['opendraw'] = true; $this->_config['opendraw'] = true;
$this->_config['opendrawbegin'] = $bbegin;
} }
public function set_cutpaper() { public function set_cutpaper(): void {
$this->_config['cutpaper'] = true; $this->_config['cutpaper'] = true;
} }
public function set_maxchr($nmax = 0) {//up: 2015-03-22 public function set_maxchr(int $max = 0): void {
if ($nmax > 0) $this->_maxchr = $nmax; if ($max > 0) $this->_maxchr = $max;
} }
public function set_fontsize($nsize = 1) {//up: 2015-09-30 public function set_fontsize(int $size = 1): void {
if ($nsize > 0) $this->_config['fontsize'] = str_pad($nsize, 2, "0", STR_PAD_LEFT); if ($size > 0) $this->_config['fontsize'] = str_pad((string)$size, 2, "0", STR_PAD_LEFT);
} }
public function set_printnv_logo() {//up: 2015-03-23 public function set_printnv_logo(): void {
$this->_config['nvlogo'] = true; $this->_config['nvlogo'] = true;
} }
public function add_header($nvlogo = false, $extra = []) {//up: 2016-11-12 public function add_header(bool $nvlogo = false, array $extra = []): void {
$this->_config['nvlogo'] = $nvlogo; $this->_config['nvlogo'] = $nvlogo;
$this->_header[] = $_SESSION['__WEB_APP']['REG_NAME'];
if (count($extra) > 0) { if (count($extra) > 0) {
foreach ($extra as $_val) { foreach ($extra as $_val) {
$this->_header[] = $_val; $this->_header[] = $_val;
} }
} }
$this->_header[] = $_SESSION['__WEB_APP']['REG_CITY'];
} }
public function add_sheet() {//up: 20170321 public function add_sheet(): void {
$this->_ncont++; $this->_ncont++;
} }
public function add_field($tnama="", $nlebar=0, $talign="L", $ffunc="") { public function add_field(string $nama, int $lebar=0, string $align="L", string $func=""): void {
$this->_atabel[] = [$tnama, $nlebar, $ffunc, $talign]; $this->_atabel[] = [ $nama, $lebar, $func, $align ];
} }
public function show_fields() { public function show_fields(): void {
$tmp_out = "<b>"; $tmp_out = "<b>";
for ($i=0; $i<count($this->_atabel); $i++) { for ($i=0; $i<count($this->_atabel); $i++) {
$tmp_out .= $this->set_align($this->_atabel[$i][0], $this->_atabel[$i][1], "C"); $tmp_out .= $this->set_align($this->_atabel[$i][0], $this->_atabel[$i][1], "C");
@@ -86,13 +91,13 @@ class PrintRAW {
$this->_avalue[$this->_ncont][] = "__LINE -"; $this->_avalue[$this->_ncont][] = "__LINE -";
} }
public function add_value() { public function add_value(): void {
$tmp_arr = func_get_args(); $tmp_arr = func_get_args();
if (is_array($tmp_arr[0])) $tmp_arr = $tmp_arr[0]; //up 2009-09-27 if (is_array($tmp_arr[0])) $tmp_arr = $tmp_arr[0];
$tmp_out = ""; $tmp_out = "";
for ($i=0; $i<count($this->_atabel); $i++) { for ($i=0; $i<count($this->_atabel); $i++) {
$tmp_val = $tmp_arr[$i]; $tmp_val = $tmp_arr[$i];
if (is_array($this->_atabel[$i][2]) && trim($tmp_val)<>"") { //up 2010-05-28 if (is_array($this->_atabel[$i][2]) && trim($tmp_val)<>"") {
$tmp_val = $this->_atabel[$i][2][$tmp_val]; $tmp_val = $this->_atabel[$i][2][$tmp_val];
} else if (function_exists($this->_atabel[$i][2]) && trim($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 = call_user_func($this->_atabel[$i][2], $tmp_val);
@@ -104,24 +109,24 @@ class PrintRAW {
$this->_avalue[$this->_ncont][] = $tmp_out; $this->_avalue[$this->_ncont][] = $tmp_out;
} }
public function add($ttext = "") { public function add(string $text): void {
$this->_avalue[$this->_ncont][] = $ttext; $this->_avalue[$this->_ncont][] = $text;
} }
public function add_line($tmp = "-") { public function add_line(string $line = "-"): void {
$this->add("__LINE ".$tmp); $this->add("__LINE ".$line);
} }
public function add_empty($nrep = 1) { public function add_empty(int $rep = 1): void {
for ($i=0;$i<$nrep;$i++) $this->add(""); for ($i=0;$i<$rep;$i++) $this->add("");
} }
public function add_stamp($ctk_ke=1, $bnama=false) { public function add_stamp(int $ctk_ke=1, bool $cetak_nama=false): void {
$this->add($_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):"")); $this->add($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):""));
} }
private function _json_out() {//up: 2016-11-12 public function show(int $jumlah_ctk=1): void {
$acontent = array(); $acontent = [];
$nmax = $this->_maxchr; $nmax = $this->_maxchr;
for ($s=0; $s<count($this->_avalue); $s++) { for ($s=0; $s<count($this->_avalue); $s++) {
@@ -135,22 +140,18 @@ class PrintRAW {
} }
} }
$aout = array('type' => "escp"); $this->_config['times'] = $jumlah_ctk;
$aout = ['type' => "escp"];
$aout['config'] = $this->_config; $aout['config'] = $this->_config;
$aout['header'] = $this->_header; $aout['header'] = $this->_header;
$aout['content'] = $acontent; $aout['content'] = $acontent;
send_json($aout); $this->app->json($aout);
} }
public function show($jumlah_ctk=1) { public function set_align(string $text, int $len, string $dir="L"): string {
$this->_config['times'] = $jumlah_ctk; $apad = ["L"=>STR_PAD_RIGHT, "R"=>STR_PAD_LEFT, "C"=>STR_PAD_BOTH];
$this->_json_out(); $ttext = (strlen($text)>$len) ? substr($text, 0, $len) : $text;
} return str_pad($text, $len, " ", $apad[$dir]);
public function set_align($ttext, $nlen, $tdir="L") {
$apad = array("L"=>STR_PAD_RIGHT, "R"=>STR_PAD_LEFT, "C"=>STR_PAD_BOTH);
$ttext = (strlen($ttext)>$nlen) ? substr($ttext, 0, $nlen) : $ttext;
return str_pad($ttext, $nlen, " ", $apad[$tdir]);
} }
} }
+34 -34
View File
@@ -3,23 +3,22 @@
/******************************************************************* /*******************************************************************
Module : /Web/Auth.php Module : /Web/Auth.php
Desc. : Class login dan user checking Desc. : Class User Control dan Manajemen
Created By : Siau Pheng ([email protected]). Created By : Siau Pheng ([email protected]).
Created Date : March 16th, 2008. Created Date : March 16th, 2008.
Last Modified : April 3rd, 2022. Last Modified : August 22nd, 2026.
(c) 2008 - 2022, 3FONIA Software; WWW.3FONIA.COM. (c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/ *******************************************************************/
//OK
declare(strict_types=1); declare(strict_types=1);
namespace siaupheng\webapp\Web; namespace siaupheng\webapp\Web;
use flight\Engine; use \flight\Engine;
use flight\Session; use \flight\Session;
use flight\database\SimplePdo; use \flight\database\SimplePdo;
final class Auth { final class Auth {
private int $__id_reg = 0; private int $__id_reg = 0;
@@ -27,23 +26,23 @@ final class Auth {
protected SimplePdo $db; protected SimplePdo $db;
protected Session $session; protected Session $session;
public function __construct(?Engine $app = null){ public function __construct(Engine $app, SimplePdo $db, Session $session){
$this->app = (empty($app) === true) ? \Flight::app() : $app; $this->app = $app;
$this->db = $this->app->db(); $this->db = $db;
$this->session = $this->app->session(); $this->session = $session;
$this->__id_reg = (int)$this->session->get('__WEB_APP', ['REG_ID'=>0])['REG_ID']; $this->__id_reg = (int)$this->session->get('__WEB_APP', ['REG_ID'=>0])['REG_ID'];
} }
public function set_id_reg($id = 0) { public function set_id_reg(int|string $id = 0): void {
if ($id > 0) $this->__id_reg = (int)$id; if ($id > 0) $this->__id_reg = (int)$id;
} }
public function user_check($user, $pass) { public function user_check(string $user, string $pass): bool {
$i_hasil = $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]);
return ($i_hasil > 0 ? true : false); return ($i_hasil > 0 ? true : false);
} }
public function user_data($user) { public function user_data(string $user): array {
$adata = $this->db->fetchRow('SELECT *,DECODE(Menu,?) Menu2 FROM app_operator WHERE Username=?', [$this->__id_reg, $user])->getData(); $adata = $this->db->fetchRow('SELECT *,DECODE(Menu,?) Menu2 FROM app_operator WHERE Username=?', [$this->__id_reg, $user])->getData();
$adata['Menu'] = $adata['Menu2']; $adata['Menu'] = $adata['Menu2'];
unset($adata['Menu2']); unset($adata['Menu2']);
@@ -53,13 +52,14 @@ final class Auth {
$this->session->set('APP_TOKEN', $_token); $this->session->set('APP_TOKEN', $_token);
$this->db->insert('app_token', [ 'Token' => $_token, 'UserID' => $adata['UserID'], 'IP' => $this->app->request()->ip ]); $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($adata['Grup_MenuID']); if ((int)$adata['Grup_MenuID'] > 0) $adata['Menu_Grup'] = $this->user_allmenu((int)$adata['Grup_MenuID']);
$adata['UNIX'] = time(); $adata['UNIX'] = time();
$adata['LOCALE'] = $this->session->get('__WEB_APP', ['DEF_LOCALE'=>'id'])['DEF_LOCALE']; $adata['LOCALE'] = $this->session->get('__WEB_APP', ['DEF_LOCALE'=>'id'])['DEF_LOCALE'];
$adata['MENU_MODUL'] = [];
return $adata; return $adata;
} }
public function gen_module_menu() { public function gen_module_menu(): void {
$amodul = []; $aallow = []; $tallow = ''; $amodul = []; $aallow = []; $tallow = '';
if ($this->session->get('__WEB_APP', ['APP_MODULE'=>0])['APP_MODULE']) { 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']]); $tallow = $this->db->fetchField('SELECT Modul_Akses FROM app_menu_grup WHERE Grup_MenuID=?', [$this->session->get('__WEB_USER', ['Grup_MenuID'=>0])['Grup_MenuID']]);
@@ -78,55 +78,55 @@ final class Auth {
$this->session->set('__WEB_USER', $auser); $this->session->set('__WEB_USER', $auser);
} }
public function user_allmenu(int $id_grup = 0) { 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]); $allmenu = $this->db->fetchField('SELECT DECODE(Menu,?) MenuX FROM app_menu_grup WHERE Grup_MenuID=?', [$this->__id_reg, $id_grup]);
return $allmenu; return $allmenu;
} }
public function user_check_level($user, $level = 9) { public function user_check_level(string $user, int $level = 9): bool {
$i_hasil = $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); return ($i_hasil > 0 ? true : false);
} }
public function user_log() { public function user_log(): void {
$a_hasil = $this->db->fetchRow('SELECT * FROM app_logs WHERE UserID=? ORDER BY Last_Date DESC LIMIT 1', [user_id()])->getData(); $_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) { if (count($a_hasil) > 0) {
$this->db->update('app_operator', [ 'Last_IP' => $a_hasil['Last_IP'], 'Last_Date' => $a_hasil['Last_Date'] ], 'UserID=?', [user_id()]); $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')]); $this->db->runQuery('INSERT IGNORE INTO app_logs SELECT UserID,Token,IP,DateStamp FROM app_token WHERE Token=?', [$this->session->get('APP_TOKEN')]);
} }
public function logout() { public function logout(): void {
$this->db->delete('app_token', 'Token=?', [$this->session->get('APP_TOKEN')]); $this->db->delete('app_token', 'Token=?', [$this->session->get('APP_TOKEN')]);
} }
public function token_check(string $token) { public function token_check(string $token): bool {
$hasil = (bool)$this->db->fetchField('SELECT 1 FROM app_token WHERE Token=?', [$token ?? $this->session->get('APP_TOKEN')]); $hasil = (bool)$this->db->fetchField('SELECT 1 FROM app_token WHERE Token=?', [$token ?? $this->session->get('APP_TOKEN')]);
if ($hasil === true) $this->db->update('app_token', ['DateStamp' => 'NOW()'], 'Token=?', [$token ?? $this->session->get('APP_TOKEN')]); if ($hasil === true) $this->db->update('app_token', ['DateStamp' => 'NOW()'], 'Token=?', [$token ?? $this->session->get('APP_TOKEN')]);
return $hasil; return $hasil;
} }
public function token_update() { public function token_update(): void {
$this->db->update('app_token', ['DateStamp' => 'NOW()'], 'Token=?', [$app->session->get('APP_TOKEN')]); $this->db->update('app_token', ['DateStamp' => 'NOW()'], 'Token=?', [$this->session->get('APP_TOKEN')]);
} }
public function redirect(string $appUrl) { public function redirect(string $appUrl): string {
$source = parse_url($appUrl); $source = parse_url($appUrl);
$desti = ""; $desti = "";
$hasil = (bool)$this->db->fetchField('SELECT 1 FROM app_host WHERE Nama_Host=?', [$source['host']]); $hasil = (bool)$this->db->fetchField('SELECT 1 FROM app_host WHERE Nama_Host=?', [$source['host']]);
if ($hasil === true) { if ($hasil) $desti = $source['scheme'].$source['host'].$source['path'].'?'.'auth='.$this->session->get('APP_TOKEN');
$desti = $source['scheme'].$source['host'].$source['path'].'?'.'auth='.$app->session->get('APP_TOKEN');
}
return $desti; return $desti;
} }
private function genToken(int $length = 16) { private function genToken(int $length = 16): string {
$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
return substr(str_shuffle(str_repeat($pool, 5)), 0, $length); return substr(str_shuffle(str_repeat($pool, 5)), 0, $length);
} }
public function getUserByToken(string $token) { 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 ??$app->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; return $hasil;
} }
} }
+24 -23
View File
@@ -6,9 +6,9 @@
Desc. : Button Generator (jQuery & Bootstrap) Desc. : Button Generator (jQuery & Bootstrap)
Created By : Siau Pheng ([email protected]). Created By : Siau Pheng ([email protected]).
Created Date : February 27th, 2008. Created Date : February 27th, 2008.
Last Modified : January 22nd, 2024. Last Modified : August 22nd, 2026.
(c) 2008 - 2024, 3FONIA Software; WWW.3FONIA.COM. (c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/ *******************************************************************/
@@ -20,41 +20,42 @@ class Button {
private $__abutton =[]; private $__abutton =[];
public function __construct() {} public function __construct() {}
private function add($type="info", $id="", $label="", $bmiss=false) {
if ($id=="") $id = "random".rand(1000, 10000); private function add(string $type="info", string $id="", string $label="", bool $miss=false): void {
$this->__abutton[] = ['type'=>$type, 'id'=>$id, 'label'=>$label, 'bmiss'=>$bmiss]; if (empty($id)) $id = "random".(string)rand(1000, 10000);
$this->__abutton[] = [ 'type' => $type, 'id' => $id, 'label' => $label, 'miss' => $miss ];
} }
public function separator() { public function separator(): void {
$this->__abutton[] = ['type'=>"separator"]; $this->__abutton[] = [ 'type' => "separator" ];
} }
public function primary($id="", $label="", $bmiss=false) { public function primary(string $id="", string $label="", bool $miss=false): void {
$this->add("primary", $id, $label, $bmiss); $this->add("primary", $id, $label, $miss);
} }
public function info($id="", $label="", $bmiss=false) { public function info(string $id="", string $label="", bool $miss=false): void {
$this->add("info", $id, $label, $bmiss); $this->add("info", $id, $label, $miss);
} }
public function danger($id="", $label="", $bmiss=false) { public function danger(string $id="", string $label="", bool $miss=false): void {
$this->add("danger", $id, $label, $bmiss); $this->add("danger", $id, $label, $miss);
} }
public function warning($id="", $label="", $bmiss=false) { public function warning(string $id="", string $label="", bool $miss=false): void {
$this->add("warning", $id, $label, $bmiss); $this->add("warning", $id, $label, $miss);
} }
public function success($id="", $label="", $bmiss=false) { public function success(string $id="", string $label="", bool $miss=false): void {
$this->add("success", $id, $label, $bmiss); $this->add("success", $id, $label, $miss);
} }
public function secondary($id="", $label="", $bmiss=false) { public function secondary(string $id="", string $label="", bool $miss=false): void {
$this->add("secondary", $id, $label, $bmiss); $this->add("secondary", $id, $label, $miss);
} }
public function Button($size=2) { public function Button(int $size=2): string {
if (0==count($this->__abutton)) return ""; if (0===count($this->__abutton)) return "";
$_out = '<div class="row mb-1"><div class="col-12 col-sm-6 my-0 mx-sm-0 text-center text-sm-start">'; $_ma = ' me-sm-2'; $_out = '<div class="row mb-1"><div class="col-12 col-sm-6 my-0 mx-sm-0 text-center text-sm-start">'; $_ma = ' me-sm-2';
foreach ($this->__abutton as $item) { foreach ($this->__abutton as $item) {
if ("separator" == $item['type']) { if ("separator" === $item['type']) {
$_out .= '</div><div class="col-12 col-sm-6 my-0 mx-sm-0 text-center text-sm-end">'; $_ma = ' ms-sm-2'; $_out .= '</div><div class="col-12 col-sm-6 my-0 mx-sm-0 text-center text-sm-end">'; $_ma = ' ms-sm-2';
} else { } else {
$_out .= '<button type="button" class="btn btn-'.$item['type'].' mb-2 mb-sm-0'.$_ma.' col-10 col-sm-auto shadow-none" id="'.$item['id'].'"'.(true==$item['bmiss']?' data-bs-dismiss="modal"':'').'>'.$item['label'].'</button>'; $_out .= '<button type="button" class="btn btn-'.$item['type'].' mb-2 mb-sm-0'.$_ma.' col-10 col-sm-auto shadow-none" id="'.$item['id'].'"'.(true===$item['miss']?' data-bs-dismiss="modal"':'').'>'.$item['label'].'</button>';
} }
} }
$_out .= '</div></div>'; $_out .= '</div></div>';
+33 -35
View File
@@ -6,20 +6,19 @@
Desc. : Form Generator (jQuery & Bootstrap) Desc. : Form Generator (jQuery & Bootstrap)
Created By : Siau Pheng ([email protected]). Created By : Siau Pheng ([email protected]).
Created Date : February 27th, 2008. Created Date : February 27th, 2008.
Last Modified : August 19th, 2026. Last Modified : August 22nd, 2026.
(c) 2008 - 2026, 3FONIA Software; WWW.3FONIA.COM. (c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/ *******************************************************************/
//OK
declare(strict_types=1); declare(strict_types=1);
namespace siaupheng\webapp\Web; namespace siaupheng\webapp\Web;
use flight\Engine; use \flight\Engine;
use flight\Session; use \flight\Session;
use flight\database\SimplePdo; use \flight\database\SimplePdo;
final class Form { final class Form {
private $__aform = []; private $__aform = [];
@@ -28,13 +27,13 @@ final class Form {
protected SimplePdo $db; protected SimplePdo $db;
protected Session $session; protected Session $session;
public function __construct(?Engine $app = null){ public function __construct(Engine $app, SimplePdo $db, Session $session){
$this->app = (empty($app) === true) ? \Flight::app() : $app; $this->app = $app;
$this->db = $this->app->db(); $this->db = $db;
$this->session = $this->app->session(); $this->session = $session;
} }
public function option(string $label, string $field, string|int|null $value=null, bool $enable=true, bool $req=false, array $arr=[], ?string $help=null, ?string $change=null, bool $multi=false, bool $group=false): string {//oke public function option(string $label, string $field, string|int|null $value=null, bool $enable=true, bool $req=false, array $arr=[], ?string $help=null, ?string $change=null, bool $multi=false, bool $group=false): string {
$_opsi = ''; $_opsi = '';
if (!empty($change)) $_opsi .= ' ochan="'.$change.'"'; if (!empty($change)) $_opsi .= ' ochan="'.$change.'"';
if ($enable===false) $_opsi .= ' disabled=true'; if ($enable===false) $_opsi .= ' disabled=true';
@@ -70,12 +69,12 @@ final class Form {
return $tout; return $tout;
} }
public function option_db(string $label, string $field, string|int|null $value=null, bool $enable=true, bool $req=false, ?string $table=null, ?array $afield=null, ?string $where=null, ?array $aarray=null, ?string $help=null, ?string $change=null, bool $multi=false): string {//oke public function option_db(string $label, string $field, string|int|null $value=null, bool $enable=true, bool $req=false, ?string $table=null, ?array $afield=null, ?string $where=null, ?array $aarray=null, ?string $help=null, ?string $change=null, bool $multi=false): string {
$_twhere = ''; $_twhere = '';
if (!is_array($afield)) $afield = ["ID", "Nama", "Label"]; if (!is_array($afield)) $afield = ["ID", "Nama", "Label"];
if (!empty($where)) { if (!empty($where)) {
$_twhere = ' WHERE '.$where; $_twhere = ' WHERE '.$where;
$_twhere .= (stripos($twhere,"ORDER BY")===false) ? ' ORDER BY '.$afield[1] : ''; $_twhere .= (stripos($where,"ORDER BY")===false) ? ' ORDER BY '.$afield[1] : '';
} }
$ahasil = []; $ahasil = [];
if (is_array($aarray)) $ahasil[$aarray[0]] = (!isset($afield[2])) ? $aarray[1] : [$aarray[1], $aarray[2]]; if (is_array($aarray)) $ahasil[$aarray[0]] = (!isset($afield[2])) ? $aarray[1] : [$aarray[1], $aarray[2]];
@@ -88,7 +87,7 @@ final class Form {
return $this->option($label, $field, $value, $enable, $req, $ahasil, $help, $change, $multi); return $this->option($label, $field, $value, $enable, $req, $ahasil, $help, $change, $multi);
} }
public function option_que(string $label, string $field, string|int|null $value=null, bool $enable=true, bool $req=false, ?string $query=null, ?array $afield=null, ?array $aarray=null, ?string $help=null, ?string $change=null): string {//oke public function option_que(string $label, string $field, string|int|null $value=null, bool $enable=true, bool $req=false, ?string $query=null, ?array $afield=null, ?array $aarray=null, ?string $help=null, ?string $change=null): string {
if (!is_array($afield)) $afield = ["ID", "Nama", "Label"]; if (!is_array($afield)) $afield = ["ID", "Nama", "Label"];
$ahasil = []; $ahasil = [];
if (is_array($aarray)) $ahasil[$aarray[0]] = (!isset($afield[2])) ? $aarray[1] : [$aarray[1], $aarray[2]]; if (is_array($aarray)) $ahasil[$aarray[0]] = (!isset($afield[2])) ? $aarray[1] : [$aarray[1], $aarray[2]];
@@ -101,15 +100,15 @@ final class Form {
return $this->option($label, $field, $value, $enable, $req, $ahasil, $help, $change); return $this->option($label, $field, $value, $enable, $req, $ahasil, $help, $change);
} }
public function option_jkl(string $label, string $field, string|int|null $value=null, bool $enable=true, bool $req=false, ?string $help=null, ?string $change=null): string {//oke public function option_jkl(string $label, string $field, string|int|null $value=null, bool $enable=true, bool $req=false, ?string $help=null, ?string $change=null): string {
return $this->option($label, $field, $value, $enable, $req, ["L" => "Laki-Laki", "P" => "Perempuan"], $help, $change); return $this->option($label, $field, $value, $enable, $req, ["L" => "Laki-Laki", "P" => "Perempuan"], $help, $change);
} }
public function option_ulevel(string $label, string $field, int $value=9, bool $enable=true, bool $req=false, ?string $help=null, ?string $change=null): string {//oke public function option_ulevel(string $label, string $field, int $value=9, bool $enable=true, bool $req=false, ?string $help=null, ?string $change=null): string {
return $this->option($label, $field, $value, $enable, $req, $this->session->get('__WEB_APP')['USER_LEVEL'], $help, $change); return $this->option($label, $field, $value, $enable, $req, $this->session->get('__WEB_APP')['USER_LEVEL'], $help, $change);
} }
public function radio(string $label, string $field, string|int|null $value=null, bool $enable=true, bool $req=false, array $arr=[], ?string $help=null, ?string $change=null): string {//oke public function radio(string $label, string $field, string|int|null $value=null, bool $enable=true, bool $req=false, array $arr=[], ?string $help=null, ?string $change=null): string {
$_val = array_values($arr); $_val = array_values($arr);
if (empty($value)) $value = $_val[0]; if (empty($value)) $value = $_val[0];
$_opsi = ''; $_opsi = '';
@@ -128,16 +127,16 @@ final class Form {
return $tout; return $tout;
} }
public function radio_jkl(string $label, string $field, ?string $value=null, bool $enable=true, bool $req=false, ?string $help=null, ?string $change=null): string {//oke public function radio_jkl(string $label, string $field, ?string $value=null, bool $enable=true, bool $req=false, ?string $help=null, ?string $change=null): string {
return $this->radio($label, $field, $value, $enable, $req, ["L" => "Laki-Laki", "P" => "Perempuan"], $help, $change); return $this->radio($label, $field, $value, $enable, $req, ["L" => "Laki-Laki", "P" => "Perempuan"], $help, $change);
} }
public function radio_gd(string $label, string $field, ?string $value=null, bool $enable=true, bool $req=false, ?string $help=null, ?string $change=null): string {//oke public function radio_gd(string $label, string $field, ?string $value=null, bool $enable=true, bool $req=false, ?string $help=null, ?string $change=null): string {
if (!empty($value)) $value = 'X'; if (!empty($value)) $value = 'X';
return $this->radio($label, $field, $value, $enable, $req, ["A"=>"A", "B"=>"B", "AB"=>"AB", "O"=>"O", "X"=>"NONE"], $help, $change); return $this->radio($label, $field, $value, $enable, $req, ["A"=>"A", "B"=>"B", "AB"=>"AB", "O"=>"O", "X"=>"NONE"], $help, $change);
} }
public function checkbox(string $label, string $field, string|int|null $value=null, bool $enable=true, bool $req=false, array $arr=[], ?string $help=null, ?string $change=null): string {//oke public function checkbox(string $label, string $field, string|int|null $value=null, bool $enable=true, bool $req=false, array $arr=[], ?string $help=null, ?string $change=null): string {
$_val = array_values($arr); $_val = array_values($arr);
if (empty($value)) $value = $_val[1]; if (empty($value)) $value = $_val[1];
$_opsi = ' odata="'.htmlspecialchars(json_encode($arr)).'"'; $_opsi = ' odata="'.htmlspecialchars(json_encode($arr)).'"';
@@ -151,7 +150,7 @@ final class Form {
return $tout; return $tout;
} }
public function switch(string $label, string $field, string|int|null $value=null, bool $enable=true, bool $req=false, array $arr=[], ?string $help=null, ?string $change=null): string {//oke public function switch(string $label, string $field, string|int|null $value=null, bool $enable=true, bool $req=false, array $arr=[], ?string $help=null, ?string $change=null): string {
$_val = array_values($arr); $_val = array_values($arr);
if (empty($value)) $value = $_val[1]; if (empty($value)) $value = $_val[1];
$_opsi = ' odata="'.htmlspecialchars(json_encode($arr)).'"'; $_opsi = ' odata="'.htmlspecialchars(json_encode($arr)).'"';
@@ -165,7 +164,7 @@ final class Form {
return $tout; return $tout;
} }
public function textbox(string $label, string $field, string|int|null $value=null, bool $enable=true, bool $req=false, string $type="text", ?string $holdtxt=null, ?int $maxsize=null, ?string $help=null, ?string $keyup=null, ?string $blur=null): string {//oke public function textbox(string $label, string $field, string|int|null $value=null, bool $enable=true, bool $req=false, string $type="text", ?string $holdtxt=null, ?int $maxsize=null, ?string $help=null, ?string $keyup=null, ?string $blur=null): string {
$_opsi = ''; $_opsi = '';
if (!empty($keyup)) $_opsi .= ' okyup="'.$keyup.'"'; if (!empty($keyup)) $_opsi .= ' okyup="'.$keyup.'"';
if (!empty($blur)) $_opsi .= ' oblur="'.$blur.'"'; if (!empty($blur)) $_opsi .= ' oblur="'.$blur.'"';
@@ -184,7 +183,7 @@ final class Form {
return $tout; return $tout;
} }
public function textauto(string $label, string $field, array $avalue=['value'=>0,'text'=>""], bool $enable=true, bool $req=false, ?string $holdtxt=null, ?int $maxsize=null, ?string $help=null): string {//oke public function textauto(string $label, string $field, array $avalue=['value'=>0,'text'=>""], bool $enable=true, bool $req=false, ?string $holdtxt=null, ?int $maxsize=null, ?string $help=null): string {
$_opsi = ''; $_opsi = '';
if (!empty($holdtxt)) $_opsi .= ' placeholder="'.$holdtxt.'"'; if (!empty($holdtxt)) $_opsi .= ' placeholder="'.$holdtxt.'"';
if (!empty($maxsize)) $_opsi .= ' maxlength="'.$maxsize.'"'; if (!empty($maxsize)) $_opsi .= ' maxlength="'.$maxsize.'"';
@@ -195,7 +194,7 @@ final class Form {
return $tout; return $tout;
} }
public function datebox(string $label, string $field, ?string $value=null, bool $enable=true, bool $req=false, ?string $help=null, ?string $keyup=null, ?string $blur=null): string {//oke public function datebox(string $label, string $field, ?string $value=null, bool $enable=true, bool $req=false, ?string $help=null, ?string $keyup=null, ?string $blur=null): string {
if (!empty($value)) $value = tgl_sql2str($value); if (!empty($value)) $value = tgl_sql2str($value);
$tout = '<div class="input-group date">'; $tout = '<div class="input-group date">';
$tout .= $this->textbox($label, $field, $value, $enable, $req, "pickdate", "dd-mm-yyyy", null, $help, $keyup, $blur); $tout .= $this->textbox($label, $field, $value, $enable, $req, "pickdate", "dd-mm-yyyy", null, $help, $keyup, $blur);
@@ -204,11 +203,11 @@ final class Form {
return $tout; return $tout;
} }
public function timebox(string $label, string $field, ?string $value=null, bool $enable=true, bool $req=false, ?string $help=null, ?string $keyup=null, ?string $blur=null): string {//oke public function timebox(string $label, string $field, ?string $value=null, bool $enable=true, bool $req=false, ?string $help=null, ?string $keyup=null, ?string $blur=null): string {
return $this->textbox($label, $field, $value, $enable, $req, "picktime", "hh:mm:ss", 10, $help, $keyup, $blur); return $this->textbox($label, $field, $value, $enable, $req, "picktime", "hh:mm:ss", 10, $help, $keyup, $blur);
} }
public function textarea(string $label, string $field, ?string $value=null, bool $enable=true, bool $req=false, int $rows=1, ?string $holdtxt=null, ?string $help=null, ?string $keyup=null, ?string $blur=null): string {//oke public function textarea(string $label, string $field, ?string $value=null, bool $enable=true, bool $req=false, int $rows=1, ?string $holdtxt=null, ?string $help=null, ?string $keyup=null, ?string $blur=null): string {
$_opsi = ''; $_opsi = '';
if (!empty($keyup)) $_opsi .= ' okyup="'.$keyup.'"'; if (!empty($keyup)) $_opsi .= ' okyup="'.$keyup.'"';
if (!empty($blur)) $_opsi .= ' oblur="'.$blur.'"'; if (!empty($blur)) $_opsi .= ' oblur="'.$blur.'"';
@@ -220,17 +219,17 @@ final class Form {
return $tout; return $tout;
} }
public function plaintext(string $label, string $field, string|int|null $value=null): string {//oke public function plaintext(string $label, string $field, string|int|null $value=null): string {
$tout = '<input type="text" class="form-control-plaintext" id="'.$field.'" name="'.$field.'" value="'.$value.'" readonly />'; $tout = '<input type="text" class="form-control-plaintext" id="'.$field.'" name="'.$field.'" value="'.$value.'" readonly />';
$this->__aform[$field] = ['label' => $label, 'help' => "", 'form' => $tout]; $this->__aform[$field] = ['label' => $label, 'help' => "", 'form' => $tout];
return $tout; return $tout;
} }
public function password(string $label, string $field, ?string $value=null, bool $enable=true, bool $req=false, ?string $holdtxt=null, ?int $maxsize=null, ?string $help=null, ?string $keyup=null): string {//oke public function password(string $label, string $field, ?string $value=null, bool $enable=true, bool $req=false, ?string $holdtxt=null, ?int $maxsize=null, ?string $help=null, ?string $keyup=null): string {
return $this->textbox($label, $field, $value, $enable, $req, "password", $holdtxt, $maxsize, $help, $keyup, null); return $this->textbox($label, $field, $value, $enable, $req, "password", $holdtxt, $maxsize, $help, $keyup, null);
} }
public function color(string $label, string $field, ?string $value=null, bool $enable=true, bool $req=false, ?string $help=null, ?string $change=null): string {//oke public function color(string $label, string $field, ?string $value=null, bool $enable=true, bool $req=false, ?string $help=null, ?string $change=null): string {
$_opsi = ''; $_opsi = '';
if (!empty($change)) $_opsi .= ' ochan="'.$change.'"'; if (!empty($change)) $_opsi .= ' ochan="'.$change.'"';
if ($enable===false) $_opsi .= ' disabled=true'; if ($enable===false) $_opsi .= ' disabled=true';
@@ -240,20 +239,19 @@ final class Form {
return $tout; return $tout;
} }
public function hidden(string $field, string|int|null $value=null, string $class="text"): string {//oke public function hidden(string $field, string|int|null $value=null, string $class="text"): string {
$tout = '<input type="hidden" id="'.$field.'" value="'.$value.'" class="'.$class.'" />'; $tout = '<input type="hidden" id="'.$field.'" value="'.$value.'" class="'.$class.'" />';
$this->__ahide[$field] = $tout; $this->__ahide[$field] = $tout;
return $tout; return $tout;
} }
public function clear() { public function clear(): void {
$this->__aform = []; $this->__aform = [];
} }
public function show($tstr) { public function show(int $lebar_kolom = 4): string {
if ($tstr === 0) $tstr = 4;//default $col_left = 'col-sm-' . ($lebar_kolom+2) . ' col-lg-' . $lebar_kolom;
$col_left = 'col-sm-' . ($tstr+2) . ' col-lg-' . $tstr; $col_right = 'col-sm-' . (10-$lebar_kolom) . ' col-lg-' . (12-$lebar_kolom);
$col_right = 'col-sm-' . (10-$tstr) . ' col-lg-' . (12-$tstr);
$tres = ''; $tres = '';
foreach ($this->__aform as $_key => $_val) { foreach ($this->__aform as $_key => $_val) {
$tres .= sprintf('<div class="row mb-1"><label class="%s col-form-label" for="%s">%s</label><div class="%s">%s %s</div></div>', $col_left, $_key, $_val['label'], $col_right, $_val['form'], (empty($_val['help'])?'':'<span class="help-block"><small>'.$_val['help'].'</small></span>')); $tres .= sprintf('<div class="row mb-1"><label class="%s col-form-label" for="%s">%s</label><div class="%s">%s %s</div></div>', $col_left, $_key, $_val['label'], $col_right, $_val['form'], (empty($_val['help'])?'':'<span class="help-block"><small>'.$_val['help'].'</small></span>'));
+53 -24
View File
@@ -3,40 +3,43 @@
/******************************************************************* /*******************************************************************
Module : /Web/Menu.php Module : /Web/Menu.php
Desc. : Class menu Desc. : Class Menu Manajemen
Created By : Siau Pheng ([email protected]). Created By : Siau Pheng ([email protected]).
Created Date : January 16th, 2008. Created Date : January 16th, 2008.
Last Modified : December 26th, 2025. Last Modified : August 22nd, 2026.
(c) 2008 - 2025, 3FONIA Software; WWW.3FONIA.COM. (c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/ *******************************************************************/
//OK
declare(strict_types=1); declare(strict_types=1);
namespace siaupheng\webapp\Web; namespace siaupheng\webapp\Web;
use flight\Engine; use \flight\Engine;
use flight\Session; use \flight\Session;
use flight\database\SimplePdo; use \flight\database\SimplePdo;
final class Menu { final class Menu {
private array $webapp;
private array $webuser;
protected Engine $app; protected Engine $app;
protected SimplePdo $db; protected SimplePdo $db;
protected Session $session; protected Session $session;
public function __construct(?Engine $app = null){ public function __construct(Engine $app, SimplePdo $db, Session $session){
$this->app = (empty($app) === true) ? \Flight::app() : $app; $this->app = $app;
$this->db = $this->app->db(); $this->db = $db;
$this->session = $this->app->session(); $this->session = $session;
$this->webapp = $session->get('__WEB_APP', ['APP_MODULE'=>'', 'PARENT_SITE'=>'', 'PARENT_SUB'=>false]);
$this->webuser = $session->get('__WEB_USER', ['Menu'=>'', 'Menu_Grup'=>'', 'MENU_MODUL'=>[]]);
} }
public function Menu_Sidebar() { public function Sidebar(): string {
$a_modul = []; $a_modul = [];
$is_modul = ($this->session->get('__WEB_APP', ['APP_MODULE'=>''])['APP_MODULE'] <> '') ? true : false; $is_modul = ($this->webapp['APP_MODULE'] !== '') ? true : false;
if ($is_modul == true) { if ($is_modul == true) {
$a_modul[] = $this->session->get('__WEB_APP')['APP_MODULE']; $a_modul[] = $this->webapp['APP_MODULE'];
} else { } else {
$atmp = $this->db->fetchAll('SELECT * FROM app_menu WHERE Level=0 AND Aktif=1 AND Modul<>"IND" ORDER BY Urut'); $atmp = $this->db->fetchAll('SELECT * FROM app_menu WHERE Level=0 AND Aktif=1 AND Modul<>"IND" ORDER BY Urut');
foreach ($atmp as $tmp) { foreach ($atmp as $tmp) {
@@ -44,7 +47,7 @@ final class Menu {
} }
} }
$my_menu = array_unique(array_filter(explode(",", $this->session->get('__WEB_USER', ['Menu_Grup'=>''])['Menu_Grup'].",".$this->session->get('__WEB_USER', ['Menu'=>''])['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 (?)'; $tsql = 'SELECT * FROM app_menu WHERE Aktif=1 AND Modul IN (?) AND Kode IN (?)';
if ($is_modul == true) $tsql .= ' AND Level>0'; if ($is_modul == true) $tsql .= ' AND Level>0';
@@ -70,12 +73,12 @@ final class Menu {
return $thasil; return $thasil;
} }
public function Menu_Header() { public function Header(): string {
$a_modul = []; $a_modul = [];
$is_modul = ($this->session->get('__WEB_APP', ['APP_MODULE'=>''])['APP_MODULE'] <> '') ? true : false; $is_modul = ($this->webapp['APP_MODULE'] !== '') ? true : false;
$mulai_level = 0; $mulai_level = 0;
if ($is_modul == true) { if ($is_modul == true) {
$a_modul[] = $this->session->get('__WEB_APP')['APP_MODULE']; $a_modul[] = $this->webapp['APP_MODULE'];
$mulai_level = 1; $mulai_level = 1;
} else { } else {
$atmp = $this->db->fetchAll('SELECT * FROM app_menu WHERE Level=0 AND Aktif=1 AND Modul<>"IND" ORDER BY Urut'); $atmp = $this->db->fetchAll('SELECT * FROM app_menu WHERE Level=0 AND Aktif=1 AND Modul<>"IND" ORDER BY Urut');
@@ -84,7 +87,7 @@ final class Menu {
} }
} }
$my_menu = array_unique(array_filter(explode(",", $this->session->get('__WEB_USER', ['Menu_Grup'=>''])['Menu_Grup'].",".$this->session->get('__WEB_USER', ['Menu'=>''])['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 (?)'; $tsql = 'SELECT * FROM app_menu WHERE Aktif=1 AND Modul IN (?) AND Kode IN (?)';
if ($is_modul == true) $tsql .= ' AND Level>0'; if ($is_modul == true) $tsql .= ' AND Level>0';
@@ -116,9 +119,35 @@ final class Menu {
return $thasil; return $thasil;
} }
static function MenuJSON($db = null, $page = "", $tquery = "") { public function Modul(): string {
$_mdb = (empty($db) === true) ? new SimplePdo() : $db; $t_modul = '';
$_query = ($tquery=="") ? "" : ",'".$tquery."'"; if (is_array($this->webuser['MENU_MODUL']) && count($this->webuser['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 = str_replace(['http://','https://'], "", $_host);
if ($this->webapp['PARENT_SUB'] === true) {
$_subs = explode('.', $_host);
if (count($_subs) > 2) array_shift($_subs);
$href1 = "//";
$href2 = "." . implode('.', $_subs);
} else {
$href1 = "//" . $_host . '/';
$href2 = "";
}
}
foreach ($this->webuser['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>';
}
}
return $t_modul;
}
static function MenuJSON(SimplePdo $db, string $page = "", string $q = ""): array {
$ajson = ['login' => true]; $ajson = ['login' => true];
$apage = ['Link' => ""]; $apage = ['Link' => ""];
@@ -130,14 +159,14 @@ final class Menu {
if ($acus_page[$page] ?? false) { if ($acus_page[$page] ?? false) {
$apage = $acus_page[$page]; $apage = $acus_page[$page];
} else if ($page <> "") { } else if ($page <> "") {
$apage = $_mdb->fetchRow('SELECT * FROM app_menu WHERE Kode=?', [$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; $ajson['iswindow'] = ($apage['Width'] > 0) ? true : false;
$ajson['width'] = $apage['Width']; $ajson['width'] = $apage['Width'];
$ajson['title'] = $apage['Judul']; $ajson['title'] = $apage['Judul'];
$ajson['button'] = is_json($apage['Button']) ? json_decode($apage['Button']) : $apage['Button']; $ajson['button'] = json_validate($apage['Button']) ? json_decode($apage['Button']) : $apage['Button'];
$ajson['php'] = $apage['Link']; $ajson['php'] = $apage['Link'];
$ajson['func'] = $apage['JS']; $ajson['func'] = $apage['JS'];
$ajson['kode'] = $apage['Kode']; $ajson['kode'] = $apage['Kode'];
+12 -13
View File
@@ -3,16 +3,15 @@
/******************************************************************* /*******************************************************************
Module : /Web/Param.php Module : /Web/Param.php
Desc. : Class data parameter dari client side Desc. : Class Parameter Manajemen
Created By : Siau Pheng ([email protected]). Created By : Siau Pheng ([email protected]).
Created Date : November 14th, 2013. Created Date : November 14th, 2013.
Last Modified : August 8th, 2026. Last Modified : August 22nd, 2026.
(c) 2013 - 2026, 3FONIA Software; WWW.3FONIA.COM. (c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/ *******************************************************************/
//OK
declare(strict_types=1); declare(strict_types=1);
namespace siaupheng\webapp\Web; namespace siaupheng\webapp\Web;
@@ -26,7 +25,7 @@ final class Param {
if (count(self::$__ahasil)==0) self::__data(); if (count(self::$__ahasil)==0) self::__data();
} }
private static function __data() { private static function __data(): void {
global $app; global $app;
if (empty($app)) $app = \Flight::app(); if (empty($app)) $app = \Flight::app();
$_asumber = array_merge($app->request()->query->getData(), $app->request()->data->getData()); $_asumber = array_merge($app->request()->query->getData(), $app->request()->data->getData());
@@ -35,28 +34,28 @@ final class Param {
} }
} }
public static function safeSQL($tstr = "") { public static function safeSQL(string $str = ""): string {
$_se = array("\\","\0","\n","\r","\x1a","'",'"'); $_se = array("\\","\0","\n","\r","\x1a","'",'"');
$_re = array("\\\\","\\0","\\n","\\r","\Z","\'",'\"'); $_re = array("\\\\","\\0","\\n","\\r","\Z","\'",'\"');
return str_replace($_se, $_re, $tstr); return str_replace($_se, $_re, $str);
} }
public static function Get($tkey = "", $tdef = null) { public static function Get(string $key = "", mixed $def = null): mixed {
if (count(self::$__ahasil)==0) self::__data(); if (count(self::$__ahasil)==0) self::__data();
if (isset(self::$__ahasil[$tkey]) && self::$__ahasil[$tkey]) return self::$__ahasil[$tkey]; if (isset(self::$__ahasil[$key]) && self::$__ahasil[$key]) return self::$__ahasil[$key];
return $tdef; return $def;
} }
public static function Get_Text($tkey = "", $tdef = null) { public static function Get_Text(string $key, mixed $def = null): mixed {
if (count(self::$__ahasil)==0) self::__data(); if (count(self::$__ahasil)==0) self::__data();
$_str = (isset(self::$__ahasil[$tkey])) ? self::$__ahasil[$tkey] : $tdef; $_str = (isset(self::$__ahasil[$key])) ? self::$__ahasil[$key] : $def;
$_str = str_replace("\\r", "", $_str); $_str = str_replace("\\r", "", $_str);
$_str = str_replace("\\n", " ", $_str); $_str = str_replace("\\n", " ", $_str);
$_str = str_replace("\\t", " ", $_str); $_str = str_replace("\\t", " ", $_str);
return (trim($_str)); return (trim($_str));
} }
public static function Get_Array() { public static function Get_Array(): array {
if (count(self::$__ahasil)==0) self::__data(); if (count(self::$__ahasil)==0) self::__data();
return self::$__ahasil; return self::$__ahasil;
} }
+10 -7
View File
@@ -18,15 +18,18 @@ declare(strict_types=1);
namespace siaupheng\webapp\Web; namespace siaupheng\webapp\Web;
use flight\Engine; use flight\Engine;
use flight\Session;
use flight\database\SimplePdo; use flight\database\SimplePdo;
final class Register { final class Register {
protected Engine $app; protected Engine $app;
protected SimplePdo $db; protected SimplePdo $db;
protected Session $session;
public function __construct(?Engine $app = null){ public function __construct(Engine $app, SimplePdo $db, Session $session){
$this->app = (empty($app) === true) ? \Flight::app() : $app; $this->app = $app;
$this->db = $this->app->db(); $this->db = $db;
$this->session = $session;
} }
public static function reg_id() { public static function reg_id() {
@@ -41,13 +44,13 @@ final class Register {
return (substr($id,0,6)."-".substr($id,6,5)."-".substr($id,11,5)."-".substr($id,16,5)."-".substr($id,21,5)."-".substr($id,26,6)); return (substr($id,0,6)."-".substr($id,6,5)."-".substr($id,11,5)."-".substr($id,16,5)."-".substr($id,21,5)."-".substr($id,26,6));
} }
public static function reg_check() { static function reg_check(Session $session) {//oke
$webapp = (array)\Flight::app()->session()->get('__WEB_APP'); $webapp = $session->get('__WEB_APP');
return (bool)(isset($webapp['REG_STATUS']) && $webapp['REG_STATUS']) ?? false; return (bool)(isset($webapp['REG_STATUS']) && $webapp['REG_STATUS']) ?? false;
} }
public function reg_status(array $apps) { static function reg_status(SimplePdo $db, array $apps) {//oke
$kode_db = (bool)$this->db->fetchField('SELECT UPPER(CONVERT(MD5(CONCAT(REG_YEAR,CONVERT(MD5(CONCAT(REG_ID,REG_NAME)) using latin1),REG_ID,REG_NAME)) using latin1))=REG_CODE FROM app_config WHERE REG_ID=?', [$apps['APP_CODE'] ?? '']); $kode_db = (bool)$db->fetchField('SELECT UPPER(CONVERT(MD5(CONCAT(REG_YEAR,CONVERT(MD5(CONCAT(REG_ID,REG_NAME)) using latin1),REG_ID,REG_NAME)) using latin1))=REG_CODE FROM app_config WHERE REG_ID=?', [$apps['APP_CODE'] ?? '']);
return [ 'REG_STATUS' => $kode_db === true ]; return [ 'REG_STATUS' => $kode_db === true ];
} }
} }
+8 -9
View File
@@ -3,22 +3,21 @@
/******************************************************************* /*******************************************************************
Module : /Web/Table.php Module : /Web/Table.php
Desc. : HTML Table (jQuery & Bootstrap) Desc. : Datatable (jQuery & Bootstrap)
Created By : Siau Pheng ([email protected]). Created By : Siau Pheng ([email protected]).
Created Date : January 16th, 2008. Created Date : January 16th, 2008.
Last Modified : August 16th, 2026. Last Modified : August 22nd, 2026.
(c) 2008 - 2026, 3FONIA Software; WWW.3FONIA.COM. (c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/ *******************************************************************/
//OK
declare(strict_types=1); declare(strict_types=1);
namespace siaupheng\webapp\Web; namespace siaupheng\webapp\Web;
use flight\Engine; use \flight\Engine;
use flight\database\SimplePdo; use \flight\database\SimplePdo;
final class Table { final class Table {
private $__ttable = ""; private $__ttable = "";
@@ -46,9 +45,9 @@ final class Table {
protected SimplePdo $db; protected SimplePdo $db;
protected array $data; protected array $data;
public function __construct(?Engine $app = null) { public function __construct(Engine $app, SimplePdo $db) {
$this->app = (empty($app) === true) ? \Flight::app() : $app; $this->app = $app;
$this->db = $this->app->db(); $this->db = $db;
$this->data = $this->app->request()->data->getData(); $this->data = $this->app->request()->data->getData();
} }
+10 -10
View File
@@ -6,9 +6,9 @@
Desc. : Class Format Angka & Terbilang Desc. : Class Format Angka & Terbilang
Created By : Siau Pheng (siaupheng@3fonia.com). Created By : Siau Pheng (siaupheng@3fonia.com).
Created Date : February 12th, 2009. Created Date : February 12th, 2009.
Last Modified : May 6th, 2021. Last Modified : August 22nd, 2026.
(c) 2009 - 2021, 3FONIA Software; WWW.3FONIA.COM. (c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/ *******************************************************************/
@@ -17,14 +17,14 @@ declare(strict_types=1);
namespace siaupheng\webapp\Web; namespace siaupheng\webapp\Web;
final class Terbilang { final class Terbilang {
private $numb = array("","Satu","Dua","Tiga","Empat","Lima","Enam","Tujuh","Delapan","Sembilan"); private $numb = ["","Satu","Dua","Tiga","Empat","Lima","Enam","Tujuh","Delapan","Sembilan"];
public function __construct() {} public function __construct() {}
public function Terbilang($nilai=0, $muang="Rupiah") { public function Terbilang(float $nilai=0, string $muang="Rupiah"): string {
$number = 0; $number = 0;
$hasil = ""; $hasil = "";
$int = trim($nilai); $int = (string)$nilai;
if (is_int(strpos($int,"-"))) { if (is_int(strpos($int,"-"))) {
$number = substr($int,strpos($int,"-")+1,strlen($int)); $number = substr($int,strpos($int,"-")+1,strlen($int));
$hasil = "Minus"; $hasil = "Minus";
@@ -36,11 +36,11 @@ final class Terbilang {
$xpos = strpos($number,"."); $xpos = strpos($number,".");
if (is_int($xpos)) { if (is_int($xpos)) {
# round : Untuk pembulatan angka desimal, strlen : untuk menghitung jumlah karakter # round : Untuk pembulatan angka desimal, strlen : untuk menghitung jumlah karakter
$pecahan = round(substr($number,$xpos,strlen($number)),2); $pecahan = round((float)substr($number,$xpos,strlen($number)),2);
$last = substr($number,0,$xpos); $last = substr($number,0,$xpos);
} else { } else {
$pecahan = ""; $pecahan = "";
$last = $number; $last = (float)$number;
} }
if ($last==0 || $number==0) { if ($last==0 || $number==0) {
return $hasil."NOL ".$muang; return $hasil."NOL ".$muang;
@@ -71,12 +71,12 @@ final class Terbilang {
return $hasil . $kata; return $hasil . $kata;
} }
private function mod($a, $b) { private function mod(float $a, float $b): float {
return $a-$b*floor($a/$b); return $a-$b*floor($a/$b);
} }
private function tigadigit($amount, $suffix="") { private function tigadigit(float $amount, string $suffix=""): string {
$last = (int) $amount; $last = (int)$amount;
$kata = ""; $kata = "";
if ($last == 1 && $suffix=="Ribu") { if ($last == 1 && $suffix=="Ribu") {
$kata = " Seribu"; $kata = " Seribu";
+7 -7
View File
@@ -6,27 +6,27 @@
Desc. : Class Update Aplikasi Otomatis Desc. : Class Update Aplikasi Otomatis
Created By : Siau Pheng (siaupheng@3fonia.com). Created By : Siau Pheng (siaupheng@3fonia.com).
Created Date : June 14th, 2013. Created Date : June 14th, 2013.
Last Modified : August 12th, 2026. Last Modified : August 22nd, 2026.
(c) 2013 - 2026, 3FONIA Software; WWW.3FONIA.COM. (c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/ *******************************************************************/
//OK
declare(strict_types=1); declare(strict_types=1);
namespace siaupheng\webapp\Web; namespace siaupheng\webapp\Web;
use flight\Engine; use \flight\Engine;
use \flight\Session;
final class Update { final class Update {
protected Array $__conf = []; protected Array $__conf = [];
protected Bool $is_git = false; protected Bool $is_git = false;
protected Engine $app; protected Engine $app;
public function __construct(?Engine $app = null){ public function __construct(Engine $app, Session $session){
$this->app = (empty($app) === true) ? \Flight::app() : $app; $this->app = $app;
$this->__conf = $app->session()->get('__WEB_APP'); $this->__conf = $session->get('__WEB_APP');
$this->current(); $this->current();
} }