Skip to content

Commit

Permalink
* Update code to AppGini 23.16
Browse files Browse the repository at this point in the history
* Customize product drop-down in order details to show only active items
  • Loading branch information
bigprof committed Oct 18, 2023
1 parent 11fd960 commit f30488a
Show file tree
Hide file tree
Showing 38 changed files with 246 additions and 56 deletions.
2 changes: 1 addition & 1 deletion app/admin/getUsers.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
// This script and data application were generated by AppGini 23.15
// This script and data application were generated by AppGini 23.16
// Download AppGini for free from https://bigprof.com/appgini/download/

/*
Expand Down
38 changes: 34 additions & 4 deletions app/admin/incFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ function makeSafe($string, $is_gpc = true) {
static $cached = []; /* str => escaped_str */

if(!strlen($string)) return '';
if(is_numeric($string)) return db_escape($string); // don't cache numbers to avoid cases like '3.5' being equivelant to '3' in array indexes

if(!db_link()) sql("SELECT 1+1", $eo);

Expand Down Expand Up @@ -630,7 +631,7 @@ function curl_insert_handler($table, $data) {
$payload = $data;
$payload['insert_x'] = 1;

$url = (isset($_SERVER['HTTPS']) ? 'https://' : 'http://') . config('host') . '/' . application_uri("{$table}_view.php");
$url = application_url("{$table}_view.php");
$token = jwt_token();
$options = [
CURLOPT_URL => $url,
Expand Down Expand Up @@ -863,9 +864,13 @@ function setupMembership() {
'pageRebuildFields.php',
'pageSettings.php',
'ajax_check_login.php',
'ajax-update-calculated-fields.php',
'parent-children.php',
])) return;

// abort if current page is ajax
if(is_ajax()) return;
if(strpos(basename($_SERVER['PHP_SELF']), 'ajax-') === 0) return;

// run once per session, but force proceeding if not all mem tables created
$res = sql("show tables like 'membership_%'", $eo);
$num_mem_tables = db_num_rows($res);
Expand Down Expand Up @@ -1781,6 +1786,22 @@ function update_membership_usersessions() {
$eo);
}
########################################################################
function update_membership_cache() {
$tn = 'membership_cache';
$eo = ['silentErrors' => true, 'noErrorQueryLog' => true];

sql(
"CREATE TABLE IF NOT EXISTS `membership_cache` (
`request` VARCHAR(100) NOT NULL,
`request_ts` INT,
`response` LONGTEXT,
PRIMARY KEY (`request`))
) CHARSET " . mysql_charset,
$eo);

