From 9521a9e77fcf568c8a23559b519a82914dcd6279 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 17 Aug 2021 20:02:19 +0200 Subject: [PATCH] Clean code --- htdocs/accountancy/admin/card.php | 23 ++++++++++++++++++++--- htdocs/core/db/DoliDB.class.php | 6 ++++-- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index 1d62fe1d414..4c99acf4205 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -262,9 +262,13 @@ if ($action == 'create') { print ''; $sql = 'SELECT DISTINCT pcg_type FROM ' . MAIN_DB_PREFIX . 'accounting_account'; $sql .= ' WHERE fk_pcg_version = "' . $db->escape($accountsystem->ref) . '"'; + $sql .= ' AND entity in ('.getEntity('accounting_account', 0).')'; // Always limit to current entity. No sharing in accountancy. $sql .= ' LIMIT 50000'; // just as a sanity check - foreach ($db->getRows($sql) as $obj) { - print ''; print ''; @@ -329,7 +333,20 @@ if ($action == 'create') { print $form->textwithpicto($langs->trans("Pcgtype"), $langs->transnoentitiesnoconv("PcgtypeDesc")); print ''; print ''; - print ''; + print ''; + // autosuggest from existing account types if found + print ''; + $sql = 'SELECT DISTINCT pcg_type FROM ' . MAIN_DB_PREFIX . 'accounting_account'; + $sql .= ' WHERE fk_pcg_version = "' . $db->escape($accountsystem->ref) . '"'; + $sql .= ' AND entity in ('.getEntity('accounting_account', 0).')'; // Always limit to current entity. No sharing in accountancy. + $sql .= ' LIMIT 50000'; // just as a sanity check + $resql = $db->query($sql); + if ($resql) { + while ($obj = $db->fetch_object($resql)) { + print ''; print ''; // Category diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index b93a3f40cea..8c62390f447 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -321,6 +321,7 @@ abstract class DoliDB implements Database * Dont add LIMIT to your query, it will be added by this method * @param string $sql the sql query string * @return bool| object + * @deprecated */ public function getRow($sql) { @@ -338,8 +339,9 @@ abstract class DoliDB implements Database * return all results from query as an array of objects * Note : This method executes a given SQL query and retrieves all row of results as an array of objects. It should only be used with SELECT queries * be carefull with this method use it only with some limit of results to avoid performences loss - * @param string $sql the sql query string - * @return bool| array + * @param string $sql the sql query string + * @return bool| array + * @deprecated */ public function getRows($sql) {