diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index a9db33b9980..dd7fe7f33b5 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2250,6 +2250,53 @@ class Adherent extends CommonObject return $langs->getLabelFromKey($this->db, "Civility".$code, "c_civility", "code", "label", $code); } + /** + * getTooltipContentArray + * @param array $params params to construct tooltip data + * @since v18 + * @return array + */ + public function getTooltipContentArray($params) + { + global $conf, $langs; + + $datas = []; + + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + $langs->load("users"); + return ['optimize' => $langs->trans("ShowUser")]; + } + if (!empty($this->photo)) { + $photo = '
'; + $photo .= Form::showphoto('memberphoto', $this, 80, 0, 0, 'photoref photowithmargin photologintooltip', 'small', 0, 1); + $photo .= '
'; + $datas['photo'] = $photo; + //$label .= '
'; + } + + $datas['divopen'] = '
'; + $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("Member").' '.$this->getLibStatut(4); + if (!empty($this->ref)) { + $datas['ref'] = '
'.$langs->trans('Ref').': '.$this->ref; + } + if (!empty($this->login)) { + $datas['login'] = '
'.$langs->trans('Login').': '.$this->login; + } + if (!empty($this->firstname) || !empty($this->lastname)) { + $datas['name'] = '
'.$langs->trans('Name').': '.$this->getFullName($langs); + } + if (!empty($this->company)) { + $datas['company'] = '
'.$langs->trans('Company').': '.$this->company; + } + if (!empty($this->email)) { + $datas['email'] = '
'.$langs->trans("EMail").': '.$this->email; + } + $datas['address'] = '
'.$langs->trans("Address").': '.dol_format_address($this, 1, ' ', $langs); + $datas['divclose'] = '
'; + + return $datas; + } + /** * Return clicable name (with picto eventually) * @@ -2324,8 +2371,18 @@ class Adherent extends CommonObject $label = $langs->trans("ShowUser"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + 'option' => $option, + ]; + $linkclose .= ' data-params='.json_encode($params).' id="' . uniqid('member') . '" title="' . $langs->trans('Loading') . '"'; + $linkclose .= ' class="classforajaxtooltip'.($morecss ? ' '.$morecss : '').'"'; + } else { + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + } } $linkstart .= $linkclose.'>';