From 83b4fde50c2c02914a1a6e867fff8af1447bbfb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 4 Feb 2023 22:00:47 +0100 Subject: [PATCH] add ajax tooltip on salaries --- htdocs/core/ajax/ajaxtooltip.php | 3 ++ htdocs/salaries/class/salary.class.php | 52 ++++++++++++++++++++------ 2 files changed, 44 insertions(+), 11 deletions(-) diff --git a/htdocs/core/ajax/ajaxtooltip.php b/htdocs/core/ajax/ajaxtooltip.php index d5461b0dc1b..a72b57c4ebe 100644 --- a/htdocs/core/ajax/ajaxtooltip.php +++ b/htdocs/core/ajax/ajaxtooltip.php @@ -198,6 +198,9 @@ if ($objecttype == 'invoice_supplier') { $classname = 'AdherentType'; } elseif ($objecttype == 'contact') { $module = 'societe'; +} elseif ($objecttype == 'salary') { + $classpath = 'salaries/class'; + $module = 'salaries'; } // print "objecttype=".$objecttype." module=".$module." subelement=".$subelement." classfile=".$classfile." classname=".$classname." classpath=".$classpath."
"; diff --git a/htdocs/salaries/class/salary.class.php b/htdocs/salaries/class/salary.class.php index 2f7bb36869e..4eb403a71a1 100644 --- a/htdocs/salaries/class/salary.class.php +++ b/htdocs/salaries/class/salary.class.php @@ -479,6 +479,25 @@ class Salary extends CommonObject } } + /** + * getTooltipContentArray + * @param array $params params to construct tooltip data + * @since v18 + * @return array + */ + public function getTooltipContentArray($params) + { + global $conf, $langs, $user; + + $langs->loadLangs(['salaries']); + + $datas = []; + $option = $params['option'] ?? ''; + $datas['picto'] = ''.$langs->trans("Salary").''; + $datas['ref'] = '
'.$langs->trans('Ref').': '.$this->ref; + + return $datas; + } /** * Send name clicable (with possibly the picto) @@ -523,29 +542,40 @@ class Salary extends CommonObject } $linkclose = ''; + $classfortooltip = 'classfortooltip'; + $dataparams = ''; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + 'option' => $option, + ]; + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); + $label = $langs->trans('Loading'); + } if (empty($notooltip)) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("ShowMyObject"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - - /* - $hookmanager->initHooks(array('myobjectdao')); - $parameters=array('id'=>$this->id); - $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) $linkclose = $hookmanager->resPrint; - */ - } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + $linkclose .= $dataparams.' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"'; + } else { + $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } $linkstart = ''; $linkend = ''; $result .= $linkstart; - if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright pictofixedwidth"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip pictofixedwidth"'), 0, 0, $notooltip ? 0 : 1); - if ($withpicto != 2) $result .= $this->ref; + if ($withpicto) { + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright pictofixedwidth"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.' pictofixedwidth"'), 0, 0, $notooltip ? 0 : 1); + } + if ($withpicto != 2) { + $result .= $this->ref; + } $result .= $linkend; //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');