From 436fb91901f6cce57a4f5a0ea5c27f057b414b8b Mon Sep 17 00:00:00 2001
From: aspangaro <alexandre.spangaro@gmail.com>
Date: Mon, 28 Mar 2016 14:50:51 +0200
Subject: [PATCH] Uniformize name of table

---
 htdocs/accountancy/class/accountingaccount.class.php | 12 ++++++------
 htdocs/admin/dict.php                                |  6 +++---
 htdocs/core/class/html.formaccounting.class.php      |  4 ++--
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php
index b2bd4a1af93..5a9b5e3788c 100644
--- a/htdocs/accountancy/class/accountingaccount.class.php
+++ b/htdocs/accountancy/class/accountingaccount.class.php
@@ -69,16 +69,16 @@ class AccountingAccount extends CommonObject
 		
 		if ($rowid || $account_number) {
 			$sql  = "SELECT a.rowid, a.datec, a.tms, a.fk_pcg_version, a.pcg_type, a.pcg_subtype, a.account_number, a.account_parent, a.label, a.fk_accounting_category, a.fk_user_author, a.fk_user_modif, a.active";
-			$sql .= ", ac.label as category_label";
-			$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as a, ".MAIN_DB_PREFIX."c_accounting_category as ac";
-			$sql .= " WHERE a.fk_accounting_category = ac.rowid";
+			$sql .= ", ac.rowid, ac.label as category_label";
+			$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as a, " . MAIN_DB_PREFIX . "c_accounting_category as ac";
+			$sql .= " WHERE ";
 			if ($rowid) {
-				$sql .= " AND rowid = '" . $rowid . "'";
+				$sql .= " a.rowid = '" . $rowid . "'";
 			} elseif ($account_number) {
-				$sql .= " AND account_number = '" . $account_number . "'";
+				$sql .= " a.account_number = '" . $account_number . "'";
 			}
 			if (! empty($limittocurentchart)) {
-				$sql .= ' AND fk_pcg_version IN (SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS . ')';
+				$sql .= ' AND a.fk_pcg_version IN (SELECT a.pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system as as WHERE as.rowid=' . $conf->global->CHARTOFACCOUNTS . ')';
 			}
 			dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG);
 			$result = $this->db->query($sql);
diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php
index e1fe67518bc..d88df512b8c 100644
--- a/htdocs/admin/dict.php
+++ b/htdocs/admin/dict.php
@@ -80,7 +80,7 @@ $hookmanager->initHooks(array('admin'));
 // Put here declaration of dictionaries properties
 
 // Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this.
-$taborder=array(9,0,4,3,2,0,1,8,19,16,27,0,5,11,33,34,0,6,0,29,0,7,17,24,28,0,10,23,12,13,0,14,0,22,20,18,21,0,15,30,0,25,0,26,0,31,0);
+$taborder=array(9,0,4,3,2,0,1,8,19,16,27,0,5,11,33,34,0,6,0,29,0,7,17,24,28,0,10,23,12,13,0,14,0,22,20,18,21,0,15,30,0,25,0,26,0,31,32,0);
 
 // Name of SQL tables of dictionaries
 $tabname=array();
@@ -115,7 +115,7 @@ $tabname[28]= MAIN_DB_PREFIX."c_holiday_types";
 $tabname[29]= MAIN_DB_PREFIX."c_lead_status";
 $tabname[30]= MAIN_DB_PREFIX."c_format_cards";
 $tabname[31]= MAIN_DB_PREFIX."accounting_system";
-$tabname[32]= MAIN_DB_PREFIX."c_accountancy_category";
+$tabname[32]= MAIN_DB_PREFIX."c_accounting_category";
 $tabname[33]= MAIN_DB_PREFIX."c_hrm_department";
 $tabname[34]= MAIN_DB_PREFIX."c_hrm_function";
 
@@ -189,7 +189,7 @@ $tabsql[28]= "SELECT h.rowid as rowid, h.code, h.label, h.affect, h.delay, h.new
 $tabsql[29]= "SELECT rowid   as rowid, code, label, percent, position, active FROM ".MAIN_DB_PREFIX."c_lead_status";
 $tabsql[30]= "SELECT rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active FROM ".MAIN_DB_PREFIX."c_format_cards";
 $tabsql[31]= "SELECT s.rowid as rowid, pcg_version, s.fk_pays as country_id, c.code as country_code, c.label as country, s.label, s.active FROM ".MAIN_DB_PREFIX."accounting_system as s, ".MAIN_DB_PREFIX."c_country as c WHERE s.fk_pays=c.rowid and c.active=1";
-$tabsql[32]= "SELECT a.rowid as rowid, a.code as code, a.label, a.range, a.position, a.fk_country as country_id, c.code as country_code, c.label as country, a.active FROM ".MAIN_DB_PREFIX."c_accountancy_category as a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_country=c.rowid and c.active=1";
+$tabsql[32]= "SELECT a.rowid as rowid, a.code as code, a.label, a.range, a.position, a.fk_country as country_id, c.code as country_code, c.label as country, a.active FROM ".MAIN_DB_PREFIX."c_accounting_category as a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_country=c.rowid and c.active=1";
 $tabsql[33]= "SELECT rowid, pos, code, label, active FROM ".MAIN_DB_PREFIX."c_hrm_department";
 $tabsql[34]= "SELECT rowid, pos, code, label, c_level, active FROM ".MAIN_DB_PREFIX."c_hrm_function";
 
diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php
index 4120a4f74b6..dc01907ad15 100644
--- a/htdocs/core/class/html.formaccounting.class.php
+++ b/htdocs/core/class/html.formaccounting.class.php
@@ -65,7 +65,7 @@ class FormAccounting
         if (! empty($mysoc->country_id))
         {
             $sql = "SELECT c.rowid, c.label as type, c.range";
-            $sql.= " FROM ".MAIN_DB_PREFIX."c_accountancy_category as c";
+            $sql.= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c";
             $sql.= " WHERE c.active = 1";
             $sql.= " AND c.fk_country = ".$mysoc->country_id;
             $sql.= " ORDER BY c.label ASC";
@@ -73,7 +73,7 @@ class FormAccounting
         else
         {
             $sql = "SELECT c.rowid, c.label as type, c.range";
-            $sql.= " FROM ".MAIN_DB_PREFIX."c_accountancy_category, ".MAIN_DB_PREFIX."c_country as co";
+            $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.label ASC";
-- 
GitLab