From 086754e149e82e8dd3c72c967c5c066cff9161f8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Sep 2021 14:31:20 +0200 Subject: [PATCH] Fix translation of category codes --- htdocs/core/class/html.formticket.class.php | 56 +++++++++++++-------- htdocs/langs/en_US/ticket.lang | 2 + htdocs/langs/fr_FR/ticket.lang | 2 + htdocs/ticket/class/ticket.class.php | 17 ++++--- 4 files changed, 49 insertions(+), 28 deletions(-) diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index d486805cf46..811965250cf 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -589,23 +589,28 @@ class FormTicket /** * Return html list of ticket anaytic codes * - * @param string $selected Id categorie pre-selectionnée - * @param string $htmlname Name of select component - * @param string $filtertype To filter on some properties in llx_c_ticket_category ('public = 1'). This parameter must not come from input of users. - * @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 $noadmininfo 0=Add admin info, 1=Disable admin info - * @param int $maxlength Max length of label - * @param string $morecss More CSS - * @param int $use_multilevel If > 0 create a multilevel select which use $htmlname example: $use_multilevel = 1 permit to have 2 select boxes. + * @param string $selected Id categorie pre-selectionnée + * @param string $htmlname Name of select component + * @param string $filtertype To filter on some properties in llx_c_ticket_category ('public = 1'). This parameter must not come from input of users. + * @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 $noadmininfo 0=Add admin info, 1=Disable admin info + * @param int $maxlength Max length of label + * @param string $morecss More CSS + * @param int $use_multilevel If > 0 create a multilevel select which use $htmlname example: $use_multilevel = 1 permit to have 2 select boxes. + * @param Translate $outputlangs Output lnaguage * @return void */ - public function selectGroupTickets($selected = '', $htmlname = 'ticketcategory', $filtertype = '', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss = '', $use_multilevel = 0) + public function selectGroupTickets($selected = '', $htmlname = 'ticketcategory', $filtertype = '', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss = '', $use_multilevel = 0, $outputlangs = null) { - global $langs, $user; + global $conf, $langs, $user; dol_syslog(get_class($this)."::selectCategoryTickets ".$selected.", ".$htmlname.", ".$filtertype.", ".$format, LOG_DEBUG); + if (empty($outputlangs)) { + $outputlangs = $langs; + } + $ticketstat = new Ticket($this->db); $ticketstat->loadCacheCategoriesTickets(); @@ -629,6 +634,8 @@ class FormTicket continue; } + $label = ($outputlangs->trans("TicketCategoryShort".$arraycategories['code']) != ("TicketCategoryShort".$arraycategories['code']) ? $outputlangs->trans("TicketCategoryShort".$arraycategories['code']) : ($arraycategories['label'] != '-' ? $arraycategories['label'] : '')); + if ($format == 0) { print '