Compare commits
2
Commits
v1.0.3
..
a2978ae927
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a2978ae927 | ||
|
|
64e9c02c38 |
@@ -4,7 +4,7 @@
|
||||
[![Software License][ico-license]](LICENSE.md)
|
||||
[![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.
|
||||
|
||||
|
||||
@@ -493,3 +493,14 @@ input.double, input.integer, input.number {
|
||||
background-color: #d8dbe0;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
/** bashboard **/
|
||||
.my-bashboard {
|
||||
height: auto;
|
||||
}
|
||||
|
||||
@media (min-width: 992px) {
|
||||
.my-bashboard {
|
||||
height: 500px;
|
||||
}
|
||||
}
|
||||
+2
-3
@@ -373,7 +373,7 @@ var FoniaJS = {
|
||||
});
|
||||
$('.option-tags').each((i, 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 _dmodal = elm.closest('div.modal');
|
||||
if (_dmodal.length) _opts.dropdownParent = _dmodal;
|
||||
@@ -798,7 +798,7 @@ class _Request_JSONF extends _Request {
|
||||
strBody += '</tbody>';
|
||||
|
||||
$(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 **/
|
||||
if (ini.config.live){
|
||||
var post_data = {};
|
||||
@@ -1009,7 +1009,6 @@ class _Request_JSONF extends _Request {
|
||||
tr.addClass('dt-hasChild parent');
|
||||
}
|
||||
});
|
||||
// disnini
|
||||
}
|
||||
var otabel = $('#'+ini.id+'Tabel').DataTable(opsi);
|
||||
}
|
||||
|
||||
+3
-2
@@ -17,7 +17,7 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php" : ">=8.3",
|
||||
"php": ">=8.3",
|
||||
"flightphp/core": "^3.18",
|
||||
"flightphp/session": "^0.3",
|
||||
"mpdf/mpdf": ">=8.0",
|
||||
@@ -27,8 +27,9 @@
|
||||
"shuchkin/simplexlsxgen": "^1.3"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": ["src/"],
|
||||
"psr-4": {
|
||||
"siaupheng\\webapp\\": "src/"
|
||||
"Webapp\\": "src/"
|
||||
},
|
||||
"files": [
|
||||
"src/Function/Auth.php",
|
||||
|
||||
+17
-4
@@ -3,7 +3,6 @@
|
||||
/*******************************************************************
|
||||
|
||||
Module : /DB/CheckSQL.php
|
||||
Desc. : Class Check SQL / Repair Database
|
||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||
Created Date : May 11th, 2011.
|
||||
Last Modified : August 21st, 2026.
|
||||
@@ -14,20 +13,34 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace siaupheng\webapp\DB;
|
||||
namespace Webapp\DB;
|
||||
|
||||
use \Exception;
|
||||
use \flight\Engine;
|
||||
use \flight\database\SimplePdo;
|
||||
|
||||
/**
|
||||
* Class CheckSQL
|
||||
*
|
||||
* Check Database Mysql/MariaDB dan Repair.
|
||||
*
|
||||
* @license MIT, https://www.3fonia.com
|
||||
* @copyright Copyright (c) 2008-2026, Siau Pheng <siaupheng@3fonia.com>
|
||||
*
|
||||
* @package Webapp\DB
|
||||
*/
|
||||
|
||||
final class CheckSQL {
|
||||
private Array $__atabel = [];
|
||||
protected Engine $app;
|
||||
protected SimplePdo $db;
|
||||
|
||||
public function __construct(Engine $app, SimplePdo $db) {
|
||||
/**
|
||||
* @param Engine $app
|
||||
*/
|
||||
public function __construct(Engine $app) {
|
||||
$this->app = $app;
|
||||
$this->db = $db;
|
||||
$this->db = $app->db();
|
||||
$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'");
|
||||
foreach ($arow as $row) {
|
||||
|
||||
+6
-6
@@ -15,7 +15,7 @@
|
||||
//todo: deprecated
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace siaupheng\webapp\DB;
|
||||
namespace Webapp\DB;
|
||||
|
||||
final class DumpSQL {
|
||||
private $__adata = array();
|
||||
@@ -24,7 +24,7 @@ final class DumpSQL {
|
||||
|
||||
public function __construct($db = null){
|
||||
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();
|
||||
}
|
||||
@@ -56,7 +56,7 @@ final class DumpSQL {
|
||||
|
||||
public function create_backup($folder="backups") {
|
||||
$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 (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'];
|
||||
@@ -97,8 +97,8 @@ final class DumpSQL {
|
||||
}
|
||||
|
||||
public function disk_space() {
|
||||
$_free = disk_free_space($_SESSION['__WEB_APP']['REAL_PATH']);
|
||||
$_tot = disk_total_space($_SESSION['__WEB_APP']['REAL_PATH']);
|
||||
$_free = disk_free_space(PROJECT_ROOT);
|
||||
$_tot = disk_total_space(PROJECT_ROOT);
|
||||
$_used = $_tot - $_free;
|
||||
$_aret = array();
|
||||
$_aret['TOTAL'] = $this->format_bytes($_tot);
|
||||
@@ -110,7 +110,7 @@ final class DumpSQL {
|
||||
}
|
||||
|
||||
public function update_list($folder="backups") {
|
||||
$folder = $_SESSION['__WEB_APP']['REAL_PATH'].$folder;
|
||||
$folder = PROJECT_ROOT.$folder;
|
||||
$this->__db->Query("TRUNCATE TABLE app_backup");
|
||||
$afile = $this->get_file_list($folder);
|
||||
foreach($afile as $_key => $_val) {
|
||||
|
||||
+19
-6
@@ -3,7 +3,6 @@
|
||||
/*******************************************************************
|
||||
|
||||
Module : /DB/SQL.php
|
||||
Desc. : Class Query database
|
||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||
Created Date : February 2nd, 2007.
|
||||
Last Modified : August 21st, 2026.
|
||||
@@ -14,12 +13,23 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace siaupheng\webapp\DB;
|
||||
namespace Webapp\DB;
|
||||
|
||||
use \flight\Engine;
|
||||
use \flight\Session;
|
||||
use \flight\database\SimplePdo;
|
||||
use siaupheng\webapp\Web\Param;
|
||||
use Webapp\Web\Param;
|
||||
|
||||
/**
|
||||
* Class SQL
|
||||
*
|
||||
* Database CRUD dengan data dari GET/POST.
|
||||
*
|
||||
* @license MIT, https://www.3fonia.com
|
||||
* @copyright Copyright (c) 2008-2026, Siau Pheng <siaupheng@3fonia.com>
|
||||
*
|
||||
* @package Webapp\DB
|
||||
*/
|
||||
|
||||
final class SQL {
|
||||
private string $_ttable;
|
||||
@@ -29,10 +39,13 @@ final class SQL {
|
||||
protected SimplePdo $db;
|
||||
protected array webuser;
|
||||
|
||||
public function __construct(Engine $app, Ssssion $session, SimplePdo $db){
|
||||
/**
|
||||
* @param Engine $app
|
||||
*/
|
||||
public function __construct(Engine $app){
|
||||
$this->app = $app;
|
||||
$this->db = $db;
|
||||
$this->webuser = $session->get('__WEB_USER', ['UserID'=>0, 'UNIX'=>0]);
|
||||
$this->db = $app->db();
|
||||
$this->webuser = $app->session()->get('__WEB_USER', ['UserID'=>0, 'UNIX'=>0]);
|
||||
}
|
||||
|
||||
//todo: deprecated
|
||||
|
||||
+12
-2
@@ -3,7 +3,6 @@
|
||||
/*******************************************************************
|
||||
|
||||
Module : /Data/CSV.php
|
||||
Desc. : Class pembuatan file CSV
|
||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||
Created Date : April 2rd, 2011.
|
||||
Last Modified : August 21st, 2026.
|
||||
@@ -14,11 +13,22 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace siaupheng\webapp\Data;
|
||||
namespace Webapp\Data;
|
||||
|
||||
define( DELI_CSV, ";" );
|
||||
define( CRLF_CSV, "\r\n" );
|
||||
|
||||
/**
|
||||
* Class CSV
|
||||
*
|
||||
* Membuat file CSV.
|
||||
*
|
||||
* @license MIT, https://www.3fonia.com
|
||||
* @copyright Copyright (c) 2008-2026, Siau Pheng <siaupheng@3fonia.com>
|
||||
*
|
||||
* @package Webapp\Data
|
||||
*/
|
||||
|
||||
final class CSV {
|
||||
private $__avalue = [];
|
||||
private $__atabel = [];
|
||||
|
||||
+18
-4
@@ -3,7 +3,6 @@
|
||||
/*******************************************************************
|
||||
|
||||
Module : /Data/Cache.php
|
||||
Desc. : Class cache css dan js aplikasi
|
||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||
Created Date : March 16th, 2008.
|
||||
Last Modified : August 21st, 2026.
|
||||
@@ -14,7 +13,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace siaupheng\webapp\Data;
|
||||
namespace Webapp\Data;
|
||||
|
||||
use \flight\Engine;
|
||||
use \flight\Session;
|
||||
@@ -22,6 +21,17 @@ use \FilesystemIterator;
|
||||
use \MatthiasMullie\Minify;
|
||||
use \SplFileInfo;
|
||||
|
||||
/**
|
||||
* Class Cache
|
||||
*
|
||||
* Membuat Cache gabungan CSS dan JS sesuai dengan session.
|
||||
*
|
||||
* @license MIT, https://www.3fonia.com
|
||||
* @copyright Copyright (c) 2008-2026, Siau Pheng <siaupheng@3fonia.com>
|
||||
*
|
||||
* @package Webapp\Data
|
||||
*/
|
||||
|
||||
final class Cache {
|
||||
private $__cachedir = "";
|
||||
private $__cssdir = "";
|
||||
@@ -34,9 +44,13 @@ final class Cache {
|
||||
protected Session $session;
|
||||
protected array $__asset = [];
|
||||
|
||||
public function __construct(Engine $app, Session $session) {
|
||||
/**
|
||||
* @param Engine $app
|
||||
*/
|
||||
|
||||
public function __construct(Engine $app) {
|
||||
$this->app = $app;
|
||||
$this->session = $session;
|
||||
$this->session = $app->session();
|
||||
$rootdir = (defined('PROJECT_ROOT')) ? PROJECT_ROOT : $this->app->get('app.project_root');
|
||||
$this->__cachedir = $rootdir . '/public/chunks/';
|
||||
$this->__localedir = $rootdir . '/app/Scripts/locale/';
|
||||
|
||||
+20
-6
@@ -3,7 +3,6 @@
|
||||
/*******************************************************************
|
||||
|
||||
Module : /Data/PDF.php
|
||||
Desc. : Class pembuatan file PDF
|
||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||
Created Date : April 18th, 2015.
|
||||
Last Modified : August 21st, 2026.
|
||||
@@ -14,11 +13,22 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace siaupheng\webapp\Data;
|
||||
namespace Webapp\Data;
|
||||
|
||||
use \flight\Session;
|
||||
use \flight\Engine;
|
||||
use \Mpdf;
|
||||
|
||||
/**
|
||||
* Class PDF
|
||||
*
|
||||
* Membuat file PDF.
|
||||
*
|
||||
* @license MIT, https://www.3fonia.com
|
||||
* @copyright Copyright (c) 2008-2026, Siau Pheng <siaupheng@3fonia.com>
|
||||
*
|
||||
* @package Webapp\Data
|
||||
*/
|
||||
|
||||
final class PDF {
|
||||
private $__avalue = [];
|
||||
private $__atabel = [];
|
||||
@@ -27,9 +37,13 @@ final class PDF {
|
||||
protected array $webapp;
|
||||
protected array $webuser;
|
||||
|
||||
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'=>'']);
|
||||
/**
|
||||
* @param Engine $app
|
||||
*/
|
||||
|
||||
public function __construct(Engine $app) {
|
||||
$this->webapp = $app->session()->get('__WEB_APP', ['REG_NAME'=>'', 'APP_NAME'=>'', 'APP_VER'=>'']);
|
||||
$this->webuser = $app->session()->get('__WEB_USER', ['UserID'=>0, 'Username'=>'']);
|
||||
}
|
||||
|
||||
public function add_field(string $nama, string|int $lebar=0, string $align="L", string $func="", int $kol=1): void {
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
//todo: deprecated
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace siaupheng\webapp\Data;
|
||||
namespace Webapp\Data;
|
||||
|
||||
final class SimpleXLS {
|
||||
private $__wbook = null;
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
//todo: deprecated
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace siaupheng\webapp\Data;
|
||||
namespace Webapp\Data;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
|
||||
@@ -18,14 +18,14 @@ use \flight\Session;
|
||||
|
||||
if (!function_exists('user_level')) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('user_level_not')) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -38,8 +38,9 @@ if (!function_exists('user_logged')) {
|
||||
|
||||
if (!function_exists('user_id')) {
|
||||
function user_id(Session $session, int $digit = 0): string|int {
|
||||
if ($digit > 0) return isi_nol($session->get('__WEB_USER', ['UserID'=>0])['UserID'], $digit);
|
||||
return (int)$session->get('__WEB_USER', ['UserID'=>0])['UserID'];
|
||||
$id_user = (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'];
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
+91
-90
@@ -16,20 +16,20 @@ declare(strict_types=1);
|
||||
|
||||
/*************************** FORMAT ANGKA / CURRENCY *****************************/
|
||||
|
||||
if (!function_exists('rupiah')) {//oke
|
||||
function rupiah(string|float $angka = 0, int $desi = 0): string {
|
||||
return number_format((float)$angka, $desi, ",", ".");
|
||||
if (!function_exists('rupiah')) {
|
||||
function rupiah(mixed $angka = 0, int $desi = 0): string {
|
||||
return number_format((float) $angka, $desi, ",", ".");
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('rupiah2')) {//oke
|
||||
function rupiah2($angka = 0): string {
|
||||
if (!function_exists('rupiah2')) {
|
||||
function rupiah2(mixed $angka = 0): string {
|
||||
return rupiah($angka, 2);
|
||||
}
|
||||
}
|
||||
|
||||
//todo: deprecated
|
||||
/*if (!function_exists('rupiah30')) {
|
||||
/* todo: deprecated
|
||||
if (!function_exists('rupiah30')) {
|
||||
function rupiah30($angka = 0): string {
|
||||
$nilai = explode(".", $angka);
|
||||
$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')) {
|
||||
function kurung_rup($angka = 0, $desi = 0) {
|
||||
$thasil = rupiah(abs($angka), $desi);
|
||||
if ($angka<0) return "(".$thasil.")";
|
||||
function kurung_rup(mixed $angka = 0, int $desi = 0): string {
|
||||
$thasil = rupiah(abs((float) $angka), $desi);
|
||||
if ((float) $angka < 0) return "(".$thasil.")";
|
||||
return $thasil." ";
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('kurung')) {
|
||||
function kurung($angka = 0, $desi = 0) {
|
||||
$thasil = uang(abs($angka), $desi);
|
||||
if ($angka<0) return "(".$thasil.")";
|
||||
function kurung(mixed $angka = 0, int $desi = 0): string {
|
||||
$thasil = uang(abs((float) $angka), $desi);
|
||||
if ((float) $angka < 0) return "(".$thasil.")";
|
||||
return $thasil." ";
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('kurung2')) {
|
||||
function kurung2($angka = 0) {
|
||||
function kurung2(mixed $angka = 0): string {
|
||||
return kurung($angka, 2);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('uang')) {//oke
|
||||
function uang(string|float $angka = '0', int $desi = 0) {
|
||||
$angka = str_replace(",", "", (string)$angka);
|
||||
return number_format((float)$angka, $desi);
|
||||
if (!function_exists('uang')) {
|
||||
function uang(mixed $angka = 0, int $desi = 0): string {
|
||||
$angka = str_replace(",", "", (string) $angka);
|
||||
return number_format((float) $angka, $desi);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('uang2')) {
|
||||
function uang2($angka = 0) {
|
||||
function uang2(mixed $angka = 0): string {
|
||||
return uang($angka, 2);
|
||||
}
|
||||
}
|
||||
|
||||
/* todo: deprecated
|
||||
if (!function_exists('koma30')) {
|
||||
function koma30($angka = 0) {
|
||||
$nilai = explode(".", $angka);
|
||||
$hasil = (intval($nilai[1])==0) ? uang($angka, 0) : uang($angka, 3);
|
||||
return $hasil;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
if (!function_exists('items')) {
|
||||
function items($item = 0) {
|
||||
function items(mixed $item = 0): string {
|
||||
return rupiah($item)." Items";
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('records')) {
|
||||
function records($item = 0) {
|
||||
function records(mixed $item = 0): string {
|
||||
return rupiah($item)." Records";
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('baris')) {
|
||||
function baris($item = 0) {
|
||||
function baris(mixed $item = 0): string {
|
||||
return rupiah($item)." Baris";
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('romawi')) {
|
||||
function romawi($n) {
|
||||
function romawi(int $n): string {
|
||||
$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");
|
||||
if (array_key_exists($n,$iromawi)) {
|
||||
$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)) {
|
||||
$hasil = $iromawi[$n];
|
||||
} else if ($n >= 11 && $n <= 99) {
|
||||
$i = $n % 10;
|
||||
@@ -125,7 +126,7 @@ if (!function_exists('romawi')) {
|
||||
}
|
||||
|
||||
if (!function_exists('abjad')) {
|
||||
function abjad($n) {
|
||||
function abjad(int $n): string {
|
||||
$_str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
return substr($_str, ($n-1), 1);
|
||||
}
|
||||
@@ -134,8 +135,8 @@ if (!function_exists('abjad')) {
|
||||
/*************************** FORM CONTROL *****************************/
|
||||
|
||||
if (!function_exists('checkbox')) {
|
||||
function checkbox($nilai = 0) {
|
||||
$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";
|
||||
function checkbox(mixed $nilai): string {
|
||||
$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>';
|
||||
}
|
||||
}
|
||||
@@ -143,34 +144,34 @@ if (!function_exists('checkbox')) {
|
||||
/*************************** FORMAT TANGGAL / KALENDER *****************************/
|
||||
|
||||
if (!function_exists('sqltgl')) {
|
||||
function sqltgl($waktu = "0") {
|
||||
function sqltgl(string $waktu): string {
|
||||
return tgl_sql2str($waktu);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('sqltgls')) {
|
||||
function sqltgls($waktu = "0") {
|
||||
function sqltgls(string $waktu): string {
|
||||
return tgl_sql2str($waktu, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('sqljam')) {
|
||||
function sqljam($waktu = "0") {
|
||||
function sqljam(string $waktu): string {
|
||||
return tgl_sql2str($waktu, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('sqljams')) {
|
||||
function sqljams($waktu = "0") {
|
||||
function sqljams(string $waktu): string {
|
||||
return tgl_sql2str($waktu, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('tgl_sql2str')) {
|
||||
function tgl_sql2str($waktu = "0", $jam = false, $short = false) {
|
||||
if ($waktu=="0" || $waktu=="") return;
|
||||
function tgl_sql2str(string $waktu, bool $jam = false, bool $short = false): string {
|
||||
if (empty($waktu)) return '';
|
||||
$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]);
|
||||
$stgl = $atgl[2]."-".$atgl[1]."-".$atgl[0];
|
||||
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')) {
|
||||
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"));
|
||||
}
|
||||
}
|
||||
|
||||
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"));
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('tgl_operasi')) {
|
||||
function tgl_operasi($dtgl = "", $nhari = 0, $nbln = 0, $nthn = 0) {
|
||||
$atgl = explode("-", $dtgl);
|
||||
return date("d-m-Y", mktime(0,0,0, $atgl[1]+$nbln, $atgl[0]+$nhari, $atgl[2]+$nthn));
|
||||
function tgl_operasi(string $tgl, int $hari = 0, int $bln = 0, int $thn = 0): string {
|
||||
$atgl = explode("-", $tgl);
|
||||
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')) {
|
||||
function tgl_range_hari($dftgl="", $dttgl="", $bhitung_awal=false) {
|
||||
$_start = strtotime(tgl_sql2str($dftgl));
|
||||
$_end = strtotime(tgl_sql2str($dttgl));
|
||||
return ceil(abs($_end - $_start) / 86400) + (($bhitung_awal==true)?1:0);
|
||||
function tgl_range_hari(string $tgl_from, string $tgl_to, bool $hitung_awal = false): float {
|
||||
if (empty($tgl_to) or empty($tgl_from)) return 0;
|
||||
$_start = strtotime(tgl_sql2str($tgl_from));
|
||||
$_end = strtotime(tgl_sql2str($tgl_to));
|
||||
return ceil(abs($_end - $_start) / 86400) + (($hitung_awal)?1:0);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('tgl_akhbln')) {
|
||||
function tgl_akhbln($tgl) {
|
||||
function tgl_akhbln(string $tgl): string {
|
||||
if (empty($tgl)) return '';
|
||||
$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
|
||||
if ( (round($atgl[2]/4)==($atgl[2]/4)) && intval($atgl[1])==2 ) return "29-02-".$atgl[2];
|
||||
return $ablna[(intval($atgl[1])-1)]."-".isi_nol($atgl[1],2)."-".$atgl[2];
|
||||
if ((round((int) $atgl[2]/4) === ((int) $atgl[2]/4)) && (int) $atgl[1] === 2) return "29-02-".$atgl[2];
|
||||
return $ablna[(int) $atgl[1]-1]."-".isi_nol($atgl[1],2)."-".$atgl[2];
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('tgl_panjang')) {
|
||||
function tgl_panjang($dtgl = "") {
|
||||
if (trim($dtgl)=="") $dtgl = tgl_dmy();
|
||||
$atgl = explode("-", $dtgl);
|
||||
function tgl_panjang(string $tgl): string {
|
||||
if (empty($tgl)) $tgl = tgl_dmy();
|
||||
$atgl = explode("-", $tgl);
|
||||
$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')) {
|
||||
function tgl_hari($dtgl = "") {
|
||||
function tgl_hari(string $tgl): string {
|
||||
$nhari = date("w");
|
||||
if (trim($dtgl)!="") {
|
||||
//$atgl = getdate($dtgl);
|
||||
//$nhari = $atgl[wday];
|
||||
$nhari = date("w", strtotime(tgl_sql2str($dtgl)));
|
||||
if (!empty($tgl)) {
|
||||
$nhari = date("w", strtotime(tgl_sql2str($tgl)));
|
||||
}
|
||||
$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];
|
||||
}
|
||||
}
|
||||
if (!function_exists('tgl_triwulan')) {
|
||||
function tgl_triwulan($dtgl = "") {
|
||||
if ($dtgl == "") {
|
||||
function tgl_triwulan(string $tgl): int {
|
||||
if (empty($tgl)) {
|
||||
$dtgl = date("m");
|
||||
} else {
|
||||
$atgl = explode("-", $tgl);
|
||||
@@ -254,13 +255,13 @@ if (!function_exists('tgl_triwulan')) {
|
||||
}
|
||||
|
||||
if (!function_exists('bulan_array')) {
|
||||
function bulan_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");
|
||||
function bulan_array(): array {
|
||||
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')) {
|
||||
function triwulan_array() {
|
||||
function triwulan_array(): array {
|
||||
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 *****************************/
|
||||
|
||||
if (!function_exists('subjudul')) {
|
||||
function subjudul($tjudul) {
|
||||
return '<table border="0" align="center" valign="middle" width="100%" height="26px"><tr><td width="50%"><hr /></td><td> <span style="text-align:center;font-weight:bold;white-space:nowrap;">'.$tjudul.'</span> </td><td width="50%"><hr /></td></tr></table>';
|
||||
function subjudul(string $judul): string {
|
||||
return '<table border="0" align="center" valign="middle" width="100%" height="26px"><tr><td width="50%"><hr /></td><td> <span style="text-align:center;font-weight:bold;white-space:nowrap;">'.$judul.'</span> </td><td width="50%"><hr /></td></tr></table>';
|
||||
}
|
||||
}
|
||||
|
||||
/* todo: deprecated
|
||||
if (!function_exists('showerror')) {
|
||||
function showerror($terror) {
|
||||
echo '<input type="hidden" id="_Error" class="error" value="'.$terror.'!" />';
|
||||
function showerror(string $error): void {
|
||||
echo '<input type="hidden" id="_Error" class="error" value="'.$error.'!" />';
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
if (!function_exists('br2nl')) {
|
||||
function br2nl($string) {
|
||||
function br2nl(string $string): 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 {
|
||||
$nilai = (string)$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')) {
|
||||
function isMobile() {
|
||||
function isMobile(): bool {
|
||||
$agen = $_SERVER['HTTP_USER_AGENT'];
|
||||
$amobile = ['Android', 'webOS', 'iPhone', 'iPad', 'iPod', 'BlackBerry', 'Windows Phone', 'Mobile'];
|
||||
foreach ($amobile as $keyword) {
|
||||
@@ -304,46 +306,47 @@ if (!function_exists('isMobile')) {
|
||||
}
|
||||
|
||||
if (!function_exists('isLinux')) {
|
||||
function isLinux() {
|
||||
function isLinux(): bool {
|
||||
$agen = $_SERVER['HTTP_USER_AGENT'];
|
||||
if (stripos($agen,'linux') !== false) return true;
|
||||
if (stripos($agen, 'linux') !== false) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('isIE')) {
|
||||
function isIE() {
|
||||
function isIE(): bool {
|
||||
$agen = $_SERVER['HTTP_USER_AGENT'];
|
||||
if (stripos($agen,'msie') !== false) return true;
|
||||
if (stripos($agen, 'msie') !== false) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('isChrome')) {
|
||||
function isChrome() {
|
||||
function isChrome(): bool {
|
||||
$agen = $_SERVER['HTTP_USER_AGENT'];
|
||||
if (stripos($agen,'chrome') !== false) return true;
|
||||
if (stripos($agen, 'chrome') !== false) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('isFirefox')) {
|
||||
function isFirefox() {
|
||||
function isFirefox(): bool {
|
||||
$agen = $_SERVER['HTTP_USER_AGENT'];
|
||||
if (stripos($agen,'firefox') !== false) return true;
|
||||
if (stripos($agen, 'firefox') !== false) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* todo: deprecated
|
||||
if (!function_exists('potong')) {
|
||||
function potong($nilai) {//utk rkpd
|
||||
return substr($nilai, 0, 60);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
if (!function_exists('format_bytes')) {
|
||||
function format_bytes($bytes) {
|
||||
if ($bytes < 1024) return $bytes.' B';
|
||||
function format_bytes(int $bytes): string {
|
||||
if ($bytes < 1024) return (string) $bytes.' B';
|
||||
elseif ($bytes < 1048576) return uang2($bytes / 1024).' KB';
|
||||
elseif ($bytes < 1073741824) return uang2($bytes / 1048576).' MB';
|
||||
elseif ($bytes < 1099511627776) return uang2($bytes / 1073741824).' GB';
|
||||
@@ -352,12 +355,10 @@ if (!function_exists('format_bytes')) {
|
||||
}
|
||||
|
||||
if (!function_exists('random_color')) {
|
||||
function random_color($trans = "0.6") {
|
||||
$col_r = mt_rand( 0, 255 );
|
||||
$col_g = mt_rand( 0, 255 );
|
||||
$col_b = mt_rand( 0, 255 );
|
||||
function random_color(string $trans = "0.6"): string {
|
||||
$col_r = (string) mt_rand( 0, 255 );
|
||||
$col_g = (string) mt_rand( 0, 255 );
|
||||
$col_b = (string) mt_rand( 0, 255 );
|
||||
return "rgba(".$col_r.",".$col_g.",".$col_b.",".$trans.")";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -3,10 +3,9 @@
|
||||
/*******************************************************************
|
||||
|
||||
Module : /Printer/PrintHTML.php
|
||||
Desc. : Class cetak HTML
|
||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||
Created Date : June 15th, 2008.
|
||||
Last Modified : August 21st, 2026.
|
||||
Last Modified : August 26th, 2026.
|
||||
|
||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
@@ -14,9 +13,20 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace siaupheng\webapp\Printer;
|
||||
namespace Webapp\Printer;
|
||||
|
||||
use \flight\Session;
|
||||
use \flight\Engine;
|
||||
|
||||
/**
|
||||
* Class PrintHTML
|
||||
*
|
||||
* Menghasilkan bentuk laporan dalam format HTML.
|
||||
*
|
||||
* @license MIT, https://www.3fonia.com
|
||||
* @copyright Copyright (c) 2008-2026, Siau Pheng <siaupheng@3fonia.com>
|
||||
*
|
||||
* @package Webapp\Printer
|
||||
*/
|
||||
|
||||
final class PrintHTML {
|
||||
private $__avalue = [];
|
||||
@@ -26,9 +36,12 @@ final class PrintHTML {
|
||||
protected array $webapp;
|
||||
protected array $webuser;
|
||||
|
||||
public function __construct(Session $session) {
|
||||
$this->webapp = $session->get('__WEB_APP', ['APP_NAME'=>'', 'APP_VER'=>'']);
|
||||
$this->webuser = $session->get('__WEB_USER', ['UserID'=>0, 'Username'=>'']);
|
||||
/**
|
||||
* @param Engine $app
|
||||
*/
|
||||
public function __construct(Engine $app) {
|
||||
$this->webapp = $app->session()->get('__WEB_APP', ['APP_NAME'=>'', 'APP_VER'=>'']);
|
||||
$this->webuser = $app->session()->get('__WEB_USER', ['UserID'=>0, 'Username'=>'']);
|
||||
}
|
||||
|
||||
public function set_css(string $style): void {
|
||||
@@ -54,7 +67,7 @@ final class PrintHTML {
|
||||
} else if (function_exists($this->__atabel[$i][2]) && trim("".$tmp_val)<>"") {
|
||||
$tmp_val = call_user_func($this->__atabel[$i][2], $tmp_val);
|
||||
}
|
||||
$tmp_val = $this->set_align($tmp_val, $this->__atabel[$i][1], $this->__atabel[$i][3]);
|
||||
$tmp_val = $this->set_align((string) $tmp_val, $this->__atabel[$i][1], $this->__atabel[$i][3]);
|
||||
$tmp_out .= $tmp_val;
|
||||
}
|
||||
$tmp_out .= "</tr>";
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
/*******************************************************************
|
||||
|
||||
Module : /Printer/PrintPOS.php
|
||||
Desc. : Class cetak POS
|
||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||
Created Date : June 15th, 2008.
|
||||
Last Modified : August 21st, 2026.
|
||||
@@ -14,10 +13,20 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace siaupheng\webapp\Printer;
|
||||
namespace Webapp\Printer;
|
||||
|
||||
use \flight\Engine;
|
||||
use \flight\Session;
|
||||
|
||||
/**
|
||||
* Class PrintPOS
|
||||
*
|
||||
* Pembuatan Nota/Struk untuk cetak ke Printer POS.
|
||||
*
|
||||
* @license MIT, https://www.3fonia.com
|
||||
* @copyright Copyright (c) 2008-2026, Siau Pheng <siaupheng@3fonia.com>
|
||||
*
|
||||
* @package Webapp\Printer
|
||||
*/
|
||||
|
||||
class PrintPOS {
|
||||
private $_header = [];
|
||||
@@ -35,10 +44,13 @@ class PrintPOS {
|
||||
private array $webuser;
|
||||
protected Engine $app;
|
||||
|
||||
public function __construct(Engine $app, Session $session) {
|
||||
/**
|
||||
* @param Engine $app
|
||||
*/
|
||||
public function __construct(Engine $app) {
|
||||
$this->app = $app;
|
||||
$this->webapp = $session->get('__WEB_APP', ['APP_NAME'=>'', 'APP_VER'=>'', 'REAL_PATH'=>'']);
|
||||
$this->webuser = $session->get('__WEB_USER', ['UserID'=>0, 'Username'=>'']);
|
||||
$this->webapp = $app->session()->get('__WEB_APP', ['APP_NAME'=>'', 'APP_VER'=>'']);
|
||||
$this->webuser = $app->session()->get('__WEB_USER', ['UserID'=>0, 'Username'=>'']);
|
||||
}
|
||||
|
||||
public function set_opendrawer(): void {
|
||||
@@ -58,8 +70,8 @@ class PrintPOS {
|
||||
}
|
||||
|
||||
public function set_header_logo(string $logo_file = ""): void {
|
||||
if (!empty($logo_file) && file_exists($this->webapp['REAL_PATH']."assets/images/".$logo_file)) {
|
||||
$this->_config['logo'] = $this->webapp['WEB_PATH']."assets/images/".$logo_file;
|
||||
if (!empty($logo_file) && file_exists(PROJECT_ROOT."assets/images/".$logo_file)) {
|
||||
$this->_config['logo'] = PROJECT_BASE."assets/images/".$logo_file;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
/*******************************************************************
|
||||
|
||||
Module : /Printer/PrintRAW.php
|
||||
Desc. : Class cetak RAW
|
||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||
Created Date : June 15th, 2008.
|
||||
Last Modified : November 1st, 2023.
|
||||
@@ -14,10 +13,20 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace siaupheng\webapp\Printer;
|
||||
namespace Webapp\Printer;
|
||||
|
||||
use \flight\Engine;
|
||||
use \flight\Session;
|
||||
|
||||
/**
|
||||
* Class PrintRAW
|
||||
*
|
||||
* Pembuatan Laporan dalam bentuk RAW / Natural.
|
||||
*
|
||||
* @license MIT, https://www.3fonia.com
|
||||
* @copyright Copyright (c) 2008-2026, Siau Pheng <siaupheng@3fonia.com>
|
||||
*
|
||||
* @package Webapp\Printer
|
||||
*/
|
||||
|
||||
class PrintRAW {
|
||||
private $_header = [];
|
||||
@@ -32,14 +41,17 @@ class PrintRAW {
|
||||
'opendraw' => false,
|
||||
'cutpaper' => false,
|
||||
];
|
||||
private array $webapp;
|
||||
private array $webuser;
|
||||
protected Engine $app;
|
||||
protected array $webapp;
|
||||
protected array $webuser;
|
||||
|
||||
public function __construct(Engine $app, Session $session) {
|
||||
/**
|
||||
* @param Engine $app
|
||||
*/
|
||||
public function __construct(Engine $app) {
|
||||
$this->app = $app;
|
||||
$this->webapp = $session->get('__WEB_APP', ['APP_NAME'=>'', 'APP_VER'=>'', 'REAL_PATH'=>'']);
|
||||
$this->webuser = $session->get('__WEB_USER', ['UserID'=>0, 'Username'=>'']);
|
||||
$this->webapp = $app->session()->get('__WEB_APP', ['APP_NAME'=>'', 'APP_VER'=>'']);
|
||||
$this->webuser = $app->session()->get('__WEB_USER', ['UserID'=>0, 'Username'=>'']);
|
||||
}
|
||||
|
||||
public function set_opendrawer(): void {
|
||||
|
||||
+18
-5
@@ -3,7 +3,6 @@
|
||||
/*******************************************************************
|
||||
|
||||
Module : /Web/Auth.php
|
||||
Desc. : Class User Control dan Manajemen
|
||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||
Created Date : March 16th, 2008.
|
||||
Last Modified : August 22nd, 2026.
|
||||
@@ -14,22 +13,36 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace siaupheng\webapp\Web;
|
||||
namespace Webapp\Web;
|
||||
|
||||
use \flight\Engine;
|
||||
use \flight\Session;
|
||||
use \flight\database\SimplePdo;
|
||||
|
||||
/**
|
||||
* Class Auth
|
||||
*
|
||||
* Kontrol dan Manajemen User Session.
|
||||
*
|
||||
* @license MIT, https://www.3fonia.com
|
||||
* @copyright Copyright (c) 2008-2026, Siau Pheng <siaupheng@3fonia.com>
|
||||
*
|
||||
* @package Webapp\Web
|
||||
*/
|
||||
|
||||
final class Auth {
|
||||
private int $__id_reg = 0;
|
||||
protected Engine $app;
|
||||
protected SimplePdo $db;
|
||||
protected Session $session;
|
||||
|
||||
public function __construct(Engine $app, SimplePdo $db, Session $session){
|
||||
/**
|
||||
* @param Engine $app
|
||||
*/
|
||||
public function __construct(Engine $app){
|
||||
$this->app = $app;
|
||||
$this->db = $db;
|
||||
$this->session = $session;
|
||||
$this->db = $app->db();
|
||||
$this->session = $app->session();
|
||||
$this->__id_reg = (int)$this->session->get('__WEB_APP', ['REG_ID'=>0])['REG_ID'];
|
||||
}
|
||||
|
||||
|
||||
+12
-2
@@ -3,7 +3,6 @@
|
||||
/*******************************************************************
|
||||
|
||||
Module : /Web/Button.php
|
||||
Desc. : Button Generator (jQuery & Bootstrap)
|
||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||
Created Date : February 27th, 2008.
|
||||
Last Modified : August 22nd, 2026.
|
||||
@@ -14,7 +13,18 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace siaupheng\webapp\Web;
|
||||
namespace Webapp\Web;
|
||||
|
||||
/**
|
||||
* Class Button
|
||||
*
|
||||
* Pembuatan tombol aplikasi (jQuery & Bootstrap).
|
||||
*
|
||||
* @license MIT, https://www.3fonia.com
|
||||
* @copyright Copyright (c) 2008-2026, Siau Pheng <siaupheng@3fonia.com>
|
||||
*
|
||||
* @package Webapp\Web
|
||||
*/
|
||||
|
||||
class Button {
|
||||
private $__abutton =[];
|
||||
|
||||
+29
-16
@@ -3,7 +3,6 @@
|
||||
/*******************************************************************
|
||||
|
||||
Module : /Web/Form.php
|
||||
Desc. : Form Generator (jQuery & Bootstrap)
|
||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||
Created Date : February 27th, 2008.
|
||||
Last Modified : August 22nd, 2026.
|
||||
@@ -14,12 +13,23 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace siaupheng\webapp\Web;
|
||||
namespace Webapp\Web;
|
||||
|
||||
use \flight\Engine;
|
||||
use \flight\Session;
|
||||
use \flight\database\SimplePdo;
|
||||
|
||||
/**
|
||||
* Class Form
|
||||
*
|
||||
* Pembuatan form (jQuery & Bootstrap).
|
||||
*
|
||||
* @license MIT, https://www.3fonia.com
|
||||
* @copyright Copyright (c) 2008-2026, Siau Pheng <siaupheng@3fonia.com>
|
||||
*
|
||||
* @package Webapp\Web
|
||||
*/
|
||||
|
||||
final class Form {
|
||||
private $__aform = [];
|
||||
private $__ahide = [];
|
||||
@@ -27,13 +37,16 @@ final class Form {
|
||||
protected SimplePdo $db;
|
||||
protected Session $session;
|
||||
|
||||
public function __construct(Engine $app, SimplePdo $db, Session $session){
|
||||
/**
|
||||
* @param Engine $app
|
||||
*/
|
||||
public function __construct(Engine $app){
|
||||
$this->app = $app;
|
||||
$this->db = $db;
|
||||
$this->session = $session;
|
||||
$this->db = $app->db();
|
||||
$this->session = $app->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 = '';
|
||||
if (!empty($change)) $_opsi .= ' ochan="'.$change.'"';
|
||||
if ($enable===false) $_opsi .= ' disabled=true';
|
||||
@@ -69,7 +82,7 @@ final class Form {
|
||||
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 = '';
|
||||
if (!is_array($afield)) $afield = ["ID", "Nama", "Label"];
|
||||
if (!empty($where)) {
|
||||
@@ -87,7 +100,7 @@ final class Form {
|
||||
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"];
|
||||
$ahasil = [];
|
||||
if (is_array($aarray)) $ahasil[$aarray[0]] = (!isset($afield[2])) ? $aarray[1] : [$aarray[1], $aarray[2]];
|
||||
@@ -100,7 +113,7 @@ final class Form {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -108,7 +121,7 @@ final class Form {
|
||||
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);
|
||||
if (empty($value)) $value = $_val[0];
|
||||
$_opsi = '';
|
||||
@@ -136,7 +149,7 @@ final class Form {
|
||||
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);
|
||||
if (empty($value)) $value = $_val[1];
|
||||
$_opsi = ' odata="'.htmlspecialchars(json_encode($arr)).'"';
|
||||
@@ -150,7 +163,7 @@ final class Form {
|
||||
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);
|
||||
if (empty($value)) $value = $_val[1];
|
||||
$_opsi = ' odata="'.htmlspecialchars(json_encode($arr)).'"';
|
||||
@@ -164,7 +177,7 @@ final class Form {
|
||||
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 = '';
|
||||
if (!empty($keyup)) $_opsi .= ' okyup="'.$keyup.'"';
|
||||
if (!empty($blur)) $_opsi .= ' oblur="'.$blur.'"';
|
||||
@@ -178,7 +191,7 @@ final class Form {
|
||||
if ($type === 'double') $value = uang2($value);
|
||||
$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 ];
|
||||
return $tout;
|
||||
}
|
||||
@@ -219,7 +232,7 @@ final class Form {
|
||||
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 />';
|
||||
$this->__aform[$field] = ['label' => $label, 'help' => "", 'form' => $tout];
|
||||
return $tout;
|
||||
@@ -239,7 +252,7 @@ final class Form {
|
||||
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.'" />';
|
||||
$this->__ahide[$field] = $tout;
|
||||
return $tout;
|
||||
|
||||
+20
-7
@@ -3,7 +3,6 @@
|
||||
/*******************************************************************
|
||||
|
||||
Module : /Web/Menu.php
|
||||
Desc. : Class Menu Manajemen
|
||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||
Created Date : January 16th, 2008.
|
||||
Last Modified : August 22nd, 2026.
|
||||
@@ -14,12 +13,23 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace siaupheng\webapp\Web;
|
||||
namespace Webapp\Web;
|
||||
|
||||
use \flight\Engine;
|
||||
use \flight\Session;
|
||||
use \flight\database\SimplePdo;
|
||||
|
||||
/**
|
||||
* Class Menu
|
||||
*
|
||||
* Manajemen Menu aplikasi.
|
||||
*
|
||||
* @license MIT, https://www.3fonia.com
|
||||
* @copyright Copyright (c) 2008-2026, Siau Pheng <siaupheng@3fonia.com>
|
||||
*
|
||||
* @package Webapp\Web
|
||||
*/
|
||||
|
||||
final class Menu {
|
||||
private array $webapp;
|
||||
private array $webuser;
|
||||
@@ -27,12 +37,15 @@ final class Menu {
|
||||
protected SimplePdo $db;
|
||||
protected Session $session;
|
||||
|
||||
public function __construct(Engine $app, SimplePdo $db, Session $session){
|
||||
/**
|
||||
* @param Engine $app
|
||||
*/
|
||||
public function __construct(Engine $app){
|
||||
$this->app = $app;
|
||||
$this->db = $db;
|
||||
$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'=>[]]);
|
||||
$this->db = $app->db();
|
||||
$this->session = $app->session();
|
||||
$this->webapp = $this->session->get('__WEB_APP', ['APP_MODULE'=>'', 'PARENT_SITE'=>'', 'PARENT_SUB'=>false]);
|
||||
$this->webuser = $this->session->get('__WEB_USER', ['Menu'=>'', 'Menu_Grup'=>'', 'MENU_MODUL'=>[]]);
|
||||
}
|
||||
|
||||
public function Sidebar(): string {
|
||||
|
||||
+13
-3
@@ -3,7 +3,6 @@
|
||||
/*******************************************************************
|
||||
|
||||
Module : /Web/Param.php
|
||||
Desc. : Class Parameter Manajemen
|
||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||
Created Date : November 14th, 2013.
|
||||
Last Modified : August 22nd, 2026.
|
||||
@@ -14,10 +13,21 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace siaupheng\webapp\Web;
|
||||
namespace Webapp\Web;
|
||||
|
||||
use \flight\Engine;
|
||||
|
||||
/**
|
||||
* Class Param
|
||||
*
|
||||
* Manajemen Variable Request dari GET / POST.
|
||||
*
|
||||
* @license MIT, https://www.3fonia.com
|
||||
* @copyright Copyright (c) 2008-2026, Siau Pheng <siaupheng@3fonia.com>
|
||||
*
|
||||
* @package Webapp\Web
|
||||
*/
|
||||
|
||||
final class Param {
|
||||
private static $__ahasil = [];
|
||||
|
||||
@@ -30,7 +40,7 @@ final class Param {
|
||||
if (empty($app)) $app = \Flight::app();
|
||||
$_asumber = array_merge($app->request()->query->getData(), $app->request()->data->getData());
|
||||
foreach ($_asumber as $__key => $__val) {
|
||||
self::$__ahasil[$__key] = self::safeSQL($__val);
|
||||
self::$__ahasil[$__key] = is_string($__val) ? self::safeSQL($__val) : $__val;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+24
-24
@@ -3,53 +3,53 @@
|
||||
/*******************************************************************
|
||||
|
||||
Module : /Web/Register.php
|
||||
Desc. : Class Registrasi Aplikasi
|
||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||
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);
|
||||
|
||||
namespace siaupheng\webapp\Web;
|
||||
namespace Webapp\Web;
|
||||
|
||||
use flight\Engine;
|
||||
use flight\Session;
|
||||
use flight\database\SimplePdo;
|
||||
use \flight\Engine;
|
||||
use \flight\Session;
|
||||
use \flight\database\SimplePdo;
|
||||
|
||||
/**
|
||||
* Class Register
|
||||
*
|
||||
* Registrasi aplikasi.
|
||||
*
|
||||
* @license MIT, https://www.3fonia.com
|
||||
* @copyright Copyright (c) 2008-2026, Siau Pheng <siaupheng@3fonia.com>
|
||||
*
|
||||
* @package Webapp\Web
|
||||
*/
|
||||
|
||||
final class Register {
|
||||
protected Engine $app;
|
||||
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 function __construct(){
|
||||
}
|
||||
|
||||
public static function reg_id() {
|
||||
$webapp = (array)\Flight::app()->session()->get('__WEB_APP');
|
||||
$id = (string)$webapp['REG_ID'] ?? '';
|
||||
public static function reg_id(Session $session) {
|
||||
$id = (string)$session->get('__WEB_APP', ['REG_ID'=>''])['REG_ID'];
|
||||
return (substr($id,0,3).".".substr($id,3,3).".".substr($id,6));
|
||||
}
|
||||
|
||||
public static function reg_code() {
|
||||
$webapp = (array)\Flight::app()->session()->get('__WEB_APP');
|
||||
$id = (string)$webapp['REG_CODE'] ?? '';
|
||||
public static function reg_code(Session $session) {
|
||||
$id = (string)$session->get('__WEB_APP', ['REG_CODE'=>''])['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));
|
||||
}
|
||||
|
||||
static function reg_check(Session $session) {//oke
|
||||
public static function reg_check(Session $session) {
|
||||
$webapp = $session->get('__WEB_APP');
|
||||
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'] ?? '']);
|
||||
return [ 'REG_STATUS' => $kode_db === true ];
|
||||
}
|
||||
|
||||
+18
-5
@@ -3,7 +3,6 @@
|
||||
/*******************************************************************
|
||||
|
||||
Module : /Web/Table.php
|
||||
Desc. : Datatable (jQuery & Bootstrap)
|
||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||
Created Date : January 16th, 2008.
|
||||
Last Modified : August 22nd, 2026.
|
||||
@@ -14,11 +13,22 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace siaupheng\webapp\Web;
|
||||
namespace Webapp\Web;
|
||||
|
||||
use \flight\Engine;
|
||||
use \flight\database\SimplePdo;
|
||||
|
||||
/**
|
||||
* Class Table
|
||||
*
|
||||
* Pembuatan DataTable (jQuery & Bootstrap).
|
||||
*
|
||||
* @license MIT, https://www.3fonia.com
|
||||
* @copyright Copyright (c) 2008-2026, Siau Pheng <siaupheng@3fonia.com>
|
||||
*
|
||||
* @package Webapp\Web
|
||||
*/
|
||||
|
||||
final class Table {
|
||||
private $__ttable = "";
|
||||
private $__tfield = "";
|
||||
@@ -45,9 +55,12 @@ final class Table {
|
||||
protected SimplePdo $db;
|
||||
protected array $data;
|
||||
|
||||
public function __construct(Engine $app, SimplePdo $db) {
|
||||
/**
|
||||
* @param Engine $app
|
||||
*/
|
||||
public function __construct(Engine $app) {
|
||||
$this->app = $app;
|
||||
$this->db = $db;
|
||||
$this->db = $app->db();
|
||||
$this->data = $this->app->request()->data->getData();
|
||||
}
|
||||
|
||||
@@ -81,7 +94,7 @@ final class Table {
|
||||
}
|
||||
|
||||
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 ];
|
||||
}
|
||||
|
||||
|
||||
+12
-2
@@ -3,7 +3,6 @@
|
||||
/*******************************************************************
|
||||
|
||||
Module : /Web/Terbilang.php
|
||||
Desc. : Class Format Angka & Terbilang
|
||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||
Created Date : February 12th, 2009.
|
||||
Last Modified : August 22nd, 2026.
|
||||
@@ -14,7 +13,18 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace siaupheng\webapp\Web;
|
||||
namespace Webapp\Web;
|
||||
|
||||
/**
|
||||
* Class Terbilang
|
||||
*
|
||||
* Pembuatan text terbilang.
|
||||
*
|
||||
* @license MIT, https://www.3fonia.com
|
||||
* @copyright Copyright (c) 2008-2026, Siau Pheng <siaupheng@3fonia.com>
|
||||
*
|
||||
* @package Webapp\Web
|
||||
*/
|
||||
|
||||
final class Terbilang {
|
||||
private $numb = ["","Satu","Dua","Tiga","Empat","Lima","Enam","Tujuh","Delapan","Sembilan"];
|
||||
|
||||
+26
-17
@@ -3,7 +3,6 @@
|
||||
/*******************************************************************
|
||||
|
||||
Module : /Web/Update.php
|
||||
Desc. : Class Update Aplikasi Otomatis
|
||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||
Created Date : June 14th, 2013.
|
||||
Last Modified : August 22nd, 2026.
|
||||
@@ -14,26 +13,37 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace siaupheng\webapp\Web;
|
||||
namespace Webapp\Web;
|
||||
|
||||
use \flight\Engine;
|
||||
use \flight\Session;
|
||||
|
||||
/**
|
||||
* Class Update
|
||||
*
|
||||
* Update Otomatis Aplikasi berbasis GIT.
|
||||
*
|
||||
* @license MIT, https://www.3fonia.com
|
||||
* @copyright Copyright (c) 2008-2026, Siau Pheng <siaupheng@3fonia.com>
|
||||
*
|
||||
* @package Webapp\Web
|
||||
*/
|
||||
|
||||
final class Update {
|
||||
protected Array $__conf = [];
|
||||
protected Bool $is_git = false;
|
||||
private Array $__conf = [];
|
||||
private Bool $is_git = false;
|
||||
protected Engine $app;
|
||||
|
||||
public function __construct(Engine $app, Session $session){
|
||||
/**
|
||||
* @param Engine $app
|
||||
*/
|
||||
public function __construct(Engine $app){
|
||||
$this->app = $app;
|
||||
$this->__conf = $session->get('__WEB_APP');
|
||||
$this->__conf = $app->session()->get('__WEB_APP');
|
||||
$this->current();
|
||||
}
|
||||
|
||||
public function current() {
|
||||
$_target = $this->__conf['REAL_PATH'];
|
||||
if (isset($_target)) chdir($_target);
|
||||
|
||||
public function current(): void {
|
||||
if (defined('PROJECT_ROOT')) chdir(PROJECT_ROOT);
|
||||
try {
|
||||
$output = shell_exec("git log -1 --pretty=format:\"%H||%s||%ci\" --abbrev-commit 2>&1");
|
||||
if ($output) {
|
||||
@@ -57,7 +67,7 @@ final class Update {
|
||||
}
|
||||
}
|
||||
|
||||
public function check() {
|
||||
public function check(): array {
|
||||
$_ainfo['cur_version'] = $this->__conf['APP_BUILD'];
|
||||
$_ainfo['cur_sha'] = substr($this->__conf['GIT_SHA1'], 0, 10);
|
||||
$_ainfo['cur_sha1'] = $this->__conf['GIT_SHA1'];
|
||||
@@ -89,14 +99,13 @@ final class Update {
|
||||
return $_ainfo;
|
||||
}
|
||||
|
||||
public function go() {
|
||||
$_target = $this->__conf['REAL_PATH'];
|
||||
public function go(): array {
|
||||
$_branch = $this->__conf['GIT_BRANCH'] ?? "main";
|
||||
if (isset($_target)) {
|
||||
chdir($_target);
|
||||
if (defined('PROJECT_ROOT')) {
|
||||
chdir(PROJECT_ROOT);
|
||||
$output = shell_exec("git reset --hard HEAD && git pull origin {$_branch} 2>&1");
|
||||
return ['success'=>true,'message'=>$output];
|
||||
} else return ['success'=>false,'message'=>"Tanpa REAL_PATH !"];
|
||||
} else return ['success'=>false,'message'=>"Tanpa PROJECT_ROOT !"];
|
||||
}
|
||||
|
||||
public function mysql() {
|
||||
|
||||
Reference in New Issue
Block a user