sql("ALTER TABLE `{$tn}` CHANGE COLUMN `response` `response` LONGTEXT", $eo);
}
########################################################################
function thisOr($this_val, $or = '&nbsp;') {
return ($this_val != '' ? $this_val : $or);
}
Expand Down Expand Up @@ -1899,8 +1920,15 @@ function normalize_path($path) {
########################################################################
function application_url($page = '', $s = false) {
if($s === false) $s = $_SERVER;
$ssl = (!empty($s['HTTPS']) && strtolower($s['HTTPS']) != 'off');

$ssl = (
(!empty($s['HTTPS']) && strtolower($s['HTTPS']) != 'off')
// detect reverse proxy SSL
|| (!empty($s['HTTP_X_FORWARDED_PROTO']) && strtolower($s['HTTP_X_FORWARDED_PROTO']) == 'https')
|| (!empty($s['HTTP_X_FORWARDED_SSL']) && strtolower($s['HTTP_X_FORWARDED_SSL']) == 'on')
);
$http = ($ssl ? 'https:' : 'http:');

$port = $s['SERVER_PORT'];
$port = ($port == '80' || $port == '443' || !$port) ? '' : ':' . $port;
// HTTP_HOST already includes server port if not standard, but SERVER_NAME doesn't
Expand Down Expand Up @@ -2874,7 +2902,9 @@ function lookupQuery($tn, $lookupField) {
'order_details' => [
'OrderID' => 'SELECT `orders`.`OrderID`, `orders`.`OrderID` FROM `orders` LEFT JOIN `customers` as customers1 ON `customers1`.`CustomerID`=`orders`.`CustomerID` LEFT JOIN `employees` as employees1 ON `employees1`.`EmployeeID`=`orders`.`EmployeeID` LEFT JOIN `shippers` as shippers1 ON `shippers1`.`ShipperID`=`orders`.`ShipVia` ORDER BY 2',
'Category' => 'SELECT `products`.`ProductID`, IF(CHAR_LENGTH(`products`.`CategoryID`) || CHAR_LENGTH(`products`.`SupplierID`), CONCAT_WS(\'\', IF( CHAR_LENGTH(`categories1`.`CategoryName`), CONCAT_WS(\'\', `categories1`.`CategoryName`), \'\'), \' / \', IF( CHAR_LENGTH(`suppliers1`.`CompanyName`), CONCAT_WS(\'\', `suppliers1`.`CompanyName`), \'\')), \'\') FROM `products` LEFT JOIN `suppliers` as suppliers1 ON `suppliers1`.`SupplierID`=`products`.`SupplierID` LEFT JOIN `categories` as categories1 ON `categories1`.`CategoryID`=`products`.`CategoryID` ORDER BY 2',
'ProductID' => 'SELECT `products`.`ProductID`, `products`.`ProductName` FROM `products` LEFT JOIN `suppliers` as suppliers1 ON `suppliers1`.`SupplierID`=`products`.`SupplierID` LEFT JOIN `categories` as categories1 ON `categories1`.`CategoryID`=`products`.`CategoryID` ORDER BY 2',
'ProductID' => 'SELECT `products`.`ProductID`, `products`.`ProductName` FROM `products` LEFT JOIN `suppliers` as suppliers1 ON `suppliers1`.`SupplierID`=`products`.`SupplierID` LEFT JOIN `categories` as categories1 ON `categories1`.`CategoryID`=`products`.`CategoryID`
WHERE COALESCE(`products`.`Discontinued`, 0) != 1
ORDER BY 2',
],
'products' => [
'SupplierID' => 'SELECT `suppliers`.`SupplierID`, `suppliers`.`CompanyName` FROM `suppliers` ORDER BY 2',
Expand Down
10 changes: 8 additions & 2 deletions app/admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
error_reporting(E_ERROR | E_PARSE);
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$http = (strtolower($_SERVER['HTTPS']) == 'on' ? 'https:' : 'http:');
$ssl = (
(!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off')
// detect reverse proxy SSL
|| (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https')
|| (!empty($_SERVER['HTTP_X_FORWARDED_SSL']) && strtolower($_SERVER['HTTP_X_FORWARDED_SSL']) == 'on')
);
$http = ($ssl ? 'https://' : 'http://');

header("Location: {$http}//{$host}{$uri}/pageHome.php");
header("Location: {$http}{$host}{$uri}/pageHome.php");
exit;
4 changes: 2 additions & 2 deletions app/admin/pageServerStatus.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
$appgini_version = '23.15.1469 beta';
$generated_ts = '11/09/2023 17:53:41';
$appgini_version = '23.16.1515';
$generated_ts = '18/10/2023 18:30:46';

require(__DIR__ . '/incCommon.php');

Expand Down
8 changes: 5 additions & 3 deletions app/ajax_combo.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
// This script and data application were generated by AppGini 23.15
// This script and data application were generated by AppGini 23.16
// Download AppGini for free from https://bigprof.com/appgini/download/

/*
Expand Down Expand Up @@ -177,7 +177,9 @@
'parent_caption' => '`products`.`ProductName`',
'parent_from' => '`products` LEFT JOIN `suppliers` as suppliers1 ON `suppliers1`.`SupplierID`=`products`.`SupplierID` LEFT JOIN `categories` as categories1 ON `categories1`.`CategoryID`=`products`.`CategoryID` ',
'filterers' => [],
'custom_query' => '',
'custom_query' => 'SELECT `products`.`ProductID`, `products`.`ProductName` FROM `products` LEFT JOIN `suppliers` as suppliers1 ON `suppliers1`.`SupplierID`=`products`.`SupplierID` LEFT JOIN `categories` as categories1 ON `categories1`.`CategoryID`=`products`.`CategoryID`
WHERE COALESCE(`products`.`Discontinued`, 0) != 1
ORDER BY 2',
'inherit_permissions' => false,
'list_type' => 0,
'not_null' => false,
Expand Down Expand Up @@ -373,7 +375,7 @@
$eo = ['silentErrors' => true];

$res = sql($combo->Query, $eo);
while($row = db_fetch_row($res)) {
if($res) while($row = db_fetch_row($res)) {
if(empty($prepared_data) && $page == 1 && !$search_id && !$field['not_null']) {
$prepared_data[] = ['id' => empty_lookup_value, 'text' => to_utf8("<{$Translation['none']}>")];
}
Expand Down
2 changes: 1 addition & 1 deletion app/categories_autofill.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
// This script and data application were generated by AppGini 23.15
// This script and data application were generated by AppGini 23.16
// Download AppGini for free from https://bigprof.com/appgini/download/

include_once(__DIR__ . '/lib.php');
Expand Down
2 changes: 1 addition & 1 deletion app/categories_dml.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// Data functions (insert, update, delete, form) for table categories

// This script and data application were generated by AppGini 23.15
// This script and data application were generated by AppGini 23.16
// Download AppGini for free from https://bigprof.com/appgini/download/

function categories_insert(&$error_message = '') {
Expand Down
2 changes: 1 addition & 1 deletion app/categories_view.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
// This script and data application were generated by AppGini 23.15
// This script and data application were generated by AppGini 23.16
// Download AppGini for free from https://bigprof.com/appgini/download/

include_once(__DIR__ . '/lib.php');
Expand Down
12 changes: 10 additions & 2 deletions app/common.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var AppGini = AppGini || {};

AppGini.version = 23.15;
AppGini.version = 23.16;

/* initials and fixes */
jQuery(function() {
Expand Down Expand Up @@ -168,7 +168,10 @@ jQuery(function() {
let f = $j(this).text().trim();
if(!/^\d+(\.\d+)?$/.test(f)) return; // already formatted or invalid number

$j(this).text(parseFloat(f).toLocaleString());
// preserve decimals
const countDecimals = (f.split('.')[1] || '').length;

$j(this).text(parseFloat(f).toLocaleString(undefined, {minimumFractionDigits: countDecimals, maximumFractionDigits: countDecimals}));
})
}, 100);

Expand Down Expand Up @@ -302,6 +305,11 @@ jQuery(function() {
$j(document).on('click', '.update-children-count', function() {
AppGini.updateChildrenCount(false); // update only once -- no rescheduling
})

AppGini.once({
condition: () => AppGini.Translate !== undefined,
action: () => moment.locale(AppGini.Translate._map['datetimepicker locale'])
})
});

/* show/hide TV action buttons based on whether records are selected or not */
Expand Down
2 changes: 1 addition & 1 deletion app/customers_autofill.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
// This script and data application were generated by AppGini 23.15
// This script and data application were generated by AppGini 23.16
// Download AppGini for free from https://bigprof.com/appgini/download/

include_once(__DIR__ . '/lib.php');
Expand Down
2 changes: 1 addition & 1 deletion app/customers_dml.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// Data functions (insert, update, delete, form) for table customers

// This script and data application were generated by AppGini 23.15
// This script and data application were generated by AppGini 23.16
// Download AppGini for free from https://bigprof.com/appgini/download/

function customers_insert(&$error_message = '') {
Expand Down
2 changes: 1 addition & 1 deletion app/customers_view.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
// This script and data application were generated by AppGini 23.15
// This script and data application were generated by AppGini 23.16
// Download AppGini for free from https://bigprof.com/appgini/download/

include_once(__DIR__ . '/lib.php');
Expand Down
2 changes: 1 addition & 1 deletion app/definitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@define('SESSION_NAME', 'Northwind');
@define('APP_TITLE', 'Northwind');
@define('APP_DIR', __DIR__);
@define('APP_VERSION', '23.15');
@define('APP_VERSION', '23.16');
@define('maxSortBy', 4);
@define('empty_lookup_value', '{empty_value}');
@define('MULTIPLE_SUPER_ADMINS', false);
Expand Down
2 changes: 1 addition & 1 deletion app/employees_autofill.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
// This script and data application were generated by AppGini 23.15
// This script and data application were generated by AppGini 23.16
// Download AppGini for free from https://bigprof.com/appgini/download/

include_once(__DIR__ . '/lib.php');
Expand Down
2 changes: 1 addition & 1 deletion app/employees_dml.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// Data functions (insert, update, delete, form) for table employees

// This script and data application were generated by AppGini 23.15
// This script and data application were generated by AppGini 23.16
// Download AppGini for free from https://bigprof.com/appgini/download/

function employees_insert(&$error_message = '') {
Expand Down
2 changes: 1 addition & 1 deletion app/employees_view.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
// This script and data application were generated by AppGini 23.15
// This script and data application were generated by AppGini 23.16
// Download AppGini for free from https://bigprof.com/appgini/download/

include_once(__DIR__ . '/lib.php');
Expand Down
2 changes: 1 addition & 1 deletion app/footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div style="height: 60px;" class="hidden-print"></div>
<nav class="navbar navbar-default navbar-fixed-bottom" role="navigation">
<p class="navbar-text"><small>
Powered by <a class="navbar-link" href="https://bigprof.com/appgini/" target="_blank">BigProf AppGini 23.15</a>
Powered by <a class="navbar-link" href="https://bigprof.com/appgini/" target="_blank">BigProf AppGini 23.16</a>
</small></p>
</nav>
<?php } ?>
Expand Down
Loading

0 comments on commit f30488a

Please sign in to comment.