Fix translation of category codes
This commit is contained in:
parent
8909702619
commit
086754e149
@ -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 '<option value="'.$id.'"';
|
||||
}
|
||||
@ -657,7 +664,7 @@ class FormTicket
|
||||
print '>';
|
||||
|
||||
if ($format == 0) {
|
||||
$value = ($maxlength ? dol_trunc($arraycategories['label'], $maxlength) : $arraycategories['label']);
|
||||
$value = ($maxlength ? dol_trunc($label, $maxlength) : $label);
|
||||
}
|
||||
|
||||
if ($format == 1) {
|
||||
@ -665,7 +672,7 @@ class FormTicket
|
||||
}
|
||||
|
||||
if ($format == 2) {
|
||||
$value = ($maxlength ? dol_trunc($arraycategories['label'], $maxlength) : $arraycategories['label']);
|
||||
$value = ($maxlength ? dol_trunc($label, $maxlength) : $label);
|
||||
}
|
||||
|
||||
if ($format == 3) {
|
||||
@ -691,15 +698,16 @@ class FormTicket
|
||||
$stringtoprint .= '<select id ="'.$htmlname.'" class="maxwidth500 minwidth400" child_id="0">';
|
||||
$stringtoprint .= '<option value=""> </option>';
|
||||
|
||||
$sql = "SELECT ctc.rowid, ctc.code, ctc.label, ctc.fk_parent, ";
|
||||
$sql = "SELECT ctc.rowid, ctc.code, ctc.label, ctc.fk_parent, ctc.public, ";
|
||||
$sql .= $this->db->ifsql("ctc.rowid NOT IN (SELECT ctcfather.rowid FROM llx_c_ticket_category as ctcfather JOIN llx_c_ticket_category as ctcjoin ON ctcfather.rowid = ctcjoin.fk_parent)", "'NOTPARENT'", "'PARENT'")." as isparent";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_ticket_category as ctc";
|
||||
$sql .= " WHERE ctc.active > 0";
|
||||
$sql .= " WHERE ctc.active > 0 AND entity = ".((int) $conf->entity);
|
||||
if ($filtertype == 'public=1') {
|
||||
$sql .= " AND ctc.public = 1";
|
||||
}
|
||||
$sql .= " AND ctc.fk_parent = 0";
|
||||
$sql .= $this->db->order('ctc.pos', 'ASC');
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$num_rows_level0 = $this->db->num_rows($resql);
|
||||
@ -707,23 +715,26 @@ class FormTicket
|
||||
while ($i < $num_rows_level0) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
if ($obj) {
|
||||
$label = ($outputlangs->trans("TicketCategoryShort".$obj->code) != ("TicketCategoryShort".$obj->code) ? $outputlangs->trans("TicketCategoryShort".$obj->code) : ($obj->label != '-' ? $obj->label : ''));
|
||||
|
||||
$grouprowid = $obj->rowid;
|
||||
$groupvalue = $obj->code;
|
||||
$grouplabel = $obj->label;
|
||||
$grouplabel = $label;
|
||||
|
||||
$isparent = $obj->isparent;
|
||||
$iselected = $groupticket == $obj->code ?'selected':'';
|
||||
$stringtoprint .= '<option '.$iselected.' class="'.$htmlname.dol_escape_htmltag($grouprowid).'" value="'.dol_escape_htmltag($groupvalue).'" data-html="'.dol_escape_htmltag($grouplabel).'">'.dol_escape_htmltag($grouplabel).'</option>';
|
||||
if ($isparent == 'NOTPARENT') {
|
||||
$arraycodenotparent[] = $groupvalue;
|
||||
}
|
||||
$arrayidused[]=$grouprowid;
|
||||
$arrayidused[] = $grouprowid;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
if ($num_rows_level0 == 1) {
|
||||
if (count($arrayidused) == 1) {
|
||||
return '<input type="hidden" name="'.$htmlname.'" id="'.$htmlname.'" value="'.dol_escape_htmltag($groupvalue).'">';
|
||||
} else {
|
||||
$stringtoprint .= '<input type="hidden" name="'.$htmlname.'" id="'.$htmlname.'_select" class="maxwidth500 minwidth400">';
|
||||
@ -737,11 +748,11 @@ class FormTicket
|
||||
$stringtoprint .= '<select id ="'.$htmlname.'_child_'.$levelid.'" class="maxwidth500 minwidth400 groupticketchild" child_id="'.$levelid.'">';
|
||||
$stringtoprint .= '<option value=""> </option>';
|
||||
|
||||
$sql = "SELECT ctc.rowid, ctc.code, ctc.label, ctc.fk_parent, ctcjoin.code as codefather, ";
|
||||
$sql = "SELECT ctc.rowid, ctc.code, ctc.label, ctc.fk_parent, ctc.public, ctcjoin.code as codefather, ";
|
||||
$sql .= $this->db->ifsql("ctc.rowid NOT IN (SELECT ctcfather.rowid FROM llx_c_ticket_category as ctcfather JOIN llx_c_ticket_category as ctcjoin ON ctcfather.rowid = ctcjoin.fk_parent)", "'NOTPARENT'", "'PARENT'")." as isparent";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_ticket_category as ctc";
|
||||
$sql .= " JOIN ".MAIN_DB_PREFIX."c_ticket_category as ctcjoin ON ctc.fk_parent = ctcjoin.rowid";
|
||||
$sql .= " WHERE ctc.active = 1";
|
||||
$sql .= " WHERE ctc.active > 0 AND entity = ".((int) $conf->entity);
|
||||
if ($filtertype == 'public=1') {
|
||||
$sql .= " AND ctc.public = 1";
|
||||
}
|
||||
@ -755,6 +766,7 @@ class FormTicket
|
||||
} else {
|
||||
}
|
||||
$sql .= $this->db->order('ctc.pos', 'ASC');
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$num_rows = $this->db->num_rows($resql);
|
||||
@ -763,9 +775,11 @@ class FormTicket
|
||||
while ($i < $num_rows) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
if ($obj) {
|
||||
$label = ($outputlangs->trans("TicketCategoryShort".$obj->code) != ("TicketCategoryShort".$obj->code) ? $outputlangs->trans("TicketCategoryShort".$obj->code) : ($obj->label != '-' ? $obj->label : ''));
|
||||
|
||||
$grouprowid = $obj->rowid;
|
||||
$groupvalue = $obj->code;
|
||||
$grouplabel = $obj->label;
|
||||
$grouplabel = $label;
|
||||
$isparent = $obj->isparent;
|
||||
$fatherid = $obj->fk_parent;
|
||||
$arrayidused[] = $grouprowid;
|
||||
|
||||
@ -45,6 +45,8 @@ TicketSeverityShortNORMAL=Normal
|
||||
TicketSeverityShortHIGH=High
|
||||
TicketSeverityShortBLOCKING=Critical, Blocking
|
||||
|
||||
TicketCategoryShortOTHER=Other
|
||||
|
||||
ErrorBadEmailAddress=Field '%s' incorrect
|
||||
MenuTicketMyAssign=My tickets
|
||||
MenuTicketMyAssignNonClosed=My open tickets
|
||||
|
||||
@ -45,6 +45,8 @@ TicketSeverityShortNORMAL=Normal
|
||||
TicketSeverityShortHIGH=Élevé
|
||||
TicketSeverityShortBLOCKING=Critique, bloquant
|
||||
|
||||
TicketCategoryShortOTHER=Autre
|
||||
|
||||
ErrorBadEmailAddress=Champ '%s' incorrect
|
||||
MenuTicketMyAssign=Mes tickets
|
||||
MenuTicketMyAssignNonClosed=Mes tickets ouverts
|
||||
|
||||
@ -1166,22 +1166,22 @@ class Ticket extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* Charge dans cache la liste des catégories de tickets (paramétrable dans dictionnaire)
|
||||
* Load into a cache array, the list of ticket categories (setup done into dictionary)
|
||||
*
|
||||
* @return int Number of lines loaded, 0 if already loaded, <0 if KO
|
||||
*/
|
||||
public function loadCacheCategoriesTickets()
|
||||
{
|
||||
global $langs;
|
||||
global $conf, $langs;
|
||||
|
||||
if (!empty($this->cache_category_ticket) && count($this->cache_category_tickets)) {
|
||||
// Cache already loaded
|
||||
return 0;
|
||||
}
|
||||
// Cache deja charge
|
||||
|
||||
$sql = "SELECT rowid, code, label, use_default, pos, description, public, active, force_severity, fk_parent";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_ticket_category";
|
||||
$sql .= " WHERE active > 0";
|
||||
$sql .= " WHERE active > 0 AND entity = ".((int) $conf->entity);
|
||||
$sql .= " ORDER BY pos";
|
||||
dol_syslog(get_class($this)."::load_cache_categories_tickets", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
@ -1191,15 +1191,18 @@ class Ticket extends CommonObject
|
||||
while ($i < $num) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$this->cache_category_tickets[$obj->rowid]['code'] = $obj->code;
|
||||
// Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
|
||||
$label = ($langs->trans("TicketCategoryShort".$obj->code) != ("TicketCategoryShort".$obj->code) ? $langs->trans("TicketCategoryShort".$obj->code) : ($obj->label != '-' ? $obj->label : ''));
|
||||
$this->cache_category_tickets[$obj->rowid]['label'] = $label;
|
||||
$this->cache_category_tickets[$obj->rowid]['use_default'] = $obj->use_default;
|
||||
$this->cache_category_tickets[$obj->rowid]['pos'] = $obj->pos;
|
||||
$this->cache_category_tickets[$obj->rowid]['public'] = $obj->public;
|
||||
$this->cache_category_tickets[$obj->rowid]['active'] = $obj->active;
|
||||
$this->cache_category_tickets[$obj->rowid]['force_severity'] = $obj->force_severity;
|
||||
$this->cache_category_tickets[$obj->rowid]['fk_parent'] = $obj->fk_parent;
|
||||
|
||||
// If translation exists, we use it to store already translated string.
|
||||
// Warning: You should not use this and recompute the translated string into caller code to get the value into expected language
|
||||
$label = ($langs->trans("TicketCategoryShort".$obj->code) != ("TicketCategoryShort".$obj->code) ? $langs->trans("TicketCategoryShort".$obj->code) : ($obj->label != '-' ? $obj->label : ''));
|
||||
$this->cache_category_tickets[$obj->rowid]['label'] = $label;
|
||||
|
||||
$i++;
|
||||
}
|
||||
return $num;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user