bugfix for input type double, integer, etc

This commit is contained in:
2026-08-18 17:33:36 +07:00
parent d72a842a1b
commit 18fa7ac48d
9 changed files with 226 additions and 199 deletions
+29 -41
View File
@@ -290,48 +290,36 @@ var FoniaJS = {
return smenu; return smenu;
}, },
FormDecorated: function() { FormDecorated: function() {
$('input').each((i, el) => { $('input.form-control[class*=integer], input.form-control[class*=angka]').each((i, el) => {
const elm = $(el); const elm = $(el);
// 16:shift 17:ctrl 18:alt 35:end 36:home 37:left 38:up 39:right 40:down 9:tab 13:enter 27:esc elm.on('keypress keyup blur paste', (e) => {
// 8:backspace 46:delete 45:delete 48-57/96-105:num 110/190:dot 109/189/173:minus 107/187/61:plus elm.val(elm.val().replace(/[^\d].+/, ""));
if (elm.hasClass('integer') || elm.hasClass('angka')) { if ((e.which < 48 || e.which > 57)) e.preventDefault();
elm.keydown((e) => { });
var key = e.keyCode ?? e.which; });
return (jQuery.inArray(key,[8,9,13,46,110,190])!==-1 || (key>=16 && key<=18) || (key>=35 && key<=40) || (key>=48 && key<=57) || (key>=96 && key<=105)); $('input.form-control[class*=double]').each((i, el) => {
}); const elm = $(el);
} else if (elm.hasClass('number')) { elm.on('keypress keyup blur paste', (e) => {
elm.keydown((e) => { elm.val(elm.val().replace(/[^0-9\.]/g,''));
var key = e.keyCode ?? e.which; if (e.type === 'blur') elm.val( FoniaJS.FloatToStr(elm.val(), 2) );
return (jQuery.inArray(key,[8,9,13,46,110,190,109,189,173])!==-1 || (key>=16 && key<=18) || (key>=35 && key<=40) || (key>=48 && key<=57) || (key>=96 && key<=105)); if ((e.which != 46 || elm.val().indexOf('.') != -1) && (e.which < 48 || e.which > 57)) e.preventDefault();
}); });
elm.focus((e) => { elm.on('focus', (e) => {
$(e.currentTarget).val( FoniaJS.StrToFloat($(e.currentTarget).val()) ); elm.val( FoniaJS.StrToFloat(elm.val()) );
}); elm.select();
elm.blur((e) => { e.preventDefault();
$(e.currentTarget).val( FoniaJS.FloatToStr($(e.currentTarget).val(), 0) ); });
}); });
} else if (elm.hasClass('double')) { $('input.form-control[type=number]').each((i, el) => {
elm.keydown((e) => { const elm = $(el);
var key = e.keyCode ?? e.which; elm.on('keypress keyup blur paste', (e) => {
return (jQuery.inArray(key,[8,9,13,46,110,190,109,189,173])!==-1 || (key>=16 && key<=18) || (key>=35 && key<=40) || (key>=48 && key<=57) || (key>=96 && key<=105)); elm.val(elm.val().replace(/[^0-9]/g,''));
}); if ((e.which != 46 || elm.val().indexOf('.') != -1) && (e.which < 48 || e.which > 57)) e.preventDefault();
elm.focus((e) => { });
$(e.currentTarget).val( FoniaJS.StrToFloat($(e.currentTarget).val()) ); });
$(e.currentTarget).select(); $('input[class*=error][type=hidden]').each((i, el) => {
}); const elm = $(el);
elm.blur((e) => { this.showError(elm.val());
$(e.currentTarget).val( FoniaJS.FloatToStr($(e.currentTarget).val(), 2) );
});
} else if (elm.hasClass('phone')) {
elm.keyup((e) => {
var key = e.keyCode ?? e.which;
return (jQuery.inArray(key,[8,9,13,46,110,190,109,189,173,107,187,61])!==-1 || (key>=16 && key<=18) || (key>=35 && key<=40) || (key>=48 && key<=57) || (key>=96 && key<=105));
});
} else if (elm.hasClass('error') && elm.val()) {
var tmp_str = elm.val();
elm.val('');
FoniaJS.showError(tmp_str);
}
}); });
$('.option-tags').each((i, el) => { $('.option-tags').each((i, el) => {
const elm = $(el); const elm = $(el);
File diff suppressed because one or more lines are too long
+6 -6
View File
@@ -18,8 +18,8 @@ namespace siaupheng\fonia3;
final class App { final class App {
public $version = "4.0.0"; public $version = "4.0.0";
private $apps = array(); private $apps = [];
private $auser = array(); private $auser = [];
private $cache = null; private $cache = null;
private $menu = null; private $menu = null;
private $reg = null; private $reg = null;
@@ -35,9 +35,9 @@ final class App {
if (isset($_SESSION['__WEB_USER'])) { if (isset($_SESSION['__WEB_USER'])) {
$this->apps['TEMPLATE'] = "index.php"; $this->apps['TEMPLATE'] = "index.php";
$this->auser = $_SESSION['__WEB_USER']; $this->auser = $_SESSION['__WEB_USER'];
$this->auser['user_img'] = "profile.png"; $this->auser['user_img'] = "profiles/profile.png";
if (file_exists($this->apps['REAL_PATH']."assets/images/profiles/".$this->auser['UserID'].".png")) { if (file_exists($this->apps['REAL_PATH']."assets/images/profiles/".$this->auser['UserID'].".png")) {
$this->auser['user_img'] = $this->auser['UserID'].".png"; $this->auser['user_img'] = "profiles/".$this->auser['UserID'].".png";
} }
} }
$this->reg = new \siaupheng\fonia3\Web\Register($this->__db); $this->reg = new \siaupheng\fonia3\Web\Register($this->__db);
@@ -45,7 +45,7 @@ final class App {
$this->menu = new \siaupheng\fonia3\Web\Menu($this->__db); $this->menu = new \siaupheng\fonia3\Web\Menu($this->__db);
} }
public function TampilApp($aoption = array()) { public function TampilApp($aoption = []) {
// cek register // cek register
if ($this->reg->reg_check()) { if ($this->reg->reg_check()) {
if (!user_logged()) { if (!user_logged()) {
@@ -99,7 +99,7 @@ final class App {
// perubahan variabel dari data konfigurasi // perubahan variabel dari data konfigurasi
$asrc = array("[_CREATOR_NAME_]", "[_CREATOR_WEBSITE_]", "[_CREATOR_YEAR_]", "[_APP_NAME_VER_]", "[_APP_NAMES_VER_]", "[_APP_NAME_]", "[_APP_NAMES_]", "[_APP_NAMES_UP_]", "[_APP_VER_]", "[_APP_UPDATED_]", "[_REG_ID_]", "[_REG_NAME_]", "[_REG_NAME_UP_]", "[_REG_ADDRESS_]", "[_REG_CITY_]", "[_REG_CITY_UP_]", "[_REG_PHONE_]", "[_REG_FAX_]", "[_REG_EMAIL_]", "[_REG_POSTCODE_]", "[_REG_WEBSITE_]", "[_REG_YEAR_]", "[_USER_IMG_]", "[_WEB_PATH_]", "[_NAVI_SIDEBAR_]", "[_NAVI_HEADER_]"); $asrc = array("[_CREATOR_NAME_]", "[_CREATOR_WEBSITE_]", "[_CREATOR_YEAR_]", "[_APP_NAME_VER_]", "[_APP_NAMES_VER_]", "[_APP_NAME_]", "[_APP_NAMES_]", "[_APP_NAMES_UP_]", "[_APP_VER_]", "[_APP_UPDATED_]", "[_REG_ID_]", "[_REG_NAME_]", "[_REG_NAME_UP_]", "[_REG_ADDRESS_]", "[_REG_CITY_]", "[_REG_CITY_UP_]", "[_REG_PHONE_]", "[_REG_FAX_]", "[_REG_EMAIL_]", "[_REG_POSTCODE_]", "[_REG_WEBSITE_]", "[_REG_YEAR_]", "[_USER_IMG_]", "[_WEB_PATH_]", "[_NAVI_SIDEBAR_]", "[_NAVI_HEADER_]");
$adst = array($this->apps['CREATOR_NAME'], $this->apps['CREATOR_WEBSITE'], $this->apps['CREATOR_YEAR'], $this->apps['APP_NAME']." v".$this->apps['APP_VER'], $this->apps['APP_NAMES']." v".$this->apps['APP_VER'], $this->apps['APP_NAME'], $this->apps['APP_NAMES'], strtoupper($this->apps['APP_NAMES']??""), $this->apps['APP_VER'], $this->apps['APP_UPDATED'], $this->reg->reg_id(), $this->apps['REG_NAME'], strtoupper($this->apps['REG_NAME']??""), $this->apps['REG_ADDRESS'], $this->apps['REG_CITY'], strtoupper($this->apps['REG_CITY']??""), $this->apps['REG_PHONE'], $this->apps['REG_FAX'], $this->apps['REG_EMAIL'], $this->apps['REG_POSTCODE'], $this->apps['REG_WEBSITE'], $this->apps['REG_YEAR'], "profiles/".$this->auser['user_img'], $this->apps['WEB_PATH'], $tnaviside, $tnavihead); $adst = array($this->apps['CREATOR_NAME'], $this->apps['CREATOR_WEBSITE'], $this->apps['CREATOR_YEAR'], $this->apps['APP_NAME']." v".$this->apps['APP_VER'], $this->apps['APP_NAMES']." v".$this->apps['APP_VER'], $this->apps['APP_NAME'], $this->apps['APP_NAMES'], strtoupper($this->apps['APP_NAMES']??""), $this->apps['APP_VER'], $this->apps['APP_UPDATED'], $this->reg->reg_id(), $this->apps['REG_NAME'], strtoupper($this->apps['REG_NAME']??""), $this->apps['REG_ADDRESS'], $this->apps['REG_CITY'], strtoupper($this->apps['REG_CITY']??""), $this->apps['REG_PHONE'], $this->apps['REG_FAX'], $this->apps['REG_EMAIL'], $this->apps['REG_POSTCODE'], $this->apps['REG_WEBSITE'], $this->apps['REG_YEAR'], $this->auser['user_img']??"", $this->apps['WEB_PATH'], $tnaviside, $tnavihead);
$buffer = str_replace($asrc, $adst, $buffer); $buffer = str_replace($asrc, $adst, $buffer);
if (isset($this->auser) && is_array($this->auser)) { if (isset($this->auser) && is_array($this->auser)) {
+77 -76
View File
@@ -3,7 +3,7 @@
/******************************************************************* /*******************************************************************
Module : /DB/MySQL.php Module : /DB/MySQL.php
Desc. : v4 - Class database MySQL / MariaDB Desc. : Class database MySQL / MariaDB
Created By : Siau Pheng (siaupheng@3fonia.com). Created By : Siau Pheng (siaupheng@3fonia.com).
Created Date : February 2nd, 2007. Created Date : February 2nd, 2007.
Last Modified : October 19th, 2023. Last Modified : October 19th, 2023.
@@ -14,88 +14,87 @@
declare(strict_types=1); declare(strict_types=1);
namespace siaupheng\fonia3\DB; namespace siaupheng\webapp\DB;
final class MySQL { final class MySQL {
private $cnn; private $conn = null;
private $rs = 0; private $rs = 0;
private $rec = array(); private $rec = [];
private $row = 0; private $row = 0;
private $halt_on_error = 1; //1: halt w message, 2: not halt w message, 3: not halt no message
private $auto_free = 1; //1: free query automatically, 0: must call free method to free query private $auto_free = 1; //1: free query automatically, 0: must call free method to free query
private $db_config = null; private $db_config = [ 'host'=>"", 'port'=>3306, 'user'=>"", 'pwd'=>"", 'db'=>"", 'sock'=>"" ];
private $err_num = 0; private $err_num = 0;
private $err_msg = ''; private $err_msg = '';
private $debug_msg = 1; private $debug_msg = 1;
private $ischangingdb = false; private $ischangingdb = false;
public function __construct() { public function __construct() {//oke
if (!is_array($this->db_config)) $this->setConfig(); if ($this->db_config['host']=="") $this->setConfig();
$this->debug_msg = ($_SERVER['SERVER_ADDR'] == "127.0.0.1") ? 1 : 0; $this->debug_msg = ($_SERVER['SERVER_ADDR'] == "127.0.0.1") ? 1 : 0;
} }
private function setConfig() { private function setConfig() {//oke
global $APP_DATA; global $APP_DATA;
if (!is_array($APP_DATA)) { if (!is_array($APP_DATA)) {
if (file_exists($_SESSION['__WEB_APP']['REAL_PATH']."apps/cfg/mysql.php")) if (file_exists($_SESSION['__WEB_APP']['REAL_PATH']."apps/cfg/mysql.php"))
require_once($_SESSION['__WEB_APP']['REAL_PATH']."apps/cfg/mysql.php"); require_once($_SESSION['__WEB_APP']['REAL_PATH']."apps/cfg/mysql.php");
if (file_exists($_SESSION['__WEB_APP']['REAL_PATH']."apps/cfg/mariadb.php"))
require_once($_SESSION['__WEB_APP']['REAL_PATH']."apps/cfg/mariadb.php");
} }
$this->db_config = $APP_DATA; $this->db_config = array_merge($this->db_config, $APP_DATA);
} }
public function getConfig() { public function getConfig() {//oke
return $this->db_config; return $this->db_config;
} }
function Connect() { function Connect() {//oke
if (!$this->cnn) { if (!$this->conn) {
$this->cnn = @mysqli_connect($this->db_config['host'], $this->db_config['user'], $this->db_config['pwd'], $this->db_config['db'], intval($this->db_config['port']), $this->db_config['sock']); [ $host, $port, $user, $pwd, $db, $sock ] = array_values($this->db_config);
if (!$this->cnn) { $this->conn = new \mysqli($host, $user, $pwd, $db, (int)$port, $sock);
$this->ErrHandler("Connection failed!"); if ($this->conn->connect_error) {
$this->ErrHandler("Connection failed: " . $this->conn->connect_error);
return 0; return 0;
} else {
@mysqli_query($this->cnn, "SET NAMES utf8");
@mysqli_query($this->cnn, "SET CHARACTER SET utf8");
@mysqli_query($this->cnn, "SET character_set_connection=utf8");
} }
$this->conn->set_charset("utf8mb4");
} }
return $this->cnn; return $this->conn;
} }
function Connection() { function Connection() {//oke
return $this->cnn; return $this->conn;
} }
function ResultSet() { function ResultSet() {//oke
return $this->rs; return $this->rs;
} }
function Free() { function Free() {//oke
if (is_resource($this->rs)) @mysqli_free_result($this->rs); if (is_resource($this->rs)) $this->rs->free();
$this->rs = 0; $this->rs = 0;
$this->row = 0; $this->row = 0;
$this->rec = array(); $this->rec = [];
$this->err_num = 0; $this->err_num = 0;
$this->err_msg = ''; $this->err_msg = '';
} }
function SafeSQL($str) { function SafeSQL($str = "") {//oke
if (!$this->cnn) $this->Connect(); if (!$this->conn) $this->Connect();
return mysqli_real_escape_string($this->cnn, strval($str)); return $this->conn->real_escape_string((string) $str);
} }
function &Query($stqry = "", $dbname = "") { function Query($stqry = "", $dbname = "") {//oke
if ($stqry == "") return 0; if ($stqry == "") return 0;
if (!$this->Connect()) return 0; if (!$this->Connect()) return 0;
if ($dbname != "" || $this->ischangingdb) { if ($dbname != "" || $this->ischangingdb) {
if ($dbname != "") { if ($dbname != "") {
if (!@mysqli_select_db($this->cnn, $dbname)) { if (!$this->conn->select_db($dbname)) {
$this->ErrHandler("Cannot select database!"); $this->ErrHandler("Cannot select database!");
return 0; return 0;
} }
$this->ischangingdb = true; $this->ischangingdb = true;
} else { } else {
if (!@mysqli_select_db($this->cnn, $this->db_config['db'])) { if (!$this->conn->select_db($this->db_config['db'])) {
$this->ErrHandler("Cannot select database!"); $this->ErrHandler("Cannot select database!");
return 0; return 0;
} }
@@ -103,35 +102,43 @@ final class MySQL {
} }
} }
if ($this->rs) $this->Free(); if ($this->rs) $this->Free();
$this->rs = @mysqli_query($this->cnn, $stqry); $this->rs = $this->conn->query($stqry);
$this->row = 0; $this->row = 0;
$this->err_msg = @mysqli_error($this->cnn); if (!$this->rs) $this->ErrHandler("Invalid SQL: " . $this->conn->error);
if (!$this->rs) $this->ErrHandler("Invalid SQL!: ".$stqry);
return $this->rs; return $this->rs;
} }
function Next() { function Execute($sqry = "", $aval = []) {//oke
if ($sqry == "" || count($aval) == 0) return 0;
if (!$this->Connect()) return 0;
if ($this->rs) $this->Free();
$this->rs = $this->conn->execute_query($sqry, $aval);
$this->row = 0;
if (!$this->rs) $this->ErrHandler("Invalid SQL: " . $this->conn->error);
return $this->rs;
}
function Next() {//oke
if (!$this->rs) { if (!$this->rs) {
$this->ErrHandler("Cannot move cursor to next record!"); $this->ErrHandler("Cannot move cursor to next record!");
return 0; return 0;
} }
$this->rec = @mysqli_fetch_array($this->rs, MYSQLI_ASSOC); $this->rec = $this->rs->fetch_assoc();
$this->row += 1; $this->row++;
$this->err_msg = @mysqli_error($this->cnn);
$result = is_array($this->rec); $result = is_array($this->rec);
if (!$result && $this->auto_free) $this->Free(); if (!$result && $this->auto_free) $this->Free();
return $result; return $result;
} }
function Reset() { function Reset() {//oke
@mysqli_data_seek($this->rs, 0); $this->rs->data_seek(0);
} }
function Seek($rownum = 0) { function Seek($rownum = 0) {//oke
return @mysqli_data_seek($this->rs, $rownum); return $this->rs->data_seek($rownum);
} }
function Row($name = "", $defval = "") { function Row($name = "", $defval = "") {//oke
if (isset($this->rec[$name])) { if (isset($this->rec[$name])) {
return (($this->rec[$name] == "") ? $defval : $this->rec[$name]); return (($this->rec[$name] == "") ? $defval : $this->rec[$name]);
} else { } else {
@@ -147,80 +154,74 @@ final class MySQL {
} else return $defval; } else return $defval;
} }
function RowFloat($name = "", $defval = 0) { function RowFloat($name = "", $defval = 0) {//oke
$defval = is_numeric($defval) ? $defval : 0; $defval = is_numeric($defval) ? $defval : 0;
if (isset($this->rec[$name])) { if (isset($this->rec[$name])) {
if ($this->rec[$name]) $defval = $this->rec[$name]; if ($this->rec[$name]) $defval = $this->rec[$name];
} }
return floatval($defval); return (float)$defval;
} }
function AllRow() { function AllRow() {//oke
return $this->rec; return $this->rec;
} }
function ValueArray($colname = "") { function ValueArray($colname = "") {//oke
$currrow = $this->row; $currrow = $this->row;
@mysqli_data_seek($this->rs, 0); $this->rs->data_seek(0);
$result = array(); $result = [];
while ($__row = mysqli_fetch_array($this->rs)) while ($__row = $this->rs->fetch_array())
if (isset($__row[$colname])) array_push($result, $__row[$colname]); if (isset($__row[$colname])) array_push($result, $__row[$colname]);
@mysqli_data_seek($this->rs, $currrow); $this->rs->data_seek($currrow);
return $result; return $result;
} }
function ValueArrayFormater($colname = "", $formater = "") { function ValueArrayFormater($colname = "", $formater = "") {
/* TIDAK DIGUNAKAN !
$currrow = $this->row; $currrow = $this->row;
$formater = $formater == ""?$formater = "return \$__row[\$colname];":"return ".str_replace("<value>", "\$__row[\$colname]", $formater).";"; $formater = $formater == ""?$formater = "return \$__row[\$colname];":"return ".str_replace("<value>", "\$__row[\$colname]", $formater).";";
@mysqli_data_seek($this->rs, 0); @mysqli_data_seek($this->rs, 0);
$result = array(); $result = [];
while ($__row = mysqli_fetch_array($this->rs)) while ($__row = mysqli_fetch_array($this->rs))
if (isset($__row[$colname])) array_push($result, eval($formater)); if (isset($__row[$colname])) array_push($result, eval($formater));
@mysqli_data_seek($this->rs, $currrow); @mysqli_data_seek($this->rs, $currrow);
return $result; return $result;*/
} }
function ValueList($colname = "", $delim = ",") { function ValueList($colname = "", $delim = ",") {//oke
$result = @$this->ValueArray($colname); $result = @$this->ValueArray($colname);
return @implode($delim, $result); return @implode($delim, $result);
} }
function CurrentRow() { function CurrentRow() {//oke
return $this->row; return $this->row;
} }
function AffectedRows() { function AffectedRows() {//oke
return @mysqli_affected_rows($this->cnn); return $this->conn->affected_rows;
} }
function RecordCount() { function RecordCount() {//oke
return @mysqli_num_rows($this->rs); return $this->rs->num_rows;
} }
function NumFields() { function NumFields() {//oke
return @mysqli_num_fields($this->rs); return $this->rs->field_count;
} }
function LastInsertID() { function LastInsertID() {//oke
$lastinsertid = -1; return $this->conn->insert_id ?? -1;
$crs = @mysqli_query($this->cnn, "SELECT LAST_INSERT_ID() AS lastinsertid");
$crow = @mysqli_fetch_array($crs);
if (isset($crow["lastinsertid"])) if (is_numeric($crow["lastinsertid"])) $lastinsertid = $crow["lastinsertid"];
return $lastinsertid;
} }
function ErrHandler($err_msg = "") { function ErrHandler($err_msg = "") {//oke
$this->err_msg = @mysqli_error($this->cnn); $err_msg = $err_msg ?? $this->conn->error ?? "Undefined error!";
if ($this->halt_on_error == 3) return;
if ($err_msg == "") $err_msg = "Undefined error!";
if ($this->debug_msg) { if ($this->debug_msg) {
printf('<span style="font-size:1.2em;"><b>MySQL Error : %s</b> %s</span><br>', $this->db_config['db'], $this->err_msg); printf('<span style="font-size:1.2em;"><b>MySQL Error : %s</b> %s</span><br>', $this->db_config['db'], $err_msg);
printf('<span style="font-size:1.2em;"><b>Database error : </b> %s</span><br>', $err_msg); printf('<span style="font-size:1.2em;"><b>Database error : </b> %s</span><br>', $err_msg);
} }
if ($this->halt_on_error == 1) die("");
} }
function getDBName() { function getDBName() {//oke
return $this->db_config['db']; return $this->db_config['db'];
} }
} }
+103 -69
View File
@@ -3,7 +3,7 @@
/******************************************************************* /*******************************************************************
Module : /DB/SQL.php Module : /DB/SQL.php
Desc. : v4 - Class Query database Desc. : Class Query database
Created By : Siau Pheng (siaupheng@3fonia.com). Created By : Siau Pheng (siaupheng@3fonia.com).
Created Date : February 2nd, 2007. Created Date : February 2nd, 2007.
Last Modified : December 17th, 2023. Last Modified : December 17th, 2023.
@@ -14,116 +14,150 @@
declare(strict_types=1); declare(strict_types=1);
namespace siaupheng\fonia3\DB; namespace siaupheng\webapp\DB;
final class SQL { final class SQL {
private $__ttable = ""; private $__ttable = "";
private $__afield = array(); private $__avalue = [];
private $__avalue = array(); private $__awhere = [];
private $__anomor = array();
private $__twhere = "";
protected $__db = null; protected $__db = null;
public function __construct($db = null){ public function __construct($db = null) {//oke
if (is_resource($db)) { $this->__db = $db; } if (is_resource($db)) { $this->__db = $db; }
else { $this->__db = new \siaupheng\fonia3\DB\MySQL(); } else { $this->__db = new \siaupheng\webapp\DB\MySQL(); }
} }
public function SafeSQL($ttext = "") { public function SafeSQL($ttext = "") {//oke
return $this->__db->SafeSQL($ttext); return $this->__db->SafeSQL($ttext);
} }
public function set_table($ttable = "") { public function set_table($ttable = "") {//oke
$this->__ttable = $ttable; $this->__ttable = $ttable;
} }
public function add_param($tparam = "", $tvalue = null, $bnomor = false) { public function add_param($tparam = "", $tvalue = null, $bnomor = false) {//oke
$this->__afield[] = $tparam; $this->__avalue[$tparam] = [ 'value' => (is_null($tvalue) && isset($_REQUEST[$tparam])) ? $this->__db->SafeSQL($_REQUEST[$tparam]) : $tvalue, 'num' => $bnomor ];
$this->__avalue[] = (is_null($tvalue) && isset($_REQUEST[$tparam])) ? $this->__db->SafeSQL($_REQUEST[$tparam]) : $tvalue;
$this->__anomor[] = $bnomor;
} }
public function add_param_date($tparam = "", $tvalue = null) { public function add_param_date($tparam = "", $tvalue = null) {//oke
$this->__afield[] = $tparam; $_tvalue = (is_null($tvalue) && isset($_REQUEST[$tparam])) ? $this->__db->SafeSQL($_REQUEST[$tparam]) : $tvalue;
$this->__avalue[] = tgl_sql2str((is_null($tvalue) && isset($_REQUEST[$tparam])) ? $this->__db->SafeSQL($_REQUEST[$tparam]) : $tvalue); $this->__avalue[$tparam] = [ 'value' => (empty($_tvalue)) ? "0" : tgl_sql2str($_tvalue), 'num' => false ];
$this->__anomor[] = false;
} }
public function add_param_stamp($tparam = "DateStamp") { public function add_param_stamp($tparam = "DateStamp") {//oke
$this->__afield[] = $tparam; $this->__avalue[$tparam] = [ 'value' => "NOW()", 'num' => true ];
$this->__avalue[] = "NOW()";
$this->__anomor[] = true;
} }
public function add_param_unix() { public function add_param_unix() {//oke
$this->__afield[] = "Unix"; $this->__avalue['Unix'] = [ 'value' => user_unix(), 'num' => false ];
$this->__avalue[] = user_unix();
$this->__anomor[] = false;
} }
public function add_param_userid($tparam = "UserID") { public function add_param_userid($tparam = "UserID") {//oke
$this->__afield[] = $tparam; $this->__avalue[$tparam] = [ 'value' => user_id(), 'num' => false ];
$this->__avalue[] = user_id();
$this->__anomor[] = false;
} }
public function add_where_unix() { public function add_where($tfield = "", $tvalue = null) {//oke
$this->__twhere .= (($this->__twhere=="") ? " WHERE " : " AND ") . "(Unix='".user_unix()."')"; $this->__awhere[$tfield] = (is_null($tvalue) && isset($_REQUEST[$tfield])) ? $this->__db->SafeSQL($_REQUEST[$tfield]) : $tvalue;
} }
public function add_where_date($tfield = "", $tvalue = null) { public function add_where_unix() {//oke
$tvalue = ($tvalue == null) ? "0000-00-00" : tgl_sql2str($tvalue); $this->__awhere['Unix'] = user_unix();
$this->add_where($tfield, $tvalue);
} }
public function add_where($tfield = "", $tvalue = null) { public function add_where_date($tfield = "", $tvalue = null) {//oke
$__tvalue = (is_null($tvalue) && isset($_REQUEST[$tfield])) ? $this->__db->SafeSQL($_REQUEST[$tfield]) : $tvalue; $_tvalue = ($tvalue == null) ? "0" : tgl_sql2str($tvalue);
$this->__twhere .= (($this->__twhere=="") ? " WHERE " : " AND ") . "(".$tfield."='".$__tvalue."')"; $this->__awhere[$tfield] = $_tvalue;
} }
public function clear_param() { public function clear_param() {//oke
$this->__afield = array(); $this->__avalue = [];
$this->__avalue = array();
$this->__anomor = array();
} }
public function clear_where() { public function clear_where() {//oke
$this->__twhere = ""; $this->__awhere = [];
} }
public function InsertDB() { public function InsertDB() {//oke
$tsql = "INSERT INTO ".$this->__ttable." ("; $_columns = implode(', ', array_keys($this->__avalue));
$tfield = ""; $_aholder = []; $_avalues = [];
$tvalue = ""; foreach ($this->__avalue as $aval) {
for ($i=0; $i<count($this->__afield); $i++) { if ($aval['num'] == true) {
$tfield .= ",".$this->__afield[$i]; $_aholder[] = $aval['value'];
$tvalue .= ",".(($this->__anomor[$i])?"":"'").$this->__avalue[$i].(($this->__anomor[$i])?"":"'"); } else {
$_aholder[] = "?";
$_avalues[] = $aval['value'] ?? "";
}
} }
$tsql .= substr($tfield,1); $_holder = implode(', ', $_aholder);
$tsql .= ") VALUES ("; $_tsql = "INSERT INTO {$this->__ttable} ({$_columns}) VALUES ({$_holder})";
$tsql .= substr($tvalue,1); $this->__db->Execute($_tsql, $_avalues);
$tsql .= ")";
$this->__db->Query($tsql);
} }
public function UpdateDB() { public function UpdateDB() {//oke
$tsql = "UPDATE ".$this->__ttable." SET "; $_aupdate = []; $_awhere = []; $_avalues = [];
$tfield = ""; foreach ($this->__avalue as $field => $aval) {
for ($i=0; $i<count($this->__afield); $i++) { if ($aval['num'] == true) {
$tfield .= ",".$this->__afield[$i]."=".(($this->__anomor[$i])?"":"'").$this->__avalue[$i].(($this->__anomor[$i])?"":"'"); $_aupdate[] = "`{$field}` = " . $aval['value'];
} else {
$_aupdate[] = "`{$field}` = ?";
$_avalues[] = $aval['value'] ?? "";
}
} }
$tsql .= substr($tfield,1); foreach ($this->__awhere as $field => $val) {
$tsql .= ($this->__twhere=="") ? "" : $this->__twhere; $_awhere[] = "`{$field}` = ?";
$this->__db->Query($tsql); $_avalues[] = $val ?? "";
}
$_update = implode(", ", $_aupdate);
$_where = implode(" AND ", $_awhere);
$_tsql = "UPDATE {$this->__ttable} SET {$_update} WHERE {$_where}";
$this->__db->Execute($_tsql, $_avalues);
} }
public function DeleteDB() { public function DeleteDB() {//oke
$tsql = "DELETE FROM ".$this->__ttable; $_awhere = []; $_avalues = [];
$tsql .= ($this->__twhere=="") ? "" : $this->__twhere; foreach ($this->__awhere as $field => $val) {
$this->__db->Query($tsql); $_awhere[] = "`{$field}` = ?";
$_avalues[] = $val ?? "";
}
$_where = implode(" AND ", $_awhere);
$_tsql = "DELETE FROM {$this->__ttable} WHERE {$_where}";
$this->__db->Execute($_tsql, $_avalues);
} }
public function LastInsertID() { public function fastInsertDB($nama_tabel = "", $adata = []) {//oke
if ($nama_tabel=="" || count($adata)==0) return false;
$_columns = implode(', ', array_keys($adata));
$_holder = implode(', ', array_fill(0, count($adata), "?"));
$_avalues = array_map(fn($val) => $val ?? "", array_values($adata));
$_tsql = "INSERT IGNORE INTO {$nama_tabel} ({$_columns}) VALUES ({$_holder})";
$this->__db->Execute($_tsql, $_avalues);
return true;
}
function fastUpdateDB($nama_tabel = "", $adata = [], $awhere = []) {//oke
if ($nama_tabel=="" || count($adata)==0 || count($awhere)==0) return false;
$_aupdate = array_map(fn($key) => "`{$key}` = ?", array_keys($adata));
$_awhere = array_map(fn($key) => "`{$key}` = ?", array_keys($awhere));
$_avalues = array_merge(array_values($adata), array_values($awhere));
$_avalues = array_map(fn($val) => $val ?? "", $_avalues);
$_update = implode(", ", $_aupdate);
$_where = implode(" AND ", $_awhere);
$_tsql = "UPDATE {$nama_tabel} SET {$_update} WHERE {$_where}";
$this->__db->Execute($_tsql, $_avalues);
return true;
}
function fastDeleteDB($nama_tabel = "", $awhere = []) {//oke
if ($nama_tabel=="" || count($awhere)==0) return false;
$_awhere = array_map(fn($key) => "`{$key}` = ?", array_keys($awhere));
$_avalues = array_map(fn($val) => $val ?? "", array_values($awhere));
$_where = implode(" AND ", $_awhere);
$_tsql = "DELETE FROM {$nama_tabel} WHERE {$_where}";
$this->__db->Execute($_tsql, $_avalues);
return true;
}
public function LastInsertID() {//oke
return $this->__db->LastInsertID(); return $this->__db->LastInsertID();
} }
} }
+1 -1
View File
@@ -49,7 +49,7 @@ final class XLS {
'alignment' => ['horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER, 'vertical' => \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER, 'wrapText' => true], 'alignment' => ['horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER, 'vertical' => \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER, 'wrapText' => true],
'fill' => ['fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID, 'startColor' => ['rgb'=>"D0D0D0"]], 'fill' => ['fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID, 'startColor' => ['rgb'=>"D0D0D0"]],
'borders' => ['allBorders' => ['borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN, 'color' => ['rgb'=>"C0C0C0"]]] 'borders' => ['allBorders' => ['borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN, 'color' => ['rgb'=>"C0C0C0"]]]
] ];
} }
public function create_style($tstyle="L") {//oke public function create_style($tstyle="L") {//oke
+2 -5
View File
@@ -199,14 +199,11 @@ final class Form {
$_blur = ($tblur==null) ? "" : ' onblur="'.$tblur.'"'; $_blur = ($tblur==null) ? "" : ' onblur="'.$tblur.'"';
$_holdtxt = ($holdtxt==null) ? "" : ' placeholder="'.$holdtxt.'"'; $_holdtxt = ($holdtxt==null) ? "" : ' placeholder="'.$holdtxt.'"';
$_tclass = ""; $_tclass = "";
if (in_array($ttype,array("pickdate","picktime"))) { if (in_array($ttype,array("pickdate","picktime","integer","angka","double"))) {
$_tclass = ' '.$ttype; $_tclass = ' '.$ttype;
$ttype = "text"; $ttype = "text";
} }
if (in_array($ttype,array("double"))) { if (in_array($ttype,array("double"))) $tvalue = uang2($tvalue);
$_tclass = ' '.$ttype;
$tvalue = uang2($tvalue);
}
$tout = '<input type="'.$ttype.'" class="form-control'.$_tclass.'" id="'.$tfield.'" name="'.$tfield.'" value="'.$tvalue.'"'.$_enab.$_max.$_keyup.$_blur.$_holdtxt.$_req.' />'; $tout = '<input type="'.$ttype.'" class="form-control'.$_tclass.'" id="'.$tfield.'" name="'.$tfield.'" value="'.$tvalue.'"'.$_enab.$_max.$_keyup.$_blur.$_holdtxt.$_req.' />';
$this->__aform[$tfield] = array('label'=>$tlabel, 'help'=>$thelp, 'form'=>$tout); $this->__aform[$tfield] = array('label'=>$tlabel, 'help'=>$thelp, 'form'=>$tout);
return $tout; return $tout;
+1 -1
View File
@@ -130,7 +130,7 @@ final class Menu {
'SYSC' => ['Kode'=>"SYSC", 'Judul'=>"Ubah Password", 'Link'=>"sys/chpasswd.php", 'JS'=>"SYSChpasswdJS", 'Width'=>500, 'Button'=>'[{},{"i":"butBatal"},{"i":"butSave","v":"Simpan","c":"success"}]'] 'SYSC' => ['Kode'=>"SYSC", 'Judul'=>"Ubah Password", 'Link'=>"sys/chpasswd.php", 'JS'=>"SYSChpasswdJS", 'Width'=>500, 'Button'=>'[{},{"i":"butBatal"},{"i":"butSave","v":"Simpan","c":"success"}]']
]; ];
if ($acus_page[$page]) { if ($acus_page[$page] ?? false) {
$apage = $acus_page[$page]; $apage = $acus_page[$page];
} else if ($page <> "") { } else if ($page <> "") {
$_mdb->Query("SELECT * FROM app_menu WHERE Kode='".$page."'"); $_mdb->Query("SELECT * FROM app_menu WHERE Kode='".$page."'");
+1
View File
@@ -191,6 +191,7 @@ final class Table {
// adding all option // adding all option
for ($i=0; $i<count($this->__aoption); $i++) { for ($i=0; $i<count($this->__aoption); $i++) {
if (in_array($this->__aoption[$i]['type'], ["button","button-dt"])) { if (in_array($this->__aoption[$i]['type'], ["button","button-dt"])) {
if (!isset($this->__aoption[$i]['field'])) continue;
if (($this->__aoption[$i]['field']!="") && ($this->__cdb->Row($this->__aoption[$i]['field'])<>(trim("".$this->__aoption[$i]['value'])!="" ? $this->__aoption[$i]['value'] : $_SESSION['__WEB_USER']['UNIX']))) {} else { if (($this->__aoption[$i]['field']!="") && ($this->__cdb->Row($this->__aoption[$i]['field'])<>(trim("".$this->__aoption[$i]['value'])!="" ? $this->__aoption[$i]['value'] : $_SESSION['__WEB_USER']['UNIX']))) {} else {
$aoption['button'][] = [$this->__aoption[$i]['icon'], (empty($this->__aoption[$i]['field_css'])?'':$this->__aoption[$i]['avalue_css'][$this->__cdb->Row($this->__aoption[$i]['field_css'])]??'')]; $aoption['button'][] = [$this->__aoption[$i]['icon'], (empty($this->__aoption[$i]['field_css'])?'':$this->__aoption[$i]['avalue_css'][$this->__cdb->Row($this->__aoption[$i]['field_css'])]??'')];
} }