From c86b50e3fc0ff807e78dbe68e51313d8350d60d4 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Sat, 30 Nov 2024 14:24:13 +0100 Subject: [PATCH 1/5] The $empty param must follow same rules than other select component. --- htdocs/core/class/html.formticket.class.php | 42 +++++++++++---------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 8920b259489..0cbd3e55876 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -332,7 +332,7 @@ class FormTicket // Type of Ticket print ''; - $this->selectTypesTickets((GETPOST('type_code', 'alpha') ? GETPOST('type_code', 'alpha') : $this->type_code), 'type_code', '', 2, 1, 0, 0, 'minwidth200'); + $this->selectTypesTickets((GETPOST('type_code', 'alpha') ? GETPOST('type_code', 'alpha') : $this->type_code), 'type_code', '', 2, 'ifone', 0, 0, 'minwidth200'); print ''; // Group => Category @@ -342,12 +342,12 @@ class FormTicket $filter = 'public=1'; } $selected = (GETPOST('category_code') ? GETPOST('category_code') : $this->category_code); - $this->selectGroupTickets($selected, 'category_code', $filter, 2, 1, 0, 0, 'minwidth200'); + $this->selectGroupTickets($selected, 'category_code', $filter, 2, 'ifone', 0, 0, 'minwidth200'); print ''; // Severity => Priority print ''; - $this->selectSeveritiesTickets((GETPOST('severity_code') ? GETPOST('severity_code') : $this->severity_code), 'severity_code', '', 2, 1); + $this->selectSeveritiesTickets((GETPOST('severity_code') ? GETPOST('severity_code') : $this->severity_code), 'severity_code', '', 2, 'ifone'); print ''; if (!empty($conf->knowledgemanagement->enabled)) { @@ -690,8 +690,8 @@ class FormTicket * @param string|array $selected Id of preselected field or array of Ids * @param string $htmlname Nom de la zone select * @param string $filtertype To filter on field type in llx_c_ticket_type (array('code'=>xx,'label'=>zz)) - * @param int $format 0=id+libelle, 1=code+code, 2=code+libelle, 3=id+code - * @param int $empty 1=peut etre vide, 0 sinon + * @param int $format 0=id+label, 1=code+code, 2=code+label, 3=id+code + * @param int|string $empty 1 = can be empty or 'string' to show the string as the empty value, 0 = can't be empty, 'ifone' = can be empty but autoselected if there is one only * @param int $noadmininfo 0=Add admin info, 1=Disable admin info * @param int $maxlength Max length of label * @param string $morecss More CSS @@ -715,9 +715,9 @@ class FormTicket $ticketstat->loadCacheTypesTickets(); - print ''; + if ($empty) { + print ''; } if (is_array($ticketstat->cache_types_tickets) && count($ticketstat->cache_types_tickets)) { @@ -755,6 +755,8 @@ class FormTicket print ' selected="selected"'; } elseif ($arraytypes['use_default'] == "1" && empty($selected) && !$multiselect) { print ' selected="selected"'; + } elseif (count($ticketstat->cache_types_tickets) == 1 && (!$empty || $empty == 'ifone')) { // If only 1 choice, we autoselect it + print ' selected="selected"'; } print '>'; @@ -813,10 +815,10 @@ class FormTicket $ticketstat = new Ticket($this->db); $ticketstat->loadCacheCategoriesTickets($publicgroups ? 1 : -1); // get list of active ticket groups - if ($use_multilevel <= 0) { + if ($use_multilevel <= 0) { // Only one combo list to select the group of ticket (default) print ''; if ($empty) { - print ''; + print ''; } if (is_array($ticketstat->cache_severity_tickets) && count($ticketstat->cache_severity_tickets)) { @@ -1201,6 +1203,8 @@ class FormTicket print ' selected="selected"'; } elseif ($arrayseverities['use_default'] == "1" && empty($selected)) { print ' selected="selected"'; + } elseif (count($conf->cache['severity_tickets']) == 1 && (!$empty || $empty == 'ifone')) { // If only 1 choice, we autoselect it + print ' selected="selected"'; } print '>'; From e48e1e27d542787ca0d42f7fdc814214348f8edc Mon Sep 17 00:00:00 2001 From: tnegre Date: Fri, 6 Dec 2024 12:07:37 +0100 Subject: [PATCH 2/5] replace code from develop to match DLB18 variable name --- htdocs/core/class/html.formticket.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 0cbd3e55876..9c3a3847a24 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -1203,7 +1203,7 @@ class FormTicket print ' selected="selected"'; } elseif ($arrayseverities['use_default'] == "1" && empty($selected)) { print ' selected="selected"'; - } elseif (count($conf->cache['severity_tickets']) == 1 && (!$empty || $empty == 'ifone')) { // If only 1 choice, we autoselect it + } elseif (count($ticketstat->cache_severity_tickets) == 1 && (!$empty || $empty == 'ifone')) { // If only 1 choice, we autoselect it print ' selected="selected"'; } From e8aaa51edcf65d9feacb7000ee6e657419670275 Mon Sep 17 00:00:00 2001 From: tnegre Date: Fri, 6 Dec 2024 14:06:54 +0100 Subject: [PATCH 3/5] set empty value for choice --- htdocs/ticket/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index 9e69271f09c..9f1f30a3e7f 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -856,11 +856,11 @@ foreach ($object->fields as $key => $val) { print ''; } elseif ($key == 'category_code') { print ''; - $formTicket->selectGroupTickets(dol_escape_htmltag(empty($search[$key]) ? '' : $search[$key]), 'search_'.$key, '', 2, 1, 1, 0, (!empty($val['css']) ? $val['css'] : 'maxwidth150')); + $formTicket->selectGroupTickets(dol_escape_htmltag(empty($search[$key]) ? '' : $search[$key]), 'search_'.$key, '', 2, ' ', 1, 0, (!empty($val['css']) ? $val['css'] : 'maxwidth150')); print ''; } elseif ($key == 'severity_code') { print ''; - $formTicket->selectSeveritiesTickets(dol_escape_htmltag(empty($search[$key]) ? '' : $search[$key]), 'search_'.$key, '', 2, 1, 1, 0, (!empty($val['css']) ? $val['css'] : 'maxwidth150')); + $formTicket->selectSeveritiesTickets(dol_escape_htmltag(empty($search[$key]) ? '' : $search[$key]), 'search_'.$key, '', 2, ' ', 1, 0, (!empty($val['css']) ? $val['css'] : 'maxwidth150')); print ''; } elseif ($key == 'fk_user_assign' || $key == 'fk_user_create') { print ''; From 86833633efb1098e2363e41e2047b4813b20405a Mon Sep 17 00:00:00 2001 From: tnegre Date: Wed, 18 Dec 2024 10:26:26 +0100 Subject: [PATCH 4/5] fix --- htdocs/core/class/html.formticket.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 9c3a3847a24..4a140185432 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -863,9 +863,9 @@ class FormTicket print ' selected="selected"'; } elseif (isset($selected) && $selected == $id) { print ' selected="selected"'; - } elseif ($arraycategories['use_default'] == "1" && !$selected && !$empty) { + } elseif ($arraycategories['use_default'] == "1" && !$selected && (!$empty || $empty == 'ifone')) { print ' selected="selected"'; - } elseif (count($ticketstat->cache_category_tickets) == 1) { + } elseif (count($ticketstat->cache_category_tickets) == 1 && (!$empty || $empty == 'ifone')) { print ' selected="selected"'; } @@ -1201,7 +1201,7 @@ class FormTicket print ' selected="selected"'; } elseif (isset($selected) && $selected == $id) { print ' selected="selected"'; - } elseif ($arrayseverities['use_default'] == "1" && empty($selected)) { + } elseif ($arrayseverities['use_default'] == "1" && empty($selected) && (!$empty || $empty == 'ifone')) { print ' selected="selected"'; } elseif (count($ticketstat->cache_severity_tickets) == 1 && (!$empty || $empty == 'ifone')) { // If only 1 choice, we autoselect it print ' selected="selected"'; From 729e6c4aba1a596be4e1ff054f8c9f18cf491601 Mon Sep 17 00:00:00 2001 From: tnegre Date: Mon, 27 Jan 2025 15:12:24 +0100 Subject: [PATCH 5/5] Revert "set empty value for choice" This reverts commit e8aaa51edcf65d9feacb7000ee6e657419670275. --- htdocs/ticket/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index 9f1f30a3e7f..9e69271f09c 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -856,11 +856,11 @@ foreach ($object->fields as $key => $val) { print ''; } elseif ($key == 'category_code') { print ''; - $formTicket->selectGroupTickets(dol_escape_htmltag(empty($search[$key]) ? '' : $search[$key]), 'search_'.$key, '', 2, ' ', 1, 0, (!empty($val['css']) ? $val['css'] : 'maxwidth150')); + $formTicket->selectGroupTickets(dol_escape_htmltag(empty($search[$key]) ? '' : $search[$key]), 'search_'.$key, '', 2, 1, 1, 0, (!empty($val['css']) ? $val['css'] : 'maxwidth150')); print ''; } elseif ($key == 'severity_code') { print ''; - $formTicket->selectSeveritiesTickets(dol_escape_htmltag(empty($search[$key]) ? '' : $search[$key]), 'search_'.$key, '', 2, ' ', 1, 0, (!empty($val['css']) ? $val['css'] : 'maxwidth150')); + $formTicket->selectSeveritiesTickets(dol_escape_htmltag(empty($search[$key]) ? '' : $search[$key]), 'search_'.$key, '', 2, 1, 1, 0, (!empty($val['css']) ? $val['css'] : 'maxwidth150')); print ''; } elseif ($key == 'fk_user_assign' || $key == 'fk_user_create') { print '';