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;
},
FormDecorated: function() {
$('input').each((i, el) => {
$('input.form-control[class*=integer], input.form-control[class*=angka]').each((i, 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
// 8:backspace 46:delete 45:delete 48-57/96-105:num 110/190:dot 109/189/173:minus 107/187/61:plus
if (elm.hasClass('integer') || elm.hasClass('angka')) {
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));
});
} else if (elm.hasClass('number')) {
elm.keydown((e) => {
var key = e.keyCode ?? e.which;
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.focus((e) => {
$(e.currentTarget).val( FoniaJS.StrToFloat($(e.currentTarget).val()) );
});
elm.blur((e) => {
$(e.currentTarget).val( FoniaJS.FloatToStr($(e.currentTarget).val(), 0) );
});
} else if (elm.hasClass('double')) {
elm.keydown((e) => {
var key = e.keyCode ?? e.which;
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.focus((e) => {
$(e.currentTarget).val( FoniaJS.StrToFloat($(e.currentTarget).val()) );
$(e.currentTarget).select();
});
elm.blur((e) => {
$(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);
}
elm.on('keypress keyup blur paste', (e) => {
elm.val(elm.val().replace(/[^\d].+/, ""));
if ((e.which < 48 || e.which > 57)) e.preventDefault();
});
});
$('input.form-control[class*=double]').each((i, el) => {
const elm = $(el);
elm.on('keypress keyup blur paste', (e) => {
elm.val(elm.val().replace(/[^0-9\.]/g,''));
if (e.type === 'blur') elm.val( FoniaJS.FloatToStr(elm.val(), 2) );
if ((e.which != 46 || elm.val().indexOf('.') != -1) && (e.which < 48 || e.which > 57)) e.preventDefault();
});
elm.on('focus', (e) => {
elm.val( FoniaJS.StrToFloat(elm.val()) );
elm.select();
e.preventDefault();
});
});
$('input.form-control[type=number]').each((i, el) => {
const elm = $(el);
elm.on('keypress keyup blur paste', (e) => {
elm.val(elm.val().replace(/[^0-9]/g,''));
if ((e.which != 46 || elm.val().indexOf('.') != -1) && (e.which < 48 || e.which > 57)) e.preventDefault();
});
});
$('input[class*=error][type=hidden]').each((i, el) => {
const elm = $(el);
this.showError(elm.val());
});
$('.option-tags').each((i, 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 {
public $version = "4.0.0";
private $apps = array();
private $auser = array();
private $apps = [];
private $auser = [];
private $cache = null;
private $menu = null;
private $reg = null;
@@ -35,9 +35,9 @@ final class App {
if (isset($_SESSION['__WEB_USER'])) {
$this->apps['TEMPLATE'] = "index.php";
$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")) {
$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);
@@ -45,7 +45,7 @@ final class App {
$this->menu = new \siaupheng\fonia3\Web\Menu($this->__db);
}
public function TampilApp($aoption = array()) {
public function TampilApp($aoption = []) {
// cek register
if ($this->reg->reg_check()) {
if (!user_logged()) {
@@ -99,7 +99,7 @@ final class App {
// 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_]");
$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);
if (isset($this->auser) && is_array($this->auser)) {
+77 -76
View File
@@ -3,7 +3,7 @@
/*******************************************************************
Module : /DB/MySQL.php
Desc. : v4 - Class database MySQL / MariaDB
Desc. : Class database MySQL / MariaDB
Created By : Siau Pheng ([email protected]).
Created Date : February 2nd, 2007.
Last Modified : October 19th, 2023.
@@ -14,88 +14,87 @@
declare(strict_types=1);
namespace siaupheng\fonia3\DB;
namespace siaupheng\webapp\DB;
final class MySQL {
private $cnn;
private $conn = null;
private $rs = 0;
private $rec = array();
private $rec = [];
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 $db_config = null;
private $db_config = [ 'host'=>"", 'port'=>3306, 'user'=>"", 'pwd'=>"", 'db'=>"", 'sock'=>"" ];
private $err_num = 0;
private $err_msg = '';
private $debug_msg = 1;
private $ischangingdb = false;
public function __construct() {
if (!is_array($this->db_config)) $this->setConfig();
public function __construct() {//oke
if ($this->db_config['host']=="") $this->setConfig();
$this->debug_msg = ($_SERVER['SERVER_ADDR'] == "127.0.0.1") ? 1 : 0;
}
private function setConfig() {
private function setConfig() {//oke
global $APP_DATA;
if (!is_array($APP_DATA)) {
if (file_exists($_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;
}
function Connect() {
if (!$this->cnn) {
$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']);
if (!$this->cnn) {
$this->ErrHandler("Connection failed!");
function Connect() {//oke
if (!$this->conn) {
[ $host, $port, $user, $pwd, $db, $sock ] = array_values($this->db_config);
$this->conn = new \mysqli($host, $user, $pwd, $db, (int)$port, $sock);
if ($this->conn->connect_error) {
$this->ErrHandler("Connection failed: " . $this->conn->connect_error);
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() {
return $this->cnn;
function Connection() {//oke
return $this->conn;
}
function ResultSet() {
function ResultSet() {//oke
return $this->rs;
}
function Free() {
if (is_resource($this->rs)) @mysqli_free_result($this->rs);
function Free() {//oke
if (is_resource($this->rs)) $this->rs->free();
$this->rs = 0;
$this->row = 0;
$this->rec = array();
$this->rec = [];
$this->err_num = 0;
$this->err_msg = '';
}
function SafeSQL($str) {
if (!$this->cnn) $this->Connect();
return mysqli_real_escape_string($this->cnn, strval($str));
function SafeSQL($str = "") {//oke
if (!$this->conn) $this->Connect();
return $this->conn->real_escape_string((string) $str);
}
function &Query($stqry = "", $dbname = "") {
function Query($stqry = "", $dbname = "") {//oke
if ($stqry == "") return 0;
if (!$this->Connect()) return 0;
if ($dbname != "" || $this->ischangingdb) {
if ($dbname != "") {
if (!@mysqli_select_db($this->cnn, $dbname)) {
if (!$this->conn->select_db($dbname)) {
$this->ErrHandler("Cannot select database!");
return 0;
}
$this->ischangingdb = true;
} 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!");
return 0;
}
@@ -103,35 +102,43 @@ final class MySQL {
}
}
if ($this->rs) $this->Free();
$this->rs = @mysqli_query($this->cnn, $stqry);
$this->rs = $this->conn->query($stqry);
$this->row = 0;
$this->err_msg = @mysqli_error($this->cnn);
if (!$this->rs) $this->ErrHandler("Invalid SQL!: ".$stqry);
if (!$this->rs) $this->ErrHandler("Invalid SQL: " . $this->conn->error);
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) {
$this->ErrHandler("Cannot move cursor to next record!");
return 0;
}
$this->rec = @mysqli_fetch_array($this->rs, MYSQLI_ASSOC);
$this->row += 1;
$this->err_msg = @mysqli_error($this->cnn);
$this->rec = $this->rs->fetch_assoc();
$this->row++;
$result = is_array($this->rec);
if (!$result && $this->auto_free) $this->Free();
return $result;
}
function Reset() {
@mysqli_data_seek($this->rs, 0);
function Reset() {//oke
$this->rs->data_seek(0);
}
function Seek($rownum = 0) {
return @mysqli_data_seek($this->rs, $rownum);
function Seek($rownum = 0) {//oke
return $this->rs->data_seek($rownum);
}
function Row($name = "", $defval = "") {
function Row($name = "", $defval = "") {//oke
if (isset($this->rec[$name])) {
return (($this->rec[$name] == "") ? $defval : $this->rec[$name]);
} else {
@@ -147,80 +154,74 @@ final class MySQL {
} else return $defval;
}
function RowFloat($name = "", $defval = 0) {
function RowFloat($name = "", $defval = 0) {//oke
$defval = is_numeric($defval) ? $defval : 0;
if (isset($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;
}
function ValueArray($colname = "") {
function ValueArray($colname = "") {//oke
$currrow = $this->row;
@mysqli_data_seek($this->rs, 0);
$result = array();
while ($__row = mysqli_fetch_array($this->rs))
$this->rs->data_seek(0);
$result = [];
while ($__row = $this->rs->fetch_array())
if (isset($__row[$colname])) array_push($result, $__row[$colname]);
@mysqli_data_seek($this->rs, $currrow);
$this->rs->data_seek($currrow);
return $result;
}
function ValueArrayFormater($colname = "", $formater = "") {
/* TIDAK DIGUNAKAN !
$currrow = $this->row;
$formater = $formater == ""?$formater = "return \$__row[\$colname];":"return ".str_replace("<value>", "\$__row[\$colname]", $formater).";";
@mysqli_data_seek($this->rs, 0);
$result = array();
$result = [];
while ($__row = mysqli_fetch_array($this->rs))
if (isset($__row[$colname])) array_push($result, eval($formater));
@mysqli_data_seek($this->rs, $currrow);
return $result;
return $result;*/
}
function ValueList($colname = "", $delim = ",") {
function ValueList($colname = "", $delim = ",") {//oke
$result = @$this->ValueArray($colname);
return @implode($delim, $result);
}
function CurrentRow() {
function CurrentRow() {//oke
return $this->row;
}
function AffectedRows() {
return @mysqli_affected_rows($this->cnn);
function AffectedRows() {//oke
return $this->conn->affected_rows;
}
function RecordCount() {
return @mysqli_num_rows($this->rs);
function RecordCount() {//oke
return $this->rs->num_rows;
}
function NumFields() {
return @mysqli_num_fields($this->rs);
function NumFields() {//oke
return $this->rs->field_count;
}
function LastInsertID() {
$lastinsertid = -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 LastInsertID() {//oke
return $this->conn->insert_id ?? -1;
}
function ErrHandler($err_msg = "") {
$this->err_msg = @mysqli_error($this->cnn);
if ($this->halt_on_error == 3) return;
if ($err_msg == "") $err_msg = "Undefined error!";
function ErrHandler($err_msg = "") {//oke
$err_msg = $err_msg ?? $this->conn->error ?? "Undefined error!";
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);
}
if ($this->halt_on_error == 1) die("");
}
function getDBName() {
function getDBName() {//oke
return $this->db_config['db'];
}
}
+103 -69
View File
@@ -3,7 +3,7 @@
/*******************************************************************
Module : /DB/SQL.php
Desc. : v4 - Class Query database
Desc. : Class Query database
Created By : Siau Pheng ([email protected]).
Created Date : February 2nd, 2007.
Last Modified : December 17th, 2023.
@@ -14,116 +14,150 @@
declare(strict_types=1);
namespace siaupheng\fonia3\DB;
namespace siaupheng\webapp\DB;
final class SQL {
private $__ttable = "";
private $__afield = array();
private $__avalue = array();
private $__anomor = array();
private $__twhere = "";
private $__avalue = [];
private $__awhere = [];
protected $__db = null;
public function __construct($db = null){
public function __construct($db = null) {//oke
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);
}
public function set_table($ttable = "") {
public function set_table($ttable = "") {//oke
$this->__ttable = $ttable;
}
public function add_param($tparam = "", $tvalue = null, $bnomor = false) {
$this->__afield[] = $tparam;
$this->__avalue[] = (is_null($tvalue) && isset($_REQUEST[$tparam])) ? $this->__db->SafeSQL($_REQUEST[$tparam]) : $tvalue;
$this->__anomor[] = $bnomor;
public function add_param($tparam = "", $tvalue = null, $bnomor = false) {//oke
$this->__avalue[$tparam] = [ 'value' => (is_null($tvalue) && isset($_REQUEST[$tparam])) ? $this->__db->SafeSQL($_REQUEST[$tparam]) : $tvalue, 'num' => $bnomor ];
}
public function add_param_date($tparam = "", $tvalue = null) {
$this->__afield[] = $tparam;
$this->__avalue[] = tgl_sql2str((is_null($tvalue) && isset($_REQUEST[$tparam])) ? $this->__db->SafeSQL($_REQUEST[$tparam]) : $tvalue);
$this->__anomor[] = false;
public function add_param_date($tparam = "", $tvalue = null) {//oke
$_tvalue = (is_null($tvalue) && isset($_REQUEST[$tparam])) ? $this->__db->SafeSQL($_REQUEST[$tparam]) : $tvalue;
$this->__avalue[$tparam] = [ 'value' => (empty($_tvalue)) ? "0" : tgl_sql2str($_tvalue), 'num' => false ];
}
public function add_param_stamp($tparam = "DateStamp") {
$this->__afield[] = $tparam;
$this->__avalue[] = "NOW()";
$this->__anomor[] = true;
public function add_param_stamp($tparam = "DateStamp") {//oke
$this->__avalue[$tparam] = [ 'value' => "NOW()", 'num' => true ];
}
public function add_param_unix() {
$this->__afield[] = "Unix";
$this->__avalue[] = user_unix();
$this->__anomor[] = false;
public function add_param_unix() {//oke
$this->__avalue['Unix'] = [ 'value' => user_unix(), 'num' => false ];
}
public function add_param_userid($tparam = "UserID") {
$this->__afield[] = $tparam;
$this->__avalue[] = user_id();
$this->__anomor[] = false;
public function add_param_userid($tparam = "UserID") {//oke
$this->__avalue[$tparam] = [ 'value' => user_id(), 'num' => false ];
}
public function add_where_unix() {
$this->__twhere .= (($this->__twhere=="") ? " WHERE " : " AND ") . "(Unix='".user_unix()."')";
public function add_where($tfield = "", $tvalue = null) {//oke
$this->__awhere[$tfield] = (is_null($tvalue) && isset($_REQUEST[$tfield])) ? $this->__db->SafeSQL($_REQUEST[$tfield]) : $tvalue;
}
public function add_where_date($tfield = "", $tvalue = null) {
$tvalue = ($tvalue == null) ? "0000-00-00" : tgl_sql2str($tvalue);
$this->add_where($tfield, $tvalue);
public function add_where_unix() {//oke
$this->__awhere['Unix'] = user_unix();
}
public function add_where($tfield = "", $tvalue = null) {
$__tvalue = (is_null($tvalue) && isset($_REQUEST[$tfield])) ? $this->__db->SafeSQL($_REQUEST[$tfield]) : $tvalue;
$this->__twhere .= (($this->__twhere=="") ? " WHERE " : " AND ") . "(".$tfield."='".$__tvalue."')";
public function add_where_date($tfield = "", $tvalue = null) {//oke
$_tvalue = ($tvalue == null) ? "0" : tgl_sql2str($tvalue);
$this->__awhere[$tfield] = $_tvalue;
}
public function clear_param() {
$this->__afield = array();
$this->__avalue = array();
$this->__anomor = array();
public function clear_param() {//oke
$this->__avalue = [];
}
public function clear_where() {
$this->__twhere = "";
public function clear_where() {//oke
$this->__awhere = [];
}
public function InsertDB() {
$tsql = "INSERT INTO ".$this->__ttable." (";
$tfield = "";
$tvalue = "";
for ($i=0; $i<count($this->__afield); $i++) {
$tfield .= ",".$this->__afield[$i];
$tvalue .= ",".(($this->__anomor[$i])?"":"'").$this->__avalue[$i].(($this->__anomor[$i])?"":"'");
public function InsertDB() {//oke
$_columns = implode(', ', array_keys($this->__avalue));
$_aholder = []; $_avalues = [];
foreach ($this->__avalue as $aval) {
if ($aval['num'] == true) {
$_aholder[] = $aval['value'];
} else {
$_aholder[] = "?";
$_avalues[] = $aval['value'] ?? "";
}
}
$tsql .= substr($tfield,1);
$tsql .= ") VALUES (";
$tsql .= substr($tvalue,1);
$tsql .= ")";
$this->__db->Query($tsql);
$_holder = implode(', ', $_aholder);
$_tsql = "INSERT INTO {$this->__ttable} ({$_columns}) VALUES ({$_holder})";
$this->__db->Execute($_tsql, $_avalues);
}
public function UpdateDB() {
$tsql = "UPDATE ".$this->__ttable." SET ";
$tfield = "";
for ($i=0; $i<count($this->__afield); $i++) {
$tfield .= ",".$this->__afield[$i]."=".(($this->__anomor[$i])?"":"'").$this->__avalue[$i].(($this->__anomor[$i])?"":"'");
public function UpdateDB() {//oke
$_aupdate = []; $_awhere = []; $_avalues = [];
foreach ($this->__avalue as $field => $aval) {
if ($aval['num'] == true) {
$_aupdate[] = "`{$field}` = " . $aval['value'];
} else {
$_aupdate[] = "`{$field}` = ?";
$_avalues[] = $aval['value'] ?? "";
}
}
$tsql .= substr($tfield,1);
$tsql .= ($this->__twhere=="") ? "" : $this->__twhere;
$this->__db->Query($tsql);
foreach ($this->__awhere as $field => $val) {
$_awhere[] = "`{$field}` = ?";
$_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() {
$tsql = "DELETE FROM ".$this->__ttable;
$tsql .= ($this->__twhere=="") ? "" : $this->__twhere;
$this->__db->Query($tsql);
public function DeleteDB() {//oke
$_awhere = []; $_avalues = [];
foreach ($this->__awhere as $field => $val) {
$_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();
}
}
+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],
'fill' => ['fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID, 'startColor' => ['rgb'=>"D0D0D0"]],
'borders' => ['allBorders' => ['borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN, 'color' => ['rgb'=>"C0C0C0"]]]
]
];
}
public function create_style($tstyle="L") {//oke
+2 -5
View File
@@ -199,14 +199,11 @@ final class Form {
$_blur = ($tblur==null) ? "" : ' onblur="'.$tblur.'"';
$_holdtxt = ($holdtxt==null) ? "" : ' placeholder="'.$holdtxt.'"';
$_tclass = "";
if (in_array($ttype,array("pickdate","picktime"))) {
if (in_array($ttype,array("pickdate","picktime","integer","angka","double"))) {
$_tclass = ' '.$ttype;
$ttype = "text";
}
if (in_array($ttype,array("double"))) {
$_tclass = ' '.$ttype;
$tvalue = uang2($tvalue);
}
if (in_array($ttype,array("double"))) $tvalue = uang2($tvalue);
$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);
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"}]']
];
if ($acus_page[$page]) {
if ($acus_page[$page] ?? false) {
$apage = $acus_page[$page];
} else if ($page <> "") {
$_mdb->Query("SELECT * FROM app_menu WHERE Kode='".$page."'");
+1
View File
@@ -191,6 +191,7 @@ final class Table {
// adding all option
for ($i=0; $i<count($this->__aoption); $i++) {
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 {
$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'])]??'')];
}