From c533dc3f4cd1aa10c1225335b589f311402969cf Mon Sep 17 00:00:00 2001 From: William Mead Date: Fri, 12 Jan 2024 12:34:49 +0100 Subject: [PATCH 1/3] Fixed method filter argument type. Cleaned code. --- htdocs/resource/class/dolresource.class.php | 12 ++++++------ htdocs/resource/class/html.formresource.class.php | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index 2783a366405..9fc546e0802 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -502,12 +502,12 @@ class Dolresource extends CommonObject /** * Load resource objects into $this->lines * - * @param string $sortorder sort order - * @param string $sortfield sort field - * @param int $limit limit page - * @param int $offset page - * @param array $filter filter output - * @return int Return integer <0 if KO, Number of lines loaded if OK + * @param string $sortorder sort order + * @param string $sortfield sort field + * @param int $limit limit page + * @param int $offset page + * @param array $filter filter output + * @return int Return integer <0 if KO, Number of lines loaded if OK */ public function fetchAll($sortorder, $sortfield, $limit, $offset, $filter = []) { diff --git a/htdocs/resource/class/html.formresource.class.php b/htdocs/resource/class/html.formresource.class.php index 6186a90cd60..a2fce129532 100644 --- a/htdocs/resource/class/html.formresource.class.php +++ b/htdocs/resource/class/html.formresource.class.php @@ -65,9 +65,9 @@ class FormResource /** * Output html form to select a resource * - * @param int $selected Preselected resource id - * @param string $htmlname Name of field in form - * @param string $filter Optionnal filters criteras (example: 's.rowid <> x') + * @param int $selected Preselected resource id + * @param string $htmlname Name of field in form + * @param array $filter Optionnal filters criteras (example: 's.rowid <> x') * @param int $showempty Add an empty field * @param int $showtype Show third party type in combolist (customer, prospect or supplier) * @param int $forcecombo Force to use combo box @@ -76,10 +76,10 @@ class FormResource * @param int $outputmode 0=HTML select string, 1=Array, 2=without form tag * @param int $limit Limit number of answers * @param string $morecss More css - * @param bool $multiple add [] in the name of element and add 'multiple' attribut + * @param bool $multiple add [] in the name of element and add 'multiple' attribut * @return string|array HTML string with */ - public function select_resource_list($selected = '', $htmlname = 'fk_resource', $filter = '', $showempty = 0, $showtype = 0, $forcecombo = 0, $event = array(), $filterkey = '', $outputmode = 0, $limit = 20, $morecss = '', $multiple = false) + public function select_resource_list($selected = '', $htmlname = 'fk_resource', $filter = [], $showempty = 0, $showtype = 0, $forcecombo = 0, $event = array(), $filterkey = '', $outputmode = 0, $limit = 20, $morecss = '', $multiple = false) { // phpcs:enable global $conf, $user, $langs; From 19f7fa0030b5618123605b49259f7ec3e72704c4 Mon Sep 17 00:00:00 2001 From: William Mead Date: Mon, 15 Jan 2024 09:18:18 +0100 Subject: [PATCH 2/3] Fixed selected default value --- htdocs/core/class/html.form.class.php | 2 +- htdocs/core/tpl/resource_add.tpl.php | 2 +- htdocs/resource/class/html.formresource.class.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index d8653ba4220..8214d2c7956 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2425,7 +2425,7 @@ class Form $events = array(); $out .= img_picto('', 'resource', 'class="pictofixedwidth"'); - $out .= $formresources->select_resource_list('', $htmlname, '', 1, 1, 0, $events, '', 2, null); + $out .= $formresources->select_resource_list(0, $htmlname, '', 1, 1, 0, $events, '', 2, null); //$out .= $this->select_dolusers('', $htmlname, $show_empty, $exclude, $disabled, $include, $enableonly, $force_entity, $maxlength, $showstatus, $morefilter); $out .= ' '; $out .= '
'; diff --git a/htdocs/core/tpl/resource_add.tpl.php b/htdocs/core/tpl/resource_add.tpl.php index 0595d636956..7fd994793d8 100644 --- a/htdocs/core/tpl/resource_add.tpl.php +++ b/htdocs/core/tpl/resource_add.tpl.php @@ -32,7 +32,7 @@ $out .= '
'; $events = array(); $out .= img_picto('', 'resource', 'class="pictofixedwidth"'); -$out .= $formresources->select_resource_list('', 'fk_resource', '', 1, 1, 0, $events, '', 2, null); +$out .= $formresources->select_resource_list(0, 'fk_resource', '', 1, 1, 0, $events, '', 2, null); $out .= '
'; $out .= '
'; diff --git a/htdocs/resource/class/html.formresource.class.php b/htdocs/resource/class/html.formresource.class.php index a2fce129532..b4b497212c2 100644 --- a/htdocs/resource/class/html.formresource.class.php +++ b/htdocs/resource/class/html.formresource.class.php @@ -79,7 +79,7 @@ class FormResource * @param bool $multiple add [] in the name of element and add 'multiple' attribut * @return string|array HTML string with */ - public function select_resource_list($selected = '', $htmlname = 'fk_resource', $filter = [], $showempty = 0, $showtype = 0, $forcecombo = 0, $event = array(), $filterkey = '', $outputmode = 0, $limit = 20, $morecss = '', $multiple = false) + public function select_resource_list($selected = 0, $htmlname = 'fk_resource', $filter = [], $showempty = 0, $showtype = 0, $forcecombo = 0, $event = array(), $filterkey = '', $outputmode = 0, $limit = 20, $morecss = '', $multiple = false) { // phpcs:enable global $conf, $user, $langs; From cc4cf8bf0dab136b262363cfde4dfc41215df73d Mon Sep 17 00:00:00 2001 From: William Mead Date: Mon, 15 Jan 2024 09:42:39 +0100 Subject: [PATCH 3/3] Updated PHPDoc --- htdocs/resource/class/html.formresource.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/resource/class/html.formresource.class.php b/htdocs/resource/class/html.formresource.class.php index b4b497212c2..7222264b939 100644 --- a/htdocs/resource/class/html.formresource.class.php +++ b/htdocs/resource/class/html.formresource.class.php @@ -67,16 +67,16 @@ class FormResource * * @param int $selected Preselected resource id * @param string $htmlname Name of field in form - * @param array $filter Optionnal filters criteras (example: 's.rowid <> x') + * @param array $filter Optional filters criteria (example: 's.rowid <> x') * @param int $showempty Add an empty field - * @param int $showtype Show third party type in combolist (customer, prospect or supplier) + * @param int $showtype Show third party type in combo list (customer, prospect or supplier) * @param int $forcecombo Force to use combo box * @param array $event Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) * @param string $filterkey Filter on key value * @param int $outputmode 0=HTML select string, 1=Array, 2=without form tag * @param int $limit Limit number of answers * @param string $morecss More css - * @param bool $multiple add [] in the name of element and add 'multiple' attribut + * @param bool $multiple add [] in the name of element and add 'multiple' attribute * @return string|array HTML string with */ public function select_resource_list($selected = 0, $htmlname = 'fk_resource', $filter = [], $showempty = 0, $showtype = 0, $forcecombo = 0, $event = array(), $filterkey = '', $outputmode = 0, $limit = 20, $morecss = '', $multiple = false) @@ -164,7 +164,7 @@ class FormResource // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Return html list of tickets type + * Return html list of tickets type // TODO translate PHPDoc to english * * @param string $selected Id du type pre-selectionne * @param string $htmlname Nom de la zone select