Empty numeric input fields globally defaulted to 0.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Fri, 15 Jan 2010 22:17:36 +0000 (22:17 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Fri, 15 Jan 2010 22:17:36 +0000 (22:17 +0000)
CHANGELOG.txt
includes/data_checks.inc
includes/ui/ui_input.inc

index 04ef157585aff0f54eea83b306803c6595d6e4f9..f0ae99edb485827acf8b55d5873a2368bd4e1f8b 100644 (file)
@@ -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.
index 9589f13c9e60d181db3d8b3abef14017c0690969..ff316953030d9c322fea21c2a7e3aced11717340 100644 (file)
@@ -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 <min, max> 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)) 
index b2a49e2b90a447cdb5848382d2f922ccd0ac205e..b27f5fde11ae787a486fc4fa73ecce2556dca591 100644 (file)
@@ -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;