From bb0c53996f8fd662ec34ece2caab40755d004c48 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2023 13:20:04 +0200 Subject: [PATCH] FIX #25929 #25934 --- .../comm/propal/class/api_proposals.class.php | 5 ++--- htdocs/comm/propal/class/propal.class.php | 17 ++++++++--------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 8658c759202..fd0b4c0cdb6 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -285,7 +285,7 @@ class Proposals extends DolibarrApi * Get lines of a commercial proposal * * @param int $id Id of commercial proposal - * @param string $sqlfilters Other criteria to filter answers separated by a comma. d is the alias for proposal lines table, p is the alias for product table. "Syntax example "(p.ref:like:'SO-%') and (d.date_start:<:'20220101')" + * @param string $sqlfilters Other criteria to filter answers separated by a comma. d is the alias for proposal lines table, p is the alias for product table. "Syntax example "(p.ref:like:'SO-%') AND (d.date_start:<:'20220101')" * * @url GET {id}/lines * @@ -293,8 +293,6 @@ class Proposals extends DolibarrApi */ public function getLines($id, $sqlfilters = '') { - $filters = ""; - if (!DolibarrApiAccess::$user->hasRight('propal', 'lire')) { throw new RestException(401); } @@ -308,6 +306,7 @@ class Proposals extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } + $sql = ''; if (!empty($sqlfilters)) { $errormessage = ''; $sql = forgeSQLFromUniversalSearchCriteria($sqlfilters, $errormessage); diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 3626d2ca987..9676c352e44 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1866,11 +1866,10 @@ class Propal extends CommonObject * * @param int $only_product Return only physical products * @param int $loadalsotranslation Return translation for products - * @param string $sqlfilters Filter on other fields - * + * @param string $sqlforgedfilters Filter on other fields * @return int <0 if KO, >0 if OK */ - public function fetch_lines($only_product = 0, $loadalsotranslation = 0, $sqlfilters = '') + public function fetch_lines($only_product = 0, $loadalsotranslation = 0, $sqlforgedfilters = '') { // phpcs:enable $this->lines = array(); @@ -1888,8 +1887,8 @@ class Propal extends CommonObject if ($only_product) { $sql .= ' AND p.fk_product_type = 0'; } - if ($sqlfilters) { - $sql .= $sqlfilters; + if ($sqlforgedfilters) { + $sql .= $sqlforgedfilters; } $sql .= ' ORDER by d.rang'; @@ -3944,12 +3943,12 @@ class Propal extends CommonObject /** * Retrieve an array of proposal lines * - * @param string $sqlfilters Filter on other fields - * @return int >0 if OK, <0 if KO + * @param string $sqlforgedfilters Filter on other fields + * @return int >0 if OK, <0 if KO */ - public function getLinesArray($sqlfilters = '') + public function getLinesArray($sqlforgedfilters = '') { - return $this->fetch_lines(0, 0, $sqlfilters); + return $this->fetch_lines(0, 0, $sqlforgedfilters); } /**