add ajax tooltip on actioncomm

This commit is contained in:
Frédéric FRANCE 2023-02-02 23:47:01 +01:00
parent a32a0cc25a
commit dc33289a10
3 changed files with 85 additions and 4 deletions

View File

@ -5,7 +5,7 @@
* Copyright (C) 2011-2017 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2018-2023 Frédéric France <frederic.france@netlogic.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -1568,6 +1568,73 @@ class ActionComm extends CommonObject
return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode);
}
/**
* getTooltipContentArray
* @param array $params params to construct tooltip data
* @since v18
* @return array
*/
public function getTooltipContentArray($params)
{
global $conf, $langs, $user;
$langs->load('agenda');
$datas = [];
// Set label of type
$labeltype = '';
if ($this->type_code) {
$labeltype = ($langs->transnoentities("Action".$this->type_code) != "Action".$this->type_code) ? $langs->transnoentities("Action".$this->type_code) : $this->type_label;
}
if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
if ($this->type_code != 'AC_OTH_AUTO') {
$labeltype = $langs->trans('ActionAC_MANUAL');
}
}
$datas['picto'] = img_picto('', $this->picto).' <u>'.$langs->trans('Action').'</u>';
if (!empty($this->ref)) {
$datas['ref'] = '<br><b>'.$langs->trans('Ref').':</b> '.dol_escape_htmltag($this->ref);
}
if (!empty($this->label)) {
$datas['title'] = '<br><b>'.$langs->trans('Title').':</b> '.dol_escape_htmltag($this->label);
}
if (!empty($labeltype)) {
$datas['labeltype'] = '<br><b>'.$langs->trans('Type').':</b> '.dol_escape_htmltag($labeltype);
}
if (!empty($this->location)) {
$datas['location'] = '<br><b>'.$langs->trans('Location').':</b> '.dol_escape_htmltag($this->location);
}
if (isset($this->transparency)) {
$datas['transparency'] = '<br><b>'.$langs->trans('Busy').':</b> '.yn($this->transparency);
}
if (!empty($this->email_msgid)) {
$langs->load("mails");
$datas['space'] = '<br>';
// $datas['email'] = '<br><b>'.img_picto('', 'email').' '.$langs->trans("Email").'</b>';
$datas['mailtopic'] = '<br><b>'.$langs->trans('MailTopic').':</b> '.dol_escape_htmltag($this->email_subject);
$datas['mailfrom'] = '<br><b>'.$langs->trans('MailFrom').':</b> '.str_replace(array('<', '>'), array('&amp;lt', '&amp;gt'), $this->email_from);
$datas['mailto'] = '<br><b>'.$langs->trans('MailTo').':</b> '.str_replace(array('<', '>'), array('&amp;lt', '&amp;gt'), $this->email_to);
if (!empty($this->email_tocc)) {
$datas['mailcc'] = '<br><b>'.$langs->trans('MailCC').':</b> '.str_replace(array('<', '>'), array('&amp;lt', '&amp;gt'), $this->email_tocc);
}
/* Disabled because bcc must remain by defintion not visible
if (!empty($this->email_tobcc)) {
$datas['mailccc'] = '<br><b>'.$langs->trans('MailCCC').':</b> '.$this->email_tobcc;
} */
}
if (!empty($this->note_private)) {
$datas['description'] = '<br><b>'.$langs->trans('Description').':</b><br>';
// Try to limit length of content
$texttoshow = dolGetFirstLineOfText($this->note_private, 10);
// Restrict height of content into the tooltip
$datas['note'] = '<div class="tenlinesmax">';
$datas['note'] .= (dol_textishtml($texttoshow) ? str_replace(array("\r", "\n"), "", $texttoshow) : str_replace(array("\r", "\n"), '<br>', $texttoshow));
$datas['note'] .= '</div>';
}
return $datas;
}
/**
* Return URL of event
* Use $this->id, $this->type_code, $this->label and $this->type_label
@ -1668,8 +1735,18 @@ class ActionComm extends CommonObject
$label = $langs->trans("ShowAction");
$linkclose .= ' alt="'.dol_escape_htmltag($tooltip, 1).'"';
}
$linkclose .= ' title="'.dol_escape_htmltag($tooltip, 1, 0, '', 1).'"';
$linkclose .= ' class="'.$classname.' classfortooltip"';
if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
$params = [
'id' => $this->id,
'objecttype' => $this->element,
'option' => $option,
];
$linkclose .= '" data-params='.json_encode($params).' title="' . $langs->trans('Loading') . '"';
$linkclose .= ' class="'.$classname.' classforajaxtooltip"';
} else {
$linkclose .= ' title="'.dol_escape_htmltag($tooltip, 1, 0, '', 1).'"';
$linkclose .= ' class="'.$classname.' classfortooltip"';
}
} else {
$linkclose .= ' class="'.$classname.'"';
}

View File

@ -93,6 +93,11 @@ if ($objecttype == 'facture' || $objecttype == 'invoice') {
} elseif ($objecttype == 'propal') {
$langs->load('propal');
$classpath = 'comm/propal/class';
} elseif ($objecttype == 'action') {
$langs->load('agenda');
$classpath = 'comm/action/class';
$module = 'agenda';
$myobject = 'actioncomm';
} elseif ($objecttype == 'supplier_proposal') {
$langs->load('supplier_proposal');
$classpath = 'supplier_proposal/class';

View File

@ -688,7 +688,6 @@ class Entrepot extends CommonObject
return dolGetStatus($label, $labelshort, '', $statusType, $mode);
}
/**
* getTooltipContentArray
* @param array $params params to construct tooltip data