From 0a076813322d3ea57892e55f0fd87f8b0c59ff9d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 23 Jul 2024 11:49:06 +0200 Subject: [PATCH] Fix label of type of event not consistent between screen --- htdocs/comm/action/class/actioncomm.class.php | 75 +++++++++++++++---- htdocs/core/class/html.formactions.class.php | 23 +----- htdocs/langs/en_US/main.lang | 1 + 3 files changed, 64 insertions(+), 35 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 9a439752aea..05346c589b9 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -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).' '.$langs->trans('Action').''; + + $tooltip .= '   -   '.$this->getTypePicto('pictofixedwidth paddingright valignmiddle').$labeltype; if (!empty($this->ref)) { $tooltip .= '
'.$langs->trans('Ref').': '.dol_escape_htmltag($this->ref); } if (!empty($label)) { $tooltip .= '
'.$langs->trans('Title').': '.dol_escape_htmltag($label); } - if (!empty($labeltype)) { - $tooltip .= '
'.$langs->trans('Type').': '.dol_escape_htmltag($labeltype); - } if (!empty($this->location)) { $tooltip .= '
'.$langs->trans('Location').': '.dol_escape_htmltag($this->location); } - if (isset($this->transparency)) { + + $tooltip .= '
'.$langs->trans('Date').': '.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 .= '
'.$langs->trans('Busy').': '.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. * diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index 30c5ac70fd9..337f211f182 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -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 ''; - $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 ''; print $actioncomm->getTypePicto(); print $labeltype; diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 18dc30a2c5f..81a316b7f68 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1299,3 +1299,4 @@ AllEntities=All entities TranslationOfKey=Translation of the key AnyTranslationKey SignedStatus=Signed status NbRecordQualified=Number of qualified records +auto=auto