From 55d233e2da43880acfe3806938c56601676e80a2 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sun, 30 Oct 2022 17:19:32 +0100 Subject: [PATCH 1/2] NEW translate for contact type API cf #22699 --- htdocs/api/class/api_setup.class.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 406172590d7..aa05b5fc588 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -779,6 +779,7 @@ class Setup extends DolibarrApi * @param string $type To filter on type of contact * @param string $module To filter on module contacts * @param int $active Contact's type is active or not {@min 0} {@max 1} + * @param string $lang Code of the language the label of the civility must be translated to * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" * @return array List of Contacts types * @@ -786,7 +787,7 @@ class Setup extends DolibarrApi * * @throws RestException */ - public function getListOfContactTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $module = '', $active = 1, $sqlfilters = '') + public function getListOfContactTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $module = '', $active = 1, $lang ='', $sqlfilters = '') { $list = array(); @@ -827,7 +828,9 @@ class Setup extends DolibarrApi $num = $this->db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); for ($i = 0; $i < $min; $i++) { - $list[] = $this->db->fetch_object($result); + $contact_type = $this->db->fetch_object($result); + $this->translateLabel($contact_type, $lang, 'TypeContact_'.$contact_type->type.'_'.$contact_type->source.'_', array("eventorganization", "resource", "projects", "contracts", "bills", "orders", "agenda", "propal", "stocks", "supplier_proposal", "interventions", "sendings", "ticket")); + $list[] = $contact_type; } } else { throw new RestException(503, 'Error when retrieving list of contacts types : '.$this->db->lasterror()); From 82da70841fe8b293a4ee9734aafd6cd2200d33b5 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 30 Oct 2022 16:20:15 +0000 Subject: [PATCH 2/2] Fixing style errors. --- htdocs/api/class/api_setup.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index aa05b5fc588..c671053f84f 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -787,7 +787,7 @@ class Setup extends DolibarrApi * * @throws RestException */ - public function getListOfContactTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $module = '', $active = 1, $lang ='', $sqlfilters = '') + public function getListOfContactTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $module = '', $active = 1, $lang = '', $sqlfilters = '') { $list = array();