diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 5a9b5e3788c..2f2cf023db0 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -68,18 +68,19 @@ class AccountingAccount extends CommonObject global $conf; 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 = "SELECT a.rowid as 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.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 "; + $sql .= " WHERE a.fk_accounting_category = ac.rowid"; if ($rowid) { - $sql .= " a.rowid = '" . $rowid . "'"; + $sql .= " AND a.rowid = '" . $rowid . "'"; } elseif ($account_number) { - $sql .= " a.account_number = '" . $account_number . "'"; + $sql .= " AND a.account_number = '" . $account_number . "'"; } if (! empty($limittocurentchart)) { $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); if ($result) { diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index dc01907ad15..8103575d2c9 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -52,7 +52,7 @@ class FormAccounting * @param int $help Add or not the admin help picto * @return void */ - function select_accounting_category($selected='',$htmlname='actioncode', $useempty=0, $maxlen=64, $help=1) + function select_accounting_category($selected='',$htmlname='account_category', $useempty=0, $maxlen=64, $help=1) { global $db,$langs,$user,$mysoc;