diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index 3e661958931..6c1ec86c6f2 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -276,31 +276,25 @@ class AccountancyCategory * * @return array Result in table */ - public function getCatsCpts() { + public function getCatsCpts() + { global $mysoc; + $sql = ""; - if (empty($mysoc->country_id) && empty($mysoc->country_code)) { + if (empty($mysoc->country_id)) { dol_print_error('', 'Call to select_accounting_account with mysoc country not yet defined'); exit(); } - if (! empty($mysoc->country_id)) { - $sql = "SELECT t.rowid, t.account_number, t.label as account_label, cat.code, cat.position, cat.label as name_cat, cat.sens "; - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t, " . MAIN_DB_PREFIX . "c_accounting_category as cat"; - $sql .= " WHERE t.fk_accounting_category IN ( SELECT c.rowid "; - $sql .= " FROM " . MAIN_DB_PREFIX . "c_accounting_category as c"; - $sql .= " WHERE c.active = 1"; - $sql .= " AND c.fk_country = " . $mysoc->country_id . ")"; - $sql .= " AND cat.rowid = t.fk_accounting_category"; - $sql .= " ORDER BY cat.position ASC"; - } else { - $sql = "SELECT c.rowid, c.code, c.label, c.category_type "; - $sql .= " FROM " . MAIN_DB_PREFIX . "c_accounting_category as c, " . MAIN_DB_PREFIX . "c_country as co"; - $sql .= " WHERE c.active = 1 AND c.fk_country = co.rowid"; - $sql .= " AND co.code = '" . $mysoc->country_code . "'"; - $sql .= " ORDER BY c.position ASC"; - } + $sql = "SELECT t.rowid, t.account_number, t.label as account_label, cat.code, cat.position, cat.label as name_cat, cat.sens "; + $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t, " . MAIN_DB_PREFIX . "c_accounting_category as cat"; + $sql .= " WHERE t.fk_accounting_category IN ( SELECT c.rowid "; + $sql .= " FROM " . MAIN_DB_PREFIX . "c_accounting_category as c"; + $sql .= " WHERE c.active = 1"; + $sql .= " AND (c.fk_country = ".$mysoc->country_id." OR c.fk_country = 0)"; + $sql .= " AND cat.rowid = t.fk_accounting_category"; + $sql .= " ORDER BY cat.position ASC"; $resql = $this->db->query($sql); if ($resql) { @@ -390,26 +384,17 @@ class AccountancyCategory { global $db, $langs, $user, $mysoc; - if (empty($mysoc->country_id) && empty($mysoc->country_code)) { + if (empty($mysoc->country_id)) { dol_print_error('', 'Call to select_accounting_account with mysoc country not yet defined'); exit(); } - if (! empty($mysoc->country_id)) { - $sql = "SELECT c.rowid, c.code, c.label, c.formula, c.position, c.category_type"; - $sql .= " FROM " . MAIN_DB_PREFIX . "c_accounting_category as c"; - $sql .= " WHERE c.active = 1 "; - if ($categorytype >= 0) $sql.=" AND c.category_type = 1"; - $sql .= " AND c.fk_country = " . $mysoc->country_id; - $sql .= " ORDER BY c.position ASC"; - } else { // Note: this should not happen - $sql = "SELECT c.rowid, c.code, c.label, c.formula, c.position, c.category_type"; - $sql .= " FROM " . MAIN_DB_PREFIX . "c_accounting_category as c, " . MAIN_DB_PREFIX . "c_country as co"; - $sql .= " WHERE c.active = 1 AND c.fk_country = co.rowid"; - if ($categorytype >= 0) $sql.=" AND c.category_type = 1"; - $sql .= " AND co.code = '" . $mysoc->country_code . "'"; - $sql .= " ORDER BY c.position ASC"; - } + $sql = "SELECT c.rowid, c.code, c.label, c.formula, c.position, c.category_type"; + $sql .= " FROM " . MAIN_DB_PREFIX . "c_accounting_category as c"; + $sql .= " WHERE c.active = 1 "; + if ($categorytype >= 0) $sql.=" AND c.category_type = 1"; + $sql .= " AND (c.fk_country = ".$mysoc->country_id." OR c.fk_country = 0)"; + $sql .= " ORDER BY c.position ASC"; $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/compta/resultat/result.php b/htdocs/compta/resultat/result.php index 8b9cba79b0c..7b52c5b3cbd 100644 --- a/htdocs/compta/resultat/result.php +++ b/htdocs/compta/resultat/result.php @@ -373,7 +373,10 @@ else if ($modecompta=="BOOKKEEPING") // Column group print '