From ffa9e1e52f20a4c3864cd91ed7ae3be311037ccf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 2 Feb 2023 22:23:43 +0100 Subject: [PATCH] add ajax tooltip on categories --- htdocs/categories/class/categorie.class.php | 38 +++++++++++++++++++-- htdocs/core/ajax/ajaxtooltip.php | 7 +++- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 4d6e3e1736f..5dcad42d936 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -10,7 +10,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2016 Charlie Benke - * Copyright (C) 2018-2022 Frédéric France + * Copyright (C) 2018-2023 Frédéric France * * 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 @@ -1597,6 +1597,23 @@ class Categorie extends CommonObject } } + /** + * getTooltipContentArray + * @param array $params params to construct tooltip data + * @since v18 + * @return array + */ + public function getTooltipContentArray($params) + { + global $conf, $langs, $user; + + $datas = []; + + $datas['label'] = $langs->trans("ShowCategory").': '.($this->ref ? $this->ref : $this->label); + + return $datas; + } + /** * Return name and link of category (with picto) * Use ->id, ->ref, ->label, ->color @@ -1622,7 +1639,22 @@ class Categorie extends CommonObject } } - $link = ''; + $link = ''; + $link2 .= '" data-params='.json_encode($params).' id="' . uniqid('category') . '" title="' . $langs->trans('Loading') . '"'; + $link2 .= ' class="classforajaxtooltip '.$forced_color.'">'; + } else { + $link .= '" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip '.$forced_color.'">'; + $link2 = $link; + } $linkend = ''; $picto = 'category'; @@ -1635,7 +1667,7 @@ class Categorie extends CommonObject $result .= ' '; } if ($withpicto != 2) { - $result .= $link.dol_trunc(($this->ref ? $this->ref : $this->label), $maxlength).$linkend; + $result .= $link2.dol_trunc(($this->ref ? $this->ref : $this->label), $maxlength).$linkend; } global $action; $hookmanager->initHooks(array($this->element . 'dao')); diff --git a/htdocs/core/ajax/ajaxtooltip.php b/htdocs/core/ajax/ajaxtooltip.php index 2656a788631..ae4f17246d1 100644 --- a/htdocs/core/ajax/ajaxtooltip.php +++ b/htdocs/core/ajax/ajaxtooltip.php @@ -75,11 +75,16 @@ if ($objecttype == 'facture' || $objecttype == 'invoice') { $classpath = 'compta/facture/class'; $module = 'facture'; $myobject = 'facture'; -} elseif ($objecttype == 'bank_account') { +} elseif ($objecttype == 'bank_accoun') { $langs->loadLangs(['banks', 'compta']); $classpath = 'compta/bank/class'; $module = 'banque'; $myobject = 'account'; +} elseif ($objecttype == 'category') { + $langs->loadLangs(['categories']); + $classpath = 'categories/class'; + $module = 'categorie'; + $myobject = 'categorie'; } elseif ($objecttype == 'commande' || $objecttype == 'order') { $langs->load('orders'); $classpath = 'commande/class';