Skip to content

Commit

Permalink
The $empty param must follow same rules than other select component.
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Nov 30, 2024
1 parent 4337141 commit b56ac12
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions htdocs/core/class/html.formticket.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ function(response) {

// Type of Ticket
print '<tr><td class="titlefield"><span class="fieldrequired"><label for="selecttype_code">'.$langs->trans("TicketTypeRequest").'</span></label></td><td>';
$this->selectTypesTickets($type_code, 'type_code', '', 2, 1, 0, 0, 'minwidth200 maxwidth500');
$this->selectTypesTickets($type_code, 'type_code', '', 2, 'ifone', 0, 0, 'minwidth200 maxwidth500');
print '</td></tr>';

// Group => Category
Expand All @@ -469,12 +469,12 @@ function(response) {
if ($public) {
$filter = '(public:=:1)';
}
$this->selectGroupTickets($category_code, 'category_code', $filter, 2, 1, 0, 0, 'minwidth200 maxwidth500');
$this->selectGroupTickets($category_code, 'category_code', $filter, 2, 'ifone', 0, 0, 'minwidth200 maxwidth500');
print '</td></tr>';

// Severity => Priority
print '<tr><td><span class="fieldrequired"><label for="selectseverity_code">'.$langs->trans("TicketSeverity").'</span></label></td><td>';
$this->selectSeveritiesTickets($severity_code, 'severity_code', '', 2, 1, 0, 0, 'minwidth200 maxwidth500');
$this->selectSeveritiesTickets($severity_code, 'severity_code', '', 2, 'ifone', 0, 0, 'minwidth200 maxwidth500');
print '</td></tr>';

if (isModEnabled('knowledgemanagement')) {
Expand Down Expand Up @@ -869,8 +869,8 @@ function(response) {
* @param string|int[] $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
Expand All @@ -896,7 +896,7 @@ public function selectTypesTickets($selected = '', $htmlname = 'tickettype', $fi

print '<select id="select'.$htmlname.'" class="flat minwidth100'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.($multiselect ? '[]' : '').'"'.($multiselect ? ' multiple' : '').'>';
if ($empty) {
print '<option value="">&nbsp;</option>';
print '<option value="">'.((is_numeric($empty) || $empty == 'ifone') ? '&nbsp;' : $empty).'</option>';
}

if (is_array($ticketstat->cache_types_tickets) && count($ticketstat->cache_types_tickets)) {
Expand Down Expand Up @@ -934,6 +934,8 @@ public function selectTypesTickets($selected = '', $htmlname = 'tickettype', $fi
print ' selected="selected"';
} elseif ($arraytypes['use_default'] == "1" && empty($selected)) {
print ' selected="selected"';
} elseif (count($ticketstat->cache_types_tickets) == 1 && (!$empty || $empty == 'ifone')) { // If only 1 choice, we autoselect it
print ' selected="selected"';
}

print '>';
Expand Down Expand Up @@ -992,10 +994,10 @@ public function selectGroupTickets($selected = '', $htmlname = 'ticketcategory',
$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 '<select id="select'.$htmlname.'" class="flat minwidth100'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'">';
if ($empty) {
print '<option value="">'.(is_numeric($empty) ? '&nbsp;' : $empty).'</option>';
print '<option value="">'.((is_numeric($empty) || $empty == 'ifone') ? '&nbsp;' : $empty).'</option>';
}

if (is_array($ticketstat->cache_category_tickets) && count($ticketstat->cache_category_tickets)) {
Expand Down Expand Up @@ -1075,7 +1077,7 @@ public function selectGroupTickets($selected = '', $htmlname = 'ticketcategory',
}

print ajax_combobox('select'.$htmlname);
} elseif ($htmlname != '') {
} elseif ($htmlname != '') { // complexe mode using selection of group using a combo for each level (when using a hierarchy of groups).
$selectedgroups = array();
$groupvalue = "";
$groupticket = GETPOST($htmlname, 'aZ09');
Expand Down Expand Up @@ -1320,14 +1322,14 @@ public function selectGroupTickets($selected = '', $htmlname = 'ticketcategory',
/**
* Return html list of ticket severitys (priorities)
*
* @param string $selected Id severity pre-selected
* @param string $htmlname Name of the select area
* @param string $filtertype To filter on field type in llx_c_ticket_severity (array('code'=>xx,'label'=>zz))
* @param int $format 0 = id+label, 1 = code+code, 2 = code+label, 3 = id+code
* @param int $empty 1 = can be empty, 0 = or not
* @param int $noadmininfo 0 = add admin info, 1 = disable admin info
* @param int $maxlength Max length of label
* @param string $morecss More CSS
* @param string $selected Id severity pre-selected
* @param string $htmlname Name of the select area
* @param string $filtertype To filter on field type in llx_c_ticket_severity (array('code'=>xx,'label'=>zz))
* @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
* @return void
*/
public function selectSeveritiesTickets($selected = '', $htmlname = 'ticketseverity', $filtertype = '', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss = '')
Expand All @@ -1348,7 +1350,7 @@ public function selectSeveritiesTickets($selected = '', $htmlname = 'ticketsever

print '<select id="select'.$htmlname.'" class="flat minwidth100'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'">';
if ($empty) {
print '<option value="">&nbsp;</option>';
print '<option value="">'.((is_numeric($empty) || $empty == 'ifone') ? '&nbsp;' : $empty).'</option>';
}

if (is_array($conf->cache['severity_tickets']) && count($conf->cache['severity_tickets'])) {
Expand Down Expand Up @@ -1386,6 +1388,8 @@ public function selectSeveritiesTickets($selected = '', $htmlname = 'ticketsever
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 '>';
Expand Down

0 comments on commit b56ac12

Please sign in to comment.