From e96cafa952b4e9e4384c5a3434c7f2a8e10c181a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 2 Feb 2023 11:03:08 +0100 Subject: [PATCH] add ajaxtooltip on member type --- .../adherents/class/adherent_type.class.php | 35 +++++++++++++++++-- htdocs/core/ajax/ajaxtooltip.php | 9 ++++- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index f5a5a8933d0..639f417bb94 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -688,6 +688,27 @@ class AdherentType extends CommonObject //return $morphy; } + /** + * getTooltipContentArray + * @param array $params params to construct tooltip data + * @since v18 + * @return array + */ + public function getTooltipContentArray($params) + { + global $conf, $langs, $user; + + $datas = []; + + $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("MemberType").' '.$this->getLibStatut(4); + $datas['label'] = '
'.$langs->trans("Label").': '.$this->label; + if (isset($this->subscription)) { + $datas['subscription'] = '
'.$langs->trans("SubscriptionRequired").': '.yn($this->subscription); + } + + return $datas; + } + /** * Return clicable name (with picto eventually) * @@ -725,8 +746,16 @@ class AdherentType extends CommonObject $url .= '&save_lastsearch_values=1'; } } - - $linkstart = ''; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + 'option' => $option, + ]; + $linkstart = ''; + } else { + $linkstart = ''; + } $linkend = ''; $result .= $linkstart; @@ -741,7 +770,6 @@ class AdherentType extends CommonObject return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of status (activity, closed) * @@ -753,6 +781,7 @@ class AdherentType extends CommonObject return $this->LibStatut($this->status, $mode); } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return the label of a given status * diff --git a/htdocs/core/ajax/ajaxtooltip.php b/htdocs/core/ajax/ajaxtooltip.php index 516794896dc..e52d3cfd3d9 100644 --- a/htdocs/core/ajax/ajaxtooltip.php +++ b/htdocs/core/ajax/ajaxtooltip.php @@ -141,7 +141,6 @@ if ($objecttype == 'facture' || $objecttype == 'invoice') { // Generic case for $classfile and $classname $classfile = strtolower($myobject); $classname = ucfirst($myobject); -// print "objecttype=".$objecttype." module=".$module." subelement=".$subelement." classfile=".$classfile." classname=".$classname." classpath=".$classpath."\n"; if ($objecttype == 'invoice_supplier') { $classfile = 'fournisseur.facture'; @@ -171,9 +170,17 @@ if ($objecttype == 'invoice_supplier') { $classpath = 'comm/mailing/class'; $classfile = 'mailing'; $classname = 'Mailing'; +} elseif ($objecttype == 'adherent_type') { + $langs->load('members'); + $classpath = 'adherents/class'; + $classfile = 'adherent_type'; + $module = 'adherent'; + $myobject = 'adherent_type'; + $classname = 'AdherentType'; } elseif ($objecttype == 'contact') { $module = 'societe'; } +// print "objecttype=".$objecttype." module=".$module." subelement=".$subelement." classfile=".$classfile." classname=".$classname." classpath=".$classpath."\n"; if (isModEnabled($module)) { $res = dol_include_once('/'.$classpath.'/'.$classfile.'.class.php');