From 284f269213a6a3daca3bdf0f42638cb8004e16a9 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 15 Apr 2020 19:32:45 +0200 Subject: [PATCH] Update api_bankaccounts.class.php --- htdocs/compta/bank/class/api_bankaccounts.class.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index 2fb97ff949c..bc5b9d46be1 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -57,12 +57,13 @@ class BankAccounts extends DolibarrApi * @param string $sortorder Sort order * @param int $limit Limit for list * @param int $page Page number + * @param int $category Use this param to filter list by category * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.import_key:<:'20160101')" * @return array List of account objects * * @throws RestException */ - public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $category = 0, $sqlfilters = '') { $list = array(); @@ -71,7 +72,14 @@ class BankAccounts extends DolibarrApi } $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."bank_account as t"; + if ($category > 0) { + $sql .= ", ".MAIN_DB_PREFIX."categorie_account as c"; + } $sql .= ' WHERE t.entity IN ('.getEntity('bank_account').')'; + // Select accounts of given category + if ($category > 0) { + $sql .= " AND c.fk_categorie = ".$db->escape($category)." AND c.fk_account = t.rowid "; + } // Add sql filters if ($sqlfilters) {