From 42e7c789b5c755130859f7e487d7c3057fadfcdf Mon Sep 17 00:00:00 2001 From: Joe Hunt Date: Fri, 23 Oct 2009 22:41:48 +0000 Subject: [PATCH] Changed so -1 as parameters to dimensions in get_transactions db routines only fetches NO dimensions. --- CHANGELOG.txt | 7 +++++ gl/includes/db/gl_db_trans.inc | 40 +++++++++++++------------- reporting/includes/reports_classes.inc | 6 ++-- reporting/rep705.php | 8 +++--- 4 files changed, 34 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 00ef8615..1ce567ef 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -21,6 +21,13 @@ $ -> Affected files ------------------------------- Release 2.2 RC ---------------------------------- +24-Oct-2009 Joe Hunt +! Changed so -1 as parameters to dimensions in get_transactions db routines only + fetches NO dimensions. +$ /gl/includes/db/g_db_trans.inc + /reporting/rep705.php + /reporting/includes/reports_classes.inc + 23-Oct-2009 Janusz Dobrowolski # Fixed 2.2 upgrade pre_check $ /sql/alter2.2.php diff --git a/gl/includes/db/gl_db_trans.inc b/gl/includes/db/gl_db_trans.inc index a842c951..59927a41 100644 --- a/gl/includes/db/gl_db_trans.inc +++ b/gl/includes/db/gl_db_trans.inc @@ -114,11 +114,11 @@ function get_gl_transactions($from_date, $to_date, $trans_no=0, if ($account != null) $sql .= " AND ".TB_PREF."gl_trans.account = ".db_escape($account); - if ($dimension > 0) - $sql .= " AND ".TB_PREF."gl_trans.dimension_id = ".db_escape($dimension); + if ($dimension != 0) + $sql .= " AND ".TB_PREF."gl_trans.dimension_id = ".($dimension<0?0:db_escape($dimension)); - if ($dimension2 > 0) - $sql .= " AND ".TB_PREF."gl_trans.dimension2_id = ".db_escape($dimension2); + if ($dimension2 != 0) + $sql .= " AND ".TB_PREF."gl_trans.dimension2_id = ".($dimension2<0?0:db_escape($dimension2)); if ($filter_type != null AND is_numeric($filter_type)) $sql .= " AND ".TB_PREF."gl_trans.type= ".db_escape($filter_type); @@ -171,10 +171,10 @@ function get_gl_balance_from_to($from_date, $to_date, $account, $dimension=0, $d $sql .= " AND tran_date > '$from'"; if ($to_date != "") $sql .= " AND tran_date < '$to'"; - if ($dimension > 0) - $sql .= " AND dimension_id = ".db_escape($dimension); - if ($dimension2 > 0) - $sql .= " AND dimension2_id = ".db_escape($dimension2); + if ($dimension != 0) + $sql .= " AND dimension_id = ".($dimension<0?0:db_escape($dimension)); + if ($dimension2 != 0) + $sql .= " AND dimension2_id = ".($dimension2<0?0:db_escape($dimension2)); $result = db_query($sql, "The starting balance for account $account could not be calculated"); @@ -195,10 +195,10 @@ function get_gl_trans_from_to($from_date, $to_date, $account, $dimension=0, $dim $sql .= " AND tran_date >= '$from'"; if ($to_date != "") $sql .= " AND tran_date <= '$to'"; - if ($dimension > 0) - $sql .= " AND dimension_id = ".db_escape($dimension); - if ($dimension2 > 0) - $sql .= " AND dimension2_id = ".db_escape($dimension2); + if ($dimension != 0) + $sql .= " AND dimension_id = ".($dimension<0?0:db_escape($dimension)); + if ($dimension2 != 0) + $sql .= " AND dimension2_id = ".($dimension2<0?0:db_escape($dimension2)); $result = db_query($sql, "Transactions for account $account could not be calculated"); @@ -219,10 +219,10 @@ function get_balance($account, $dimension, $dimension2, $from, $to, $from_incl=t if ($account != null) $sql .= " account=".db_escape($account)." AND"; - if ($dimension > 0) - $sql .= " dimension_id=".db_escape($dimension)." AND"; - if ($dimension2 > 0) - $sql .= " dimension2_id=".db_escape($dimension2)." AND"; + if ($dimension != 0) + $sql .= " dimension_id = ".($dimension<0?0:db_escape($dimension))." AND"; + if ($dimension2 != 0) + $sql .= " dimension2_id = ".($dimension2<0?0:db_escape($dimension2))." AND"; $from_date = date2sql($from); if ($from_incl) $sql .= " tran_date >= '$from_date' AND"; @@ -253,10 +253,10 @@ function get_budget_trans_from_to($from_date, $to_date, $account, $dimension=0, $sql .= " AND tran_date >= '$from' "; if ($to_date != "") $sql .= " AND tran_date <= '$to' "; - if ($dimension > 0) - $sql .= " AND dimension_id = ".db_escape($dimension); - if ($dimension2 > 0) - $sql .= " AND dimension2_id = ".db_escape($dimension2); + if ($dimension != 0) + $sql .= " AND dimension_id = ".($dimension<0?0:db_escape($dimension)); + if ($dimension2 != 0) + $sql .= " AND dimension2_id = ".($dimension2<0?0:db_escape($dimension2)); $result = db_query($sql,"No budget accounts were returned"); $row = db_fetch_row($result); diff --git a/reporting/includes/reports_classes.inc b/reporting/includes/reports_classes.inc index 5ff1c72a..f08a13b3 100644 --- a/reporting/includes/reports_classes.inc +++ b/reporting/includes/reports_classes.inc @@ -230,7 +230,7 @@ class Report break; case 'DIMENSIONS': $sql = "SELECT id, concat(reference, ' - ', name) as DimName FROM ".TB_PREF."dimensions"; - $st .= combo_input("PARAM_$index", '', $sql, 'id', 'DimName',array('spec_option'=>_("No Dimension Filter"),'spec_id'=>ALL_NUMERIC,'order'=>array('reference'))); + $st .= combo_input("PARAM_$index", '', $sql, 'id', 'DimName',array('spec_option'=>_("No Dimension Filter"),'spec_id'=>0,'order'=>array('reference'))); break; case 'DIMENSION1': $sql = "SELECT id, concat(reference, ' - ', name) AS DimName FROM ".TB_PREF."dimensions WHERE type_=1"; @@ -238,7 +238,7 @@ class Report break; case 'DIMENSIONS1': $sql = "SELECT id, concat(reference, ' - ', name) as DimName FROM ".TB_PREF."dimensions WHERE type_=1"; - $st .= combo_input("PARAM_$index", '', $sql, 'id', 'DimName',array('spec_option'=>_("No Dimension Filter"),'spec_id'=>ALL_NUMERIC,'order'=>array('reference'))); + $st .= combo_input("PARAM_$index", '', $sql, 'id', 'DimName',array('spec_option'=>_("No Dimension Filter"),'spec_id'=>0,'order'=>array('reference'))); break; case 'DIMENSION2': $sql = "SELECT id, concat(reference, ' - ', name) AS DimName FROM ".TB_PREF."dimensions WHERE type_=2"; @@ -246,7 +246,7 @@ class Report break; case 'DIMENSIONS2': $sql = "SELECT id, concat(reference, ' - ', name) as DimName FROM ".TB_PREF."dimensions WHERE type_=2"; - $st .= combo_input("PARAM_$index", '', $sql, 'id', 'DimName',array('spec_option'=>_("No Dimension Filter"),'spec_id'=>ALL_NUMERIC,'order'=>array('reference'))); + $st .= combo_input("PARAM_$index", '', $sql, 'id', 'DimName',array('spec_option'=>_("No Dimension Filter"),'spec_id'=>0,'order'=>array('reference'))); break; case 'CUSTOMERS_NO_FILTER': case 'CUSTOMERS': diff --git a/reporting/rep705.php b/reporting/rep705.php index faf815f4..0d2c370f 100644 --- a/reporting/rep705.php +++ b/reporting/rep705.php @@ -61,10 +61,10 @@ function getPeriods($year, $account, $dimension, $dimension2) SUM(CASE WHEN tran_date >= '$date12' AND tran_date < '$date13' THEN amount / 1000 ELSE 0 END) AS per12 FROM ".TB_PREF."gl_trans WHERE account='$account'"; - if ($dimension > 0) - $sql .= " AND dimension_id = ".db_escape($dimension); - if ($dimension2 > 0) - $sql .= " AND dimension2_id = ".db_escape($dimension2); + if ($dimension != 0) + $sql .= " AND dimension_id = ".($dimension<0?0:db_escape($dimension)); + if ($dimension2 != 0) + $sql .= " AND dimension2_id = ".($dimension2<0?0:db_escape($dimension2)); $result = db_query($sql, "Transactions for account $account could not be calculated"); -- 2.30.2