Fix label of type of event not consistent between screen

This commit is contained in:
Laurent Destailleur 2024-07-23 11:49:06 +02:00
parent 745b34c176
commit 0a07681332
3 changed files with 64 additions and 35 deletions

View file

@ -1693,31 +1693,35 @@ class ActionComm extends CommonObject
$result = '';
// Set label of type
$labeltype = '';
if ($this->type_code) {
$langs->load("commercial");
$labeltype = ($langs->transnoentities("Action".$this->type_code) != "Action".$this->type_code) ? $langs->transnoentities("Action".$this->type_code) : $this->type_label;
}
if (!getDolGlobalString('AGENDA_USE_EVENT_TYPE')) {
if ($this->type_code != 'AC_OTH_AUTO') {
$labeltype = $langs->trans('ActionAC_MANUAL');
}
}
$labeltype = $this->getTypeLabel(1);
$tooltip = img_picto('', $this->picto).' <u>'.$langs->trans('Action').'</u>';
$tooltip .= ' &nbsp; - &nbsp; '.$this->getTypePicto('pictofixedwidth paddingright valignmiddle').$labeltype;
if (!empty($this->ref)) {
$tooltip .= '<br><b>'.$langs->trans('Ref').':</b> '.dol_escape_htmltag($this->ref);
}
if (!empty($label)) {
$tooltip .= '<br><b>'.$langs->trans('Title').':</b> '.dol_escape_htmltag($label);
}
if (!empty($labeltype)) {
$tooltip .= '<br><b>'.$langs->trans('Type').':</b> '.dol_escape_htmltag($labeltype);
}
if (!empty($this->location)) {
$tooltip .= '<br><b>'.$langs->trans('Location').':</b> '.dol_escape_htmltag($this->location);
}
if (isset($this->transparency)) {
$tooltip .= '<br><b>'.$langs->trans('Date').':</b> '.dol_print_date($this->datep, 'dayhourreduceformat', 'tzuserrel');
if ($this->datef) {
$tmpa = dol_getdate($this->datep);
$tmpb = dol_getdate($this->datef);
if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) {
if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes']) {
$tooltip .= '-'.dol_print_date($this->datef, 'hour', 'tzuserrel');
}
} else {
$tooltip .= '-'.dol_print_date($this->datef, 'dayhourreduceformat', 'tzuserrel');
}
}
if ($this->datef && $this->datep != $this->datef && isset($this->transparency)) {
$tooltip .= '<br><b>'.$langs->trans('Busy').':</b> '.yn($this->transparency);
}
if (!empty($this->email_msgid)) {
@ -1889,6 +1893,49 @@ class ActionComm extends CommonObject
}
/**
* Return label of type of event
*
* @param string $mode 0=Mode short, 1=Mode long
* @return string HTML String
*/
public function getTypeLabel($mode = 0)
{
global $conf, $langs;
// If cache for array of types unknown, we load it
if (!empty($conf->cache['actioncommgetypelabel'])) {
$arraylist = $conf->cache['actioncommgetypelabel'];
} else {
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php';
$caction = new CActionComm($this->db);
$arraylist = $caction->liste_array(1, 'code', '', (getDolGlobalString('AGENDA_USE_EVENT_TYPE') ? 0 : 1), '', 1);
$conf->cache['actioncommgetypelabel'] = $arraylist;
}
$labeltype = $this->type_code;
if (!getDolGlobalString('AGENDA_USE_EVENT_TYPE') && empty($arraylist[$labeltype])) {
$labeltype = 'AC_OTH';
}
if (preg_match('/^TICKET_MSG/', $this->code)) {
$labeltype = $langs->trans("Message");
} else {
if (!empty($arraylist[$labeltype])) {
$labeltype = $arraylist[$labeltype];
}
if ($this->type_code == 'AC_OTH_AUTO' && ($this->type_code != $this->code) && $labeltype && !empty($arraylist[$this->code])) {
$labeltype .= ' - '.$arraylist[$this->code]; // Use code in priority over type_code
}
}
if ($this->type == 'systemauto' && $mode == 1) {
$labeltype .= ' ('.$langs->trans("auto").')';
}
return $labeltype;
}
/**
* Sets object to supplied categories.
*

View file

@ -172,7 +172,7 @@ class FormActions
*/
public function showactions($object, $typeelement, $socid = 0, $forceshowtitle = 0, $morecss = 'listactions', $max = 0, $moreparambacktopage = '', $morehtmlcenter = '', $assignedtouser = 0)
{
global $langs, $conf, $user, $hookmanager;
global $langs, $user, $hookmanager;
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
@ -185,10 +185,6 @@ class FormActions
dol_print_error($this->db, 'FailedToGetActions');
}
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php';
$caction = new CActionComm($this->db);
$arraylist = $caction->liste_array(1, 'code', '', (!getDolGlobalString('AGENDA_USE_EVENT_TYPE') ? 1 : 0), '', 1);
$num = count($listofactions);
if ($num || $forceshowtitle) {
$title = $langs->trans("LatestLinkedEvents", $max ? $max : '');
@ -308,27 +304,12 @@ class FormActions
}
print '</td>';
$actionstatic = $actioncomm;
// Example: Email sent from invoice card
//$actionstatic->code = 'AC_BILL_SENTBYMAIL
//$actionstatic->type_code = 'AC_OTHER_AUTO'
// Type
$labeltype = $actionstatic->type_code;
if (!getDolGlobalString('AGENDA_USE_EVENT_TYPE') && empty($arraylist[$labeltype])) {
$labeltype = 'AC_OTH';
}
if (preg_match('/^TICKET_MSG/', $actionstatic->code)) {
$labeltype = $langs->trans("Message");
} else {
if (!empty($arraylist[$labeltype])) {
$labeltype = $arraylist[$labeltype];
}
if ($actionstatic->type_code == 'AC_OTH_AUTO' && ($actionstatic->type_code != $actionstatic->code) && $labeltype && !empty($arraylist[$actionstatic->code])) {
$labeltype .= ' - '.$arraylist[$actionstatic->code]; // Use code in priority on type_code
}
}
$labeltype = $actioncomm->getTypeLabel(0);
print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($labeltype).'">';
print $actioncomm->getTypePicto();
print $labeltype;

View file

@ -1299,3 +1299,4 @@ AllEntities=All entities
TranslationOfKey=Translation of the key AnyTranslationKey
SignedStatus=Signed status
NbRecordQualified=Number of qualified records
auto=auto