From 300abfd5e20c312c683d42dc175b4b4dcf3ea599 Mon Sep 17 00:00:00 2001 From: Michael Jeanmotte Date: Wed, 29 Jan 2020 14:44:50 +0100 Subject: [PATCH 1/3] Fetch thirdparty to be sure thirdparty is accessible through an API call when we use ODT template --- .../modules/facture/doc/doc_generic_invoice_odt.modules.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index ef05b9b2df9..aac525ffb55 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -303,6 +303,9 @@ class doc_generic_invoice_odt extends ModelePDFFactures $result = $object->fetch_contact($arrayidcontact[0]); } + // Fetch thirdparty to be sure thirdparty is accessible through an API call when we use ODT template + $object->fetch_thirdparty(); + // Recipient name $contactobject = null; if (!empty($usecontact)) { From a300cb9067dbb5a0e285bf8ae76e0c18721bd418 Mon Sep 17 00:00:00 2001 From: Michael Jeanmotte Date: Wed, 29 Jan 2020 15:12:14 +0100 Subject: [PATCH 2/3] Revert "Fetch thirdparty to be sure thirdparty is accessible through an API call when we use ODT template" This reverts commit 300abfd5 --- .../modules/facture/doc/doc_generic_invoice_odt.modules.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index aac525ffb55..ef05b9b2df9 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -303,9 +303,6 @@ class doc_generic_invoice_odt extends ModelePDFFactures $result = $object->fetch_contact($arrayidcontact[0]); } - // Fetch thirdparty to be sure thirdparty is accessible through an API call when we use ODT template - $object->fetch_thirdparty(); - // Recipient name $contactobject = null; if (!empty($usecontact)) { From 9c160d5181a77f751f645bfe903e9f613fd8784c Mon Sep 17 00:00:00 2001 From: Michael Jeanmotte Date: Wed, 29 Jan 2020 15:17:12 +0100 Subject: [PATCH 3/3] Feature Request: Dolibarr API - [GET] /bankaccounts/{id}/lines : add sqlfilters #11259 --- .../compta/bank/class/api_bankaccounts.class.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index 57aa50f1568..2ecb59861d9 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -411,8 +411,9 @@ class BankAccounts extends DolibarrApi * @throws RestException * * @url GET {id}/lines + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.import_key:<:'20160101')" */ - public function getLines($id) + public function getLines($id, $sqlfilters = '') { $list = array(); @@ -428,6 +429,18 @@ class BankAccounts extends DolibarrApi $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."bank "; $sql .= " WHERE fk_account = ".$id; + + // Add sql filters + if ($sqlfilters) + { + if (! DolibarrApi::_checkFilters($sqlfilters)) + { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + $sql .= " ORDER BY rowid"; $result = $this->db->query($sql);