Optimized function get_trans_tax_details() by @apmuthu.
[fa-stable.git] / includes / references.inc
index a5e872d703e0dcee08afefff37dae24e039c29c0..526dc1553cdb0cfa8b392e64228aef66d5781d7e 100644 (file)
@@ -10,6 +10,7 @@
     See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
 ***********************************************************************/
 include_once($path_to_root . "/includes/db/class.reflines_db.inc");
+include_once($path_to_root . "/includes/types.inc");
 //---------------------------------------------------------------------------------------------
 // 2.4 - further changes toward removing refs table introduced:
 //     . all transactions now have references stored in trans table.
@@ -69,7 +70,7 @@ class references
 {
        var $reflines;
        
-       function references()
+       function __construct()
        {
                $this->reflines = new reflines_db();
        }
@@ -150,6 +151,7 @@ class references
                        }
                }
 
+               $out .= $template;      // add postfix
                if (!preg_match('/^([^\{]*)?\{([^\}]*)\}(.*)/', $out, $match)) {        // parse index
                        display_error(_("Missing numeric placeholder in refline definition."));
                        return $out;
@@ -163,6 +165,7 @@ class references
                $type_fld = $db_info[1];
                $tno_fld = $db_info[2];
                $ref_fld = $db_info[3];
+               $type = db_escape($type);
 
                // retrieve last ref number in the refline from original transaction table
                $sql = "SELECT MAX(CAST(SUBSTR($ref_fld, ".(strlen($prefix)+1).",LENGTH($ref_fld)-".(strlen($postfix)+strlen($prefix)).") AS UNSIGNED))"