From 2fd6b9438fb835bd865d86cc32e3c67ae62abc5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 7 Feb 2023 13:55:36 +0100 Subject: [PATCH] add ajax tooltip on ticket --- htdocs/ticket/class/ticket.class.php | 57 +++++++++++++++++++++------- 1 file changed, 43 insertions(+), 14 deletions(-) diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 5faea34ad6c..3be6e282875 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -1400,6 +1400,34 @@ class Ticket extends CommonObject return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode, '', $params); } + /** + * getTooltipContentArray + * + * @param array $params ex option, infologin + * @since v18 + * @return array + */ + public function getTooltipContentArray($params) + { + global $langs; + + $langs->load('ticket'); + + $datas = []; + $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("Ticket").''; + $datas['picto'] .= ' '.$this->getLibStatut(4); + $datas['ref'] = '
'.$langs->trans('Ref').': '.$this->ref; + $datas['track_id'] = '
'.$langs->trans('TicketTrackId').': '.$this->track_id; + $datas['subject'] = '
'.$langs->trans('Subject').': '.$this->subject; + if ($this->date_creation) { + $datas['date_creation'] = '
'.$langs->trans('DateCreation').': '.$this->date_creation; + } + if ($this->date_modification) { + $datas['date_modification'] = '
'.$langs->trans('DateModification').': '.$this->date_modification; + } + + return $datas; + } /** * Return a link to the object card (with optionaly the picto) @@ -1423,18 +1451,19 @@ class Ticket extends CommonObject $result = ''; - $label = img_picto('', $this->picto).' '.$langs->trans("Ticket").''; - $label .= ' '.$this->getLibStatut(4); - $label .= '
'; - $label .= ''.$langs->trans('Ref').': '.$this->ref.'
'; - $label .= ''.$langs->trans('TicketTrackId').': '.$this->track_id.'
'; - $label .= ''.$langs->trans('Subject').': '.$this->subject; - if ($this->date_creation) { - $label .= '
'.$langs->trans('DateCreation').': '.$this->date_creation; - } - if ($this->date_modification) { - $label .= '
'.$langs->trans('DateModification').': '.$this->date_modification; + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + ]; + $classfortooltip = 'classfortooltip'; + $dataparams = ''; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); + // $label = $langs->trans('Loading'); } + $label = implode($this->getTooltipContentArray($params)); + $url = DOL_URL_ROOT.'/ticket/card.php?id='.$this->id; if ($option != 'nolink') { @@ -1454,8 +1483,8 @@ class Ticket extends CommonObject $label = $langs->trans("ShowTicket"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + $linkclose .= $dataparams.' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"'; } else { $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); } @@ -1466,7 +1495,7 @@ class Ticket extends CommonObject $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->ref;