change namespace to Webapp\

This commit is contained in:
2026-08-26 14:01:47 +07:00
parent 81ff3bc60c
commit 64e9c02c38
26 changed files with 179 additions and 181 deletions
+1 -1
View File
@@ -4,7 +4,7 @@
[![Software License][ico-license]](LICENSE.md) [![Software License][ico-license]](LICENSE.md)
[![Total Downloads][ico-downloads]][link-downloads] [![Total Downloads][ico-downloads]][link-downloads]
webapp adalah framework webbase aplikasi yang dibuat dengan basis kode PHP dan digabungkan dengan beberapa repo lain, sehingga menghasilkan webbase framework yang efisien dan efektif. Webapp adalah framework webbase aplikasi yang dibuat dengan basis kode PHP dan digabungkan dengan beberapa repo lain, sehingga menghasilkan webbase framework yang efisien dan efektif.
Maintenance versi repo tambahan, akan dilakukan secara periodik dengan mempertimbangkan kesiapan infrastruktur framework secara utuh. Maintenance versi repo tambahan, akan dilakukan secara periodik dengan mempertimbangkan kesiapan infrastruktur framework secara utuh.
+11
View File
@@ -493,3 +493,14 @@ input.double, input.integer, input.number {
background-color: #d8dbe0; background-color: #d8dbe0;
opacity: 1; opacity: 1;
} }
/** bashboard **/
.my-bashboard {
height: auto;
}
@media (min-width: 992px) {
.my-bashboard {
height: 500px;
}
}
+2 -3
View File
@@ -373,7 +373,7 @@ var FoniaJS = {
}); });
$('.option-tags').each((i, el) => { $('.option-tags').each((i, el) => {
const elm = $(el); const elm = $(el);
if (!jQuery.isFunction(jQuery.fn.select2)) return; if (typeof jQuery.fn.select2 !== 'function') return;
var _opts = {tags: false, dropdownAutoWidth: true, width: 'auto', theme: 'bootstrap-5', language: 'id'}; var _opts = {tags: false, dropdownAutoWidth: true, width: 'auto', theme: 'bootstrap-5', language: 'id'};
var _dmodal = elm.closest('div.modal'); var _dmodal = elm.closest('div.modal');
if (_dmodal.length) _opts.dropdownParent = _dmodal; if (_dmodal.length) _opts.dropdownParent = _dmodal;
@@ -798,7 +798,7 @@ class _Request_JSONF extends _Request {
strBody += '</tbody>'; strBody += '</tbody>';
$(divData).append(strTab + strHead + strBody + strFoot + '</table>'); $(divData).append(strTab + strHead + strBody + strFoot + '</table>');
var opsi = { responsive: true, columnDefs: [{responsivePriority:1,targets:0},{responsivePriority:2,targets:1}], lengthMenu: [], dom: '<"row"<"col-sm-12"tr>><"row"<"col-sm-12 col-lg-auto"<"toolbar">><"col-sm-3 col-lg-auto ms-lg-auto"l><"col-sm-9 col-lg-auto"p>>', autoWidth: false, processing: true, searching: false, columns: aSortCol, order: [[iCol, (ini.config.sort_dir=='A'?'asc':'desc')]], pageLength: ini.config.row_count, stateSave: true, stateSaveCallback: function(sett,data){localStorage.setItem(ini.id,JSON.stringify(data));}, stateLoadCallback: function(sett){try{var data=JSON.parse(localStorage.getItem(ini.id))??{};data.length=ini.config.row_count;return data;}catch(e){console.log(e)}} }; var opsi = { responsive: true, columnDefs: [{responsivePriority:1,targets:0},{responsivePriority:2,targets:1},{responsivePriority:0,targets:-1}], lengthMenu: [], dom: '<"row"<"col-sm-12"tr>><"row"<"col-sm-12 col-lg-auto"<"toolbar">><"col-sm-3 col-lg-auto ms-lg-auto"l><"col-sm-9 col-lg-auto"p>>', autoWidth: false, processing: true, searching: false, columns: aSortCol, order: [[iCol, (ini.config.sort_dir=='A'?'asc':'desc')]], pageLength: ini.config.row_count, stateSave: true, stateSaveCallback: function(sett,data){localStorage.setItem(ini.id,JSON.stringify(data));}, stateLoadCallback: function(sett){try{var data=JSON.parse(localStorage.getItem(ini.id))??{};data.length=ini.config.row_count;return data;}catch(e){console.log(e)}} };
/** start live db **/ /** start live db **/
if (ini.config.live){ if (ini.config.live){
var post_data = {}; var post_data = {};
@@ -1009,7 +1009,6 @@ class _Request_JSONF extends _Request {
tr.addClass('dt-hasChild parent'); tr.addClass('dt-hasChild parent');
} }
}); });
// disnini
} }
var otabel = $('#'+ini.id+'Tabel').DataTable(opsi); var otabel = $('#'+ini.id+'Tabel').DataTable(opsi);
} }
+3 -2
View File
@@ -17,7 +17,7 @@
} }
], ],
"require": { "require": {
"php" : ">=8.3", "php": ">=8.3",
"flightphp/core": "^3.18", "flightphp/core": "^3.18",
"flightphp/session": "^0.3", "flightphp/session": "^0.3",
"mpdf/mpdf": ">=8.0", "mpdf/mpdf": ">=8.0",
@@ -27,8 +27,9 @@
"shuchkin/simplexlsxgen": "^1.3" "shuchkin/simplexlsxgen": "^1.3"
}, },
"autoload": { "autoload": {
"classmap": ["src/"],
"psr-4": { "psr-4": {
"siaupheng\\webapp\\": "src/" "Webapp\\": "src/"
}, },
"files": [ "files": [
"src/Function/Auth.php", "src/Function/Auth.php",
+1 -1
View File
@@ -14,7 +14,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace siaupheng\webapp\DB; namespace Webapp\DB;
use \Exception; use \Exception;
use \flight\Engine; use \flight\Engine;
+6 -6
View File
@@ -15,7 +15,7 @@
//todo: deprecated //todo: deprecated
declare(strict_types=1); declare(strict_types=1);
namespace siaupheng\webapp\DB; namespace Webapp\DB;
final class DumpSQL { final class DumpSQL {
private $__adata = array(); private $__adata = array();
@@ -24,7 +24,7 @@ final class DumpSQL {
public function __construct($db = null){ public function __construct($db = null){
if (is_resource($db)) { $this->__db = $db; } if (is_resource($db)) { $this->__db = $db; }
else { $this->__db = new \siaupheng\webapp\DB\MySQL(); } else { $this->__db = new Webapp\DB\MySQL(); }
$this->__adata = $this->__db->getConfig(); $this->__adata = $this->__db->getConfig();
} }
@@ -56,7 +56,7 @@ final class DumpSQL {
public function create_backup($folder="backups") { public function create_backup($folder="backups") {
$namafile = date("Ymd").".gz"; $namafile = date("Ymd").".gz";
$folder = $_SESSION['__WEB_APP']['REAL_PATH'].$folder."/".date("Y"); $folder = PROJECT_ROOT.$folder."/".date("Y");
if (!is_dir($folder)) mkdir($folder); if (!is_dir($folder)) mkdir($folder);
if (file_exists($folder."/".$namafile)) unlink($folder."/".$namafile); if (file_exists($folder."/".$namafile)) unlink($folder."/".$namafile);
$_cmd = "mysqldump -C --hex-blob -h ".$this->__adata['host']." -P ".$this->__adata['port']." -u ".$this->__adata['user']." -p".$this->__adata['pwd']." ".$this->__adata['db']; $_cmd = "mysqldump -C --hex-blob -h ".$this->__adata['host']." -P ".$this->__adata['port']." -u ".$this->__adata['user']." -p".$this->__adata['pwd']." ".$this->__adata['db'];
@@ -97,8 +97,8 @@ final class DumpSQL {
} }
public function disk_space() { public function disk_space() {
$_free = disk_free_space($_SESSION['__WEB_APP']['REAL_PATH']); $_free = disk_free_space(PROJECT_ROOT);
$_tot = disk_total_space($_SESSION['__WEB_APP']['REAL_PATH']); $_tot = disk_total_space(PROJECT_ROOT);
$_used = $_tot - $_free; $_used = $_tot - $_free;
$_aret = array(); $_aret = array();
$_aret['TOTAL'] = $this->format_bytes($_tot); $_aret['TOTAL'] = $this->format_bytes($_tot);
@@ -110,7 +110,7 @@ final class DumpSQL {
} }
public function update_list($folder="backups") { public function update_list($folder="backups") {
$folder = $_SESSION['__WEB_APP']['REAL_PATH'].$folder; $folder = PROJECT_ROOT.$folder;
$this->__db->Query("TRUNCATE TABLE app_backup"); $this->__db->Query("TRUNCATE TABLE app_backup");
$afile = $this->get_file_list($folder); $afile = $this->get_file_list($folder);
foreach($afile as $_key => $_val) { foreach($afile as $_key => $_val) {
+2 -2
View File
@@ -14,12 +14,12 @@
declare(strict_types=1); declare(strict_types=1);
namespace siaupheng\webapp\DB; namespace 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 Webapp\Web\Param;
final class SQL { final class SQL {
private string $_ttable; private string $_ttable;
+1 -1
View File
@@ -14,7 +14,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace siaupheng\webapp\Data; namespace Webapp\Data;
define( DELI_CSV, ";" ); define( DELI_CSV, ";" );
define( CRLF_CSV, "\r\n" ); define( CRLF_CSV, "\r\n" );
+1 -1
View File
@@ -14,7 +14,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace siaupheng\webapp\Data; namespace Webapp\Data;
use \flight\Engine; use \flight\Engine;
use \flight\Session; use \flight\Session;
+1 -1
View File
@@ -14,7 +14,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace siaupheng\webapp\Data; namespace Webapp\Data;
use \flight\Session; use \flight\Session;
use \Mpdf; use \Mpdf;
+1 -1
View File
@@ -15,7 +15,7 @@
//todo: deprecated //todo: deprecated
declare(strict_types=1); declare(strict_types=1);
namespace siaupheng\webapp\Data; namespace Webapp\Data;
final class SimpleXLS { final class SimpleXLS {
private $__wbook = null; private $__wbook = null;
+1 -1
View File
@@ -15,7 +15,7 @@
//todo: deprecated //todo: deprecated
declare(strict_types=1); declare(strict_types=1);
namespace siaupheng\webapp\Data; namespace Webapp\Data;
use PhpOffice\PhpSpreadsheet\IOFactory; use PhpOffice\PhpSpreadsheet\IOFactory;
+5 -6
View File
@@ -18,14 +18,14 @@ use \flight\Session;
if (!function_exists('user_level')) { if (!function_exists('user_level')) {
function user_level(Session $session, int $level = 9): bool { function user_level(Session $session, int $level = 9): bool {
if ($session->get('__WEB_USER', ['Level'=>9]) <= $level) return true; if ($session->get('__WEB_USER', ['Level'=>9])['Level'] <= $level) return true;
return false; return false;
} }
} }
if (!function_exists('user_level_not')) { if (!function_exists('user_level_not')) {
function user_level_not(Session $session, int $level = 9): bool { function user_level_not(Session $session, int $level = 9): bool {
if ($session->get('__WEB_USER', ['Level'=>9]) !== $level) return true; if ($session->get('__WEB_USER', ['Level'=>9])['Level'] !== $level) return true;
return false; return false;
} }
} }
@@ -38,8 +38,9 @@ if (!function_exists('user_logged')) {
if (!function_exists('user_id')) { if (!function_exists('user_id')) {
function user_id(Session $session, int $digit = 0): string|int { function user_id(Session $session, int $digit = 0): string|int {
if ($digit > 0) return isi_nol($session->get('__WEB_USER', ['UserID'=>0])['UserID'], $digit); $id_user = (int)$session->get('__WEB_USER', ['UserID'=>0])['UserID'];
return (int)$session->get('__WEB_USER', ['UserID'=>0])['UserID']; if ($digit > 0) return isi_nol($id_user, $digit);
return $id_user;
} }
} }
@@ -60,5 +61,3 @@ if (!function_exists('user_nama')) {
return (string)$session->get('__WEB_USER', ['Nama'=>''])['Nama']; return (string)$session->get('__WEB_USER', ['Nama'=>''])['Nama'];
} }
} }
?>
+91 -90
View File
@@ -16,20 +16,20 @@ declare(strict_types=1);
/*************************** FORMAT ANGKA / CURRENCY *****************************/ /*************************** FORMAT ANGKA / CURRENCY *****************************/
if (!function_exists('rupiah')) {//oke if (!function_exists('rupiah')) {
function rupiah(string|float $angka = 0, int $desi = 0): string { function rupiah(mixed $angka = 0, int $desi = 0): string {
return number_format((float)$angka, $desi, ",", "."); return number_format((float) $angka, $desi, ",", ".");
} }
} }
if (!function_exists('rupiah2')) {//oke if (!function_exists('rupiah2')) {
function rupiah2($angka = 0): string { function rupiah2(mixed $angka = 0): string {
return rupiah($angka, 2); return rupiah($angka, 2);
} }
} }
//todo: deprecated /* todo: deprecated
/*if (!function_exists('rupiah30')) { if (!function_exists('rupiah30')) {
function rupiah30($angka = 0): string { 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);
@@ -38,77 +38,78 @@ if (!function_exists('rupiah2')) {//oke
}*/ }*/
if (!function_exists('kurung_rup')) { if (!function_exists('kurung_rup')) {
function kurung_rup($angka = 0, $desi = 0) { function kurung_rup(mixed $angka = 0, int $desi = 0): string {
$thasil = rupiah(abs($angka), $desi); $thasil = rupiah(abs((float) $angka), $desi);
if ($angka<0) return "(".$thasil.")"; if ((float) $angka < 0) return "(".$thasil.")";
return $thasil." "; return $thasil." ";
} }
} }
if (!function_exists('kurung')) { if (!function_exists('kurung')) {
function kurung($angka = 0, $desi = 0) { function kurung(mixed $angka = 0, int $desi = 0): string {
$thasil = uang(abs($angka), $desi); $thasil = uang(abs((float) $angka), $desi);
if ($angka<0) return "(".$thasil.")"; if ((float) $angka < 0) return "(".$thasil.")";
return $thasil." "; return $thasil." ";
} }
} }
if (!function_exists('kurung2')) { if (!function_exists('kurung2')) {
function kurung2($angka = 0) { function kurung2(mixed $angka = 0): string {
return kurung($angka, 2); return kurung($angka, 2);
} }
} }
if (!function_exists('uang')) {//oke if (!function_exists('uang')) {
function uang(string|float $angka = '0', int $desi = 0) { function uang(mixed $angka = 0, int $desi = 0): string {
$angka = str_replace(",", "", (string)$angka); $angka = str_replace(",", "", (string) $angka);
return number_format((float)$angka, $desi); return number_format((float) $angka, $desi);
} }
} }
if (!function_exists('uang2')) { if (!function_exists('uang2')) {
function uang2($angka = 0) { function uang2(mixed $angka = 0): string {
return uang($angka, 2); return uang($angka, 2);
} }
} }
/* todo: deprecated
if (!function_exists('koma30')) { if (!function_exists('koma30')) {
function koma30($angka = 0) { function koma30($angka = 0) {
$nilai = explode(".", $angka); $nilai = explode(".", $angka);
$hasil = (intval($nilai[1])==0) ? uang($angka, 0) : uang($angka, 3); $hasil = (intval($nilai[1])==0) ? uang($angka, 0) : uang($angka, 3);
return $hasil; return $hasil;
} }
} }*/
if (!function_exists('items')) { if (!function_exists('items')) {
function items($item = 0) { function items(mixed $item = 0): string {
return rupiah($item)." Items"; return rupiah($item)." Items";
} }
} }
if (!function_exists('records')) { if (!function_exists('records')) {
function records($item = 0) { function records(mixed $item = 0): string {
return rupiah($item)." Records"; return rupiah($item)." Records";
} }
} }
if (!function_exists('baris')) { if (!function_exists('baris')) {
function baris($item = 0) { function baris(mixed $item = 0): string {
return rupiah($item)." Baris"; return rupiah($item)." Baris";
} }
} }
if (!function_exists('npwp')) { if (!function_exists('npwp')) {
function npwp($nomor = "000000000000000") { function npwp(string $nomor = "000000000000000"): string {
return substr($nomor,0,2).".".substr($nomor,2,3).".".substr($nomor,5,3).".".substr($nomor,8,1)."-".substr($nomor,9,3).".".substr($nomor,12,3); return substr($nomor,0,2).".".substr($nomor,2,3).".".substr($nomor,5,3).".".substr($nomor,8,1)."-".substr($nomor,9,3).".".substr($nomor,12,3);
} }
} }
if (!function_exists('romawi')) { if (!function_exists('romawi')) {
function romawi($n) { function romawi(int $n): string {
$hasil = ""; $hasil = "";
$iromawi = array("","I","II","III","IV","V","VI","VII","VIII","IX","X",20=>"XX",30=>"XXX",40=>"XL",50=>"L",60=>"LX",70=>"LXX",80=>"LXXX",90=>"XC",100=>"C",200=>"CC",300=>"CCC",400=>"CD",500=>"D",600=>"DC",700=>"DCC",800=>"DCCC",900=>"CM",1000=>"M",2000=>"MM",3000=>"MMM"); $iromawi = ["","I","II","III","IV","V","VI","VII","VIII","IX","X",20=>"XX",30=>"XXX",40=>"XL",50=>"L",60=>"LX",70=>"LXX",80=>"LXXX",90=>"XC",100=>"C",200=>"CC",300=>"CCC",400=>"CD",500=>"D",600=>"DC",700=>"DCC",800=>"DCCC",900=>"CM",1000=>"M",2000=>"MM",3000=>"MMM"];
if (array_key_exists($n,$iromawi)) { if (array_key_exists($n, $iromawi)) {
$hasil = $iromawi[$n]; $hasil = $iromawi[$n];
} else if ($n >= 11 && $n <= 99) { } else if ($n >= 11 && $n <= 99) {
$i = $n % 10; $i = $n % 10;
@@ -125,7 +126,7 @@ if (!function_exists('romawi')) {
} }
if (!function_exists('abjad')) { if (!function_exists('abjad')) {
function abjad($n) { function abjad(int $n): string {
$_str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; $_str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
return substr($_str, ($n-1), 1); return substr($_str, ($n-1), 1);
} }
@@ -134,8 +135,8 @@ if (!function_exists('abjad')) {
/*************************** FORM CONTROL *****************************/ /*************************** FORM CONTROL *****************************/
if (!function_exists('checkbox')) { if (!function_exists('checkbox')) {
function checkbox($nilai = 0) { function checkbox(mixed $nilai): string {
$thasil = ((is_string($nilai) && ($nilai=="N" || $nilai=="0")) or (is_numeric($nilai) && $nilai==0) or (is_bool($nilai) && $nilai==false)) ? "circle text-secondary" : "check-circle text-info"; $thasil = (empty($nilai) or (is_string($nilai) && ($nilai=="N" || $nilai=="0")) or (is_numeric($nilai) && $nilai==0) or (is_bool($nilai) && $nilai==false)) ? "circle text-secondary" : "check-circle text-info";
return '<i class="fs-6 bi-'.$thasil.'"></i>'; return '<i class="fs-6 bi-'.$thasil.'"></i>';
} }
} }
@@ -143,34 +144,34 @@ if (!function_exists('checkbox')) {
/*************************** FORMAT TANGGAL / KALENDER *****************************/ /*************************** FORMAT TANGGAL / KALENDER *****************************/
if (!function_exists('sqltgl')) { if (!function_exists('sqltgl')) {
function sqltgl($waktu = "0") { function sqltgl(string $waktu): string {
return tgl_sql2str($waktu); return tgl_sql2str($waktu);
} }
} }
if (!function_exists('sqltgls')) { if (!function_exists('sqltgls')) {
function sqltgls($waktu = "0") { function sqltgls(string $waktu): string {
return tgl_sql2str($waktu, false, true); return tgl_sql2str($waktu, false, true);
} }
} }
if (!function_exists('sqljam')) { if (!function_exists('sqljam')) {
function sqljam($waktu = "0") { function sqljam(string $waktu): string {
return tgl_sql2str($waktu, true); return tgl_sql2str($waktu, true);
} }
} }
if (!function_exists('sqljams')) { if (!function_exists('sqljams')) {
function sqljams($waktu = "0") { function sqljams(string $waktu): string {
return tgl_sql2str($waktu, true, true); return tgl_sql2str($waktu, true, true);
} }
} }
if (!function_exists('tgl_sql2str')) { if (!function_exists('tgl_sql2str')) {
function tgl_sql2str($waktu = "0", $jam = false, $short = false) { function tgl_sql2str(string $waktu, bool $jam = false, bool $short = false): string {
if ($waktu=="0" || $waktu=="") return; if (empty($waktu)) return '';
$atgl = explode(" ", $waktu); $atgl = explode(" ", $waktu);
$sjam = ($jam) ? ((empty($atgl[1]))?date("H:i:s"):$atgl[1]) : ""; $sjam = ($jam) ? ((empty($atgl[1])) ? date("H:i:s") : $atgl[1]) : "";
$atgl = explode("-", $atgl[0]); $atgl = explode("-", $atgl[0]);
$stgl = $atgl[2]."-".$atgl[1]."-".$atgl[0]; $stgl = $atgl[2]."-".$atgl[1]."-".$atgl[0];
if ($short) $stgl = $atgl[2].".".$atgl[1].".".substr($atgl[0],2); if ($short) $stgl = $atgl[2].".".$atgl[1].".".substr($atgl[0],2);
@@ -179,66 +180,66 @@ if (!function_exists('tgl_sql2str')) {
} }
if (!function_exists('tgl_ymd')) { if (!function_exists('tgl_ymd')) {
function tgl_ymd($jam = false) { function tgl_ymd(bool $jam = false): string {
return (($jam) ? date("Y-m-d H:i:s") : date("Y-m-d")); return (($jam) ? date("Y-m-d H:i:s") : date("Y-m-d"));
} }
} }
if (!function_exists('tgl_dmy')) { if (!function_exists('tgl_dmy')) {
function tgl_dmy($jam = false) { function tgl_dmy(bool $jam = false): string {
return (($jam) ? date("d-m-Y H:i:s") : date("d-m-Y")); return (($jam) ? date("d-m-Y H:i:s") : date("d-m-Y"));
} }
} }
if (!function_exists('tgl_operasi')) { if (!function_exists('tgl_operasi')) {
function tgl_operasi($dtgl = "", $nhari = 0, $nbln = 0, $nthn = 0) { function tgl_operasi(string $tgl, int $hari = 0, int $bln = 0, int $thn = 0): string {
$atgl = explode("-", $dtgl); $atgl = explode("-", $tgl);
return date("d-m-Y", mktime(0,0,0, $atgl[1]+$nbln, $atgl[0]+$nhari, $atgl[2]+$nthn)); return date("d-m-Y", mktime(0,0,0, (int) $atgl[1]+$bln, (int) $atgl[0]+$hari, (int) $atgl[2]+$thn));
} }
} }
if (!function_exists('tgl_range_hari')) { if (!function_exists('tgl_range_hari')) {
function tgl_range_hari($dftgl="", $dttgl="", $bhitung_awal=false) { function tgl_range_hari(string $tgl_from, string $tgl_to, bool $hitung_awal = false): float {
$_start = strtotime(tgl_sql2str($dftgl)); if (empty($tgl_to) or empty($tgl_from)) return 0;
$_end = strtotime(tgl_sql2str($dttgl)); $_start = strtotime(tgl_sql2str($tgl_from));
return ceil(abs($_end - $_start) / 86400) + (($bhitung_awal==true)?1:0); $_end = strtotime(tgl_sql2str($tgl_to));
return ceil(abs($_end - $_start) / 86400) + (($hitung_awal)?1:0);
} }
} }
if (!function_exists('tgl_akhbln')) { if (!function_exists('tgl_akhbln')) {
function tgl_akhbln($tgl) { function tgl_akhbln(string $tgl): string {
if (empty($tgl)) return '';
$atgl = explode("-", $tgl); $atgl = explode("-", $tgl);
$ablna = array(31,28,31,30,31,30,31,31,30,31,30,31); $ablna = ['31','28','31','30','31','30','31','31','30','31','30','31'];
// jika tahun masehi dan bulan 2 // jika tahun masehi dan bulan 2
if ( (round($atgl[2]/4)==($atgl[2]/4)) && intval($atgl[1])==2 ) return "29-02-".$atgl[2]; if ((round((int) $atgl[2]/4) === ((int) $atgl[2]/4)) && (int) $atgl[1] === 2) return "29-02-".$atgl[2];
return $ablna[(intval($atgl[1])-1)]."-".isi_nol($atgl[1],2)."-".$atgl[2]; return $ablna[(int) $atgl[1]-1]."-".isi_nol($atgl[1],2)."-".$atgl[2];
} }
} }
if (!function_exists('tgl_panjang')) { if (!function_exists('tgl_panjang')) {
function tgl_panjang($dtgl = "") { function tgl_panjang(string $tgl): string {
if (trim($dtgl)=="") $dtgl = tgl_dmy(); if (empty($tgl)) $tgl = tgl_dmy();
$atgl = explode("-", $dtgl); $atgl = explode("-", $tgl);
$abulan = bulan_array(); $abulan = bulan_array();
return $atgl[0]." ".$abulan[intval($atgl[1])]." ".$atgl[2]; return $atgl[0]." ".$abulan[$atgl[1]]." ".$atgl[2];
} }
} }
if (!function_exists('tgl_hari')) { if (!function_exists('tgl_hari')) {
function tgl_hari($dtgl = "") { function tgl_hari(string $tgl): string {
$nhari = date("w"); $nhari = date("w");
if (trim($dtgl)!="") { if (!empty($tgl)) {
//$atgl = getdate($dtgl); $nhari = date("w", strtotime(tgl_sql2str($tgl)));
//$nhari = $atgl[wday];
$nhari = date("w", strtotime(tgl_sql2str($dtgl)));
} }
$ahari = array("0"=>"Minggu","1"=>"Senin","2"=>"Selasa","3"=>"Rabu","4"=>"Kamis","5"=>"Jum'at","6"=>"Sabtu"); $ahari = ["0"=>"Minggu","1"=>"Senin","2"=>"Selasa","3"=>"Rabu","4"=>"Kamis","5"=>"Jum'at","6"=>"Sabtu"];
return $ahari[$nhari]; return $ahari[$nhari];
} }
} }
if (!function_exists('tgl_triwulan')) { if (!function_exists('tgl_triwulan')) {
function tgl_triwulan($dtgl = "") { function tgl_triwulan(string $tgl): int {
if ($dtgl == "") { if (empty($tgl)) {
$dtgl = date("m"); $dtgl = date("m");
} else { } else {
$atgl = explode("-", $tgl); $atgl = explode("-", $tgl);
@@ -254,13 +255,13 @@ if (!function_exists('tgl_triwulan')) {
} }
if (!function_exists('bulan_array')) { if (!function_exists('bulan_array')) {
function bulan_array() { function bulan_array(): array {
return array("1"=>"Januari","2"=>"Februari","3"=>"Maret","4"=>"April","5"=>"Mei","6"=>"Juni","7"=>"Juli","8"=>"Agustus","9"=>"September","10"=>"Oktober","11"=>"November","12"=>"Desember"); return ["1"=>"Januari","2"=>"Februari","3"=>"Maret","4"=>"April","5"=>"Mei","6"=>"Juni","7"=>"Juli","8"=>"Agustus","9"=>"September","10"=>"Oktober","11"=>"November","12"=>"Desember"];
} }
} }
if (!function_exists('triwulan_array')) { if (!function_exists('triwulan_array')) {
function triwulan_array() { function triwulan_array(): array {
return ["1"=>"Triwulan 1","2"=>"Triwulan 2","3"=>"Triwulan 3","4"=>"Triwulan 4"]; return ["1"=>"Triwulan 1","2"=>"Triwulan 2","3"=>"Triwulan 3","4"=>"Triwulan 4"];
} }
} }
@@ -268,24 +269,25 @@ if (!function_exists('triwulan_array')) {
/*************************** FORMAT TAMPILAN & ERROR *****************************/ /*************************** FORMAT TAMPILAN & ERROR *****************************/
if (!function_exists('subjudul')) { if (!function_exists('subjudul')) {
function subjudul($tjudul) { function subjudul(string $judul): string {
return '<table border="0" align="center" valign="middle" width="100%" height="26px"><tr><td width="50%"><hr /></td><td>&nbsp;&nbsp;<span style="text-align:center;font-weight:bold;white-space:nowrap;">'.$tjudul.'</span>&nbsp;&nbsp;</td><td width="50%"><hr /></td></tr></table>'; return '<table border="0" align="center" valign="middle" width="100%" height="26px"><tr><td width="50%"><hr /></td><td>&nbsp;&nbsp;<span style="text-align:center;font-weight:bold;white-space:nowrap;">'.$judul.'</span>&nbsp;&nbsp;</td><td width="50%"><hr /></td></tr></table>';
} }
} }
/* todo: deprecated
if (!function_exists('showerror')) { if (!function_exists('showerror')) {
function showerror($terror) { function showerror(string $error): void {
echo '<input type="hidden" id="_Error" class="error" value="'.$terror.'!" />'; echo '<input type="hidden" id="_Error" class="error" value="'.$error.'!" />';
} }
} }*/
if (!function_exists('br2nl')) { if (!function_exists('br2nl')) {
function br2nl($string) { function br2nl(string $string): string {
return preg_replace('/\<br(\s*)?\/?\>/i', "\n\r", $string); return preg_replace('/\<br(\s*)?\/?\>/i', "\n\r", $string);
} }
} }
if (!function_exists('isi_nol')) {//oke if (!function_exists('isi_nol')) {
function isi_nol(string|int $nilai = 0, int $panjang = 1): string { function isi_nol(string|int $nilai = 0, int $panjang = 1): string {
$nilai = (string)$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;
@@ -293,7 +295,7 @@ if (!function_exists('isi_nol')) {//oke
} }
if (!function_exists('isMobile')) { if (!function_exists('isMobile')) {
function isMobile() { function isMobile(): bool {
$agen = $_SERVER['HTTP_USER_AGENT']; $agen = $_SERVER['HTTP_USER_AGENT'];
$amobile = ['Android', 'webOS', 'iPhone', 'iPad', 'iPod', 'BlackBerry', 'Windows Phone', 'Mobile']; $amobile = ['Android', 'webOS', 'iPhone', 'iPad', 'iPod', 'BlackBerry', 'Windows Phone', 'Mobile'];
foreach ($amobile as $keyword) { foreach ($amobile as $keyword) {
@@ -304,46 +306,47 @@ if (!function_exists('isMobile')) {
} }
if (!function_exists('isLinux')) { if (!function_exists('isLinux')) {
function isLinux() { function isLinux(): bool {
$agen = $_SERVER['HTTP_USER_AGENT']; $agen = $_SERVER['HTTP_USER_AGENT'];
if (stripos($agen,'linux') !== false) return true; if (stripos($agen, 'linux') !== false) return true;
return false; return false;
} }
} }
if (!function_exists('isIE')) { if (!function_exists('isIE')) {
function isIE() { function isIE(): bool {
$agen = $_SERVER['HTTP_USER_AGENT']; $agen = $_SERVER['HTTP_USER_AGENT'];
if (stripos($agen,'msie') !== false) return true; if (stripos($agen, 'msie') !== false) return true;
return false; return false;
} }
} }
if (!function_exists('isChrome')) { if (!function_exists('isChrome')) {
function isChrome() { function isChrome(): bool {
$agen = $_SERVER['HTTP_USER_AGENT']; $agen = $_SERVER['HTTP_USER_AGENT'];
if (stripos($agen,'chrome') !== false) return true; if (stripos($agen, 'chrome') !== false) return true;
return false; return false;
} }
} }
if (!function_exists('isFirefox')) { if (!function_exists('isFirefox')) {
function isFirefox() { function isFirefox(): bool {
$agen = $_SERVER['HTTP_USER_AGENT']; $agen = $_SERVER['HTTP_USER_AGENT'];
if (stripos($agen,'firefox') !== false) return true; if (stripos($agen, 'firefox') !== false) return true;
return false; return false;
} }
} }
/* todo: deprecated
if (!function_exists('potong')) { if (!function_exists('potong')) {
function potong($nilai) {//utk rkpd function potong($nilai) {//utk rkpd
return substr($nilai, 0, 60); return substr($nilai, 0, 60);
} }
} }*/
if (!function_exists('format_bytes')) { if (!function_exists('format_bytes')) {
function format_bytes($bytes) { function format_bytes(int $bytes): string {
if ($bytes < 1024) return $bytes.' B'; if ($bytes < 1024) return (string) $bytes.' B';
elseif ($bytes < 1048576) return uang2($bytes / 1024).' KB'; elseif ($bytes < 1048576) return uang2($bytes / 1024).' KB';
elseif ($bytes < 1073741824) return uang2($bytes / 1048576).' MB'; elseif ($bytes < 1073741824) return uang2($bytes / 1048576).' MB';
elseif ($bytes < 1099511627776) return uang2($bytes / 1073741824).' GB'; elseif ($bytes < 1099511627776) return uang2($bytes / 1073741824).' GB';
@@ -352,12 +355,10 @@ if (!function_exists('format_bytes')) {
} }
if (!function_exists('random_color')) { if (!function_exists('random_color')) {
function random_color($trans = "0.6") { function random_color(string $trans = "0.6"): string {
$col_r = mt_rand( 0, 255 ); $col_r = (string) mt_rand( 0, 255 );
$col_g = mt_rand( 0, 255 ); $col_g = (string) mt_rand( 0, 255 );
$col_b = mt_rand( 0, 255 ); $col_b = (string) mt_rand( 0, 255 );
return "rgba(".$col_r.",".$col_g.",".$col_b.",".$trans.")"; return "rgba(".$col_r.",".$col_g.",".$col_b.",".$trans.")";
} }
} }
?>
+1 -1
View File
@@ -14,7 +14,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace siaupheng\webapp\Printer; namespace Webapp\Printer;
use \flight\Session; use \flight\Session;
+4 -4
View File
@@ -14,7 +14,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace siaupheng\webapp\Printer; namespace Webapp\Printer;
use \flight\Engine; use \flight\Engine;
use \flight\Session; use \flight\Session;
@@ -37,7 +37,7 @@ class PrintPOS {
public function __construct(Engine $app, Session $session) { public function __construct(Engine $app, Session $session) {
$this->app = $app; $this->app = $app;
$this->webapp = $session->get('__WEB_APP', ['APP_NAME'=>'', 'APP_VER'=>'', 'REAL_PATH'=>'']); $this->webapp = $session->get('__WEB_APP', ['APP_NAME'=>'', 'APP_VER'=>'']);
$this->webuser = $session->get('__WEB_USER', ['UserID'=>0, 'Username'=>'']); $this->webuser = $session->get('__WEB_USER', ['UserID'=>0, 'Username'=>'']);
} }
@@ -58,8 +58,8 @@ class PrintPOS {
} }
public function set_header_logo(string $logo_file = ""): void { public function set_header_logo(string $logo_file = ""): void {
if (!empty($logo_file) && file_exists($this->webapp['REAL_PATH']."assets/images/".$logo_file)) { if (!empty($logo_file) && file_exists(PROJECT_ROOT."assets/images/".$logo_file)) {
$this->_config['logo'] = $this->webapp['WEB_PATH']."assets/images/".$logo_file; $this->_config['logo'] = PROJECT_BASE."assets/images/".$logo_file;
} }
} }
+4 -4
View File
@@ -14,7 +14,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace siaupheng\webapp\Printer; namespace Webapp\Printer;
use \flight\Engine; use \flight\Engine;
use \flight\Session; use \flight\Session;
@@ -32,13 +32,13 @@ class PrintRAW {
'opendraw' => false, 'opendraw' => false,
'cutpaper' => false, 'cutpaper' => false,
]; ];
private array $webapp;
private array $webuser;
protected Engine $app; protected Engine $app;
protected array $webapp;
protected array $webuser;
public function __construct(Engine $app, Session $session) { public function __construct(Engine $app, Session $session) {
$this->app = $app; $this->app = $app;
$this->webapp = $session->get('__WEB_APP', ['APP_NAME'=>'', 'APP_VER'=>'', 'REAL_PATH'=>'']); $this->webapp = $session->get('__WEB_APP', ['APP_NAME'=>'', 'APP_VER'=>'']);
$this->webuser = $session->get('__WEB_USER', ['UserID'=>0, 'Username'=>'']); $this->webuser = $session->get('__WEB_USER', ['UserID'=>0, 'Username'=>'']);
} }
+1 -1
View File
@@ -14,7 +14,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace siaupheng\webapp\Web; namespace Webapp\Web;
use \flight\Engine; use \flight\Engine;
use \flight\Session; use \flight\Session;
+1 -1
View File
@@ -14,7 +14,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace siaupheng\webapp\Web; namespace Webapp\Web;
class Button { class Button {
private $__abutton =[]; private $__abutton =[];
+12 -12
View File
@@ -14,7 +14,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace siaupheng\webapp\Web; namespace Webapp\Web;
use \flight\Engine; use \flight\Engine;
use \flight\Session; use \flight\Session;
@@ -33,7 +33,7 @@ final class Form {
$this->session = $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 { public function option(string $label, string $field, mixed $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';
@@ -69,7 +69,7 @@ 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 { public function option_db(string $label, string $field, mixed $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)) {
@@ -87,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 { public function option_que(string $label, string $field, mixed $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]];
@@ -100,7 +100,7 @@ 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 { public function option_jkl(string $label, string $field, mixed $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);
} }
@@ -108,7 +108,7 @@ final class Form {
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 { public function radio(string $label, string $field, mixed $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 = '';
@@ -136,7 +136,7 @@ final class Form {
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 { public function checkbox(string $label, string $field, mixed $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)).'"';
@@ -150,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 { public function switch(string $label, string $field, mixed $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)).'"';
@@ -164,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 { public function textbox(string $label, string $field, mixed $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.'"';
@@ -178,7 +178,7 @@ final class Form {
if ($type === 'double') $value = uang2($value); if ($type === 'double') $value = uang2($value);
$type = "text"; $type = "text";
} }
$tout = '<input type="'.$type.'" class="form-control'.$_tclass.'" id="'.$field.'" name="'.$field.'" value="'.$value.'"'.$_opsi.' />'; $tout = '<input type="'.$type.'" class="form-control'.$_tclass.'" id="'.$field.'" name="'.$field.'" value="'.(string)$value.'"'.$_opsi.' />';
$this->__aform[$field] = [ 'label' => $label, 'help' => $help, 'form' => $tout ]; $this->__aform[$field] = [ 'label' => $label, 'help' => $help, 'form' => $tout ];
return $tout; return $tout;
} }
@@ -219,7 +219,7 @@ final class Form {
return $tout; return $tout;
} }
public function plaintext(string $label, string $field, string|int|null $value=null): string { public function plaintext(string $label, string $field, mixed $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;
@@ -239,7 +239,7 @@ final class Form {
return $tout; return $tout;
} }
public function hidden(string $field, string|int|null $value=null, string $class="text"): string { public function hidden(string $field, mixed $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;
+1 -1
View File
@@ -14,7 +14,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace siaupheng\webapp\Web; namespace Webapp\Web;
use \flight\Engine; use \flight\Engine;
use \flight\Session; use \flight\Session;
+2 -2
View File
@@ -14,7 +14,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace siaupheng\webapp\Web; namespace Webapp\Web;
use \flight\Engine; use \flight\Engine;
@@ -30,7 +30,7 @@ final class Param {
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());
foreach ($_asumber as $__key => $__val) { foreach ($_asumber as $__key => $__val) {
self::$__ahasil[$__key] = self::safeSQL($__val); self::$__ahasil[$__key] = is_string($__val) ? self::safeSQL($__val) : $__val;
} }
} }
+13 -23
View File
@@ -6,50 +6,40 @@
Desc. : Class Registrasi Aplikasi Desc. : Class Registrasi Aplikasi
Created By : Siau Pheng (siaupheng@3fonia.com). Created By : Siau Pheng (siaupheng@3fonia.com).
Created Date : November 23th, 2011. Created Date : November 23th, 2011.
Last Modified : August 11th, 2026. Last Modified : August 22nd, 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\Web; namespace Webapp\Web;
use flight\Engine; use \flight\Engine;
use flight\Session; use \flight\Session;
use flight\database\SimplePdo; use \flight\database\SimplePdo;
final class Register { final class Register {
protected Engine $app; public function __construct(){
protected SimplePdo $db;
protected Session $session;
public function __construct(Engine $app, SimplePdo $db, Session $session){
$this->app = $app;
$this->db = $db;
$this->session = $session;
} }
public static function reg_id() { public static function reg_id(Session $session) {
$webapp = (array)\Flight::app()->session()->get('__WEB_APP'); $id = (string)$session->get('__WEB_APP', ['REG_ID'=>''])['REG_ID'];
$id = (string)$webapp['REG_ID'] ?? '';
return (substr($id,0,3).".".substr($id,3,3).".".substr($id,6)); return (substr($id,0,3).".".substr($id,3,3).".".substr($id,6));
} }
public static function reg_code() { public static function reg_code(Session $session) {
$webapp = (array)\Flight::app()->session()->get('__WEB_APP'); $id = (string)$session->get('__WEB_APP', ['REG_CODE'=>''])['REG_CODE'];
$id = (string)$webapp['REG_CODE'] ?? '';
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));
} }
static function reg_check(Session $session) {//oke public static function reg_check(Session $session) {
$webapp = $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;
} }
static function reg_status(SimplePdo $db, array $apps) {//oke public static function reg_status(SimplePdo $db, array $apps) {
$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'] ?? '']); $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 ];
} }
+2 -2
View File
@@ -14,7 +14,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace siaupheng\webapp\Web; namespace Webapp\Web;
use \flight\Engine; use \flight\Engine;
use \flight\database\SimplePdo; use \flight\database\SimplePdo;
@@ -81,7 +81,7 @@ final class Table {
} }
public function set_row_color(string $field = "", string $val = "", string $css = ""): void { public function set_row_color(string $field = "", string $val = "", string $css = ""): void {
if (epmty($field)) return; if (empty($field)) return;
$this->__arowcol[] = [ 'F' => $field, 'V' => $val, 'C' => $css ]; $this->__arowcol[] = [ 'F' => $field, 'V' => $val, 'C' => $css ];
} }
+1 -1
View File
@@ -14,7 +14,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace siaupheng\webapp\Web; namespace Webapp\Web;
final class Terbilang { final class Terbilang {
private $numb = ["","Satu","Dua","Tiga","Empat","Lima","Enam","Tujuh","Delapan","Sembilan"]; private $numb = ["","Satu","Dua","Tiga","Empat","Lima","Enam","Tujuh","Delapan","Sembilan"];
+10 -13
View File
@@ -14,14 +14,14 @@
declare(strict_types=1); declare(strict_types=1);
namespace siaupheng\webapp\Web; namespace Webapp\Web;
use \flight\Engine; use \flight\Engine;
use \flight\Session; use \flight\Session;
final class Update { final class Update {
protected Array $__conf = []; private Array $__conf = [];
protected Bool $is_git = false; private Bool $is_git = false;
protected Engine $app; protected Engine $app;
public function __construct(Engine $app, Session $session){ public function __construct(Engine $app, Session $session){
@@ -30,10 +30,8 @@ final class Update {
$this->current(); $this->current();
} }
public function current() { public function current(): void {
$_target = $this->__conf['REAL_PATH']; if (defined('PROJECT_ROOT')) chdir(PROJECT_ROOT);
if (isset($_target)) chdir($_target);
try { try {
$output = shell_exec("git log -1 --pretty=format:\"%H||%s||%ci\" --abbrev-commit 2>&1"); $output = shell_exec("git log -1 --pretty=format:\"%H||%s||%ci\" --abbrev-commit 2>&1");
if ($output) { if ($output) {
@@ -57,7 +55,7 @@ final class Update {
} }
} }
public function check() { public function check(): array {
$_ainfo['cur_version'] = $this->__conf['APP_BUILD']; $_ainfo['cur_version'] = $this->__conf['APP_BUILD'];
$_ainfo['cur_sha'] = substr($this->__conf['GIT_SHA1'], 0, 10); $_ainfo['cur_sha'] = substr($this->__conf['GIT_SHA1'], 0, 10);
$_ainfo['cur_sha1'] = $this->__conf['GIT_SHA1']; $_ainfo['cur_sha1'] = $this->__conf['GIT_SHA1'];
@@ -89,14 +87,13 @@ final class Update {
return $_ainfo; return $_ainfo;
} }
public function go() { public function go(): array {
$_target = $this->__conf['REAL_PATH'];
$_branch = $this->__conf['GIT_BRANCH'] ?? "main"; $_branch = $this->__conf['GIT_BRANCH'] ?? "main";
if (isset($_target)) { if (defined('PROJECT_ROOT')) {
chdir($_target); chdir(PROJECT_ROOT);
$output = shell_exec("git reset --hard HEAD && git pull origin {$_branch} 2>&1"); $output = shell_exec("git reset --hard HEAD && git pull origin {$_branch} 2>&1");
return ['success'=>true,'message'=>$output]; return ['success'=>true,'message'=>$output];
} else return ['success'=>false,'message'=>"Tanpa REAL_PATH !"]; } else return ['success'=>false,'message'=>"Tanpa PROJECT_ROOT !"];
} }
public function mysql() { public function mysql() {