work on ajax tooltip

This commit is contained in:
Frédéric FRANCE
2023-01-30 23:24:23 +01:00
parent 897477d1c7
commit 993c1d28c4
6 changed files with 578 additions and 30 deletions

View File

@@ -2744,6 +2744,99 @@ class User extends CommonObject
return $result;
}
/**
* getTooltipContentArray
*
* @param array $params ex option, infologin
* @since v18
* @return array
*/
public function getTooltipContentArray($params)
{
global $conf, $langs, $menumanager;
$infologin = $params['infologin'] ?? 0;
$option = $params['option'] ?? '';
$datas = [];
if (!empty($this->photo)) {
$photo = '<div class="photointooltip floatright">';
$photo .= Form::showphoto('userphoto', $this, 0, 60, 0, 'photoref photowithmargin photologintooltip', 'small', 0, 1); // Force height to 60 so we total height of tooltip can be calculated and collision can be managed
$photo .= '</div>';
$datas['photo'] = $photo;
//$label .= '<div style="clear: both;"></div>';
}
// Info Login
$datas['opendiv'] = '<div class="centpercent">';
$datas['picto'] = img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("User").'</u> '.$this->getLibStatut(4);
$datas['name'] = '<br><b>'.$langs->trans('Name').':</b> '.dol_string_nohtmltag($this->getFullName($langs, ''));
if (!empty($this->login)) {
$datas['login'] = '<br><b>'.$langs->trans('Login').':</b> '.dol_string_nohtmltag($this->login);
}
if (!empty($this->job)) {
$datas['job'] = '<br><b>'.$langs->trans("Job").':</b> '.dol_string_nohtmltag($this->job);
}
$datas['email'] = '<br><b>'.$langs->trans("Email").':</b> '.dol_string_nohtmltag($this->email);
if (!empty($this->office_phone) || !empty($this->office_fax) || !empty($this->fax)) {
$phonelist = array();
if ($this->office_phone) {
$phonelist[] = dol_print_phone($this->office_phone, $this->country_code, $this->id, 0, '', '&nbsp', 'phone');
}
if ($this->office_fax) {
$phonelist[] = dol_print_phone($this->office_fax, $this->country_code, $this->id, 0, '', '&nbsp', 'fax');
}
if ($this->user_mobile) {
$phonelist[] = dol_print_phone($this->user_mobile, $this->country_code, $this->id, 0, '', '&nbsp', 'mobile');
}
$datas['phones'] = '<br><b>'.$langs->trans('Phone').':</b> '.implode('&nbsp;', $phonelist);
}
if (!empty($this->admin)) {
$datas['administrator'] = '<br><b>'.$langs->trans("Administrator").'</b>: '.yn($this->admin);
}
if (!empty($this->accountancy_code) || $option == 'accountancy') {
$datas['accountancycode'] = '<br><b>'.$langs->trans("AccountancyCode").'</b>: '.$this->accountancy_code;
}
$company = '';
if (!empty($this->socid)) { // Add thirdparty for external users
$thirdpartystatic = new Societe($this->db);
$thirdpartystatic->fetch($this->socid);
if (empty($hidethirdpartylogo)) {
$companylink = ' '.$thirdpartystatic->getNomUrl(2, (($option == 'nolink') ? 'nolink' : '')); // picto only of company
}
$company = ' ('.$langs->trans("Company").': '.img_picto('', 'company').' '.dol_string_nohtmltag($thirdpartystatic->name).')';
}
$type = ($this->socid ? $langs->trans("ExternalUser").$company : $langs->trans("InternalUser"));
$datas['type'] = '<br><b>'.$langs->trans("Type").':</b> '.$type;
$datas['closediv'] = '</div>';
if ($infologin > 0) {
$datas['newlinelogin'] = '<br>';
$datas['session'] = '<br><u>'.$langs->trans("Session").'</u>';
$datas['ip'] = '<br><b>'.$langs->trans("IPAddress").'</b>: '.dol_string_nohtmltag(getUserRemoteIP());
if (!empty($conf->global->MAIN_MODULE_MULTICOMPANY)) {
$datas['multicompany'] = '<br><b>'.$langs->trans("ConnectedOnMultiCompany").':</b> '.$conf->entity.' (User entity '.$this->entity.')';
}
$datas['authentication'] = '<br><b>'.$langs->trans("AuthenticationMode").':</b> '.dol_string_nohtmltag($_SESSION["dol_authmode"].(empty($dolibarr_main_demo) ? '' : ' (demo)'));
$datas['connectedsince'] = '<br><b>'.$langs->trans("ConnectedSince").':</b> '.dol_print_date($this->datelastlogin, "dayhour", 'tzuser');
$datas['previousconnexion'] = '<br><b>'.$langs->trans("PreviousConnexion").':</b> '.dol_print_date($this->datepreviouslogin, "dayhour", 'tzuser');
$datas['currenttheme'] = '<br><b>'.$langs->trans("CurrentTheme").':</b> '.dol_string_nohtmltag($conf->theme);
$datas['currentmenumanager'] = '<br><b>'.$langs->trans("CurrentMenuManager").':</b> '.dol_string_nohtmltag($menumanager->name);
$s = picto_from_langcode($langs->getDefaultLang());
$datas['currentuserlang'] = '<br><b>'.$langs->trans("CurrentUserLanguage").':</b> '.dol_string_nohtmltag(($s ? $s.' ' : '').$langs->getDefaultLang());
$datas['browser'] = '<br><b>'.$langs->trans("Browser").':</b> '.dol_string_nohtmltag($conf->browser->name.($conf->browser->version ? ' '.$conf->browser->version : '').' ('.$_SERVER['HTTP_USER_AGENT'].')');
$datas['layout'] = '<br><b>'.$langs->trans("Layout").':</b> '.dol_string_nohtmltag($conf->browser->layout);
$datas['screen'] = '<br><b>'.$langs->trans("Screen").':</b> '.dol_string_nohtmltag($_SESSION['dol_screenwidth'].' x '.$_SESSION['dol_screenheight']);
if ($conf->browser->layout == 'phone') {
$datas['phone'] = '<br><b>'.$langs->trans("Phone").':</b> '.$langs->trans("Yes");
}
if (!empty($_SESSION["disablemodules"])) {
$datas['disabledmodules'] = '<br><b>'.$langs->trans("DisabledModules").':</b> <br>'.dol_string_nohtmltag(join(', ', explode(',', $_SESSION["disablemodules"])));
}
}
return $datas;
}
/**
* Return a HTML link to the user card (with optionaly the picto)
* Use this->id,this->lastname, this->firstname
@@ -2877,8 +2970,19 @@ class User 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,
'infologin' => $infologin,
'option' => $option,
];
$linkclose .= ' data-params='.json_encode($params).' id="user-' . uniqid() . '" title="' . $langs->trans('Loading') . '"';
$linkclose .= ' class="classforajaxtooltip'.($morecss ? ' '.$morecss : '').'"';
} else {
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
}
}
$linkstart .= $linkclose.'>';