From c0b985cc57f88e49f3402e1c55f7e884e55770ea Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Fri, 15 Jan 2010 22:17:36 +0000 Subject: [PATCH] Empty numeric input fields globally defaulted to 0. --- CHANGELOG.txt | 5 +++++ includes/data_checks.inc | 5 +++-- includes/ui/ui_input.inc | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 04ef1575..f0ae99ed 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -26,6 +26,11 @@ $ /gl/manage/gl_account_types.php $ /inventory/manage/sales_kits.php # Cleaned warnings in errorlog. $ /sales/includes/sales_db.inc +! Default 0 on empty amount fields +$ /includes/data_checks.inc +! Empty numeric input fields globaly defaulted to 0. +$ /includes/data_checks.inc + /includes/ui/ui_input.inc 15-Jan-2010 Joe Hunt # [0000190] Back link on confirmation only pages removed. diff --git a/includes/data_checks.inc b/includes/data_checks.inc index 9589f13c..ff316953 100644 --- a/includes/data_checks.inc +++ b/includes/data_checks.inc @@ -470,11 +470,12 @@ function check_int($postname, $min=null, $max=null) { // // Numeric input check. // Return 1 if number has proper form and is within range +// Empty/not defined fields are defaulted to $dflt value. // -function check_num($postname, $min=null, $max=null) { +function check_num($postname, $min=null, $max=null, $dflt=0) { if(!isset($_POST[$postname])) return 0; - $num = input_num($postname); + $num = input_num($postname, $dflt); if ($num === false || $num === null) return 0; if (isset($min) && ($num<$min)) diff --git a/includes/ui/ui_input.inc b/includes/ui/ui_input.inc index b2a49e2b..b27f5fde 100644 --- a/includes/ui/ui_input.inc +++ b/includes/ui/ui_input.inc @@ -75,7 +75,7 @@ function simple_page_mode($numeric_id = true) // // Read numeric value from user formatted input // -function input_num($postname=null, $dflt=null) +function input_num($postname=null, $dflt=0) { if (!isset($_POST[$postname]) || $_POST[$postname] == "") return $dflt; -- 2.30.2