From: Janusz Dobrowolski Date: Wed, 6 Jan 2010 07:31:51 +0000 (+0000) Subject: Small fix in session.inc and extension of reference incrementation algorithm X-Git-Tag: 2.3-final~1066 X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=71575c1115361f37b2035b77917242f60b4bd5c7;p=fa-stable.git Small fix in session.inc and extension of reference incrementation algorithm --- diff --git a/CHANGELOG.txt b/CHANGELOG.txt index ee1ccf72..de25f853 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,6 +19,12 @@ Legend: ! -> Note $ -> Affected files +06-Jan-2010 Janusz Dobrowolski +# Check on existence of locale.inc added to avoid blank pages when the file is broken. +$ /includes/session.inc +! Changed reference incrementation algorithm to preserve both number prefix and postfix. +$ /includes/references.inc + 04-Jan-2010 Joe Hunt ! Making the stretch parameter = 1 on default print pdf all over Improved layout on documents. diff --git a/includes/references.inc b/includes/references.inc index 6487404b..420e960e 100644 --- a/includes/references.inc +++ b/includes/references.inc @@ -64,16 +64,19 @@ class references function increment($reference) { // New method done by Pete. So f.i. WA036 will increment to WA037 and so on. - // If $reference is trailed by digits, and digits only, - // extract them and add 1, then put the alpha prefix back on + // If $reference contains at least one group of digits, + // extract first didgits group and add 1, then put all together. // NB. preg_match returns 1 if the regex matches completely // also $result[0] holds entire string, 1 the first captured, 2 the 2nd etc. - if (preg_match('/^(.*?)(\d+)$/', $reference, $result) == 1) + // + if (preg_match('/^(\D*?)(\d+)(.*)/', $reference, $result) == 1) { - $dig_count = strlen($result[2]); // How many digits? eg. 0003 = 4 - $fmt = '%0' . $dig_count . 'd'; // Make a format string - leading zeroes - $nextval = $result[1] . sprintf($fmt, intval($result[2] + 1)); // Add one on, and put prefix back on - return $nextval; + list($all, $prefix, $number, $postfix) = $result; + $dig_count = strlen($number); // How many digits? eg. 0003 = 4 + $fmt = '%0' . $dig_count . 'd'; // Make a format string - leading zeroes + $nextval = sprintf($fmt, intval($number + 1)); // Add one on, and put prefix back on + + return $prefix.$nextval.$postfix; } else return $reference; diff --git a/includes/session.inc b/includes/session.inc index ba703dee..8929ff2e 100644 --- a/includes/session.inc +++ b/includes/session.inc @@ -176,8 +176,9 @@ if (!isset($_SESSION['language'])) $_SESSION['language']->set_language($_SESSION['language']->code); // include $Hooks object if locale file exists -if(@include_once($path_to_root . "/lang/".$_SESSION['language']->code."/locale.inc")) +if (file_exists($path_to_root . "/lang/".$_SESSION['language']->code."/locale.inc")) { + include_once($path_to_root . "/lang/".$_SESSION['language']->code."/locale.inc"); $Hooks = new Hooks(); }