From 993c1d28c4c0fd93f069b71d9692382eae5a7d0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 30 Jan 2023 23:24:23 +0100 Subject: [PATCH 01/62] work on ajax tooltip --- htdocs/commande/class/commande.class.php | 58 ++++++- htdocs/core/ajax/ajaxtooltip.php | 200 +++++++++++++++++++++++ htdocs/core/class/commonobject.class.php | 51 ++++++ htdocs/core/js/lib_foot.js.php | 71 +++++--- htdocs/product/class/product.class.php | 120 +++++++++++++- htdocs/user/class/user.class.php | 108 +++++++++++- 6 files changed, 578 insertions(+), 30 deletions(-) create mode 100644 htdocs/core/ajax/ajaxtooltip.php diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 2a462f77bc4..4dcae469aaa 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3714,6 +3714,48 @@ class Commande extends CommonOrder return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode, '', array('tooltip' => $labelTooltip)); } + /** + * getTooltipContentArray + * @param array $parameters + * @since v18 + * @return array + */ + public function getTooltipContentArray($parameters) + { + global $conf, $langs, $user; + + $datas = []; + + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + return ['optimize' => $langs->trans("Order")]; + } + + if ($user->rights->commande->lire) { + $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("Order").''; + if (isset($this->statut)) { + $datas[] = ' '.$this->getLibStatut(5); + } + $datas['Ref'] = '
'.$langs->trans('Ref').': '.$this->ref; + $datas['RefCustomer'] = '
'.$langs->trans('RefCustomer').': '.(empty($this->ref_customer) ? (empty($this->ref_client) ? '' : $this->ref_client) : $this->ref_customer); + if (!empty($this->total_ht)) { + $datas['AmountHT'] = '
'.$langs->trans('AmountHT').': '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); + } + if (!empty($this->total_tva)) { + $datas['VAT'] = '
'.$langs->trans('VAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); + } + if (!empty($this->total_ttc)) { + $datas['AmountTTC'] = '
'.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); + } + if (!empty($this->date)) { + $datas['Date'] = '
'.$langs->trans('Date').': '.dol_print_date($this->date, 'day'); + } + if (!empty($this->delivery_date)) { + $datas['DeliveryDate'] = '
'.$langs->trans('DeliveryDate').': '.dol_print_date($this->delivery_date, 'dayhour'); + } + } + + return $datas; + } /** * Return clicable link of object (with eventually picto) @@ -3795,10 +3837,20 @@ class Commande extends CommonOrder $label = $langs->trans("Order"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip"'; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + 'option' => $option, + ]; + $linkclose .= ' data-params='.json_encode($params).' id="order-' . uniqid() . '" title="' . $langs->trans('Loading') . '"'; + $linkclose .= ' class="classforajaxtooltip"'; + } else { + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip"'; + } - $target_value=array('_self', '_blank', '_parent', '_top'); + $target_value = array('_self', '_blank', '_parent', '_top'); if (in_array($target, $target_value)) { $linkclose .= ' target="'.dol_escape_htmltag($target).'"'; } diff --git a/htdocs/core/ajax/ajaxtooltip.php b/htdocs/core/ajax/ajaxtooltip.php new file mode 100644 index 00000000000..2342bcf35f1 --- /dev/null +++ b/htdocs/core/ajax/ajaxtooltip.php @@ -0,0 +1,200 @@ + + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/ajax/ajaxtooltip.php + * \ingroup tooltip + * \brief This script returns content of tooltip + */ + + +if (!defined('NOTOKENRENEWAL')) { + define('NOTOKENRENEWAL', 1); // Disables token renewal +} +if (!defined('NOREQUIREMENU')) { + define('NOREQUIREMENU', '1'); +} +if (!defined('NOREQUIREHTML')) { + define('NOREQUIREHTML', '1'); +} +if (!defined('NOREQUIREAJAX')) { + define('NOREQUIREAJAX', '1'); +} +include '../../main.inc.php'; +include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +include_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; + +top_httphead(); + +$id = GETPOST('id', 'int'); +$objecttype = GETPOST('objecttype', 'aZ09'); + +$html = ''; +$regs = array(); +$params = array(); +if (GETPOSTISSET('infologin')) { + $params['infologin'] = GETPOST('infologin', 'int'); +} +if (GETPOSTISSET('option')) { + $params['option'] = GETPOST('option', 'restricthtml'); +} +// If we ask a resource form external module (instead of default path) +if (preg_match('/^([^@]+)@([^@]+)$/i', $objecttype, $regs)) { + $myobject = $regs[1]; + $module = $regs[2]; +} else { + // Parse $objecttype (ex: project_task) + $module = $myobject = $objecttype; + if (preg_match('/^([^_]+)_([^_]+)/i', $objecttype, $regs)) { + $module = $regs[1]; + $myobject = $regs[2]; + } +} + +// Generic case for $classpath +$classpath = $module.'/class'; + +// Special cases, to work with non standard path +if ($objecttype == 'facture' || $objecttype == 'invoice') { + $langs->load('bills'); + $classpath = 'compta/facture/class'; + $module = 'facture'; + $myobject = 'facture'; +} elseif ($objecttype == 'commande' || $objecttype == 'order') { + $langs->load('orders'); + $classpath = 'commande/class'; + $module = 'commande'; + $myobject = 'commande'; +} elseif ($objecttype == 'propal') { + $langs->load('propal'); + $classpath = 'comm/propal/class'; +} elseif ($objecttype == 'supplier_proposal') { + $langs->load('supplier_proposal'); + $classpath = 'supplier_proposal/class'; +} elseif ($objecttype == 'shipping') { + $langs->load('sendings'); + $classpath = 'expedition/class'; + $myobject = 'expedition'; + $module = 'expedition_bon'; +} elseif ($objecttype == 'delivery') { + $langs->load('deliveries'); + $classpath = 'delivery/class'; + $myobject = 'delivery'; + $module = 'delivery_note'; +} elseif ($objecttype == 'contract') { + $langs->load('contracts'); + $classpath = 'contrat/class'; + $module = 'contrat'; + $myobject = 'contrat'; +} elseif ($objecttype == 'member') { + $langs->load('members'); + $classpath = 'adherents/class'; + $module = 'adherent'; + $myobject = 'adherent'; +} elseif ($objecttype == 'cabinetmed_cons') { + $classpath = 'cabinetmed/class'; + $module = 'cabinetmed'; + $myobject = 'cabinetmedcons'; +} elseif ($objecttype == 'fichinter') { + $langs->load('interventions'); + $classpath = 'fichinter/class'; + $module = 'ficheinter'; + $myobject = 'fichinter'; +} elseif ($objecttype == 'project') { + $langs->load('projects'); + $classpath = 'projet/class'; + $module = 'projet'; +} elseif ($objecttype == 'task') { + $langs->load('projects'); + $classpath = 'projet/class'; + $module = 'projet'; + $myobject = 'task'; +} elseif ($objecttype == 'stock') { + $classpath = 'product/stock/class'; + $module = 'stock'; + $myobject = 'stock'; +} elseif ($objecttype == 'inventory') { + $classpath = 'product/inventory/class'; + $module = 'stock'; + $myobject = 'inventory'; +} elseif ($objecttype == 'mo') { + $classpath = 'mrp/class'; + $module = 'mrp'; + $myobject = 'mo'; +} elseif ($objecttype == 'productlot') { + $classpath = 'product/stock/class'; + $module = 'stock'; + $myobject = 'productlot'; +} + +// 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; + +if ($objecttype == 'invoice_supplier') { + $classfile = 'fournisseur.facture'; + $classname = 'FactureFournisseur'; + $classpath = 'fourn/class'; + $module = 'fournisseur'; +} elseif ($objecttype == 'order_supplier') { + $classfile = 'fournisseur.commande'; + $classname = 'CommandeFournisseur'; + $classpath = 'fourn/class'; + $module = 'fournisseur'; +} elseif ($objecttype == 'supplier_proposal') { + $classfile = 'supplier_proposal'; + $classname = 'SupplierProposal'; + $classpath = 'supplier_proposal/class'; + $module = 'supplier_proposal'; +} elseif ($objecttype == 'stock') { + $classpath = 'product/stock/class'; + $classfile = 'entrepot'; + $classname = 'Entrepot'; +} elseif ($objecttype == 'facturerec') { + $classpath = 'compta/facture/class'; + $classfile = 'facture-rec'; + $classname = 'FactureRec'; + $module = 'facture'; +} elseif ($objecttype == 'mailing') { + $classpath = 'comm/mailing/class'; + $classfile = 'mailing'; + $classname = 'Mailing'; +} + +if (isModEnabled($module)) { + $res = dol_include_once('/'.$classpath.'/'.$classfile.'.class.php'); + if ($res) { + if (class_exists($classname)) { + $object = new $classname($db); + $res = $object->fetch($id); + if ($res > 0) { + $html = $object->getTooltipContent($params); + } elseif ($res == 0) { + $html = $langs->trans('Deleted'); + } + unset($object); + } else { + dol_syslog("Class with classname ".$classname." is unknown even after the include", LOG_ERR); + } + } +} + +print $html; + +$db->close(); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 25f16cbbdb4..416e1ca737b 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -664,6 +664,57 @@ abstract class CommonObject } return -1; } + /** + * getTooltipContentArray + * + * @since v18 + * @param array $params + * @return array + */ + public function getTooltipContentArray($params) + { + return []; + } + + /** + * getTooltipContent + * + * @param array $params + * @since v18 + * @return string + */ + public function getTooltipContent($params) + { + global $action, $extrafields, $langs, $hookmanager; + + $datas = $this->getTooltipContentArray($params); + + if (!empty($extrafields->attributes[$this->table_element]['label'])) { + foreach ($extrafields->attributes[$this->table_element]['label'] as $key => $val) { + if (!empty($extrafields->attributes[$this->table_element]['langfile'][$key])) { + $langs->load($extrafields->attributes[$this->table_element]['langfile'][$key]); + } + $labelextra = $langs->trans((string) $extrafields->attributes[$this->table_element]['label'][$key]); + if ($extrafields->attributes[$this->table_element]['type'][$key] == 'separate') { + $datas[$key]= '
'. $labelextra . ''; + } else { + $value = $this->array_options['options_' . $key]; + $datas[$key]= '
'. $labelextra . ': ' . $extrafields->showOutputField($key, $value, '', $this->table_element); + } + } + } + + $hookmanager->initHooks(array($this->element . 'dao')); + $parameters = array( + 'tooltipcontentarray' => &$datas + ); + // Note that $action and $object may have been modified by some hooks + $hookmanager->executeHooks('getTooltipContent', $parameters, $this, $action); + + $label = implode($datas); + + return $label; + } /** diff --git a/htdocs/core/js/lib_foot.js.php b/htdocs/core/js/lib_foot.js.php index c037b86a7b9..7ec398f3368 100644 --- a/htdocs/core/js/lib_foot.js.php +++ b/htdocs/core/js/lib_foot.js.php @@ -65,38 +65,63 @@ if (empty($dolibarr_nocache)) { // Wrapper to show tooltips (html or onclick popup) -print "\n/* JS CODE TO ENABLE Tooltips on all object with class classfortooltip */\n"; -print "jQuery(document).ready(function () {\n"; +print "\n/* JS CODE TO ENABLE Tooltips on all object with class classfortooltip */ +jQuery(document).ready(function () {\n"; if (empty($conf->dol_no_mouse_hover)) { - print 'jQuery(".classfortooltip").tooltip({ + print ' + jQuery(".classfortooltip").tooltip({ show: { collision: "flipfit", effect:"toggle", delay:50, duration: 20 }, hide: { delay: 250, duration: 20 }, tooltipClass: "mytooltip", content: function () { - console.log("Return title for popup"); - return $(this).prop("title"); /* To force to get title as is */ - } - });'."\n"; + console.log("Return title for popup"); + return $(this).prop("title"); /* To force to get title as is */ + } + }); + jQuery(".classforajaxtooltip").tooltip({ + show: { collision: "flipfit", effect:"toggle", delay:50, duration: 20 }, + hide: { delay: 250, duration: 20 }, + tooltipClass: "mytooltip", + open: function (event, ui) { + var id = $(this).attr("id"); + var params = $(this).attr("data-params"); + $.ajax({ + url:"' . dol_buildpath('/core/ajax/ajaxtooltip.php', 1) . '", + type: "post", + data: JSON.parse(params), + success: function(response){ + // Setting content option + $("#"+id).tooltip("option","content",response); + } + }); + console.log(event); + } + }); + jQuery(".classforajaxtooltip").mouseout(function(){ + console.log("hide ajax tooltip"); + $(this).tooltip("close"); + }); + '; } print ' -jQuery(".classfortooltiponclicktext").dialog({ - closeOnEscape: true, classes: { "ui-dialog": "highlight" }, - maxHeight: window.innerHeight-60, width: '.($conf->browser->layout == 'phone' ? max($_SESSION['dol_screenwidth'] - 20, 320) : 700).', - modal: true, - autoOpen: false - }).css("z-index: 5000"); -jQuery(".classfortooltiponclick").click(function () { - console.log("We click on tooltip for element with dolid="+$(this).attr(\'dolid\')); - if ($(this).attr(\'dolid\')) { - obj=$("#idfortooltiponclick_"+$(this).attr(\'dolid\')); /* obj is a div component */ - obj.dialog("open"); - return false; - } -});'."\n"; - -print "});\n"; + jQuery(".classfortooltiponclicktext").dialog({ + closeOnEscape: true, classes: { "ui-dialog": "highlight" }, + maxHeight: window.innerHeight-60, width: '.($conf->browser->layout == 'phone' ? max($_SESSION['dol_screenwidth'] - 20, 320) : 700).', + modal: true, + autoOpen: false + }).css("z-index: 5000"); + jQuery(".classfortooltiponclick").click(function () { + console.log("We click on tooltip for element with dolid="+$(this).attr(\'dolid\')); + if ($(this).attr(\'dolid\')) { + obj=$("#idfortooltiponclick_"+$(this).attr(\'dolid\')); /* obj is a div component */ + obj.dialog("open"); + return false; + } + }); +}); +'; // Wrapper to manage dropdown diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 60de90d819d..e7160ef467a 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4999,6 +4999,112 @@ class Product extends CommonObject } } + /** + * getTooltipContentArray + * @param array $params + * @since v18 + * @return array + */ + public function getTooltipContentArray($params) + { + global $conf, $langs; + + $datas = []; + + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + return ['optimize' => $langs->trans("ShowProduct")]; + } + + if (!empty($this->entity)) { + $tmpphoto = $this->show_photos('product', $conf->product->multidir_output[$this->entity], 1, 1, 0, 0, 0, 80); + if ($this->nbphoto > 0) { + $datas['photo'] = '
' . $tmpphoto . '
'; + //$label .= '
'; + } + } + + if ($this->type == Product::TYPE_PRODUCT) { + $datas['picto'] = img_picto('', 'product').' '.$langs->trans("Product").''; + } elseif ($this->type == Product::TYPE_SERVICE) { + $datas['picto']= img_picto('', 'service').' '.$langs->trans("Service").''; + } + if (isset($this->status) && isset($this->status_buy)) { + $datas['status']= ' '.$this->getLibStatut(5, 0) . ' '.$this->getLibStatut(5, 1); + } + + if (!empty($this->ref)) { + $datas['ref']= '
'.$langs->trans('ProductRef').': '.$this->ref; + } + if (!empty($this->label)) { + $datas['label']= '
'.$langs->trans('ProductLabel').': '.$this->label; + } + if ($this->type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { + if (isModEnabled('productbatch')) { + $langs->load("productbatch"); + $datas['batchstatus']= "
".$langs->trans("ManageLotSerial").': '.$this->getLibStatut(0, 2); + } + } + if (isModEnabled('barcode')) { + $datas['barcode']= '
'.$langs->trans('BarCode').': '.$this->barcode; + } + + if ($this->type == Product::TYPE_PRODUCT) { + if ($this->weight) { + $datas['weight']= "
".$langs->trans("Weight").': '.$this->weight.' '.measuringUnitString(0, "weight", $this->weight_units); + } + $labelsize = ""; + if ($this->length) { + $labelsize .= ($labelsize ? " - " : "")."".$langs->trans("Length").': '.$this->length.' '.measuringUnitString(0, 'size', $this->length_units); + } + if ($this->width) { + $labelsize .= ($labelsize ? " - " : "")."".$langs->trans("Width").': '.$this->width.' '.measuringUnitString(0, 'size', $this->width_units); + } + if ($this->height) { + $labelsize .= ($labelsize ? " - " : "")."".$langs->trans("Height").': '.$this->height.' '.measuringUnitString(0, 'size', $this->height_units); + } + if ($labelsize) { + $datas['size']= "
".$labelsize; + } + + $labelsurfacevolume = ""; + if ($this->surface) { + $labelsurfacevolume .= ($labelsurfacevolume ? " - " : "")."".$langs->trans("Surface").': '.$this->surface.' '.measuringUnitString(0, 'surface', $this->surface_units); + } + if ($this->volume) { + $labelsurfacevolume .= ($labelsurfacevolume ? " - " : "")."".$langs->trans("Volume").': '.$this->volume.' '.measuringUnitString(0, 'volume', $this->volume_units); + } + if ($labelsurfacevolume) { + $datas['surface']= "
" . $labelsurfacevolume; + } + } + if (!empty($this->pmp) && $this->pmp) { + $datas['pmp'] = "
".$langs->trans("PMPValue").': '.price($this->pmp, 0, '', 1, -1, -1, $conf->currency); + } + + if (isModEnabled('accounting')) { + if ($this->status && isset($this->accountancy_code_sell)) { + include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; + $selllabel = '
'; + $selllabel .= '
'.$langs->trans('ProductAccountancySellCode').': '.length_accountg($this->accountancy_code_sell); + $selllabel .= '
'.$langs->trans('ProductAccountancySellIntraCode').': '.length_accountg($this->accountancy_code_sell_intra); + $selllabel .= '
'.$langs->trans('ProductAccountancySellExportCode').': '.length_accountg($this->accountancy_code_sell_export); + $datas['accountancysell'] = $selllabel; + } + if ($this->status_buy && isset($this->accountancy_code_buy)) { + include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; + if (empty($this->status)) { + $buylabel = '
'; + } + $buylabel .= '
'.$langs->trans('ProductAccountancyBuyCode').': '.length_accountg($this->accountancy_code_buy); + $buylabel .= '
'.$langs->trans('ProductAccountancyBuyIntraCode').': '.length_accountg($this->accountancy_code_buy_intra); + $buylabel .= '
'.$langs->trans('ProductAccountancyBuyExportCode').': '.length_accountg($this->accountancy_code_buy_export); + $datas['accountancybuy'] = $buylabel; + } + } + + return $datas; + } + /** * Return clicable link of object (with eventually picto) * @@ -5119,8 +5225,18 @@ class Product extends CommonObject $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1, 1).'"'; - $linkclose .= ' class="nowraponall 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="product-' . uniqid() . '" title="' . $langs->trans('Loading') . '"'; + $linkclose .= ' class="nowraponall classforajaxtooltip'.($morecss ? ' '.$morecss : '').'"'; + } else { + $linkclose .= ' title="'.dol_escape_htmltag($label, 1, 1).'"'; + $linkclose .= ' class="nowraponall classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + } } else { $linkclose = ' class="nowraponall'.($morecss ? ' '.$morecss : '').'"'; } diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 2893378bdd9..0a963da1f5d 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -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 = '
'; + $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 .= '
'; + $datas['photo'] = $photo; + //$label .= '
'; + } + + // Info Login + $datas['opendiv'] = '
'; + $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("User").' '.$this->getLibStatut(4); + $datas['name'] = '
'.$langs->trans('Name').': '.dol_string_nohtmltag($this->getFullName($langs, '')); + if (!empty($this->login)) { + $datas['login'] = '
'.$langs->trans('Login').': '.dol_string_nohtmltag($this->login); + } + if (!empty($this->job)) { + $datas['job'] = '
'.$langs->trans("Job").': '.dol_string_nohtmltag($this->job); + } + $datas['email'] = '
'.$langs->trans("Email").': '.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, '', ' ', 'phone'); + } + if ($this->office_fax) { + $phonelist[] = dol_print_phone($this->office_fax, $this->country_code, $this->id, 0, '', ' ', 'fax'); + } + if ($this->user_mobile) { + $phonelist[] = dol_print_phone($this->user_mobile, $this->country_code, $this->id, 0, '', ' ', 'mobile'); + } + $datas['phones'] = '
'.$langs->trans('Phone').': '.implode(' ', $phonelist); + } + if (!empty($this->admin)) { + $datas['administrator'] = '
'.$langs->trans("Administrator").': '.yn($this->admin); + } + if (!empty($this->accountancy_code) || $option == 'accountancy') { + $datas['accountancycode'] = '
'.$langs->trans("AccountancyCode").': '.$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'] = '
'.$langs->trans("Type").': '.$type; + $datas['closediv'] = '
'; + if ($infologin > 0) { + $datas['newlinelogin'] = '
'; + $datas['session'] = '
'.$langs->trans("Session").''; + $datas['ip'] = '
'.$langs->trans("IPAddress").': '.dol_string_nohtmltag(getUserRemoteIP()); + if (!empty($conf->global->MAIN_MODULE_MULTICOMPANY)) { + $datas['multicompany'] = '
'.$langs->trans("ConnectedOnMultiCompany").': '.$conf->entity.' (User entity '.$this->entity.')'; + } + $datas['authentication'] = '
'.$langs->trans("AuthenticationMode").': '.dol_string_nohtmltag($_SESSION["dol_authmode"].(empty($dolibarr_main_demo) ? '' : ' (demo)')); + $datas['connectedsince'] = '
'.$langs->trans("ConnectedSince").': '.dol_print_date($this->datelastlogin, "dayhour", 'tzuser'); + $datas['previousconnexion'] = '
'.$langs->trans("PreviousConnexion").': '.dol_print_date($this->datepreviouslogin, "dayhour", 'tzuser'); + $datas['currenttheme'] = '
'.$langs->trans("CurrentTheme").': '.dol_string_nohtmltag($conf->theme); + $datas['currentmenumanager'] = '
'.$langs->trans("CurrentMenuManager").': '.dol_string_nohtmltag($menumanager->name); + $s = picto_from_langcode($langs->getDefaultLang()); + $datas['currentuserlang'] = '
'.$langs->trans("CurrentUserLanguage").': '.dol_string_nohtmltag(($s ? $s.' ' : '').$langs->getDefaultLang()); + $datas['browser'] = '
'.$langs->trans("Browser").': '.dol_string_nohtmltag($conf->browser->name.($conf->browser->version ? ' '.$conf->browser->version : '').' ('.$_SERVER['HTTP_USER_AGENT'].')'); + $datas['layout'] = '
'.$langs->trans("Layout").': '.dol_string_nohtmltag($conf->browser->layout); + $datas['screen'] = '
'.$langs->trans("Screen").': '.dol_string_nohtmltag($_SESSION['dol_screenwidth'].' x '.$_SESSION['dol_screenheight']); + if ($conf->browser->layout == 'phone') { + $datas['phone'] = '
'.$langs->trans("Phone").': '.$langs->trans("Yes"); + } + if (!empty($_SESSION["disablemodules"])) { + $datas['disabledmodules'] = '
'.$langs->trans("DisabledModules").':
'.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.'>'; From 7eb0b712520f97e84a2c6ebb76ca0116d08ab79f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 31 Jan 2023 22:43:54 +0100 Subject: [PATCH 02/62] work on ajax tooltip --- htdocs/commande/class/commande.class.php | 8 ++++---- htdocs/core/ajax/ajaxtooltip.php | 4 ---- htdocs/core/class/commonobject.class.php | 4 ++-- htdocs/product/class/product.class.php | 2 +- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 4dcae469aaa..16f22c80c91 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3716,11 +3716,11 @@ class Commande extends CommonOrder /** * getTooltipContentArray - * @param array $parameters + * @param array $params params to construct tooltip data * @since v18 * @return array */ - public function getTooltipContentArray($parameters) + public function getTooltipContentArray($params) { global $conf, $langs, $user; @@ -3730,7 +3730,7 @@ class Commande extends CommonOrder return ['optimize' => $langs->trans("Order")]; } - if ($user->rights->commande->lire) { + if ($user->hasRight('commande', 'lire')) { $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("Order").''; if (isset($this->statut)) { $datas[] = ' '.$this->getLibStatut(5); @@ -3807,7 +3807,7 @@ class Commande extends CommonOrder $label = ''; - if ($user->rights->commande->lire) { + if ($user->hasRight('commande', 'lire')) { $label = img_picto('', $this->picto).' '.$langs->trans("Order").''; if (isset($this->statut)) { $label .= ' '.$this->getLibStatut(5); diff --git a/htdocs/core/ajax/ajaxtooltip.php b/htdocs/core/ajax/ajaxtooltip.php index 2342bcf35f1..569f2fc6ad7 100644 --- a/htdocs/core/ajax/ajaxtooltip.php +++ b/htdocs/core/ajax/ajaxtooltip.php @@ -106,10 +106,6 @@ if ($objecttype == 'facture' || $objecttype == 'invoice') { $classpath = 'adherents/class'; $module = 'adherent'; $myobject = 'adherent'; -} elseif ($objecttype == 'cabinetmed_cons') { - $classpath = 'cabinetmed/class'; - $module = 'cabinetmed'; - $myobject = 'cabinetmedcons'; } elseif ($objecttype == 'fichinter') { $langs->load('interventions'); $classpath = 'fichinter/class'; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 416e1ca737b..b209d7450f4 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -668,7 +668,7 @@ abstract class CommonObject * getTooltipContentArray * * @since v18 - * @param array $params + * @param array $params params to construct tooltip data * @return array */ public function getTooltipContentArray($params) @@ -679,7 +679,7 @@ abstract class CommonObject /** * getTooltipContent * - * @param array $params + * @param array $params params * @since v18 * @return string */ diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index e7160ef467a..ab9d33a0500 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5001,7 +5001,7 @@ class Product extends CommonObject /** * getTooltipContentArray - * @param array $params + * @param array $params params to construct tooltip data * @since v18 * @return array */ From 8d71b8101384b15d6563d2f388cb5fdb996a9d4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 1 Feb 2023 20:58:40 +0100 Subject: [PATCH 03/62] ajax tooltip on propal --- htdocs/comm/propal/class/propal.class.php | 62 +++++++++++++++++++++-- 1 file changed, 59 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index c4328328f18..dba4e0e84d6 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -3690,6 +3690,52 @@ class Propal extends CommonObject } } + /** + * getTooltipContentArray + * @param array $params params to construct tooltip data + * @since v18 + * @return array + */ + public function getTooltipContentArray($params) + { + global $conf, $langs, $user; + + $datas = []; + + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + return ['optimize' => $langs->trans("Proposal")]; + } + if ($user->hasRight('propal', 'lire')) { + $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("Proposal").''; + if (isset($this->statut)) { + $datas['status'] = ' '.$this->getLibStatut(5); + } + if (!empty($this->ref)) { + $datas['ref'] = '
'.$langs->trans('Ref').': '.$this->ref; + } + if (!empty($this->ref_client)) { + $datas['refcustomer'] = '
'.$langs->trans('RefCustomer').': '.$this->ref_client; + } + if (!empty($this->total_ht)) { + $datas['amountht'] = '
'.$langs->trans('AmountHT').': '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); + } + if (!empty($this->total_tva)) { + $datas['vat'] = '
'.$langs->trans('VAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); + } + if (!empty($this->total_ttc)) { + $datas['amountttc'] = '
'.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); + } + if (!empty($this->date)) { + $datas['date'] = '
'.$langs->trans('Date').': '.dol_print_date($this->date, 'day'); + } + if (!empty($this->delivery_date)) { + $datas['deliverydate'] = '
'.$langs->trans('DeliveryDate').': '.dol_print_date($this->delivery_date, 'dayhour'); + } + } + + return $datas; + } + /** * Return clicable link of object (with eventually picto) * @@ -3737,7 +3783,7 @@ class Propal extends CommonObject $label .= '
'.$langs->trans('Date').': '.dol_print_date($this->date, 'day'); } if (!empty($this->delivery_date)) { - $label .= '
'.$langs->trans('DeliveryDate').': '.dol_print_date($this->delivery_date, 'dayhour'); + $label .= '
'.$langs->trans('DeliveryDate').': '.dol_print_date($this->delivery_date, 'dayhour'); } if ($option == '') { @@ -3768,8 +3814,18 @@ class Propal extends CommonObject $label = $langs->trans("Proposal"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip"'; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + 'option' => $option, + ]; + $linkclose .= ' data-params='.json_encode($params).' id="propal-' . uniqid() . '" title="' . $langs->trans('Loading') . '"'; + $linkclose .= ' class="classforajaxtooltip"'; + } else { + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip"'; + } } $linkstart = ' Date: Wed, 1 Feb 2023 21:29:50 +0100 Subject: [PATCH 04/62] ajax tooltip on contact --- htdocs/contact/class/contact.class.php | 63 ++++++++++++++++++++++++-- htdocs/core/ajax/ajaxtooltip.php | 5 +- 2 files changed, 64 insertions(+), 4 deletions(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 52ea2b69c8d..9d585245f0f 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1404,6 +1404,52 @@ class Contact extends CommonObject } } + /** + * getTooltipContentArray + * @param array $params params to construct tooltip data + * @since v18 + * @return array + */ + public function getTooltipContentArray($params) + { + global $conf, $langs, $user; + + $datas = []; + + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + return ['optimize' => $langs->trans("ShowContact")]; + } + if (!empty($this->photo) && class_exists('Form')) { + $photo = '
'; + $photo .= Form::showphoto('contact', $this, 0, 40, 0, 'photoref', 'mini', 0); // Important, we must force height so image will have height tags and if image is inside a tooltip, the tooltip manager can calculate height and position correctly the tooltip. + $photo .= '
'; + $datas['photo'] = $photo; + } + + $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("Contact").' ' . $this->getLibStatut(4); + $datas['name'] = '
'.$langs->trans("Name").': '.$this->getFullName($langs); + // if ($this->civility_id) $datas['civility'] = '
' . $langs->trans("Civility") . ': '.$this->civility_id; // TODO Translate civilty_id code + if (!empty($this->poste)) { + $datas['job'] = '
'.$langs->trans("Poste").': '.$this->poste; + } + $datas['email'] = '
'.$langs->trans("EMail").': '.$this->email; + $phonelist = array(); + $country_code = empty($this->country_code) ? '': $this->country_code; + if ($this->phone_pro) { + $phonelist[] = dol_print_phone($this->phone_pro, $country_code, $this->id, 0, '', ' ', 'phone'); + } + if ($this->phone_mobile) { + $phonelist[] = dol_print_phone($this->phone_mobile, $country_code, $this->id, 0, '', ' ', 'mobile'); + } + if ($this->phone_perso) { + $phonelist[] = dol_print_phone($this->phone_perso, $country_code, $this->id, 0, '', ' ', 'phone'); + } + $datas['phonelist'] = '
'.$langs->trans("Phone").': '.implode(' ', $phonelist); + $datas['address'] = '
'.$langs->trans("Address").': '.dol_format_address($this, 1, ' ', $langs); + + return $datas; + } + /** * Return name of contact with link (and eventually picto) * Use $this->id, $this->lastname, $this->firstname, this->civility_id @@ -1421,7 +1467,8 @@ class Contact extends CommonObject { global $conf, $langs, $hookmanager; - $result = ''; $label = ''; + $result = ''; + $label = ''; if (!empty($this->photo) && class_exists('Form')) { $label .= '
'; $label .= Form::showphoto('contact', $this, 0, 40, 0, 'photoref', 'mini', 0); // Important, we must force height so image will have height tags and if image is inside a tooltip, the tooltip manager can calculate height and position correctly the tooltip. @@ -1472,8 +1519,18 @@ class Contact extends CommonObject $label = $langs->trans("ShowContact"); $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="contact-' . uniqid() . '" title="' . $langs->trans('Loading') . '"'; + $linkclose .= ' class="classforajaxtooltip'.($morecss ? ' '.$morecss : '').'"'; + } else { + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + } } $linkstart = ' Date: Wed, 1 Feb 2023 21:57:45 +0100 Subject: [PATCH 05/62] ajax tooltip on thirdparty --- htdocs/societe/class/societe.class.php | 148 ++++++++++++++++++++++++- 1 file changed, 146 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index fa6d77ad485..8cd49efe0b6 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2597,6 +2597,140 @@ class Societe 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(['companies, commercial']); + + $datas = []; + + $option = $params['option'] ?? ''; + $name = $this->name; + + if (!empty($this->name_alias) && empty($noaliasinname)) { + $name .= ' ('.$this->name_alias.')'; + } + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + return ['optimize' => $langs->trans("ShowCompany")]; + } + + $label = ''; + $label2 = ''; + + if (!empty($this->logo) && class_exists('Form')) { + $photo = '
'; + $photo .= Form::showphoto('societe', $this, 0, 40, 0, 'photoref', 'mini', 0); // Important, we must force height so image will have height tags and if image is inside a tooltip, the tooltip manager can calculate height and position correctly the tooltip. + $photo .= '
'; + $datas['photo'] = $photo; + } elseif (!empty($this->logo_squarred) && class_exists('Form')) { + /*$label.= '
'; + $label.= Form::showphoto('societe', $this, 0, 40, 0, 'photowithmargin', 'mini', 0); // Important, we must force height so image will have height tags and if image is inside a tooltip, the tooltip manager can calculate height and position correctly the tooltip. + $label.= '
';*/ + } + + $datas['divopen'] = '
'; + + if ($option == 'customer' || $option == 'compta' || $option == 'category') { + $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("Customer").''; + } elseif ($option == 'prospect' && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) { + $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("Prospect").''; + } elseif ($option == 'supplier' || $option == 'category_supplier') { + $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("Supplier").''; + } elseif ($option == 'agenda') { + $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("ThirdParty").''; + } elseif ($option == 'project') { + $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("ThirdParty").''; + } elseif ($option == 'margin') { + $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("ThirdParty").''; + } elseif ($option == 'contact') { + $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("ThirdParty").''; + } elseif ($option == 'ban') { + $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("ThirdParty").''; + } + + // By default + if (empty($datas['picto'] )) { + $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("ThirdParty").''; + } + if (isset($this->status)) { + $datas['status'] = ' '.$this->getLibStatut(5); + } + if (isset($this->client) && isset($this->fournisseur)) { + $datas['type'] = '   ' . $this->getTypeUrl(1); + } + + $datas['name'] = '
'.$langs->trans('Name').': '.dol_escape_htmltag($this->name); + if (!empty($this->name_alias)) { + $datas['namealias'] = ' ('.dol_escape_htmltag($this->name_alias).')'; + } + + if ($this->email) { + $datas['email'] = '
'.img_picto('', 'email', 'class="pictofixedwidth"').$this->email; + } + if (!empty($this->phone) || !empty($this->fax)) { + $phonelist = array(); + if ($this->phone) { + $phonelist[] = dol_print_phone($this->phone, $this->country_code, $this->id, 0, '', ' ', 'phone'); + } + if ($this->fax) { + $phonelist[] = dol_print_phone($this->fax, $this->country_code, $this->id, 0, '', ' ', 'fax'); + } + $datas['phonelist'] = '
'.implode(' ', $phonelist); + } + + if (!empty($this->address)) { + $datas['address'] = '
'.$langs->trans("Address").': '.dol_format_address($this, 1, ' ', $langs); // Address + country + } elseif (!empty($this->country_code)) { + $datas['address'] = '
'.$langs->trans('Country').': '.$this->country_code; + } + if (!empty($this->tva_intra) || (!empty($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP) && strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'vatnumber') !== false)) { + $datas['vatintra'] = '
'.$langs->trans('VATIntra').': '.dol_escape_htmltag($this->tva_intra); + } + + if (!empty($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP)) { + if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid1') !== false && $langs->trans('ProfId1'.$this->country_code) != '-') { + $datas['profid1'] = '
'.$langs->trans('ProfId1'.$this->country_code).': '.$this->idprof1; + } + if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid2') !== false && $langs->trans('ProfId2'.$this->country_code) != '-') { + $datas['profid2'] = '
'.$langs->trans('ProfId2'.$this->country_code).': '.$this->idprof2; + } + if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid3') !== false && $langs->trans('ProfId3'.$this->country_code) != '-') { + $datas['profid3'] = '
'.$langs->trans('ProfId3'.$this->country_code).': '.$this->idprof3; + } + if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid4') !== false && $langs->trans('ProfId4'.$this->country_code) != '-') { + $datas['profid4'] = '
'.$langs->trans('ProfId4'.$this->country_code).': '.$this->idprof4; + } + if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid5') !== false && $langs->trans('ProfId5'.$this->country_code) != '-') { + $datas['profid5'] = '
'.$langs->trans('ProfId5'.$this->country_code).': '.$this->idprof5; + } + if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid6') !== false && $langs->trans('ProfId6'.$this->country_code) != '-') { + $datas['profid6'] = '
'.$langs->trans('ProfId6'.$this->country_code).': '.$this->idprof6; + } + } + if (!empty($this->code_client) && ($this->client == 1 || $this->client == 3)) { + $datas['customercode'] = '
'.$langs->trans('CustomerCode').': '.$this->code_client; + } + if (!empty($this->code_fournisseur) && $this->fournisseur) { + $datas['suppliercode'] = '
'.$langs->trans('SupplierCode').': '.$this->code_fournisseur; + } + if (isModEnabled('accounting') && ($this->client == 1 || $this->client == 3)) { + $datas['accountancycustomercode'] = '
'.$langs->trans('CustomerAccountancyCode').': '.($this->code_compta ? $this->code_compta : $this->code_compta_client); + } + if (isModEnabled('accounting') && $this->fournisseur) { + $datas['accountancysuppliercode'] = '
'.$langs->trans('SupplierAccountancyCode').': '.$this->code_compta_fournisseur; + } + + $datas['divclose'] = '
'; + + return $datas; + } /** * Return a link on thirdparty (with picto) @@ -2787,8 +2921,18 @@ class Societe extends CommonObject $label = $langs->trans("ShowCompany"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip refurl valignmiddle"'; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + 'option' => $option, + ]; + $linkclose .= ' data-params='.json_encode($params).' id="societe-' . uniqid() . '" title="' . $langs->trans('Loading') . '"'; + $linkclose .= ' class="classforajaxtooltip refurl valignmiddle"'; + } else { + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip refurl valignmiddle"'; + } $target_value = array('_self', '_blank', '_parent', '_top'); if (in_array($target, $target_value)) { $linkclose .= ' target="'.dol_escape_htmltag($target).'"'; From 29d1197cbb73c5f98f06777aeb0fc4e40fcb2f1f Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 1 Feb 2023 21:03:52 +0000 Subject: [PATCH 06/62] Fixing style errors. --- htdocs/societe/class/societe.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 8cd49efe0b6..9481fb52e3f 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2656,7 +2656,7 @@ class Societe extends CommonObject } // By default - if (empty($datas['picto'] )) { + if (empty($datas['picto'])) { $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("ThirdParty").''; } if (isset($this->status)) { From 2df357c7c2e3987380e75a88a8e381803b411a67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 1 Feb 2023 22:28:29 +0100 Subject: [PATCH 07/62] do not use cache for thirdparty in order list --- htdocs/commande/list.php | 6 +++++- htdocs/societe/class/societe.class.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 119d88e7cf4..9c06f86e8c3 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -2077,7 +2077,11 @@ if ($resql) { // Third party if (!empty($arrayfields['s.nom']['checked'])) { print ''; - print $getNomUrl_cache[$obj->socid]; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + print $companystatic->getNomUrl(1, 'customer', 100, 0, 1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); + } else { + print $getNomUrl_cache[$obj->socid]; + } // If module invoices enabled and user with invoice creation permissions if (isModEnabled('facture') && !empty($conf->global->ORDER_BILLING_ALL_CUSTOMER)) { diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 9481fb52e3f..13da1bd6c03 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2927,7 +2927,7 @@ class Societe extends CommonObject 'objecttype' => $this->element, 'option' => $option, ]; - $linkclose .= ' data-params='.json_encode($params).' id="societe-' . uniqid() . '" title="' . $langs->trans('Loading') . '"'; + $linkclose .= ' data-params='.json_encode($params).' id="' . uniqid('societe-') . '" title="' . $langs->trans('Loading') . '"'; $linkclose .= ' class="classforajaxtooltip refurl valignmiddle"'; } else { $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; 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 08/62] 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'); From 1e305c4f860a3d0ae262b40fff0a4657182bfd0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 2 Feb 2023 20:53:26 +0100 Subject: [PATCH 09/62] add ajax tooltip on member --- htdocs/adherents/class/adherent.class.php | 61 ++++++++++++++++++++++- 1 file changed, 59 insertions(+), 2 deletions(-) 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.'>'; From a367fd24b7bb9df02b37ae469d522e1e7a7372e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 2 Feb 2023 21:16:09 +0100 Subject: [PATCH 10/62] add ajax tooltip on account --- htdocs/compta/bank/class/account.class.php | 49 ++++++++++++++++++++-- htdocs/core/ajax/ajaxtooltip.php | 7 +++- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index e144677832f..b72767fdcc4 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -9,7 +9,7 @@ * Copyright (C) 2015-2017 Alexandre Spangaro * Copyright (C) 2016 Ferran Marcet * Copyright (C) 2019 JC Prieto - * Copyright (C) 2022 Frédéric France + * Copyright (C) 2022-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 @@ -1367,6 +1367,40 @@ class Account extends CommonObject return $nb; } + /** + * getTooltipContentArray + * @param array $params params to construct tooltip data + * @since v18 + * @return array + */ + public function getTooltipContentArray($params) + { + global $langs; + include_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; + + $datas = []; + + $pictos = img_picto('', $this->picto).' '.$langs->trans("BankAccount").''; + if (isset($this->status)) { + $pictos .= ' '.$this->getLibStatut(5); + } + $datas['picto'] = $pictos; + $datas['label'] = '
'.$langs->trans('Label').': '.$this->label; + $datas['accountnumber'] = '
'.$langs->trans('AccountNumber').': '.$this->number; + $datas['iban'] = '
'.$langs->trans('IBAN').': '.getIbanHumanReadable($this); + $datas['bic'] = '
'.$langs->trans('BIC').': '.$this->bic; + $datas['accountcurrency'] = '
'.$langs->trans("AccountCurrency").': '.$this->currency_code; + + if (isModEnabled('accounting')) { + include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; + $langs->load("accountancy"); + $datas['accountaccounting'] = '
'.$langs->trans('AccountAccounting').': '.length_accountg($this->account_number); + $datas['accountancyjournal'] = '
'.$langs->trans('AccountancyJournal').': '.$this->accountancy_journal; + } + + return $datas; + } + /** * Return clicable name (with picto eventually) * @@ -1403,8 +1437,17 @@ class Account extends CommonObject $label .= '
'.$langs->trans('AccountAccounting').': '.length_accountg($this->account_number); $label .= '
'.$langs->trans('AccountancyJournal').': '.$this->accountancy_journal; } - - $linkclose = '" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; + 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"'; + } else { + $linkclose = '" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; + } $url = DOL_URL_ROOT.'/compta/bank/card.php?id='.$this->id; if ($mode == 'transactions') { diff --git a/htdocs/core/ajax/ajaxtooltip.php b/htdocs/core/ajax/ajaxtooltip.php index e52d3cfd3d9..2656a788631 100644 --- a/htdocs/core/ajax/ajaxtooltip.php +++ b/htdocs/core/ajax/ajaxtooltip.php @@ -75,6 +75,11 @@ if ($objecttype == 'facture' || $objecttype == 'invoice') { $classpath = 'compta/facture/class'; $module = 'facture'; $myobject = 'facture'; +} elseif ($objecttype == 'bank_account') { + $langs->loadLangs(['banks', 'compta']); + $classpath = 'compta/bank/class'; + $module = 'banque'; + $myobject = 'account'; } elseif ($objecttype == 'commande' || $objecttype == 'order') { $langs->load('orders'); $classpath = 'commande/class'; @@ -180,7 +185,7 @@ if ($objecttype == 'invoice_supplier') { } elseif ($objecttype == 'contact') { $module = 'societe'; } -// print "objecttype=".$objecttype." module=".$module." subelement=".$subelement." classfile=".$classfile." classname=".$classname." classpath=".$classpath."\n"; +// print "objecttype=".$objecttype." module=".$module." subelement=".$subelement." classfile=".$classfile." classname=".$classname." classpath=".$classpath."
"; if (isModEnabled($module)) { $res = dol_include_once('/'.$classpath.'/'.$classfile.'.class.php'); From a5b1f8c20e2095eebca96952ce43b771f0d66336 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 2 Feb 2023 21:29:23 +0100 Subject: [PATCH 11/62] add ajax tooltip on bom --- htdocs/bom/class/bom.class.php | 53 ++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index d7982a44069..2bbd1759453 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -16,7 +16,7 @@ */ /** - * \file bom/class/bom.class.php + * \file htdocs/bom/class/bom.class.php * \ingroup bom * \brief This file is a CRUD class file for BOM (Create/Read/Update/Delete) */ @@ -1064,6 +1064,43 @@ class BOM extends CommonObject return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'BOM_REOPEN'); } + /** + * getTooltipContentArray + * @param array $params params to construct tooltip data + * @since v18 + * @return array + */ + public function getTooltipContentArray($params) + { + global $conf, $langs, $user; + + $langs->load('mrp'); + + $datas = []; + + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + return ['optimize' => $langs->trans("ShowBillOfMaterials")]; + } + $picto = img_picto('', $this->picto).' '.$langs->trans("BillOfMaterials").''; + if (isset($this->status)) { + $picto .= ' '.$this->getLibStatut(5); + } + $datas['picto'] = $picto; + $datas['ref'] = '
'.$langs->trans('Ref').': '.$this->ref; + if (isset($this->label)) { + $datas['label'] = '
'.$langs->trans('Label').': '.$this->label; + } + if (!empty($this->fk_product) && $this->fk_product > 0) { + include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + $product = new Product($this->db); + $resultFetch = $product->fetch($this->fk_product); + if ($resultFetch > 0) { + $datas['product'] = "
".$langs->trans("Product").': '.$product->ref.' - '.$product->label; + } + } + + return $datas; + } /** * Return a link to the object card (with optionaly the picto) @@ -1123,8 +1160,18 @@ class BOM extends CommonObject $label = $langs->trans("ShowBillOfMaterials"); $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('bom') . '" title="' . $langs->trans('Loading') . '"'; + $linkclose .= ' class="classforajaxtooltip'.($morecss ? ' '.$morecss : '').'"'; + } else { + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + } } else { $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); } From 9f365ac568a447387e690ef175c25be55ddf7f31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 2 Feb 2023 21:35:40 +0100 Subject: [PATCH 12/62] add ajax tooltip on modulebuilder --- .../template/class/myobject.class.php | 41 +++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index c988da72b3f..1ae0991b5f2 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2017 Laurent Destailleur + * Copyright (C) 2023 Frédéric France * Copyright (C) ---Put here your own copyright and developer email--- * * This program is free software; you can redistribute it and/or modify @@ -750,6 +751,30 @@ class MyObject extends CommonObject return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'MYOBJECT_REOPEN'); } + /** + * getTooltipContentArray + * @param array $params params to construct tooltip data + * @since v18 + * @return array + */ + public function getTooltipContentArray($params) + { + global $conf, $langs, $user; + + $datas = []; + + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + return ['optimize' => $langs->trans("ShowMyObject")]; + } + $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("MyObject").''; + if (isset($this->status)) { + $datas['picto'] .= ' '.$this->getLibStatut(5); + } + $datas['ref'] .= '
'.$langs->trans('Ref').': '.$this->ref; + + return $datas; + } + /** * Return a link to the object card (with optionaly the picto) * @@ -796,8 +821,18 @@ class MyObject extends CommonObject $label = $langs->trans("ShowMyObject"); $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="propal-' . uniqid() . '" title="' . $langs->trans('Loading') . '"'; + $linkclose .= ' class="classforajaxtooltip'.($morecss ? ' '.$morecss : '').'"'; + } else { + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + } } else { $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); } From ba2f87d307c4cb52091acc5e64a5d5ce93f22517 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 2 Feb 2023 21:57:34 +0100 Subject: [PATCH 13/62] add ajax tooltip on contract --- htdocs/bom/class/bom.class.php | 2 +- htdocs/contrat/class/contrat.class.php | 90 +++++++++++++++++++++++--- 2 files changed, 83 insertions(+), 9 deletions(-) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 2bbd1759453..d96274ede59 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1074,7 +1074,7 @@ class BOM extends CommonObject { global $conf, $langs, $user; - $langs->load('mrp'); + $langs->loadLangs(['product', 'mrp']); $datas = []; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index ad2cbcea84b..66b7bd083bf 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -9,7 +9,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2015 Marcos García * Copyright (C) 2018 Nicolas ZABOURI - * Copyright (C) 2018-2021 Frédéric France + * Copyright (C) 2018-2023 Frédéric France * Copyright (C) 2015-2018 Ferran Marcet * * This program is free software; you can redistribute it and/or modify @@ -185,6 +185,7 @@ class Contrat extends CommonObject public $nbofserviceswait; public $nbofservicesopened; public $nbofservicesexpired; + public $nbofservicesclosed; //public $lower_planned_end_date; //public $higher_planner_end_date; @@ -1981,6 +1982,42 @@ class Contrat extends CommonObject } } + /** + * getTooltipContentArray + * @param array $params params to construct tooltip data + * @since v18 + * @return array + */ + public function getTooltipContentArray($params) + { + global $conf, $langs, $user; + + $datas = []; + + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + return ['optimize' => $langs->trans("ShowContract")]; + } + if ($user->hasRight('contrat', 'lire')) { + $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("Contract").''; + /* Status of a contract is status of all services, so disabled + if (isset($this->statut)) { + $label .= ' '.$this->getLibStatut(5); + }*/ + $datas['ref'] = '
'.$langs->trans('Ref').': '.($this->ref ? $this->ref : $this->id); + $datas['refcustomer'] = '
'.$langs->trans('RefCustomer').': '. $this->ref_customer; + $datas['refsupplier'] = '
'.$langs->trans('RefSupplier').': '.$this->ref_supplier; + if (!empty($this->total_ht)) { + $datas['amountht'] = '
'.$langs->trans('AmountHT').': '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); + } + if (!empty($this->total_tva)) { + $datas['vatamount'] = '
'.$langs->trans('VAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); + } + if (!empty($this->total_ttc)) { + $datas['amounttc'] = '
'.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); + } + } + return $datas; + } /** * Return clicable name (with picto eventually) @@ -2013,7 +2050,7 @@ class Contrat extends CommonObject $label = ''; - if ($user->rights->contrat->lire) { + if ($user->hasRight('contrat', 'lire')) { $label = img_picto('', $this->picto).' '.$langs->trans("Contract").''; /* Status of a contract is status of all services, so disabled if (isset($this->statut)) { @@ -2037,11 +2074,20 @@ class Contrat extends CommonObject $linkclose = ''; if (empty($notooltip) && $user->rights->contrat->lire) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label = $langs->trans("ShowOrder"); + $label = $langs->trans("ShowContract"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip"'; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + ]; + $linkclose .= '" data-params='.json_encode($params).' id="' . uniqid('contract') . '" title="' . $langs->trans('Loading') . '"'; + $linkclose .= ' class="classforajaxtooltip"'; + } else { + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip"'; + } } $linkstart = 'trans("ShowContractOfService").': '.$this->label; + if (empty($datas['label'])) { + $datas['label'] = $this->description; + } + + return $datas; + } + + /** + * Return clicable name (with picto eventually) for ContratLigne * * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @param int $maxlength Max length @@ -3087,8 +3152,17 @@ class ContratLigne extends CommonObjectLine if (empty($label)) { $label = $this->description; } - - $link = ''; + $link = ''; + } $linkend = ''; $picto = 'service'; 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 14/62] 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'; From 41dd574b1623974225e9f070d65cd0f0045f5602 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 2 Feb 2023 22:59:54 +0100 Subject: [PATCH 15/62] clean js --- htdocs/adherents/class/adherent.class.php | 2 +- htdocs/adherents/class/adherent_type.class.php | 2 +- htdocs/bom/class/bom.class.php | 2 +- htdocs/categories/class/categorie.class.php | 8 ++------ htdocs/comm/propal/class/propal.class.php | 2 +- htdocs/commande/class/commande.class.php | 2 +- htdocs/compta/bank/class/account.class.php | 2 +- htdocs/contact/class/contact.class.php | 2 +- htdocs/contrat/class/contrat.class.php | 4 ++-- htdocs/core/js/lib_foot.js.php | 4 ++-- htdocs/modulebuilder/template/class/myobject.class.php | 2 +- htdocs/product/class/product.class.php | 2 +- htdocs/societe/class/societe.class.php | 2 +- htdocs/user/class/user.class.php | 2 +- 14 files changed, 17 insertions(+), 21 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index dd7fe7f33b5..4dffa624719 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2377,7 +2377,7 @@ class Adherent extends CommonObject 'objecttype' => $this->element, 'option' => $option, ]; - $linkclose .= ' data-params='.json_encode($params).' id="' . uniqid('member') . '" title="' . $langs->trans('Loading') . '"'; + $linkclose .= ' data-params='.json_encode($params).' title="' . $langs->trans('Loading') . '"'; $linkclose .= ' class="classforajaxtooltip'.($morecss ? ' '.$morecss : '').'"'; } else { $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 639f417bb94..5543a6e8e76 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -752,7 +752,7 @@ class AdherentType extends CommonObject 'objecttype' => $this->element, 'option' => $option, ]; - $linkstart = ''; + $linkstart = ''; } else { $linkstart = ''; } diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index d96274ede59..39fcb1650f0 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1166,7 +1166,7 @@ class BOM extends CommonObject 'objecttype' => $this->element, 'option' => $option, ]; - $linkclose .= ' data-params='.json_encode($params).' id="' . uniqid('bom') . '" title="' . $langs->trans('Loading') . '"'; + $linkclose .= ' data-params='.json_encode($params).' title="' . $langs->trans('Loading') . '"'; $linkclose .= ' class="classforajaxtooltip'.($morecss ? ' '.$morecss : '').'"'; } else { $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 5dcad42d936..618a31df34f 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1646,14 +1646,10 @@ class Categorie extends CommonObject 'objecttype' => $this->element, 'option' => $option, ]; - $link2 = $link; - $link .= '" data-params='.json_encode($params).' id="' . uniqid('category') . '" title="' . $langs->trans('Loading') . '"'; + $link .= '" data-params='.json_encode($params).' title="' . $langs->trans('Loading') . '"'; $link .= ' class="classforajaxtooltip '.$forced_color.'">'; - $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 = ''; @@ -1667,7 +1663,7 @@ class Categorie extends CommonObject $result .= ' '; } if ($withpicto != 2) { - $result .= $link2.dol_trunc(($this->ref ? $this->ref : $this->label), $maxlength).$linkend; + $result .= $link.dol_trunc(($this->ref ? $this->ref : $this->label), $maxlength).$linkend; } global $action; $hookmanager->initHooks(array($this->element . 'dao')); diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index dba4e0e84d6..0876b3ea6d6 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -3820,7 +3820,7 @@ class Propal extends CommonObject 'objecttype' => $this->element, 'option' => $option, ]; - $linkclose .= ' data-params='.json_encode($params).' id="propal-' . uniqid() . '" title="' . $langs->trans('Loading') . '"'; + $linkclose .= ' data-params='.json_encode($params).' title="' . $langs->trans('Loading') . '"'; $linkclose .= ' class="classforajaxtooltip"'; } else { $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 16f22c80c91..f14989ab3ea 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3843,7 +3843,7 @@ class Commande extends CommonOrder 'objecttype' => $this->element, 'option' => $option, ]; - $linkclose .= ' data-params='.json_encode($params).' id="order-' . uniqid() . '" title="' . $langs->trans('Loading') . '"'; + $linkclose .= ' data-params='.json_encode($params).' title="' . $langs->trans('Loading') . '"'; $linkclose .= ' class="classforajaxtooltip"'; } else { $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index b72767fdcc4..ed44d13dfae 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1443,7 +1443,7 @@ class Account extends CommonObject 'objecttype' => $this->element, 'option' => $option, ]; - $linkclose = '" data-params='.json_encode($params).' id="' . uniqid('member') . '" title="' . $langs->trans('Loading') . '"'; + $linkclose = '" data-params='.json_encode($params).' title="' . $langs->trans('Loading') . '"'; $linkclose .= ' class="classforajaxtooltip"'; } else { $linkclose = '" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 9d585245f0f..c6bf780be8b 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1525,7 +1525,7 @@ class Contact extends CommonObject 'objecttype' => $this->element, 'option' => $option, ]; - $linkclose .= ' data-params='.json_encode($params).' id="contact-' . uniqid() . '" title="' . $langs->trans('Loading') . '"'; + $linkclose .= ' data-params='.json_encode($params).' title="' . $langs->trans('Loading') . '"'; $linkclose .= ' class="classforajaxtooltip'.($morecss ? ' '.$morecss : '').'"'; } else { $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 66b7bd083bf..b3da9b1ad49 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2082,7 +2082,7 @@ class Contrat extends CommonObject 'id' => $this->id, 'objecttype' => $this->element, ]; - $linkclose .= '" data-params='.json_encode($params).' id="' . uniqid('contract') . '" title="' . $langs->trans('Loading') . '"'; + $linkclose .= '" data-params='.json_encode($params).' title="' . $langs->trans('Loading') . '"'; $linkclose .= ' class="classforajaxtooltip"'; } else { $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; @@ -3158,7 +3158,7 @@ class ContratLigne extends CommonObjectLine 'id' => $this->fk_contrat, 'objecttype' => $this->element, ]; - $link .= '" data-params='.json_encode($params).' id="' . uniqid('contract') . '" title="' . $langs->trans('Loading') . '"'; + $link .= '" data-params='.json_encode($params).' title="' . $langs->trans('Loading') . '"'; $link .= ' class="classforajaxtooltip"'; } else { $link = '" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; diff --git a/htdocs/core/js/lib_foot.js.php b/htdocs/core/js/lib_foot.js.php index 7ec398f3368..8efda4e3812 100644 --- a/htdocs/core/js/lib_foot.js.php +++ b/htdocs/core/js/lib_foot.js.php @@ -84,7 +84,7 @@ if (empty($conf->dol_no_mouse_hover)) { hide: { delay: 250, duration: 20 }, tooltipClass: "mytooltip", open: function (event, ui) { - var id = $(this).attr("id"); + var elem = $(this); var params = $(this).attr("data-params"); $.ajax({ url:"' . dol_buildpath('/core/ajax/ajaxtooltip.php', 1) . '", @@ -92,7 +92,7 @@ if (empty($conf->dol_no_mouse_hover)) { data: JSON.parse(params), success: function(response){ // Setting content option - $("#"+id).tooltip("option","content",response); + elem.tooltip("option","content",response); } }); console.log(event); diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 1ae0991b5f2..3fd978e2069 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -827,7 +827,7 @@ class MyObject extends CommonObject 'objecttype' => $this->element, 'option' => $option, ]; - $linkclose .= ' data-params='.json_encode($params).' id="propal-' . uniqid() . '" title="' . $langs->trans('Loading') . '"'; + $linkclose .= ' data-params='.json_encode($params).' title="' . $langs->trans('Loading') . '"'; $linkclose .= ' class="classforajaxtooltip'.($morecss ? ' '.$morecss : '').'"'; } else { $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index ab9d33a0500..e585d35ebae 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5231,7 +5231,7 @@ class Product extends CommonObject 'objecttype' => $this->element, 'option' => $option, ]; - $linkclose .= ' data-params='.json_encode($params).' id="product-' . uniqid() . '" title="' . $langs->trans('Loading') . '"'; + $linkclose .= ' data-params='.json_encode($params).' title="' . $langs->trans('Loading') . '"'; $linkclose .= ' class="nowraponall classforajaxtooltip'.($morecss ? ' '.$morecss : '').'"'; } else { $linkclose .= ' title="'.dol_escape_htmltag($label, 1, 1).'"'; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 13da1bd6c03..269bae466bd 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2927,7 +2927,7 @@ class Societe extends CommonObject 'objecttype' => $this->element, 'option' => $option, ]; - $linkclose .= ' data-params='.json_encode($params).' id="' . uniqid('societe-') . '" title="' . $langs->trans('Loading') . '"'; + $linkclose .= ' data-params='.json_encode($params).' title="' . $langs->trans('Loading') . '"'; $linkclose .= ' class="classforajaxtooltip refurl valignmiddle"'; } else { $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 0a963da1f5d..1516769f387 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2977,7 +2977,7 @@ class User extends CommonObject 'infologin' => $infologin, 'option' => $option, ]; - $linkclose .= ' data-params='.json_encode($params).' id="user-' . uniqid() . '" title="' . $langs->trans('Loading') . '"'; + $linkclose .= ' data-params='.json_encode($params).' title="' . $langs->trans('Loading') . '"'; $linkclose .= ' class="classforajaxtooltip'.($morecss ? ' '.$morecss : '').'"'; } else { $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; From 22fb5a4e6a8d1930cf8ebc2034e29adb2e026291 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 2 Feb 2023 23:12:54 +0100 Subject: [PATCH 16/62] add ajax tooltip on delivery --- htdocs/delivery/class/delivery.class.php | 30 ++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php index 3b560ce1026..717696ac430 100644 --- a/htdocs/delivery/class/delivery.class.php +++ b/htdocs/delivery/class/delivery.class.php @@ -720,6 +720,24 @@ class Delivery extends CommonObject } } + /** + * getTooltipContentArray + * @param array $params params to construct tooltip data + * @since v18 + * @return array + */ + public function getTooltipContentArray($params) + { + global $conf, $langs; + + $datas = []; + + $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("ShowReceiving").':
'; + $datas['picto'] .= ''.$langs->trans("Status").': '.$this->ref; + + return $datas; + } + /** * Return clicable name (with picto eventually) * @@ -750,8 +768,16 @@ class Delivery extends CommonObject } //} - - $linkstart = ''; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + ]; + $linkstart = ''; + } $linkend = ''; if ($withpicto) { From a4a541a146f52f0b1daaafddc4c8a03f04bae897 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 2 Feb 2023 23:19:55 +0100 Subject: [PATCH 17/62] add ajax tooltip on delivery --- htdocs/core/ajax/ajaxtooltip.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/ajax/ajaxtooltip.php b/htdocs/core/ajax/ajaxtooltip.php index ae4f17246d1..93244c89050 100644 --- a/htdocs/core/ajax/ajaxtooltip.php +++ b/htdocs/core/ajax/ajaxtooltip.php @@ -75,7 +75,7 @@ if ($objecttype == 'facture' || $objecttype == 'invoice') { $classpath = 'compta/facture/class'; $module = 'facture'; $myobject = 'facture'; -} elseif ($objecttype == 'bank_accoun') { +} elseif ($objecttype == 'bank_account') { $langs->loadLangs(['banks', 'compta']); $classpath = 'compta/bank/class'; $module = 'banque'; @@ -205,7 +205,6 @@ if (isModEnabled($module)) { } unset($object); } else { - print "Class with classname ".$classname." is unknown even after the include"; dol_syslog("Class with classname ".$classname." is unknown even after the include", LOG_ERR); } } From a32a0cc25a3164726a83f32b6edd40e5ab43972e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 2 Feb 2023 23:28:09 +0100 Subject: [PATCH 18/62] add ajax tooltip on warehouse --- htdocs/product/stock/class/entrepot.class.php | 40 ++++++++++++++++++- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 3ce244a4bb1..080abfa6605 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -689,6 +689,32 @@ class Entrepot extends CommonObject } + /** + * getTooltipContentArray + * @param array $params params to construct tooltip data + * @since v18 + * @return array + */ + public function getTooltipContentArray($params) + { + global $conf, $langs, $user; + $langs->load('stocks'); + $datas = []; + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + return ['optimize' => $langs->trans("Warehouse")]; + } + $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("Warehouse").''; + if (isset($this->statut)) { + $datas['picto'] .= ' '.$this->getLibStatut(5); + } + $datas['ref'] .= '
'.$langs->trans('Ref').': '.(empty($this->ref) ? $this->label : $this->ref); + if (!empty($this->lieu)) { + $datas['locationsummary'] .= '
'.$langs->trans('LocationSummary').': '.$this->lieu; + } + + return $datas; + } + /** * Return clickable name (possibility with the pictogram) * @@ -743,8 +769,18 @@ class Entrepot extends CommonObject $label = $langs->trans("Warehouse"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip"'; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + 'option' => $option, + ]; + $linkclose .= '" data-params='.json_encode($params).' title="' . $langs->trans('Loading') . '"'; + $linkclose .= ' class="classforajaxtooltip"'; + } else { + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip"'; + } } $linkstart = ' Date: Thu, 2 Feb 2023 23:47:01 +0100 Subject: [PATCH 19/62] add ajax tooltip on actioncomm --- htdocs/comm/action/class/actioncomm.class.php | 83 ++++++++++++++++++- htdocs/core/ajax/ajaxtooltip.php | 5 ++ htdocs/product/stock/class/entrepot.class.php | 1 - 3 files changed, 85 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index af98356ab18..23a6b5a67c5 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -5,7 +5,7 @@ * Copyright (C) 2011-2017 Juanjo Menent * Copyright (C) 2015 Marcos García * Copyright (C) 2018 Nicolas ZABOURI - * Copyright (C) 2018-2020 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 @@ -1568,6 +1568,73 @@ class ActionComm extends CommonObject return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode); } + /** + * getTooltipContentArray + * @param array $params params to construct tooltip data + * @since v18 + * @return array + */ + public function getTooltipContentArray($params) + { + global $conf, $langs, $user; + $langs->load('agenda'); + $datas = []; + + // Set label of type + $labeltype = ''; + if ($this->type_code) { + $labeltype = ($langs->transnoentities("Action".$this->type_code) != "Action".$this->type_code) ? $langs->transnoentities("Action".$this->type_code) : $this->type_label; + } + if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) { + if ($this->type_code != 'AC_OTH_AUTO') { + $labeltype = $langs->trans('ActionAC_MANUAL'); + } + } + + $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans('Action').''; + if (!empty($this->ref)) { + $datas['ref'] = '
'.$langs->trans('Ref').': '.dol_escape_htmltag($this->ref); + } + if (!empty($this->label)) { + $datas['title'] = '
'.$langs->trans('Title').': '.dol_escape_htmltag($this->label); + } + if (!empty($labeltype)) { + $datas['labeltype'] = '
'.$langs->trans('Type').': '.dol_escape_htmltag($labeltype); + } + if (!empty($this->location)) { + $datas['location'] = '
'.$langs->trans('Location').': '.dol_escape_htmltag($this->location); + } + if (isset($this->transparency)) { + $datas['transparency'] = '
'.$langs->trans('Busy').': '.yn($this->transparency); + } + if (!empty($this->email_msgid)) { + $langs->load("mails"); + $datas['space'] = '
'; + // $datas['email'] = '
'.img_picto('', 'email').' '.$langs->trans("Email").''; + $datas['mailtopic'] = '
'.$langs->trans('MailTopic').': '.dol_escape_htmltag($this->email_subject); + $datas['mailfrom'] = '
'.$langs->trans('MailFrom').': '.str_replace(array('<', '>'), array('&lt', '&gt'), $this->email_from); + $datas['mailto'] = '
'.$langs->trans('MailTo').': '.str_replace(array('<', '>'), array('&lt', '&gt'), $this->email_to); + if (!empty($this->email_tocc)) { + $datas['mailcc'] = '
'.$langs->trans('MailCC').': '.str_replace(array('<', '>'), array('&lt', '&gt'), $this->email_tocc); + } + /* Disabled because bcc must remain by defintion not visible + if (!empty($this->email_tobcc)) { + $datas['mailccc'] = '
'.$langs->trans('MailCCC').': '.$this->email_tobcc; + } */ + } + if (!empty($this->note_private)) { + $datas['description'] = '
'.$langs->trans('Description').':
'; + // Try to limit length of content + $texttoshow = dolGetFirstLineOfText($this->note_private, 10); + // Restrict height of content into the tooltip + $datas['note'] = '
'; + $datas['note'] .= (dol_textishtml($texttoshow) ? str_replace(array("\r", "\n"), "", $texttoshow) : str_replace(array("\r", "\n"), '
', $texttoshow)); + $datas['note'] .= '
'; + } + + return $datas; + } + /** * Return URL of event * Use $this->id, $this->type_code, $this->label and $this->type_label @@ -1668,8 +1735,18 @@ class ActionComm extends CommonObject $label = $langs->trans("ShowAction"); $linkclose .= ' alt="'.dol_escape_htmltag($tooltip, 1).'"'; } - $linkclose .= ' title="'.dol_escape_htmltag($tooltip, 1, 0, '', 1).'"'; - $linkclose .= ' class="'.$classname.' classfortooltip"'; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + 'option' => $option, + ]; + $linkclose .= '" data-params='.json_encode($params).' title="' . $langs->trans('Loading') . '"'; + $linkclose .= ' class="'.$classname.' classforajaxtooltip"'; + } else { + $linkclose .= ' title="'.dol_escape_htmltag($tooltip, 1, 0, '', 1).'"'; + $linkclose .= ' class="'.$classname.' classfortooltip"'; + } } else { $linkclose .= ' class="'.$classname.'"'; } diff --git a/htdocs/core/ajax/ajaxtooltip.php b/htdocs/core/ajax/ajaxtooltip.php index 93244c89050..84dd613d1b5 100644 --- a/htdocs/core/ajax/ajaxtooltip.php +++ b/htdocs/core/ajax/ajaxtooltip.php @@ -93,6 +93,11 @@ if ($objecttype == 'facture' || $objecttype == 'invoice') { } elseif ($objecttype == 'propal') { $langs->load('propal'); $classpath = 'comm/propal/class'; +} elseif ($objecttype == 'action') { + $langs->load('agenda'); + $classpath = 'comm/action/class'; + $module = 'agenda'; + $myobject = 'actioncomm'; } elseif ($objecttype == 'supplier_proposal') { $langs->load('supplier_proposal'); $classpath = 'supplier_proposal/class'; diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 080abfa6605..78e2ba0a173 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -688,7 +688,6 @@ class Entrepot extends CommonObject return dolGetStatus($label, $labelshort, '', $statusType, $mode); } - /** * getTooltipContentArray * @param array $params params to construct tooltip data From 140a3b462d8348db9be5884bfc1c2aa8e1fad158 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 3 Feb 2023 09:29:02 +0100 Subject: [PATCH 20/62] add ajax tooltip on usergroup --- htdocs/core/ajax/ajaxtooltip.php | 4 +++ htdocs/user/card.php | 8 ++--- htdocs/user/class/usergroup.class.php | 44 +++++++++++++++++++++++++-- htdocs/user/passwordforgotten.php | 2 +- test/phpunit/AllTests.php | 2 +- 5 files changed, 51 insertions(+), 9 deletions(-) diff --git a/htdocs/core/ajax/ajaxtooltip.php b/htdocs/core/ajax/ajaxtooltip.php index 84dd613d1b5..d5461b0dc1b 100644 --- a/htdocs/core/ajax/ajaxtooltip.php +++ b/htdocs/core/ajax/ajaxtooltip.php @@ -151,6 +151,10 @@ if ($objecttype == 'facture' || $objecttype == 'invoice') { $classpath = 'product/stock/class'; $module = 'stock'; $myobject = 'productlot'; +} elseif ($objecttype == 'usergroup') { + $classpath = 'user/class'; + $module = 'user'; + $myobject = 'usergroup'; } // Generic case for $classfile and $classname diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 964f4b9a67f..f7ea29d6720 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -50,7 +50,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; -if (!empty($conf->ldap->enabled)) { +if (isModEnabled('ldap')) { require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php'; } if (isModEnabled('adherent')) { @@ -785,7 +785,7 @@ if ($action == 'create' || $action == 'adduserldap') { print "
"; - if (!empty($conf->ldap->enabled) && (isset($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_LDAP_TO_DOLIBARR)) { + if (isModEnabled('ldap')et($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_LDAP_TO_DOLIBARR)) { // Show form to add an account from LDAP if sync LDAP -> Dolibarr is set $ldap = new Ldap(); $result = $ldap->connect_bind(); @@ -1375,7 +1375,7 @@ if ($action == 'create' || $action == 'adduserldap') { // Connexion ldap // pour recuperer passDoNotExpire et userChangePassNextLogon - if (!empty($conf->ldap->enabled) && !empty($object->ldap_sid)) { + if (isModEnabled('ldap') && !empty($object->ldap_sid)) { $ldap = new Ldap(); $result = $ldap->connect_bind(); if ($result > 0) { @@ -2896,7 +2896,7 @@ if ($action == 'create' || $action == 'adduserldap') { print '
'; } - if (!empty($conf->ldap->enabled) && !empty($object->ldap_sid)) { + if (isModEnabled('ldap') && !empty($object->ldap_sid)) { $ldap->unbind(); } } diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index a9884ca59d1..327de8def0b 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -7,6 +7,7 @@ * Copyright (C) 2014 Alexis Algoud * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2019 Abbes Bahfir + * Copyright (C) 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 @@ -28,7 +29,7 @@ */ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; -if (!empty($conf->ldap->enabled)) { +if (isModEnabled('ldap')) { require_once DOL_DOCUMENT_ROOT."/core/class/ldap.class.php"; } @@ -706,6 +707,33 @@ class UserGroup extends CommonObject return ''; } + /** + * getTooltipContentArray + * + * @param array $params ex option, infologin + * @since v18 + * @return array + */ + public function getTooltipContentArray($params) + { + global $conf, $langs, $menumanager; + + $option = $params['option'] ?? ''; + + $datas = []; + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + $langs->load("users"); + return ['optimize' => $langs->trans("ShowGroup")]; + } + $datas['divopen'] = '
'; + $datas['picto'] = img_picto('', 'group').' '.$langs->trans("Group").'
'; + $datas['name'] = ''.$langs->trans('Name').': '.$this->name; + $datas['description'] = '
'.$langs->trans("Description").': '.$this->note; + $datas['divclose'] = '
'; + + return $datas; + } + /** * Return a link to the user card (with optionaly the picto) * Use this->id,this->lastname, this->firstname @@ -759,8 +787,18 @@ class UserGroup extends CommonObject $label = $langs->trans("ShowGroup"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1, 1).'"'; } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1, 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).' title="' . $langs->trans('Loading') . '"'; + $linkclose .= ' class="classforajaxtooltip'.($morecss ? ' '.$morecss : '').'"'; + } else { + $linkclose .= ' title="'.dol_escape_htmltag($label, 1, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + } } $linkstart = '
ldap->enabled)) { +if (isModEnabled('ldap')) { require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php'; } diff --git a/test/phpunit/AllTests.php b/test/phpunit/AllTests.php index 1d57db17ffc..ec419ad9987 100644 --- a/test/phpunit/AllTests.php +++ b/test/phpunit/AllTests.php @@ -41,7 +41,7 @@ if (empty($conf->adherent->enabled)) { print "Error: Module member must be enabled to have significant results.\n"; exit(1); } -if (!empty($conf->ldap->enabled)) { +if (isModEnabled('ldap')) { print "Error: LDAP module should not be enabled.\n"; exit(1); } From ba27b8c24ce97a2c2baae28c09751baec5490c55 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 3 Feb 2023 08:29:51 +0000 Subject: [PATCH 21/62] Fixing style errors. --- htdocs/user/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index f7ea29d6720..bf66b29cf5b 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -785,7 +785,7 @@ if ($action == 'create' || $action == 'adduserldap') { print "
"; - if (isModEnabled('ldap')et($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_LDAP_TO_DOLIBARR)) { + if (isModEnabled('ldap')et($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_LDAP_TO_DOLIBARR) {) // Show form to add an account from LDAP if sync LDAP -> Dolibarr is set $ldap = new Ldap(); $result = $ldap->connect_bind(); From 6ab742a530451b408b711cb11f5cee41d4355c56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 3 Feb 2023 09:46:04 +0100 Subject: [PATCH 22/62] add ajax tooltip on usergroup --- htdocs/user/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index f7ea29d6720..b3d83ddb239 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -785,7 +785,7 @@ if ($action == 'create' || $action == 'adduserldap') { print "
"; - if (isModEnabled('ldap')et($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_LDAP_TO_DOLIBARR)) { + if (isModEnabled('ldap') && (isset($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_LDAP_TO_DOLIBARR)) { // Show form to add an account from LDAP if sync LDAP -> Dolibarr is set $ldap = new Ldap(); $result = $ldap->connect_bind(); From 73bbf57db0032541a7d96d24cdc2418572f8716a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 4 Feb 2023 19:14:08 +0100 Subject: [PATCH 23/62] add ajax tooltip on supplier proposal --- .../class/supplier_proposal.class.php | 56 ++++++++++++++++++- 1 file changed, 53 insertions(+), 3 deletions(-) diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index f2e6d19afa8..98dc1e66af2 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -13,7 +13,7 @@ * Copyright (C) 2014 Marcos García * Copyright (C) 2016 Ferran Marcet * Copyright (C) 2018 Nicolas ZABOURI - * Copyright (C) 2019-2022 Frédéric France + * Copyright (C) 2019-2023 Frédéric France * Copyright (C) 2020 Tobias Sekan * Copyright (C) 2022 Gauthier VERDOL * @@ -2468,6 +2468,46 @@ class SupplierProposal extends CommonObject } } + /** + * getTooltipContentArray + * + * @param array $params ex option, infologin + * @since v18 + * @return array + */ + public function getTooltipContentArray($params) + { + global $conf, $langs, $menumanager; + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + return ['optimize' => $langs->trans("ShowSupplierProposal")]; + } + + $option = $params['option'] ?? ''; + $datas = []; + + $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("SupplierProposal").''; + if (isset($this->status)) { + $datas['picto'] .= ' '.$this->getLibStatut(5); + } + if (!empty($this->ref)) { + $datas['ref'] = '
'.$langs->trans('Ref').': '.$this->ref; + } + if (!empty($this->ref_fourn)) { + $datas['ref_supplier'] = '
'.$langs->trans('RefSupplier').': '.$this->ref_fourn; + } + if (!empty($this->total_ht)) { + $datas['amount_ht'] = '
'.$langs->trans('AmountHT').': '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); + } + if (!empty($this->total_tva)) { + $datas['amount_vat'] = '
'.$langs->trans('VAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); + } + if (!empty($this->total_ttc)) { + $datas['amount_ttc'] = '
'.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); + } + + return $datas; + } + /** * Return clicable link of object (with eventually picto) * @@ -2534,8 +2574,18 @@ class SupplierProposal extends CommonObject $label = $langs->trans("ShowSupplierProposal"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip"'; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + 'option' => $option, + ]; + $linkclose .= ' data-params='.json_encode($params).' title="' . $langs->trans('Loading') . '"'; + $linkclose .= ' class="classforajaxtooltip"'; + } else { + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip"'; + } } $linkstart = '
Date: Sat, 4 Feb 2023 21:22:30 +0100 Subject: [PATCH 24/62] fix for double tooltip --- htdocs/user/class/user.class.php | 30 ++++++++++++++------------- htdocs/user/class/usergroup.class.php | 28 +++++++++++++------------ 2 files changed, 31 insertions(+), 27 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 053ba1359fc..26b3ad3860d 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2947,25 +2947,27 @@ class User extends CommonObject $linkstart = ' $this->id, + 'objecttype' => $this->element, + 'infologin' => $infologin, + 'option' => $option, + ]; + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); + $label = $langs->trans('Loading'); + } if (empty($notooltip)) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $langs->load("users"); $label = $langs->trans("ShowUser"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { - $params = [ - 'id' => $this->id, - 'objecttype' => $this->element, - 'infologin' => $infologin, - 'option' => $option, - ]; - $linkclose .= ' data-params='.json_encode($params).' title="' . $langs->trans('Loading') . '"'; - $linkclose .= ' class="classforajaxtooltip'.($morecss ? ' '.$morecss : '').'"'; - } else { - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= $dataparams . ' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"'; } $linkstart .= $linkclose.'>'; @@ -2980,7 +2982,7 @@ class User extends CommonObject } // Only picto if ($withpictoimg > 0) { - $picto = ''.img_object('', 'user', $paddafterimage.' '.($notooltip ? '' : 'class="paddingright classfortooltip"'), 0, 0, $notooltip ? 0 : 1).''; + $picto = ''.img_object('', 'user', $paddafterimage.' '.($notooltip ? '' : $dataparams.' class="paddingright '.$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1).''; } else { // Picto must be a photo $picto = ''.Form::showphoto('userphoto', $this, 0, 0, 0, 'userphoto'.($withpictoimg == -3 ? 'small' : ''), 'mini', 0, 1).''; diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index 45028ca993e..dcc5ca3bb39 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -793,24 +793,26 @@ class UserGroup 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)) { $langs->load("users"); $label = $langs->trans("ShowGroup"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1, 1).'"'; } - if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { - $params = [ - 'id' => $this->id, - 'objecttype' => $this->element, - 'option' => $option, - ]; - $linkclose .= ' data-params='.json_encode($params).' title="' . $langs->trans('Loading') . '"'; - $linkclose .= ' class="classforajaxtooltip'.($morecss ? ' '.$morecss : '').'"'; - } else { - $linkclose .= ' title="'.dol_escape_htmltag($label, 1, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1, 1).'"'; + $linkclose .= $dataparams.' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"'; } $linkstart = 'picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.'class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->name; From 5a33e40667510b3edee0677dfa94844f28ba2ad5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 4 Feb 2023 21:34:48 +0100 Subject: [PATCH 25/62] fix for double tooltip --- .../template/class/myobject.class.php | 28 ++++++++++--------- htdocs/product/stock/class/entrepot.class.php | 28 ++++++++++--------- 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 0e17492ba80..157b8079808 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -816,23 +816,25 @@ class MyObject 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).'"'; } - if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { - $params = [ - 'id' => $this->id, - 'objecttype' => $this->element, - 'option' => $option, - ]; - $linkclose .= ' data-params='.json_encode($params).' title="' . $langs->trans('Loading') . '"'; - $linkclose .= ' class="classforajaxtooltip'.($morecss ? ' '.$morecss : '').'"'; - } else { - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= $dataparams.' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"'; } else { $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); } @@ -853,7 +855,7 @@ class MyObject extends CommonObject if (empty($this->showphoto_on_popup)) { if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); } } else { if ($withpicto) { diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 78e2ba0a173..deb7f8c8d52 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -763,23 +763,25 @@ class Entrepot 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("Warehouse"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { - $params = [ - 'id' => $this->id, - 'objecttype' => $this->element, - 'option' => $option, - ]; - $linkclose .= '" data-params='.json_encode($params).' title="' . $langs->trans('Loading') . '"'; - $linkclose .= ' class="classforajaxtooltip"'; - } else { - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip"'; - } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= $dataparams.' class="'.$classfortooltip.'"'; } $linkstart = 'picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= (($showfullpath || !empty($conf->global->STOCK_ALWAYS_SHOW_FULL_ARBO)) ? $this->get_full_arbo() : $this->label); From 7928bfd6cff8128b53be90a8e39afaf7df90ff46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 4 Feb 2023 21:48:02 +0100 Subject: [PATCH 26/62] add ajax tooltip on societeaccount --- htdocs/societe/class/societe.class.php | 28 +++++++------- htdocs/societe/class/societeaccount.class.php | 37 ++++++++++++++++++- 2 files changed, 50 insertions(+), 15 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index adc08af21c4..c7e0e568b39 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2916,23 +2916,25 @@ class Societe extends CommonObject $linkstart .= '"'; $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("ShowCompany"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { - $params = [ - 'id' => $this->id, - 'objecttype' => $this->element, - 'option' => $option, - ]; - $linkclose .= ' data-params='.json_encode($params).' title="' . $langs->trans('Loading') . '"'; - $linkclose .= ' class="classforajaxtooltip refurl valignmiddle"'; - } else { - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip refurl valignmiddle"'; - } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= $dataparams.' class="'.$classfortooltip.' refurl valignmiddle"'; $target_value = array('_self', '_blank', '_parent', '_top'); if (in_array($target, $target_value)) { $linkclose .= ' target="'.dol_escape_htmltag($target).'"'; @@ -2951,7 +2953,7 @@ class Societe extends CommonObject $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= dol_escape_htmltag($maxlen ? dol_trunc($name, $maxlen) : $name); diff --git a/htdocs/societe/class/societeaccount.class.php b/htdocs/societe/class/societeaccount.class.php index 09fee02c8a3..110f0826516 100644 --- a/htdocs/societe/class/societeaccount.class.php +++ b/htdocs/societe/class/societeaccount.class.php @@ -362,6 +362,27 @@ class SocieteAccount extends CommonObject return $this->deleteCommon($user, $notrigger); } + /** + * getTooltipContentArray + * @param array $params params to construct tooltip data + * @since v18 + * @return array + */ + public function getTooltipContentArray($params) + { + global $conf, $langs, $user; + + $langs->loadLangs(['companies, commercial']); + + $datas = []; + $option = $params['option'] ?? ''; + + $datas['picto'] = ''.$langs->trans("WebsiteAccount").''; + $datas['login'] = '
'.$langs->trans('Login').': '.$this->login; + + return $datas; + } + /** * Return a link to the object card (with optionaly the picto) * @@ -405,13 +426,25 @@ class SocieteAccount 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("WebsiteAccount"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + $linkclose .= $dataparams.' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"'; } else { $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); } @@ -422,7 +455,7 @@ class SocieteAccount extends CommonObject $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->ref; 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 27/62] 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)) : ''); From 473690f49b804fcd1a39121affc95bae11e30084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 4 Feb 2023 22:09:18 +0100 Subject: [PATCH 28/62] fix for double tooltip --- htdocs/comm/propal/class/propal.class.php | 28 ++++++++++++----------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 109cf8368e9..b3271309855 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -3809,23 +3809,25 @@ class Propal 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) && $user->rights->propal->lire) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("Proposal"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { - $params = [ - 'id' => $this->id, - 'objecttype' => $this->element, - 'option' => $option, - ]; - $linkclose .= ' data-params='.json_encode($params).' title="' . $langs->trans('Loading') . '"'; - $linkclose .= ' class="classforajaxtooltip"'; - } else { - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip"'; - } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= $dataparams.' class="'.$classfortooltip.'"'; } $linkstart = 'picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->ref; From a501ae8961ced3e3ee9871a1bc779721c4899933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 5 Feb 2023 09:46:29 +0100 Subject: [PATCH 29/62] fix tooltip --- htdocs/product/class/product.class.php | 31 +++++++++++++------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index e585d35ebae..4077fadeb5e 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5219,24 +5219,25 @@ class Product 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("ShowProduct"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - - if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { - $params = [ - 'id' => $this->id, - 'objecttype' => $this->element, - 'option' => $option, - ]; - $linkclose .= ' data-params='.json_encode($params).' title="' . $langs->trans('Loading') . '"'; - $linkclose .= ' class="nowraponall classforajaxtooltip'.($morecss ? ' '.$morecss : '').'"'; - } else { - $linkclose .= ' title="'.dol_escape_htmltag($label, 1, 1).'"'; - $linkclose .= ' class="nowraponall classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1, 1).'"'; + $linkclose .= $dataparams.' class="nowraponall '.$classfortooltip.($morecss ? ' '.$morecss : '').'"'; } else { $linkclose = ' class="nowraponall'.($morecss ? ' '.$morecss : '').'"'; } @@ -5269,10 +5270,10 @@ class Product extends CommonObject $result .= $linkstart; if ($withpicto) { if ($this->type == Product::TYPE_PRODUCT) { - $result .= (img_object(($notooltip ? '' : $label), 'product', ($notooltip ? 'class="paddingright"' : 'class="paddingright classfortooltip"'), 0, 0, $notooltip ? 0 : 1)); + $result .= (img_object(($notooltip ? '' : $label), 'product', ($notooltip ? 'class="paddingright"' : $dataparams.' class="paddingright '.$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1)); } if ($this->type == Product::TYPE_SERVICE) { - $result .= (img_object(($notooltip ? '' : $label), 'service', ($notooltip ? 'class="paddingright"' : 'class="paddingright classfortooltip"'), 0, 0, $notooltip ? 0 : 1)); + $result .= (img_object(($notooltip ? '' : $label), 'service', ($notooltip ? 'class="paddingright"' : $dataparams.' class="paddingright '.$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1)); } } $result .= dol_escape_htmltag($newref); From 661c82473e677b661da0b528fe80042ddd309b4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 5 Feb 2023 10:00:48 +0100 Subject: [PATCH 30/62] add ajax tooltip on productlot --- .../stock/class/mouvementstock.class.php | 10 ++++- .../product/stock/class/productlot.class.php | 44 ++++++++++++++++++- 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 43760d808b2..2b7c1c025f1 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -46,10 +46,18 @@ class MouvementStock extends CommonObject */ public $product_id; + /** + * @var int ID warehouse + * @deprecated + * @see $warehouse_id + */ + public $entrepot_id; + /** * @var int ID warehouse */ public $warehouse_id; + public $qty; /** @@ -541,7 +549,7 @@ class MouvementStock extends CommonObject } elseif (empty($fk_product_stock)) { $fk_product_stock = $this->db->last_insert_id($this->db->prefix()."product_stock"); } - } + }entrepot_id // Update detail of stock for the lot. if (!$error && isModEnabled('productbatch') && $product->hasbatch() && !$skip_batch) { diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index 649c5578fa4..890a9fbd0f6 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -585,6 +585,34 @@ class Productlot 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(['stocks', 'productbatch']); + + $datas = []; + $option = $params['option'] ?? ''; + $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("Batch").''; + $datas['divopen'] = '
'; + $datas['batch'] = ''.$langs->trans('Batch').': '.$this->batch; + if ($this->eatby && empty($conf->global->PRODUCT_DISABLE_EATBY)) { + $datas['eatby'] = '
'.$langs->trans('EatByDate').': '.dol_print_date($this->eatby, 'day'); + } + if ($this->sellby && empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + $datas['sellby'] = '
'.$langs->trans('SellByDate').': '.dol_print_date($this->sellby, 'day'); + } + $datas['divclose'] = '
'; + + return $datas; + } + /** * Return a link to the a lot card (with optionaly the picto) * Use this->id,this->lastname, this->firstname @@ -629,13 +657,25 @@ class Productlot 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 : '').'"'; + $linkclose .= $dataparams.' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"'; } else { $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); } @@ -654,7 +694,7 @@ class Productlot extends CommonObject $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->batch; From 9ab6c3114199d22617684650d9a24a4068fddc26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 5 Feb 2023 14:13:20 +0100 Subject: [PATCH 31/62] fix tooltip --- htdocs/adherents/class/adherent.class.php | 28 ++++++++++--------- .../adherents/class/adherent_type.class.php | 26 +++++++++-------- .../stock/class/mouvementstock.class.php | 2 +- 3 files changed, 30 insertions(+), 26 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 4dffa624719..d51035d500e 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2365,24 +2365,26 @@ class Adherent extends CommonObject $linkstart .= '
$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)) { $langs->load("users"); $label = $langs->trans("ShowUser"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { - $params = [ - 'id' => $this->id, - 'objecttype' => $this->element, - 'option' => $option, - ]; - $linkclose .= ' data-params='.json_encode($params).' title="' . $langs->trans('Loading') . '"'; - $linkclose .= ' class="classforajaxtooltip'.($morecss ? ' '.$morecss : '').'"'; - } else { - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= $dataparams.' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"'; } $linkstart .= $linkclose.'>'; @@ -2400,7 +2402,7 @@ class Adherent extends CommonObject // Only picto if ($withpictoimg > 0) { $picto = ''. - img_object('', 'user', $paddafterimage.' '.($notooltip ? '' : 'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1).''; + img_object('', 'user', $paddafterimage.' '.($notooltip ? '' : $dataparams.' class="'.$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1).''; } else { // Picto must be a photo $picto = ''; diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 9a27b87f249..1a8c6c7b26c 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -735,7 +735,18 @@ class AdherentType extends CommonObject $option = ''; $url = DOL_URL_ROOT.'/adherents/type.php?rowid='.((int) $this->id); - + $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 ($option != 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); @@ -746,21 +757,12 @@ class AdherentType extends CommonObject $url .= '&save_lastsearch_values=1'; } } - if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { - $params = [ - 'id' => $this->id, - 'objecttype' => $this->element, - 'option' => $option, - ]; - $linkstart = ''; - } else { - $linkstart = ''; - } + $linkstart = ''; $linkend = ''; $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= ($maxlen ?dol_trunc($this->label, $maxlen) : $this->label); diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 2b7c1c025f1..2392962a500 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -549,7 +549,7 @@ class MouvementStock extends CommonObject } elseif (empty($fk_product_stock)) { $fk_product_stock = $this->db->last_insert_id($this->db->prefix()."product_stock"); } - }entrepot_id + } // Update detail of stock for the lot. if (!$error && isModEnabled('productbatch') && $product->hasbatch() && !$skip_batch) { From 8b6bb4161cc592e1433a72a986915925ef5ae6ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 5 Feb 2023 16:02:03 +0100 Subject: [PATCH 32/62] fix tooltip --- htdocs/bom/class/bom.class.php | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 553372a31f8..109e01818e4 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1155,23 +1155,25 @@ class BOM 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("ShowBillOfMaterials"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { - $params = [ - 'id' => $this->id, - 'objecttype' => $this->element, - 'option' => $option, - ]; - $linkclose .= ' data-params='.json_encode($params).' title="' . $langs->trans('Loading') . '"'; - $linkclose .= ' class="classforajaxtooltip'.($morecss ? ' '.$morecss : '').'"'; - } else { - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= $dataparams.' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"'; } else { $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); } @@ -1182,7 +1184,7 @@ class BOM extends CommonObject $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->ref; From 6e07cee3fcbf3a0c5a952ccc10e16cbe2d28de60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 5 Feb 2023 17:04:26 +0100 Subject: [PATCH 33/62] fix tooltip --- htdocs/categories/class/categorie.class.php | 15 ++++---- htdocs/contact/class/contact.class.php | 30 ++++++++------- htdocs/contrat/class/contrat.class.php | 41 +++++++++++---------- 3 files changed, 46 insertions(+), 40 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 618a31df34f..5dc7d53cc49 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1638,26 +1638,27 @@ class Categorie extends CommonObject $forced_color = 'categtextblack'; } } - - $link = ''; - } else { - $link .= '" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip '.$forced_color.'">'; + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); + $label = $langs->trans('Loading'); } + $link = ''; $linkend = ''; $picto = 'category'; if ($withpicto) { - $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); + $result .= ($link.img_object($label, $picto, $dataparams.' class="'.$classfortooltip.'"').$linkend); } if ($withpicto && $withpicto != 2) { $result .= ' '; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 459c7807c43..103b8177994 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1514,23 +1514,25 @@ class Contact extends CommonObject $url .= $moreparam; $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("ShowContact"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { - $params = [ - 'id' => $this->id, - 'objecttype' => $this->element, - 'option' => $option, - ]; - $linkclose .= ' data-params='.json_encode($params).' title="' . $langs->trans('Loading') . '"'; - $linkclose .= ' class="classforajaxtooltip'.($morecss ? ' '.$morecss : '').'"'; - } else { - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= $dataparams.' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"'; } $linkstart = ''; + $linkstart = ''; $linkend = ''; } @@ -1547,7 +1549,7 @@ class Contact extends CommonObject if ($withpicto < 0) { $result .= ''.Form::showphoto('contact', $this, 0, 0, 0, 'userphoto'.($withpicto == -3 ? 'small' : ''), 'mini', 0, 1).''; } else { - $result .= img_object(($notooltip ? '' : $label), ( $this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ( $this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); } } if ($withpicto != 2 && $withpicto != -2) { diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 7785a8ad3e7..981d7d71f02 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2072,31 +2072,32 @@ class Contrat extends CommonObject } $linkclose = ''; + $classfortooltip = 'classfortooltip'; + $dataparams = ''; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + ]; + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); + $label = $langs->trans('Loading'); + } if (empty($notooltip) && $user->rights->contrat->lire) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("ShowContract"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { - $params = [ - 'id' => $this->id, - 'objecttype' => $this->element, - ]; - $linkclose .= '" data-params='.json_encode($params).' title="' . $langs->trans('Loading') . '"'; - $linkclose .= ' class="classforajaxtooltip"'; - } else { - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip"'; - } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= $dataparams.' class="'.$classfortooltip.'"'; } - $linkstart = ''; $linkend = ''; $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= ($this->ref ? $this->ref : $this->id); @@ -3152,17 +3153,19 @@ class ContratLigne extends CommonObjectLine if (empty($label)) { $label = $this->description; } - $link = ''; + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); + $label = $langs->trans('Loading'); } + $link = ''; $linkend = ''; $picto = 'service'; @@ -3171,7 +3174,7 @@ class ContratLigne extends CommonObjectLine } if ($withpicto) { - $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); + $result .= ($link.img_object($label, $picto, $dataparams.' class="'.$classfortooltip.'"').$linkend); } if ($withpicto && $withpicto != 2) { $result .= ' '; From 19631fef742d73fd7502df071a2497c080a611ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 5 Feb 2023 20:41:29 +0100 Subject: [PATCH 34/62] fix tooltip --- htdocs/comm/action/class/actioncomm.class.php | 28 ++++++++++--------- htdocs/commande/class/commande.class.php | 28 ++++++++++--------- htdocs/product/class/product.class.php | 2 ++ htdocs/societe/class/societe.class.php | 7 +++-- 4 files changed, 36 insertions(+), 29 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 23a6b5a67c5..a127cc2d3f2 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1727,6 +1727,18 @@ class ActionComm extends CommonObject $tooltip .= ''; } $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($conf->global->AGENDA_USE_EVENT_TYPE) && $this->type_color) // $linkclose = ' style="background-color:#'.$this->type_color.'"'; @@ -1735,18 +1747,8 @@ class ActionComm extends CommonObject $label = $langs->trans("ShowAction"); $linkclose .= ' alt="'.dol_escape_htmltag($tooltip, 1).'"'; } - if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { - $params = [ - 'id' => $this->id, - 'objecttype' => $this->element, - 'option' => $option, - ]; - $linkclose .= '" data-params='.json_encode($params).' title="' . $langs->trans('Loading') . '"'; - $linkclose .= ' class="'.$classname.' classforajaxtooltip"'; - } else { - $linkclose .= ' title="'.dol_escape_htmltag($tooltip, 1, 0, '', 1).'"'; - $linkclose .= ' class="'.$classname.' classfortooltip"'; - } + $linkclose .= ' title="'.dol_escape_htmltag($tooltip, 1, 0, '', 1).'"'; + $linkclose .= $dataparams.' class="'.$classname.' '.$classfortooltip.'"'; } else { $linkclose .= ' class="'.$classname.'"'; } @@ -1806,7 +1808,7 @@ class ActionComm extends CommonObject $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $langs->trans("ShowAction").': '.$label), ($overwritepicto ? $overwritepicto : 'action'), (($this->type_color && $overwritepicto) ? 'style="color: #'.$this->type_color.' !important;" ' : '').($notooltip ? 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"' : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $langs->trans("ShowAction").': '.$label), ($overwritepicto ? $overwritepicto : 'action'), (($this->type_color && $overwritepicto) ? 'style="color: #'.$this->type_color.' !important;" ' : '').($notooltip ? 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"' : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); } $result .= dol_escape_htmltag($labelshort); $result .= $linkend; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index d5e6fff5fce..f44a545c879 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3832,23 +3832,25 @@ class Commande extends CommonOrder } $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) && $user->rights->commande->lire) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("Order"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { - $params = [ - 'id' => $this->id, - 'objecttype' => $this->element, - 'option' => $option, - ]; - $linkclose .= ' data-params='.json_encode($params).' title="' . $langs->trans('Loading') . '"'; - $linkclose .= ' class="classforajaxtooltip"'; - } else { - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip"'; - } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= $dataparams.' class="'.$classfortooltip.'"'; $target_value = array('_self', '_blank', '_parent', '_top'); if (in_array($target, $target_value)) { @@ -3867,7 +3869,7 @@ class Commande extends CommonOrder $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->ref; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 4077fadeb5e..00e745cff47 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5009,6 +5009,8 @@ class Product extends CommonObject { global $conf, $langs; + $langs->load('products'); + $datas = []; if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index c7e0e568b39..1541ca8e8bb 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2665,15 +2665,16 @@ class Societe extends CommonObject if (isset($this->client) && isset($this->fournisseur)) { $datas['type'] = '   ' . $this->getTypeUrl(1); } - $datas['name'] = '
'.$langs->trans('Name').': '.dol_escape_htmltag($this->name); if (!empty($this->name_alias)) { $datas['namealias'] = ' ('.dol_escape_htmltag($this->name_alias).')'; } - - if ($this->email) { + if (!empty($this->email)) { $datas['email'] = '
'.img_picto('', 'email', 'class="pictofixedwidth"').$this->email; } + if (!empty($this->url)) { + $datas['url'] = '
'.img_picto('', 'globe', 'class="pictofixedwidth"').$this->url; + } if (!empty($this->phone) || !empty($this->fax)) { $phonelist = array(); if ($this->phone) { From c0c10866e909af56003c5c347249fe6597b2b044 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 5 Feb 2023 20:54:18 +0100 Subject: [PATCH 35/62] fix tooltip --- htdocs/compta/bank/class/account.class.php | 12 ++++---- htdocs/core/class/commonobject.class.php | 2 +- htdocs/delivery/class/delivery.class.php | 12 ++++---- .../class/supplier_proposal.class.php | 28 ++++++++++--------- 4 files changed, 30 insertions(+), 24 deletions(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index b978d9cba56..230b0336631 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1460,17 +1460,19 @@ class Account extends CommonObject $label .= '
'.$langs->trans('AccountAccounting').': '.length_accountg($this->account_number); $label .= '
'.$langs->trans('AccountancyJournal').': '.$this->accountancy_journal; } + $classfortooltip = 'classfortooltip'; + $dataparams = ''; if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { $params = [ 'id' => $this->id, 'objecttype' => $this->element, 'option' => $option, ]; - $linkclose = '" data-params='.json_encode($params).' title="' . $langs->trans('Loading') . '"'; - $linkclose .= ' class="classforajaxtooltip"'; - } else { - $linkclose = '" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); + $label = $langs->trans('Loading'); } + $linkclose = '"'.$dataparams.' title="'.dol_escape_htmltag($label, 1).'" class="'.$classfortooltip.'">'; $url = DOL_URL_ROOT.'/compta/bank/card.php?id='.$this->id; if ($mode == 'transactions') { @@ -1500,7 +1502,7 @@ class Account extends CommonObject $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->ref.($option == 'reflabel' && $this->label ? ' - '.$this->label : ''); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index e30ef60b124..f3bde4fe826 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -696,7 +696,7 @@ abstract class CommonObject } $labelextra = $langs->trans((string) $extrafields->attributes[$this->table_element]['label'][$key]); if ($extrafields->attributes[$this->table_element]['type'][$key] == 'separate') { - $datas[$key]= '
'. $labelextra . ''; + $datas[$key]= '
'. $labelextra . ''; } else { $value = $this->array_options['options_' . $key]; $datas[$key]= '
'. $labelextra . ': ' . $extrafields->showOutputField($key, $value, '', $this->table_element); diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php index 717696ac430..525d5458891 100644 --- a/htdocs/delivery/class/delivery.class.php +++ b/htdocs/delivery/class/delivery.class.php @@ -768,20 +768,22 @@ class Delivery extends CommonObject } //} + $classfortooltip = 'classfortooltip'; + $dataparams = ''; if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { $params = [ 'id' => $this->id, 'objecttype' => $this->element, ]; - $linkstart = ''; + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); + $label = $langs->trans('Loading'); } + $linkstart = ''; $linkend = ''; if ($withpicto) { - $result .= ($linkstart.img_object($label, $this->picto, 'class="classfortooltip"').$linkend); + $result .= ($linkstart.img_object($label, $this->picto, $dataparams.' class="'.$classfortooltip.'"').$linkend); } if ($withpicto && $withpicto != 2) { $result .= ' '; diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 98dc1e66af2..db3070f8b8d 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -2569,23 +2569,25 @@ class SupplierProposal 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) && $user->rights->propal->lire) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("ShowSupplierProposal"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { - $params = [ - 'id' => $this->id, - 'objecttype' => $this->element, - 'option' => $option, - ]; - $linkclose .= ' data-params='.json_encode($params).' title="' . $langs->trans('Loading') . '"'; - $linkclose .= ' class="classforajaxtooltip"'; - } else { - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip"'; - } + $linkclose .= $dataparams.' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="'.$classfortooltip.'"'; } $linkstart = 'picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->ref; From 1ad1889d98125dacfc3768b41ea2964240c36381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 5 Feb 2023 21:06:30 +0100 Subject: [PATCH 36/62] fix tooltip --- htdocs/compta/bank/class/account.class.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 230b0336631..7032f9c40e2 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -244,6 +244,20 @@ class Account extends CommonObject */ public $date_solde; + /** + * Balance. Used in Account::create + * @var float + * @deprecated + * @see $balance + */ + public $solde; + + /** + * Balance. Used in Account::create + * @var float + */ + public $balance; + /** * Creditor Identifier CI. Some banks use different ICS for direct debit and bank tranfer * @var string From b7b4737ef8228fe1c789ce98205e15b5c7a82828 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 5 Feb 2023 21:28:27 +0100 Subject: [PATCH 37/62] add ajax tooltip on holidays --- htdocs/holiday/class/holiday.class.php | 40 +++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index e4a82be6ea7..dc4e09d6fe9 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -4,7 +4,7 @@ * Copyright (C) 2012-2016 Regis Houssin * Copyright (C) 2013 Florian Henry * Copyright (C) 2016 Juanjo Menent - * Copyright (C) 2018-2021 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 @@ -1299,6 +1299,28 @@ class Holiday extends CommonObject return $result; } + /** + * getTooltipContentArray + * + * @param array $params ex option, infologin + * @since v18 + * @return array + */ + public function getTooltipContentArray($params) + { + global $conf, $langs; + + $langs->load('holiday'); + + $datas = []; + $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("Holiday").''; + if (isset($this->statut)) { + $datas['picto'] .= ' '.$this->getLibStatut(5); + } + $datas['label'] = '
'.$langs->trans('Ref').': '.$this->ref; + + return $datas; + } /** * Return clicable name (with picto eventually) @@ -1333,13 +1355,23 @@ class Holiday extends CommonObject $url .= '&save_lastsearch_values=1'; } //} - - $linkstart = '
'; + $classfortooltip = 'classfortooltip'; + $dataparams = ''; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + ]; + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); + $label = $langs->trans('Loading'); + } + $linkstart = ''; $linkend = ''; $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->ref; From 1e0125540a5eb0b70f6b3ab1f18874e9d32356aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 5 Feb 2023 21:43:18 +0100 Subject: [PATCH 38/62] add ajax tooltip on invoices --- htdocs/compta/facture/class/facture.class.php | 84 ++++++++++++++++++- 1 file changed, 81 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 75869a900dd..ed2c729b424 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1766,6 +1766,71 @@ class Facture extends CommonInvoice return $deposit; } + /** + * getTooltipContentArray + * + * @param array $params ex option, infologin + * @since v18 + * @return array + */ + public function getTooltipContentArray($params) + { + global $conf, $langs, $mysoc, $user; + + $langs->load('bills'); + + $datas = []; + $moretitle = $params['moretitle'] ?? ''; + $picto = $this->picto; + if ($this->type == self::TYPE_REPLACEMENT) { + $picto .= 'r'; // Replacement invoice + } + if ($this->type == self::TYPE_CREDIT_NOTE) { + $picto .= 'a'; // Credit note + } + if ($this->type == self::TYPE_DEPOSIT) { + $picto .= 'd'; // Deposit invoice + } + + if ($user->hasRight("facture", "read")) { + $datas['picto'] = img_picto('', $picto).' '.$langs->trans("Invoice").''; + if (isset($this->statut) && isset($this->alreadypaid)) { + $datas['picto'] .= ' '.$this->getLibStatut(5, $this->alreadypaid); + } + $datas['picto'] .= ' '.$this->getLibType(1); + if ($moretitle) { + $datas['picto'] = ' - '.$moretitle; + } + if (!empty($this->ref)) { + $datas['ref'] = '
'.$langs->trans('Ref').': '.$this->ref; + } + if (!empty($this->ref_customer)) { + $datas['refcustomer'] = '
'.$langs->trans('RefCustomer').': '.$this->ref_customer; + } + if (!empty($this->date)) { + $datas['date'] = '
'.$langs->trans('Date').': '.dol_print_date($this->date, 'day'); + } + if (!empty($this->total_ht)) { + $datas['amountht'] = '
'.$langs->trans('AmountHT').': '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); + } + if (!empty($this->total_tva)) { + $datas['amountvat'] = '
'.$langs->trans('AmountVAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); + } + if (!empty($this->total_localtax1) && $this->total_localtax1 != 0) { + // We keep test != 0 because $this->total_localtax1 can be '0.00000000' + $datas['amountlt1'] = '
'.$langs->transcountry('AmountLT1', $mysoc->country_code).': '.price($this->total_localtax1, 0, $langs, 0, -1, -1, $conf->currency); + } + if (!empty($this->total_localtax2) && $this->total_localtax2 != 0) { + $datas['amountlt2'] = '
'.$langs->transcountry('AmountLT2', $mysoc->country_code).': '.price($this->total_localtax2, 0, $langs, 0, -1, -1, $conf->currency); + } + if (!empty($this->total_ttc)) { + $datas['amountttc'] = '
'.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); + } + } + + return $datas; + } + /** * Return clicable link of object (with eventually picto) * @@ -1863,13 +1928,26 @@ class Facture extends CommonInvoice } $linkclose = ($target ? ' target="'.$target.'"' : ''); + $classfortooltip = 'classfortooltip'; + $dataparams = ''; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + 'moretitle' => $moretitle, + 'option' => $option, + ]; + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); + $label = $langs->trans('Loading'); + } if (empty($notooltip) && $user->hasRight("facture", "read")) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("Invoice"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip"'; + $linkclose .= $dataparams.' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="'.$classfortooltip.'"'; } $linkstart = 'ref, $max) : $this->ref); From c1b959cdc806db2721ef209dfb2a97c824ab3918 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 5 Feb 2023 22:56:46 +0100 Subject: [PATCH 39/62] add ajax tooltip on supplier_order --- .../class/fournisseur.commande.class.php | 63 +++++++++++++++++-- 1 file changed, 59 insertions(+), 4 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index c7357813d43..600c0c09915 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -9,7 +9,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2018 Nicolas ZABOURI - * Copyright (C) 2018-2022 Frédéric France + * Copyright (C) 2018-2023 Frédéric France * Copyright (C) 2018-2022 Ferran Marcet * Copyright (C) 2021 Josep Lluís Amador * Copyright (C) 2022 Gauthier VERDOL @@ -818,6 +818,49 @@ class CommandeFournisseur extends CommonOrder return dolGetStatus($statusLong, $statusShort, '', $statusClass, $mode); } + /** + * getTooltipContentArray + * + * @param array $params ex option, infologin + * @since v18 + * @return array + */ + public function getTooltipContentArray($params) + { + global $conf, $langs, $user; + + $langs->loadLangs(['bills', 'orders']); + + $datas = []; + if ($user->hasRight("fournisseur", "commande", "read")) { + $datas['picto'] = ''.$langs->trans("SupplierOrder").''; + if (isset($this->statut)) { + $datas['picto'] .= ' '.$this->getLibStatut(5); + } + if (!empty($this->ref)) { + $datas['ref'] = '
'.$langs->trans('Ref').': '.$this->ref; + } + if (!empty($this->ref_supplier)) { + $datas['refsupplier'] = '
'.$langs->trans('RefSupplier').': '.$this->ref_supplier; + } + if (!empty($this->total_ht)) { + $datas['totalht'] = '
'.$langs->trans('AmountHT').': '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); + } + if (!empty($this->total_tva)) { + $datas['totaltva'] = '
'.$langs->trans('VAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); + } + if (!empty($this->total_ttc)) { + $datas['totalttc'] = '
'.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); + } + if (!empty($this->date)) { + $datas['date'] = '
'.$langs->trans('Date').': '.dol_print_date($this->date, 'day'); + } + if (!empty($this->delivery_date)) { + $datas['deliverydate'] = '
'.$langs->trans('DeliveryDate').': '.dol_print_date($this->delivery_date, 'dayhour'); + } + } + return $datas; + } /** * Return clicable name (with picto eventually) @@ -880,13 +923,25 @@ class CommandeFournisseur extends CommonOrder } $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("ShowOrder"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip"'; + $linkclose .= $dataparams.' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="'.$classfortooltip.'"'; } $linkstart = '
picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->ref; From b238830c82e62b7e10ed2f56a45f1d872805bca3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 5 Feb 2023 23:19:56 +0100 Subject: [PATCH 40/62] keep original label --- htdocs/adherents/class/adherent.class.php | 2 +- htdocs/bom/class/bom.class.php | 2 +- htdocs/categories/class/categorie.class.php | 2 +- htdocs/comm/action/class/actioncomm.class.php | 2 +- htdocs/comm/propal/class/propal.class.php | 2 +- htdocs/commande/class/commande.class.php | 2 +- htdocs/compta/facture/class/facture.class.php | 2 +- htdocs/contact/class/contact.class.php | 2 +- htdocs/contrat/class/contrat.class.php | 4 +- htdocs/delivery/class/delivery.class.php | 2 +- .../class/fournisseur.commande.class.php | 2 +- .../fourn/class/fournisseur.facture.class.php | 89 ++++++++++++++++++- htdocs/holiday/class/holiday.class.php | 2 +- .../template/class/myobject.class.php | 2 +- htdocs/product/class/product.class.php | 2 +- htdocs/product/stock/class/entrepot.class.php | 2 +- .../product/stock/class/productlot.class.php | 2 +- htdocs/salaries/class/salary.class.php | 2 +- htdocs/societe/class/societe.class.php | 2 +- htdocs/societe/class/societeaccount.class.php | 2 +- .../class/supplier_proposal.class.php | 2 +- htdocs/user/class/user.class.php | 2 +- htdocs/user/class/usergroup.class.php | 2 +- 23 files changed, 108 insertions(+), 27 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index d51035d500e..0b645571947 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2375,7 +2375,7 @@ class Adherent extends CommonObject ]; $classfortooltip = 'classforajaxtooltip'; $dataparams = ' data-params='.json_encode($params); - $label = $langs->trans('Loading'); + // $label = $langs->trans('Loading'); } if (empty($notooltip)) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 109e01818e4..4420950af30 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1165,7 +1165,7 @@ class BOM extends CommonObject ]; $classfortooltip = 'classforajaxtooltip'; $dataparams = ' data-params='.json_encode($params); - $label = $langs->trans('Loading'); + // $label = $langs->trans('Loading'); } if (empty($notooltip)) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 5dc7d53cc49..f57bca581bd 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1648,7 +1648,7 @@ class Categorie extends CommonObject ]; $classfortooltip = 'classforajaxtooltip'; $dataparams = ' data-params='.json_encode($params); - $label = $langs->trans('Loading'); + // $label = $langs->trans('Loading'); } $link = ''; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index a127cc2d3f2..fd5b55e70fe 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1737,7 +1737,7 @@ class ActionComm extends CommonObject ]; $classfortooltip = 'classforajaxtooltip'; $dataparams = ' data-params='.json_encode($params); - $label = $langs->trans('Loading'); + // $label = $langs->trans('Loading'); } //if (!empty($conf->global->AGENDA_USE_EVENT_TYPE) && $this->type_color) // $linkclose = ' style="background-color:#'.$this->type_color.'"'; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index b3271309855..51c8c4518b5 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -3819,7 +3819,7 @@ class Propal extends CommonObject ]; $classfortooltip = 'classforajaxtooltip'; $dataparams = ' data-params='.json_encode($params); - $label = $langs->trans('Loading'); + // $label = $langs->trans('Loading'); } if (empty($notooltip) && $user->rights->propal->lire) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index f44a545c879..5f810a8610a 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3842,7 +3842,7 @@ class Commande extends CommonOrder ]; $classfortooltip = 'classforajaxtooltip'; $dataparams = ' data-params='.json_encode($params); - $label = $langs->trans('Loading'); + // $label = $langs->trans('Loading'); } if (empty($notooltip) && $user->rights->commande->lire) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index ed2c729b424..82ef9fc5b06 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1939,7 +1939,7 @@ class Facture extends CommonInvoice ]; $classfortooltip = 'classforajaxtooltip'; $dataparams = ' data-params='.json_encode($params); - $label = $langs->trans('Loading'); + // $label = $langs->trans('Loading'); } if (empty($notooltip) && $user->hasRight("facture", "read")) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 103b8177994..d0e9a2200f3 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1524,7 +1524,7 @@ class Contact extends CommonObject ]; $classfortooltip = 'classforajaxtooltip'; $dataparams = ' data-params='.json_encode($params); - $label = $langs->trans('Loading'); + // $label = $langs->trans('Loading'); } if (empty($notooltip)) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 981d7d71f02..c3177bd2b1e 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2081,7 +2081,7 @@ class Contrat extends CommonObject ]; $classfortooltip = 'classforajaxtooltip'; $dataparams = ' data-params='.json_encode($params); - $label = $langs->trans('Loading'); + // $label = $langs->trans('Loading'); } if (empty($notooltip) && $user->rights->contrat->lire) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { @@ -3162,7 +3162,7 @@ class ContratLigne extends CommonObjectLine ]; $classfortooltip = 'classforajaxtooltip'; $dataparams = ' data-params='.json_encode($params); - $label = $langs->trans('Loading'); + // $label = $langs->trans('Loading'); } $link = ''; diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php index 525d5458891..b9c301806f9 100644 --- a/htdocs/delivery/class/delivery.class.php +++ b/htdocs/delivery/class/delivery.class.php @@ -777,7 +777,7 @@ class Delivery extends CommonObject ]; $classfortooltip = 'classforajaxtooltip'; $dataparams = ' data-params='.json_encode($params); - $label = $langs->trans('Loading'); + // $label = $langs->trans('Loading'); } $linkstart = ''; $linkend = ''; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 600c0c09915..2ba0097af33 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -933,7 +933,7 @@ class CommandeFournisseur extends CommonOrder ]; $classfortooltip = 'classforajaxtooltip'; $dataparams = ' data-params='.json_encode($params); - $label = $langs->trans('Loading'); + // $label = $langs->trans('Loading'); } if (empty($notooltip)) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index dd9ba7a6248..6572fc29cbb 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -12,7 +12,7 @@ * Copyright (C) 2015-2022 Ferran Marcet * Copyright (C) 2016-2021 Alexandre Spangaro * Copyright (C) 2018 Nicolas ZABOURI - * Copyright (C) 2018-2022 Frédéric France + * Copyright (C) 2018-2023 Frédéric France * Copyright (C) 2022 Gauthier VERDOL * * This program is free software; you can redistribute it and/or modify @@ -2700,6 +2700,74 @@ class FactureFournisseur extends CommonInvoice } } + /** + * getTooltipContentArray + * + * @param array $params ex option, infologin + * @since v18 + * @return array + */ + public function getTooltipContentArray($params) + { + global $conf, $langs; + + $langs->load('bills'); + + $datas = []; + $moretitle = $params['moretitle'] ?? ''; + $picto = $this->picto; + if ($this->type == self::TYPE_REPLACEMENT) { + $picto .= 'r'; // Replacement invoice + } + if ($this->type == self::TYPE_CREDIT_NOTE) { + $picto .= 'a'; // Credit note + } + if ($this->type == self::TYPE_DEPOSIT) { + $picto .= 'd'; // Deposit invoice + } + + $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("SupplierInvoice").''; + if ($this->type == self::TYPE_REPLACEMENT) { + $datas['picto'] .= ''.$langs->transnoentitiesnoconv("InvoiceReplace").''; + } elseif ($this->type == self::TYPE_CREDIT_NOTE) { + $datas['picto'] .= ''.$langs->transnoentitiesnoconv("CreditNote").''; + } elseif ($this->type == self::TYPE_DEPOSIT) { + $datas['picto'] .= ''.$langs->transnoentitiesnoconv("Deposit").''; + } + if (isset($this->status)) { + $alreadypaid = -1; + if (isset($this->alreadypaid)) { + $alreadypaid = $this->alreadypaid; + } + + $$datas['picto'] .= ' '.$this->getLibStatut(5, $alreadypaid); + } + if ($moretitle) { + $datas['picto'] .= ' - '.$moretitle; + } + if (!empty($this->ref)) { + $datas['ref'] = '
'.$langs->trans('Ref').': '.$this->ref; + } + if (!empty($this->ref_supplier)) { + $datas['refsupplier'] = '
'.$langs->trans('RefSupplier').': '.$this->ref_supplier; + } + if (!empty($this->label)) { + $datas['label'] = '
'.$langs->trans('Label').': '.$this->label; + } + if (!empty($this->date)) { + $datas['date'] = '
'.$langs->trans('Date').': '.dol_print_date($this->date, 'day'); + } + if (!empty($this->total_ht)) { + $datas['amountht'] = '
'.$langs->trans('AmountHT').': '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); + } + if (!empty($this->total_tva)) { + $datas['totaltva'] = '
'.$langs->trans('AmountVAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); + } + if (!empty($this->total_ttc)) { + $datas['totalttc'] = '
'.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); + } + return $datas; + } /** * Return clicable name (with picto eventually) @@ -2801,13 +2869,26 @@ class FactureFournisseur extends CommonInvoice } $linkclose = ''; + $classfortooltip = 'classfortooltip'; + $dataparams = ''; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + 'option' => $option, + 'moretitle' => $moretitle, + ]; + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); + // $label = $langs->trans('Loading'); + } if (empty($notooltip)) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("ShowSupplierInvoice"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip"'; + $linkclose .= $dataparams.' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="'.$classfortooltip.'"'; } $linkstart = 'trans('Loading'); + // $label = $langs->trans('Loading'); } $linkstart = ''; $linkend = ''; diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 157b8079808..8ad88bdec8a 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -826,7 +826,7 @@ class MyObject extends CommonObject ]; $classfortooltip = 'classforajaxtooltip'; $dataparams = ' data-params='.json_encode($params); - $label = $langs->trans('Loading'); + // $label = $langs->trans('Loading'); } if (empty($notooltip)) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 00e745cff47..877bcedecdd 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5231,7 +5231,7 @@ class Product extends CommonObject ]; $classfortooltip = 'classforajaxtooltip'; $dataparams = ' data-params='.json_encode($params); - $label = $langs->trans('Loading'); + // $label = $langs->trans('Loading'); } if (empty($notooltip)) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index deb7f8c8d52..5af056d8080 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -773,7 +773,7 @@ class Entrepot extends CommonObject ]; $classfortooltip = 'classforajaxtooltip'; $dataparams = ' data-params='.json_encode($params); - $label = $langs->trans('Loading'); + // $label = $langs->trans('Loading'); } if (empty($notooltip)) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index 890a9fbd0f6..1ddcb073d3f 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -667,7 +667,7 @@ class Productlot extends CommonObject ]; $classfortooltip = 'classforajaxtooltip'; $dataparams = ' data-params='.json_encode($params); - $label = $langs->trans('Loading'); + // $label = $langs->trans('Loading'); } if (empty($notooltip)) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { diff --git a/htdocs/salaries/class/salary.class.php b/htdocs/salaries/class/salary.class.php index 4eb403a71a1..d201c4f44c0 100644 --- a/htdocs/salaries/class/salary.class.php +++ b/htdocs/salaries/class/salary.class.php @@ -552,7 +552,7 @@ class Salary extends CommonObject ]; $classfortooltip = 'classforajaxtooltip'; $dataparams = ' data-params='.json_encode($params); - $label = $langs->trans('Loading'); + // $label = $langs->trans('Loading'); } if (empty($notooltip)) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 1541ca8e8bb..7860ef161c3 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2927,7 +2927,7 @@ class Societe extends CommonObject ]; $classfortooltip = 'classforajaxtooltip'; $dataparams = ' data-params='.json_encode($params); - $label = $langs->trans('Loading'); + // $label = $langs->trans('Loading'); } if (empty($notooltip)) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { diff --git a/htdocs/societe/class/societeaccount.class.php b/htdocs/societe/class/societeaccount.class.php index 110f0826516..a10fee1666e 100644 --- a/htdocs/societe/class/societeaccount.class.php +++ b/htdocs/societe/class/societeaccount.class.php @@ -436,7 +436,7 @@ class SocieteAccount extends CommonObject ]; $classfortooltip = 'classforajaxtooltip'; $dataparams = ' data-params='.json_encode($params); - $label = $langs->trans('Loading'); + // $label = $langs->trans('Loading'); } if (empty($notooltip)) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index db3070f8b8d..d7013c596b0 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -2579,7 +2579,7 @@ class SupplierProposal extends CommonObject ]; $classfortooltip = 'classforajaxtooltip'; $dataparams = ' data-params='.json_encode($params); - $label = $langs->trans('Loading'); + // $label = $langs->trans('Loading'); } if (empty($notooltip) && $user->rights->propal->lire) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 26b3ad3860d..17123f7e40a 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2958,7 +2958,7 @@ class User extends CommonObject ]; $classfortooltip = 'classforajaxtooltip'; $dataparams = ' data-params='.json_encode($params); - $label = $langs->trans('Loading'); + // $label = $langs->trans('Loading'); } if (empty($notooltip)) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index dcc5ca3bb39..8d5a054f646 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -803,7 +803,7 @@ class UserGroup extends CommonObject ]; $classfortooltip = 'classforajaxtooltip'; $dataparams = ' data-params='.json_encode($params); - $label = $langs->trans('Loading'); + // $label = $langs->trans('Loading'); } if (empty($notooltip)) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { From e5190ef6a575976cce91904e87bff13e902fb17f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 5 Feb 2023 23:28:54 +0100 Subject: [PATCH 41/62] add ajax tooltip on mo --- htdocs/mrp/class/mo.class.php | 45 ++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 9a7ba6007cc..3ea38f28251 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -1077,6 +1077,33 @@ class Mo extends CommonObject return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'MRP_MO_REOPEN'); } + /** + * getTooltipContentArray + * + * @param array $params ex option, infologin + * @since v18 + * @return array + */ + public function getTooltipContentArray($params) + { + global $conf, $langs; + + $langs->load('mrp'); + + $datas = []; + + $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("ManufacturingOrder").''; + if (isset($this->status)) { + $datas['picto'] .= ' '.$this->getLibStatut(5); + } + $datas['ref'] = '
'.$langs->trans('Ref').': '.$this->ref; + if (isset($this->label)) { + $datas['label'] = '
'.$langs->trans('Label').': '.$this->label; + } + + return $datas; + } + /** * Return a link to the object card (with optionaly the picto) * @@ -1124,13 +1151,25 @@ class Mo 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("ShowMo"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + $linkclose .= $dataparams.' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"'; } else { $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); } @@ -1141,7 +1180,7 @@ class Mo extends CommonObject $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->ref; From 06904246f86511f83c1d2fbb24843b96917b49e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 5 Feb 2023 23:40:02 +0100 Subject: [PATCH 42/62] clean code --- htdocs/holiday/class/holiday.class.php | 26 +++++++--------- .../template/class/myobject.class.php | 30 ++++++++----------- 2 files changed, 23 insertions(+), 33 deletions(-) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 9666b1642ef..e3a605a09aa 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1336,11 +1336,18 @@ class Holiday extends CommonObject $result = ''; - $label = img_picto('', $this->picto).' '.$langs->trans("Holiday").''; - if (isset($this->statut)) { - $label .= ' '.$this->getLibStatut(5); + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + ]; + $classfortooltip = 'classfortooltip'; + $dataparams = ''; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); + // $label = $langs->trans('Loading'); } - $label .= '
'.$langs->trans('Ref').': '.$this->ref; + $label = implode($this->getTooltipContentArray($params)); $url = DOL_URL_ROOT.'/holiday/card.php?id='.$this->id; @@ -1355,17 +1362,6 @@ class Holiday extends CommonObject $url .= '&save_lastsearch_values=1'; } //} - $classfortooltip = 'classfortooltip'; - $dataparams = ''; - if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { - $params = [ - 'id' => $this->id, - 'objecttype' => $this->element, - ]; - $classfortooltip = 'classforajaxtooltip'; - $dataparams = ' data-params='.json_encode($params); - // $label = $langs->trans('Loading'); - } $linkstart = ''; $linkend = ''; diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 8ad88bdec8a..e4594e6d615 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -794,13 +794,19 @@ class MyObject extends CommonObject } $result = ''; - - $label = img_picto('', $this->picto).' '.$langs->trans("MyObject").''; - if (isset($this->status)) { - $label .= ' '.$this->getLibStatut(5); + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + 'option' => $option, + ]; + $classfortooltip = 'classfortooltip'; + $dataparams = ''; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); + // $label = $langs->trans('Loading'); } - $label .= '
'; - $label .= ''.$langs->trans('Ref').': '.$this->ref; + $label = implode($this->getTooltipContentArray($params)); $url = dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.$this->id; @@ -816,18 +822,6 @@ class MyObject 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"); From 1c24804f06f36b95f212bfbcf2e90901f377271a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 6 Feb 2023 14:14:15 +0100 Subject: [PATCH 43/62] clean code --- htdocs/core/js/lib_foot.js.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/htdocs/core/js/lib_foot.js.php b/htdocs/core/js/lib_foot.js.php index 8efda4e3812..b319185909a 100644 --- a/htdocs/core/js/lib_foot.js.php +++ b/htdocs/core/js/lib_foot.js.php @@ -95,13 +95,8 @@ if (empty($conf->dol_no_mouse_hover)) { elem.tooltip("option","content",response); } }); - console.log(event); } }); - jQuery(".classforajaxtooltip").mouseout(function(){ - console.log("hide ajax tooltip"); - $(this).tooltip("close"); - }); '; } From 1b9f8d46b05def1bbc900db192d5bcafd4a418e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 6 Feb 2023 21:14:24 +0100 Subject: [PATCH 44/62] clean code --- htdocs/adherents/class/adherent.class.php | 48 +++++-------------- .../adherents/class/adherent_type.class.php | 25 ++++------ 2 files changed, 22 insertions(+), 51 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 0b645571947..e2b7cda5e07 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2319,33 +2319,21 @@ class Adherent extends CommonObject } $result = ''; - $label = ''; $linkstart = ''; $linkend = ''; - - if (!empty($this->photo)) { - $label .= '
'; - $label .= Form::showphoto('memberphoto', $this, 80, 0, 0, 'photoref photowithmargin photologintooltip', 'small', 0, 1); - $label .= '
'; - //$label .= '
'; + $classfortooltip = 'classfortooltip'; + $dataparams = ''; + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + 'option' => $option, + ]; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); + // $label = $langs->trans('Loading'); } - - $label .= '
'; - $label .= img_picto('', $this->picto).' '.$langs->trans("Member").''; - $label .= ' '.$this->getLibStatut(4); - if (!empty($this->ref)) { - $label .= '
'.$langs->trans('Ref').': '.$this->ref; - } - if (!empty($this->login)) { - $label .= '
'.$langs->trans('Login').': '.$this->login; - } - if (!empty($this->firstname) || !empty($this->lastname)) { - $label .= '
'.$langs->trans('Name').': '.$this->getFullName($langs); - } - if (!empty($this->company)) { - $label .= '
'.$langs->trans('Company').': '.$this->company; - } - $label .= '
'; + $label = implode($this->getTooltipContentArray($params)); $url = DOL_URL_ROOT.'/adherents/card.php?rowid='.((int) $this->id); if ($option == 'subscription') { @@ -2365,18 +2353,6 @@ class Adherent extends CommonObject $linkstart .= ' $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)) { $langs->load("users"); diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 1a8c6c7b26c..9819110e6bc 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -724,29 +724,24 @@ class AdherentType extends CommonObject global $langs; $result = ''; - - $label = img_picto('', $this->picto).' '.$langs->trans("MemberType").''; - $label .= ' '.$this->getLibStatut(4); - $label .= '
'.$langs->trans("Label").': '.$this->label; - if (isset($this->subscription)) { - $label .= '
'.$langs->trans("SubscriptionRequired").': '.yn($this->subscription); - } - $option = ''; - $url = DOL_URL_ROOT.'/adherents/type.php?rowid='.((int) $this->id); $classfortooltip = 'classfortooltip'; $dataparams = ''; + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + 'option' => $option, + ]; 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'); + // $label = $langs->trans('Loading'); } + + $label = implode($this->getTooltipContentArray($params)); + + $url = DOL_URL_ROOT.'/adherents/type.php?rowid='.((int) $this->id); if ($option != 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); From dc15349e83784bbdb8df41a7bd1a1833e40d2f92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 6 Feb 2023 21:43:50 +0100 Subject: [PATCH 45/62] clean code --- htdocs/bom/class/bom.class.php | 42 +++------ htdocs/categories/class/categorie.class.php | 28 +++--- htdocs/contact/class/contact.class.php | 98 +++++++++------------ 3 files changed, 71 insertions(+), 97 deletions(-) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 4420950af30..8746999e00b 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1121,24 +1121,20 @@ class BOM extends CommonObject } $result = ''; + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + 'option' => $option, + ]; + $classfortooltip = 'classfortooltip'; + $dataparams = ''; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); + // $label = $langs->trans('Loading'); + } - $label = img_picto('', $this->picto).' '.$langs->trans("BillOfMaterials").''; - if (isset($this->status)) { - $label .= ' '.$this->getLibStatut(5); - } - $label .= '
'; - $label .= ''.$langs->trans('Ref').': '.$this->ref; - if (isset($this->label)) { - $label .= '
'.$langs->trans('Label').': '.$this->label; - } - if (!empty($this->fk_product) && $this->fk_product > 0) { - include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - $product = new Product($db); - $resultFetch = $product->fetch($this->fk_product); - if ($resultFetch > 0) { - $label .= "
".$langs->trans("Product").': '.$product->ref.' - '.$product->label; - } - } + $label = implode($this->getTooltipContentArray($params)); $url = DOL_URL_ROOT.'/bom/bom_card.php?id='.$this->id; @@ -1155,18 +1151,6 @@ class BOM 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("ShowBillOfMaterials"); diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index f57bca581bd..592b0204983 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1605,7 +1605,7 @@ class Categorie extends CommonObject */ public function getTooltipContentArray($params) { - global $conf, $langs, $user; + global $langs; $datas = []; @@ -1629,7 +1629,19 @@ class Categorie extends CommonObject global $langs, $hookmanager; $result = ''; - $label = $langs->trans("ShowCategory").': '.($this->ref ? $this->ref : $this->label); + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + 'option' => $option, + ]; + $classfortooltip = 'classfortooltip'; + $dataparams = ''; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); + // $label = $langs->trans('Loading'); + } + $label = implode($this->getTooltipContentArray($params)); // Check contrast with background and correct text color $forced_color = 'categtextwhite'; @@ -1638,18 +1650,6 @@ class Categorie extends CommonObject $forced_color = 'categtextblack'; } } - $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'); - } $link = '
'; $linkend = ''; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index d0e9a2200f3..b44d22da312 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -133,6 +133,11 @@ class Contact extends CommonObject public $civility_code; public $civility; + /** + * @var string gender + */ + public $gender; + /** * @var int egroupware_id */ @@ -193,6 +198,11 @@ class Contact extends CommonObject public $socid; // both socid and fk_soc are used public $fk_soc; // both socid and fk_soc are used + /** + * @var string thirdparty name + */ + public $socname; + /** * @var int 0=inactive, 1=active */ @@ -206,6 +216,14 @@ class Contact extends CommonObject */ public $email; + /** + * Email + * @var string + * @deprecated + * @see $email + */ + public $mail; + /** * URL * @var string @@ -1045,12 +1063,12 @@ class Contact extends CommonObject $this->country_id = $obj->country_id; $this->country_code = $obj->country_id ? $obj->country_code : ''; - $this->country = $obj->country_id ? ($langs->trans('Country'.$obj->country_code) != 'Country'.$obj->country_code ? $langs->transnoentities('Country'.$obj->country_code) : $obj->country) : ''; + $this->country = $obj->country_id ? ($langs->trans('Country'.$obj->country_code) != 'Country'.$obj->country_code ? $langs->transnoentities('Country'.$obj->country_code) : $obj->country) : ''; - $this->fk_soc = $obj->fk_soc; // Both fk_soc and socid are used - $this->socid = $obj->fk_soc; // Both fk_soc and socid are used - $this->socname = $obj->socname; - $this->poste = $obj->poste; + $this->fk_soc = $obj->fk_soc; // Both fk_soc and socid are used + $this->socid = $obj->fk_soc; // Both fk_soc and socid are used + $this->socname = $obj->socname; + $this->poste = $obj->poste; $this->statut = $obj->statut; $this->fk_prospectlevel = $obj->fk_prospectlevel; @@ -1066,22 +1084,22 @@ class Contact extends CommonObject $this->phone_perso = trim($obj->phone_perso); $this->phone_mobile = trim($obj->phone_mobile); - $this->email = $obj->email; + $this->email = $obj->email; $this->socialnetworks = ($obj->socialnetworks ? (array) json_decode($obj->socialnetworks, true) : array()); - $this->photo = $obj->photo; - $this->priv = $obj->priv; - $this->mail = $obj->email; + $this->photo = $obj->photo; + $this->priv = $obj->priv; + $this->mail = $obj->email; $this->birthday = $this->db->jdate($obj->birthday); - $this->note = $obj->note_private; // deprecated - $this->note_private = $obj->note_private; + $this->note = $obj->note_private; // deprecated + $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; - $this->default_lang = $obj->default_lang; + $this->default_lang = $obj->default_lang; $this->user_id = $obj->user_id; - $this->user_login = $obj->user_login; + $this->user_login = $obj->user_login; $this->canvas = $obj->canvas; - $this->import_key = $obj->import_key; + $this->import_key = $obj->import_key; // Define gender according to civility $this->setGenderFromCivility(); @@ -1468,35 +1486,19 @@ class Contact extends CommonObject global $conf, $langs, $hookmanager; $result = ''; - $label = ''; - if (!empty($this->photo) && class_exists('Form')) { - $label .= '
'; - $label .= Form::showphoto('contact', $this, 0, 40, 0, 'photoref', 'mini', 0); // Important, we must force height so image will have height tags and if image is inside a tooltip, the tooltip manager can calculate height and position correctly the tooltip. - $label .= '
'; - //$label .= '
'; + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + 'option' => $option, + ]; + $classfortooltip = 'classfortooltip'; + $dataparams = ''; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); + // $label = $langs->trans('Loading'); } - - $label .= img_picto('', $this->picto).' '.$langs->trans("Contact").''; - $label .= ' '.$this->getLibStatut(4); - $label .= '
'.$langs->trans("Name").': '.$this->getFullName($langs); - //if ($this->civility_id) $label.= '
' . $langs->trans("Civility") . ': '.$this->civility_id; // TODO Translate cibilty_id code - if (!empty($this->poste)) { - $label .= '
'.$langs->trans("Poste").': '.$this->poste; - } - $label .= '
'.$langs->trans("EMail").': '.$this->email; - $phonelist = array(); - $country_code = empty($this->country_code) ? '': $this->country_code; - if ($this->phone_pro) { - $phonelist[] = dol_print_phone($this->phone_pro, $country_code, $this->id, 0, '', ' ', 'phone'); - } - if ($this->phone_mobile) { - $phonelist[] = dol_print_phone($this->phone_mobile, $country_code, $this->id, 0, '', ' ', 'mobile'); - } - if ($this->phone_perso) { - $phonelist[] = dol_print_phone($this->phone_perso, $country_code, $this->id, 0, '', ' ', 'phone'); - } - $label .= '
'.$langs->trans("Phone").': '.implode(' ', $phonelist); - $label .= '
'.$langs->trans("Address").': '.dol_format_address($this, 1, ' ', $langs); + $label = implode($this->getTooltipContentArray($params)); $url = DOL_URL_ROOT.'/contact/card.php?id='.$this->id; @@ -1514,18 +1516,6 @@ class Contact extends CommonObject $url .= $moreparam; $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("ShowContact"); From f3b5990d2b8012909fb24614ee4aa89d5eefdcf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 6 Feb 2023 21:49:23 +0100 Subject: [PATCH 46/62] clean code --- htdocs/contrat/class/contrat.class.php | 37 ++++++-------------------- 1 file changed, 8 insertions(+), 29 deletions(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index c3177bd2b1e..97b586a2cde 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2047,42 +2047,21 @@ class Contrat extends CommonObject $url .= '&save_lastsearch_values=1'; } //} - - $label = ''; - - if ($user->hasRight('contrat', 'lire')) { - $label = img_picto('', $this->picto).' '.$langs->trans("Contract").''; - /* Status of a contract is status of all services, so disabled - if (isset($this->statut)) { - $label .= ' '.$this->getLibStatut(5); - }*/ - $label .= '
'.$langs->trans('Ref').': '.($this->ref ? $this->ref : $this->id); - $ref_customer = (!empty($this->ref_customer) ? $this->ref_customer : (empty($this->ref_client) ? '' : $this->ref_client)); - $label .= '
'.$langs->trans('RefCustomer').': '.$ref_customer; - $label .= '
'.$langs->trans('RefSupplier').': '.$this->ref_supplier; - if (!empty($this->total_ht)) { - $label .= '
'.$langs->trans('AmountHT').': '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); - } - if (!empty($this->total_tva)) { - $label .= '
'.$langs->trans('VAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); - } - if (!empty($this->total_ttc)) { - $label .= '
'.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); - } - } - - $linkclose = ''; + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + ]; $classfortooltip = 'classfortooltip'; $dataparams = ''; if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { - $params = [ - 'id' => $this->id, - 'objecttype' => $this->element, - ]; $classfortooltip = 'classforajaxtooltip'; $dataparams = ' data-params='.json_encode($params); // $label = $langs->trans('Loading'); } + + $label = implode($this->getTooltipContentArray($params)); + + $linkclose = ''; if (empty($notooltip) && $user->rights->contrat->lire) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("ShowContract"); From 4a74e7d87519f686f2322c0310a848a6d1fb7a9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 6 Feb 2023 21:59:32 +0100 Subject: [PATCH 47/62] clean code --- htdocs/compta/facture/class/facture.class.php | 53 ++++--------------- htdocs/delivery/class/delivery.class.php | 30 ++++++----- 2 files changed, 26 insertions(+), 57 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 82ef9fc5b06..8505af85ce5 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1890,57 +1890,22 @@ class Facture extends CommonInvoice if ($this->type == self::TYPE_DEPOSIT) { $picto .= 'd'; // Deposit invoice } - $label = ''; - - if ($user->hasRight("facture", "read")) { - $label = img_picto('', $picto).' '.$langs->trans("Invoice").''; - if (isset($this->statut) && isset($this->alreadypaid)) { - $label .= ' '.$this->getLibStatut(5, $this->alreadypaid); - } - $label .= '   '.$this->getLibType(1); - if (!empty($this->ref)) { - $label .= '
'.$langs->trans('Ref').': '.$this->ref; - } - if (!empty($this->ref_client)) { - $label .= '
'.$langs->trans('RefCustomer').': '.$this->ref_client; - } - if (!empty($this->date)) { - $label .= '
'.$langs->trans('Date').': '.dol_print_date($this->date, 'day'); - } - if (!empty($this->total_ht)) { - $label .= '
'.$langs->trans('AmountHT').': '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); - } - if (!empty($this->total_tva)) { - $label .= '
'.$langs->trans('AmountVAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); - } - if (!empty($this->total_localtax1) && $this->total_localtax1 != 0) { // We keep test != 0 because $this->total_localtax1 can be '0.00000000' - $label .= '
'.$langs->transcountry('AmountLT1', $mysoc->country_code).': '.price($this->total_localtax1, 0, $langs, 0, -1, -1, $conf->currency); - } - if (!empty($this->total_localtax2) && $this->total_localtax2 != 0) { - $label .= '
'.$langs->transcountry('AmountLT2', $mysoc->country_code).': '.price($this->total_localtax2, 0, $langs, 0, -1, -1, $conf->currency); - } - if (!empty($this->total_ttc)) { - $label .= '
'.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); - } - if ($moretitle) { - $label .= ' - '.$moretitle; - } - } - - $linkclose = ($target ? ' target="'.$target.'"' : ''); + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + 'moretitle' => $moretitle, + 'option' => $option, + ]; $classfortooltip = 'classfortooltip'; $dataparams = ''; if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { - $params = [ - 'id' => $this->id, - 'objecttype' => $this->element, - 'moretitle' => $moretitle, - 'option' => $option, - ]; $classfortooltip = 'classforajaxtooltip'; $dataparams = ' data-params='.json_encode($params); // $label = $langs->trans('Loading'); } + $label = implode($this->getTooltipContentArray($params)); + + $linkclose = ($target ? ' target="'.$target.'"' : ''); if (empty($notooltip) && $user->hasRight("facture", "read")) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("Invoice"); diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php index 8fa0094f219..bb0d8ac162d 100644 --- a/htdocs/delivery/class/delivery.class.php +++ b/htdocs/delivery/class/delivery.class.php @@ -108,6 +108,11 @@ class Delivery extends CommonObject public $commande_id; + /** + * @var array statuts labels + */ + public $statuts; + public $lines = array(); @@ -751,8 +756,18 @@ class Delivery extends CommonObject $result = ''; - $label = img_picto('', $this->picto).' '.$langs->trans("ShowReceiving").':
'; - $label .= ''.$langs->trans("Status").': '.$this->ref; + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + ]; + $classfortooltip = 'classfortooltip'; + $dataparams = ''; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); + // $label = $langs->trans('Loading'); + } + $label = implode($this->getTooltipContentArray($params)); $url = DOL_URL_ROOT.'/delivery/card.php?id='.$this->id; @@ -768,17 +783,6 @@ class Delivery extends CommonObject } //} - $classfortooltip = 'classfortooltip'; - $dataparams = ''; - if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { - $params = [ - 'id' => $this->id, - 'objecttype' => $this->element, - ]; - $classfortooltip = 'classforajaxtooltip'; - $dataparams = ' data-params='.json_encode($params); - // $label = $langs->trans('Loading'); - } $linkstart = ''; $linkend = ''; From 8a5e983d7ea3f8c8ecfffe630510bf6c9fd0e1ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 6 Feb 2023 22:21:54 +0100 Subject: [PATCH 48/62] clean code --- htdocs/comm/propal/class/propal.class.php | 54 +++------ htdocs/commande/class/commande.class.php | 42 ++----- htdocs/mrp/class/mo.class.php | 34 +++--- htdocs/product/class/product.class.php | 106 ++---------------- htdocs/product/stock/class/entrepot.class.php | 33 +++--- .../product/stock/class/productlot.class.php | 34 +++--- 6 files changed, 72 insertions(+), 231 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 51c8c4518b5..3a48230de40 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -3756,36 +3756,22 @@ class Propal extends CommonObject } $result = ''; - $label = ''; + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + 'option' => $option, + ]; + $classfortooltip = 'classfortooltip'; + $dataparams = ''; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); + // $label = $langs->trans('Loading'); + } + $label = implode($this->getTooltipContentArray($params)); + $url = ''; - if ($user->rights->propal->lire) { - $label = img_picto('', $this->picto).' '.$langs->trans("Proposal").''; - if (isset($this->statut)) { - $label .= ' '.$this->getLibStatut(5); - } - if (!empty($this->ref)) { - $label .= '
'.$langs->trans('Ref').': '.$this->ref; - } - if (!empty($this->ref_client)) { - $label .= '
'.$langs->trans('RefCustomer').': '.$this->ref_client; - } - if (!empty($this->total_ht)) { - $label .= '
'.$langs->trans('AmountHT').': '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); - } - if (!empty($this->total_tva)) { - $label .= '
'.$langs->trans('VAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); - } - if (!empty($this->total_ttc)) { - $label .= '
'.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); - } - if (!empty($this->date)) { - $label .= '
'.$langs->trans('Date').': '.dol_print_date($this->date, 'day'); - } - if (!empty($this->delivery_date)) { - $label .= '
'.$langs->trans('DeliveryDate').': '.dol_print_date($this->delivery_date, 'dayhour'); - } - if ($option == '') { $url = DOL_URL_ROOT.'/comm/propal/card.php?id='.$this->id.$get_params; } elseif ($option == 'compta') { // deprecated @@ -3809,18 +3795,6 @@ class Propal 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) && $user->rights->propal->lire) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("Proposal"); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 5f810a8610a..5b111f67e6c 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3804,46 +3804,22 @@ class Commande extends CommonOrder if ($short) { return $url; } - - $label = ''; - - if ($user->hasRight('commande', 'lire')) { - $label = img_picto('', $this->picto).' '.$langs->trans("Order").''; - if (isset($this->statut)) { - $label .= ' '.$this->getLibStatut(5); - } - $label .= '
'.$langs->trans('Ref').': '.$this->ref; - $label .= '
'.$langs->trans('RefCustomer').': '.(empty($this->ref_customer) ? (empty($this->ref_client) ? '' : $this->ref_client) : $this->ref_customer); - if (!empty($this->total_ht)) { - $label .= '
'.$langs->trans('AmountHT').': '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); - } - if (!empty($this->total_tva)) { - $label .= '
'.$langs->trans('VAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); - } - if (!empty($this->total_ttc)) { - $label .= '
'.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); - } - if (!empty($this->date)) { - $label .= '
'.$langs->trans('Date').': '.dol_print_date($this->date, 'day'); - } - if (!empty($this->delivery_date)) { - $label .= '
'.$langs->trans('DeliveryDate').': '.dol_print_date($this->delivery_date, 'dayhour'); - } - } - - $linkclose = ''; + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + 'option' => $option, + ]; $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'); } + + $label = implode($this->getTooltipContentArray($params)); + + $linkclose = ''; if (empty($notooltip) && $user->rights->commande->lire) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("Order"); diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 3ea38f28251..ddfd8a7f57b 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -1123,16 +1123,20 @@ class Mo extends CommonObject } $result = ''; + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + 'option' => $option, + ]; + $classfortooltip = 'classfortooltip'; + $dataparams = ''; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); + // $label = $langs->trans('Loading'); + } - $label = img_picto('', $this->picto).' '.$langs->trans("ManufacturingOrder").''; - if (isset($this->status)) { - $label .= ' '.$this->getLibStatut(5); - } - $label .= '
'; - $label .= ''.$langs->trans('Ref').': '.$this->ref; - if (isset($this->label)) { - $label .= '
'.$langs->trans('Label').': '.$this->label; - } + $label = implode($this->getTooltipContentArray($params)); $url = DOL_URL_ROOT.'/mrp/mo_card.php?id='.$this->id; if ($option == 'production') { @@ -1151,18 +1155,6 @@ class Mo 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("ShowMo"); diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 877bcedecdd..6686b4fce8d 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5125,114 +5125,28 @@ class Product extends CommonObject global $conf, $langs, $hookmanager; include_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; - $result = ''; $label = ''; + $result = ''; $newref = $this->ref; if ($maxlength) { $newref = dol_trunc($newref, $maxlength, 'middle'); } - - if (!empty($this->entity)) { - $tmpphoto = $this->show_photos('product', $conf->product->multidir_output[$this->entity], 1, 1, 0, 0, 0, 80); - if ($this->nbphoto > 0) { - $label .= '
'; - $label .= $tmpphoto; - $label .= '
'; - //$label .= '
'; - } - } - - if ($this->type == Product::TYPE_PRODUCT) { - $label .= img_picto('', 'product').' '.$langs->trans("Product").''; - } elseif ($this->type == Product::TYPE_SERVICE) { - $label .= img_picto('', 'service').' '.$langs->trans("Service").''; - } - if (isset($this->status) && isset($this->status_buy)) { - $label .= ' '.$this->getLibStatut(5, 0); - $label .= ' '.$this->getLibStatut(5, 1); - } - - if (!empty($this->ref)) { - $label .= '
'.$langs->trans('ProductRef').': '.$this->ref; - } - if (!empty($this->label)) { - $label .= '
'.$langs->trans('ProductLabel').': '.$this->label; - } - if ($this->type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - if (isModEnabled('productbatch')) { - $langs->load("productbatch"); - $label .= "
".$langs->trans("ManageLotSerial").': '.$this->getLibStatut(0, 2); - } - } - if (isModEnabled('barcode')) { - $label .= '
'.$langs->trans('BarCode').': '.$this->barcode; - } - - if ($this->type == Product::TYPE_PRODUCT) { - if ($this->weight) { - $label .= "
".$langs->trans("Weight").': '.$this->weight.' '.measuringUnitString(0, "weight", $this->weight_units); - } - $labelsize = ""; - if ($this->length) { - $labelsize .= ($labelsize ? " - " : "")."".$langs->trans("Length").': '.$this->length.' '.measuringUnitString(0, 'size', $this->length_units); - } - if ($this->width) { - $labelsize .= ($labelsize ? " - " : "")."".$langs->trans("Width").': '.$this->width.' '.measuringUnitString(0, 'size', $this->width_units); - } - if ($this->height) { - $labelsize .= ($labelsize ? " - " : "")."".$langs->trans("Height").': '.$this->height.' '.measuringUnitString(0, 'size', $this->height_units); - } - if ($labelsize) { - $label .= "
".$labelsize; - } - - $labelsurfacevolume = ""; - if ($this->surface) { - $labelsurfacevolume .= ($labelsurfacevolume ? " - " : "")."".$langs->trans("Surface").': '.$this->surface.' '.measuringUnitString(0, 'surface', $this->surface_units); - } - if ($this->volume) { - $labelsurfacevolume .= ($labelsurfacevolume ? " - " : "")."".$langs->trans("Volume").': '.$this->volume.' '.measuringUnitString(0, 'volume', $this->volume_units); - } - if ($labelsurfacevolume) { - $label .= "
".$labelsurfacevolume; - } - } - if (!empty($this->pmp) && $this->pmp) { - $label .= "
".$langs->trans("PMPValue").': '.price($this->pmp, 0, '', 1, -1, -1, $conf->currency); - } - - if (isModEnabled('accounting')) { - if ($this->status && isset($this->accountancy_code_sell)) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - $label .= '
'; - $label .= '
'.$langs->trans('ProductAccountancySellCode').': '.length_accountg($this->accountancy_code_sell); - $label .= '
'.$langs->trans('ProductAccountancySellIntraCode').': '.length_accountg($this->accountancy_code_sell_intra); - $label .= '
'.$langs->trans('ProductAccountancySellExportCode').': '.length_accountg($this->accountancy_code_sell_export); - } - if ($this->status_buy && isset($this->accountancy_code_buy)) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - if (empty($this->status)) { - $label .= '
'; - } - $label .= '
'.$langs->trans('ProductAccountancyBuyCode').': '.length_accountg($this->accountancy_code_buy); - $label .= '
'.$langs->trans('ProductAccountancyBuyIntraCode').': '.length_accountg($this->accountancy_code_buy_intra); - $label .= '
'.$langs->trans('ProductAccountancyBuyExportCode').': '.length_accountg($this->accountancy_code_buy_export); - } - } - - $linkclose = ''; + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + 'option' => $option, + ]; $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'); } + + $label = implode($this->getTooltipContentArray($params)); + + $linkclose = ''; if (empty($notooltip)) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("ShowProduct"); diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 5af056d8080..e6d3ecbd236 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -739,15 +739,20 @@ class Entrepot extends CommonObject } $result = ''; + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + 'option' => $option, + ]; + $classfortooltip = 'classfortooltip'; + $dataparams = ''; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); + // $label = $langs->trans('Loading'); + } - $label = img_picto('', $this->picto).' '.$langs->trans("Warehouse").''; - if (isset($this->statut)) { - $label .= ' '.$this->getLibStatut(5); - } - $label .= '
'.$langs->trans('Ref').': '.(empty($this->ref) ? $this->label : $this->ref); - if (!empty($this->lieu)) { - $label .= '
'.$langs->trans('LocationSummary').': '.$this->lieu; - } + $label = implode($this->getTooltipContentArray($params)); $url = DOL_URL_ROOT.'/product/stock/card.php?id='.$this->id; @@ -763,18 +768,6 @@ class Entrepot 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("Warehouse"); diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index 1ddcb073d3f..39a8d5721a9 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -632,16 +632,20 @@ class Productlot extends CommonObject global $menumanager; $result = ''; + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + 'option' => $option, + ]; + $classfortooltip = 'classfortooltip'; + $dataparams = ''; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); + // $label = $langs->trans('Loading'); + } - $label = img_picto('', $this->picto).' '.$langs->trans("Batch").''; - $label .= '
'; - $label .= ''.$langs->trans('Batch').': '.$this->batch; - if ($this->eatby && empty($conf->global->PRODUCT_DISABLE_EATBY)) { - $label .= '
'.$langs->trans('EatByDate').': '.dol_print_date($this->eatby, 'day'); - } - if ($this->sellby && empty($conf->global->PRODUCT_DISABLE_SELLBY)) { - $label .= '
'.$langs->trans('SellByDate').': '.dol_print_date($this->sellby, 'day'); - } + $label = implode($this->getTooltipContentArray($params)); $url = DOL_URL_ROOT.'/product/stock/productlot_card.php?id='.$this->id; @@ -657,18 +661,6 @@ class Productlot 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"); From e5a1b226f3f33c955f6af5e45f8f5596a93948b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 6 Feb 2023 22:28:03 +0100 Subject: [PATCH 49/62] clean code --- htdocs/salaries/class/salary.class.php | 59 ++++++++++++++------------ 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/htdocs/salaries/class/salary.class.php b/htdocs/salaries/class/salary.class.php index d201c4f44c0..acf811b4f88 100644 --- a/htdocs/salaries/class/salary.class.php +++ b/htdocs/salaries/class/salary.class.php @@ -79,6 +79,17 @@ class Salary extends CommonObject */ public $fk_bank; + /** + * @var int + * @see $accountid + */ + public $fk_account; + + /** + * @var int + */ + public $accountid; + /** * @var int ID */ @@ -250,7 +261,8 @@ class Salary extends CommonObject $this->fk_bank = $obj->fk_bank; $this->fk_user_author = $obj->fk_user_author; $this->fk_user_modif = $obj->fk_user_modif; - $this->fk_account = $this->accountid = $obj->fk_account; + $this->fk_account = $obj->fk_account; + $this->accountid = $obj->fk_account; // Retrieve all extrafield // fetch optionals attributes and labels @@ -518,42 +530,35 @@ class Salary extends CommonObject if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips $result = ''; + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + 'option' => $option, + ]; + $classfortooltip = 'classfortooltip'; + $dataparams = ''; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); + // $label = $langs->trans('Loading'); + } - $label = ''.$langs->trans("Salary").''; - $label .= '
'; - $label .= ''.$langs->trans('Ref').': '.$this->ref; - if ($this->label) { - $label .= '
'.$langs->trans('Label').': '.$this->label; - } - if ($this->datesp && $this->dateep) { - $label .= '
'.$langs->trans('Period').': '.dol_print_date($this->datesp, 'day').' - '.dol_print_date($this->dateep, 'day'); - } - if (isset($this->amount)) { - $label .= '
'.$langs->trans('Amount').': '.price($this->amount); - } + $label = implode($this->getTooltipContentArray($params)); $url = DOL_URL_ROOT.'/salaries/card.php?id='.$this->id; if ($option != 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; - if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + $add_save_lastsearch_values = 1; + } + if ($add_save_lastsearch_values) { + $url .= '&save_lastsearch_values=1'; + } } $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"); From 3238d82386f7bca056dad365df819d6c5b10ebc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 6 Feb 2023 22:50:36 +0100 Subject: [PATCH 50/62] clean code --- .../class/fournisseur.commande.class.php | 109 ++++++++------- .../fourn/class/fournisseur.facture.class.php | 67 ++-------- htdocs/societe/class/societe.class.php | 124 +++--------------- 3 files changed, 88 insertions(+), 212 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 2ba0097af33..335bd6b2df4 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -100,14 +100,37 @@ class CommandeFournisseur extends CommonOrder */ public $ref; + /** + * @var string ref supplier + */ public $ref_supplier; + + /** + * @var string ref supplier + * @deprecated + * @see $ref_supplier + */ + public $ref_fourn; + public $brouillon; + /** + * @var int + */ public $statut; // 0=Draft -> 1=Validated -> 2=Approved -> 3=Ordered/Process runing -> 4=Received partially -> 5=Received totally -> (reopen) 4=Received partially // -> 7=Canceled/Never received -> (reopen) 3=Process runing // -> 6=Canceled -> (reopen) 2=Approved // -> 9=Refused -> (reopen) 1=Validated // Note: billed or not is on another field "billed" - public $statuts; // List of status + + /** + * @var array List of status + */ + public $statuts; + + /** + * @var array List of status short + */ + public $statuts_short; public $billed; @@ -169,7 +192,12 @@ class CommandeFournisseur extends CommonOrder */ public $lines = array(); - //Add for supplier_proposal + /** + * @var CommandeFournisseurLigne + */ + public $line; + + // Add for supplier_proposal public $origin; public $origin_id; public $linked_objects = array(); @@ -389,9 +417,9 @@ class CommandeFournisseur extends CommonOrder $this->ref_supplier = $obj->ref_supplier; $this->socid = $obj->fk_soc; $this->fourn_id = $obj->fk_soc; - $this->statut = $obj->fk_statut; - $this->status = $obj->fk_statut; - $this->billed = $obj->billed; + $this->statut = $obj->fk_statut; + $this->status = $obj->fk_statut; + $this->billed = $obj->billed; $this->user_author_id = $obj->fk_user_author; $this->user_valid_id = $obj->fk_user_valid; $this->user_approve_id = $obj->fk_user_approve; @@ -587,10 +615,10 @@ class CommandeFournisseur extends CommonOrder // Multicurrency $line->fk_multicurrency = $objp->fk_multicurrency; $line->multicurrency_code = $objp->multicurrency_code; - $line->multicurrency_subprice = $objp->multicurrency_subprice; - $line->multicurrency_total_ht = $objp->multicurrency_total_ht; - $line->multicurrency_total_tva = $objp->multicurrency_total_tva; - $line->multicurrency_total_ttc = $objp->multicurrency_total_ttc; + $line->multicurrency_subprice = $objp->multicurrency_subprice; + $line->multicurrency_total_ht = $objp->multicurrency_total_ht; + $line->multicurrency_total_tva = $objp->multicurrency_total_tva; + $line->multicurrency_total_ttc = $objp->multicurrency_total_ttc; $line->special_code = $objp->special_code; $line->fk_parent_line = $objp->fk_parent_line; @@ -877,38 +905,21 @@ class CommandeFournisseur extends CommonOrder global $langs, $conf, $user, $hookmanager; $result = ''; - - $label = ''; - - if ($user->hasRight("fournisseur", "commande", "read")) { - $label = ''.$langs->trans("SupplierOrder").''; - if (isset($this->statut)) { - $label .= ' '.$this->getLibStatut(5); - } - if (!empty($this->ref)) { - $label .= '
'.$langs->trans('Ref').': '.$this->ref; - } - if (!empty($this->ref_supplier)) { - $label .= '
'.$langs->trans('RefSupplier').': '.$this->ref_supplier; - } - if (!empty($this->total_ht)) { - $label .= '
'.$langs->trans('AmountHT').': '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); - } - if (!empty($this->total_tva)) { - $label .= '
'.$langs->trans('VAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); - } - if (!empty($this->total_ttc)) { - $label .= '
'.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); - } - if (!empty($this->date)) { - $label .= '
'.$langs->trans('Date').': '.dol_print_date($this->date, 'day'); - } - if (!empty($this->delivery_date)) { - $label .= '
'.$langs->trans('DeliveryDate').': '.dol_print_date($this->delivery_date, 'dayhour'); - } + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + 'option' => $option, + ]; + $classfortooltip = 'classfortooltip'; + $dataparams = ''; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); + // $label = $langs->trans('Loading'); } - $picto = 'order'; + $label = implode($this->getTooltipContentArray($params)); + $url = DOL_URL_ROOT.'/fourn/commande/card.php?id='.$this->id; if ($option !== 'nolink') { @@ -923,18 +934,6 @@ class CommandeFournisseur extends CommonOrder } $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("ShowOrder"); @@ -3702,6 +3701,14 @@ class CommandeFournisseurLigne extends CommonOrderLine * @var string */ public $ref_supplier; + + /** + * @var string ref supplier + * @deprecated + * @see $ref_supplier + */ + public $ref_fourn; + public $remise; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 6572fc29cbb..c6cc2acc722 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -2821,47 +2821,21 @@ class FactureFournisseur extends CommonInvoice if ($this->type == self::TYPE_DEPOSIT) { $picto .= 'd'; // Deposit invoice } + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + 'option' => $option, + 'moretitle' => $moretitle, + ]; + $classfortooltip = 'classfortooltip'; + $dataparams = ''; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); + // $label = $langs->trans('Loading'); + } - $label = img_picto('', $this->picto).' '.$langs->trans("SupplierInvoice").''; - if ($this->type == self::TYPE_REPLACEMENT) { - $label = ''.$langs->transnoentitiesnoconv("InvoiceReplace").''; - } elseif ($this->type == self::TYPE_CREDIT_NOTE) { - $label = ''.$langs->transnoentitiesnoconv("CreditNote").''; - } elseif ($this->type == self::TYPE_DEPOSIT) { - $label = ''.$langs->transnoentitiesnoconv("Deposit").''; - } - if (isset($this->status)) { - $alreadypaid = -1; - if (isset($this->alreadypaid)) { - $alreadypaid = $this->alreadypaid; - } - - $label .= ' '.$this->getLibStatut(5, $alreadypaid); - } - if (!empty($this->ref)) { - $label .= '
'.$langs->trans('Ref').': '.$this->ref; - } - if (!empty($this->ref_supplier)) { - $label .= '
'.$langs->trans('RefSupplier').': '.$this->ref_supplier; - } - if (!empty($this->label)) { - $label .= '
'.$langs->trans('Label').': '.$this->label; - } - if (!empty($this->date)) { - $label .= '
'.$langs->trans('Date').': '.dol_print_date($this->date, 'day'); - } - if (!empty($this->total_ht)) { - $label .= '
'.$langs->trans('AmountHT').': '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); - } - if (!empty($this->total_tva)) { - $label .= '
'.$langs->trans('AmountVAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); - } - if (!empty($this->total_ttc)) { - $label .= '
'.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); - } - if ($moretitle) { - $label .= ' - '.$moretitle; - } + $label = implode($this->getTooltipContentArray($params)); $ref = $this->ref; if (empty($ref)) { @@ -2869,19 +2843,6 @@ class FactureFournisseur extends CommonInvoice } $linkclose = ''; - $classfortooltip = 'classfortooltip'; - $dataparams = ''; - if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { - $params = [ - 'id' => $this->id, - 'objecttype' => $this->element, - 'option' => $option, - 'moretitle' => $moretitle, - ]; - $classfortooltip = 'classforajaxtooltip'; - $dataparams = ' data-params='.json_encode($params); - // $label = $langs->trans('Loading'); - } if (empty($notooltip)) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("ShowSupplierInvoice"); diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 7860ef161c3..bc0e8cff3bd 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2607,7 +2607,7 @@ class Societe extends CommonObject { global $conf, $langs, $user; - $langs->loadLangs(['companies, commercial']); + $langs->loadLangs(['companies', 'commercial']); $datas = []; @@ -2621,9 +2621,6 @@ class Societe extends CommonObject return ['optimize' => $langs->trans("ShowCompany")]; } - $label = ''; - $label2 = ''; - if (!empty($this->logo) && class_exists('Form')) { $photo = '
'; $photo .= Form::showphoto('societe', $this, 0, 40, 0, 'photoref', 'mini', 0); // Important, we must force height so image will have height tags and if image is inside a tooltip, the tooltip manager can calculate height and position correctly the tooltip. @@ -2787,122 +2784,45 @@ class Societe extends CommonObject $name .= ' ('.$this->name_alias.')'; } - $result = ''; $label = ''; $label2 = ''; - $linkstart = ''; $linkend = ''; - - if (!empty($this->logo) && class_exists('Form')) { - $label .= '
'; - $label .= Form::showphoto('societe', $this, 0, 40, 0, 'photoref', 'mini', 0); // Important, we must force height so image will have height tags and if image is inside a tooltip, the tooltip manager can calculate height and position correctly the tooltip. - $label .= '
'; - //$label .= '
'; - } elseif (!empty($this->logo_squarred) && class_exists('Form')) { - /*$label.= '
'; - $label.= Form::showphoto('societe', $this, 0, 40, 0, 'photowithmargin', 'mini', 0); // Important, we must force height so image will have height tags and if image is inside a tooltip, the tooltip manager can calculate height and position correctly the tooltip. - $label.= '
';*/ + $result = ''; + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + 'option' => $option, + ]; + $classfortooltip = 'classfortooltip'; + $dataparams = ''; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); + // $label = $langs->trans('Loading'); } - - $label .= '
'; + $label = implode($this->getTooltipContentArray($params)); + $linkstart = ''; + $linkend = ''; if ($option == 'customer' || $option == 'compta' || $option == 'category') { - $label .= img_picto('', $this->picto).' '.$langs->trans("Customer").''; $linkstart = ''.$langs->trans("Prospect").''; $linkstart = ''.$langs->trans("Supplier").''; $linkstart = ''.$langs->trans("ThirdParty").''; $linkstart = ''.$langs->trans("ThirdParty").''; $linkstart = ''.$langs->trans("ThirdParty").''; $linkstart = ''.$langs->trans("ThirdParty").''; $linkstart = ''.$langs->trans("ThirdParty").''; $linkstart = ''.$langs->trans("ThirdParty").''; $linkstart = 'email; - } - if (!empty($this->phone) || !empty($this->fax)) { - $phonelist = array(); - if ($this->phone) { - $phonelist[] = dol_print_phone($this->phone, $this->country_code, $this->id, 0, '', ' ', 'phone'); - } - if ($this->fax) { - $phonelist[] = dol_print_phone($this->fax, $this->country_code, $this->id, 0, '', ' ', 'fax'); - } - $label .= '
'.implode(' ', $phonelist); - } - - if (!empty($this->address)) { - $label2 .= '
'.$langs->trans("Address").': '.dol_format_address($this, 1, ' ', $langs); // Address + country - } elseif (!empty($this->country_code)) { - $label2 .= '
'.$langs->trans('Country').': '.$this->country_code; - } - if (!empty($this->tva_intra) || (!empty($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP) && strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'vatnumber') !== false)) { - $label2 .= '
'.$langs->trans('VATIntra').': '.dol_escape_htmltag($this->tva_intra); - } - - if (!empty($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP)) { - if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid1') !== false && $langs->trans('ProfId1'.$this->country_code) != '-') { - $label2 .= '
'.$langs->trans('ProfId1'.$this->country_code).': '.$this->idprof1; - } - if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid2') !== false && $langs->trans('ProfId2'.$this->country_code) != '-') { - $label2 .= '
'.$langs->trans('ProfId2'.$this->country_code).': '.$this->idprof2; - } - if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid3') !== false && $langs->trans('ProfId3'.$this->country_code) != '-') { - $label2 .= '
'.$langs->trans('ProfId3'.$this->country_code).': '.$this->idprof3; - } - if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid4') !== false && $langs->trans('ProfId4'.$this->country_code) != '-') { - $label2 .= '
'.$langs->trans('ProfId4'.$this->country_code).': '.$this->idprof4; - } - if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid5') !== false && $langs->trans('ProfId5'.$this->country_code) != '-') { - $label2 .= '
'.$langs->trans('ProfId5'.$this->country_code).': '.$this->idprof5; - } - if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid6') !== false && $langs->trans('ProfId6'.$this->country_code) != '-') { - $label2 .= '
'.$langs->trans('ProfId6'.$this->country_code).': '.$this->idprof6; - } - } - if (!empty($this->code_client) && ($this->client == 1 || $this->client == 3)) { - $label2 .= '
'.$langs->trans('CustomerCode').': '.$this->code_client; - } - if (!empty($this->code_fournisseur) && $this->fournisseur) { - $label2 .= '
'.$langs->trans('SupplierCode').': '.$this->code_fournisseur; - } - if (isModEnabled('accounting') && ($this->client == 1 || $this->client == 3)) { - $label2 .= '
'.$langs->trans('CustomerAccountancyCode').': '.($this->code_compta ? $this->code_compta : $this->code_compta_client); - } - if (isModEnabled('accounting') && $this->fournisseur) { - $label2 .= '
'.$langs->trans('SupplierAccountancyCode').': '.$this->code_compta_fournisseur; - } - $label .= ($label2 ? '
'.$label2 : '').'
'; // Add type of canvas $linkstart .= (!empty($this->canvas) ? '&canvas='.$this->canvas : ''); @@ -2917,18 +2837,6 @@ class Societe extends CommonObject $linkstart .= '"'; $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("ShowCompany"); From ff94600d8f37c16f8425fadb2b081dffe88b015d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 6 Feb 2023 23:00:42 +0100 Subject: [PATCH 51/62] clean code --- htdocs/user/class/user.class.php | 99 +++++---------------------- htdocs/user/class/usergroup.class.php | 38 +++++----- 2 files changed, 36 insertions(+), 101 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 17123f7e40a..ff92cc54ede 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2849,82 +2849,30 @@ class User extends CommonObject $withpictoimg = 0; } - $result = ''; $label = ''; $companylink = ''; - - if (!empty($this->photo)) { - $label .= '
'; - $label .= 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 - $label .= '
'; - //$label .= '
'; + $result = ''; + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + 'infologin' => $infologin, + 'option' => $option, + ]; + $classfortooltip = 'classfortooltip'; + $dataparams = ''; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); + // $label = $langs->trans('Loading'); } - - // Info Login - $label .= '
'; - $label .= img_picto('', $this->picto).' '.$langs->trans("User").''; - $label .= ' '.$this->getLibStatut(4); - $label .= '
'.$langs->trans('Name').': '.dol_string_nohtmltag($this->getFullName($langs, '')); - if (!empty($this->login)) { - $label .= '
'.$langs->trans('Login').': '.dol_string_nohtmltag($this->login); - } - if (!empty($this->job)) { - $label .= '
'.$langs->trans("Job").': '.dol_string_nohtmltag($this->job); - } - $label .= '
'.$langs->trans("Email").': '.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, '', ' ', 'phone'); - } - if ($this->office_fax) { - $phonelist[] = dol_print_phone($this->office_fax, $this->country_code, $this->id, 0, '', ' ', 'fax'); - } - if ($this->user_mobile) { - $phonelist[] = dol_print_phone($this->user_mobile, $this->country_code, $this->id, 0, '', ' ', 'mobile'); - } - $label .= '
'.$langs->trans('Phone').': '.implode(' ', $phonelist); - } - if (!empty($this->admin)) { - $label .= '
'.$langs->trans("Administrator").': '.yn($this->admin); - } - if (!empty($this->accountancy_code) || $option == 'accountancy') { - $label .= '
'.$langs->trans("AccountancyCode").': '.$this->accountancy_code; - } - $company = ''; + $label = implode($this->getTooltipContentArray($params)); + $companylink = ''; if (!empty($this->socid)) { // Add thirdparty for external users - $thirdpartystatic = new Societe($db); + $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")); - $label .= '
'.$langs->trans("Type").': '.$type; - $label .= '
'; - if ($infologin > 0) { - $label .= '
'; - $label .= '
'.$langs->trans("Session").''; - $label .= '
'.$langs->trans("IPAddress").': '.dol_string_nohtmltag(getUserRemoteIP()); - if (!empty($conf->global->MAIN_MODULE_MULTICOMPANY)) { - $label .= '
'.$langs->trans("ConnectedOnMultiCompany").': '.$conf->entity.' (User entity '.$this->entity.')'; - } - $label .= '
'.$langs->trans("AuthenticationMode").': '.dol_string_nohtmltag($_SESSION["dol_authmode"].(empty($dolibarr_main_demo) ? '' : ' (demo)')); - $label .= '
'.$langs->trans("ConnectedSince").': '.dol_print_date($this->datelastlogin, "dayhour", 'tzuser'); - $label .= '
'.$langs->trans("PreviousConnexion").': '.dol_print_date($this->datepreviouslogin, "dayhour", 'tzuser'); - $label .= '
'.$langs->trans("CurrentTheme").': '.dol_string_nohtmltag($conf->theme); - $label .= '
'.$langs->trans("CurrentMenuManager").': '.dol_string_nohtmltag($menumanager->name); - $s = picto_from_langcode($langs->getDefaultLang()); - $label .= '
'.$langs->trans("CurrentUserLanguage").': '.dol_string_nohtmltag(($s ? $s.' ' : '').$langs->getDefaultLang()); - $label .= '
'.$langs->trans("Browser").': '.dol_string_nohtmltag($conf->browser->name.($conf->browser->version ? ' '.$conf->browser->version : '').' ('.$_SERVER['HTTP_USER_AGENT'].')'); - $label .= '
'.$langs->trans("Layout").': '.dol_string_nohtmltag($conf->browser->layout); - $label .= '
'.$langs->trans("Screen").': '.dol_string_nohtmltag($_SESSION['dol_screenwidth'].' x '.$_SESSION['dol_screenheight']); - if ($conf->browser->layout == 'phone') { - $label .= '
'.$langs->trans("Phone").': '.$langs->trans("Yes"); - } - if (!empty($_SESSION["disablemodules"])) { - $label .= '
'.$langs->trans("DisabledModules").':
'.dol_string_nohtmltag(join(', ', explode(',', $_SESSION["disablemodules"]))); - } } + if ($infologin < 0) { $label = ''; } @@ -2947,19 +2895,6 @@ class User extends CommonObject $linkstart = '
$this->id, - 'objecttype' => $this->element, - 'infologin' => $infologin, - 'option' => $option, - ]; - $classfortooltip = 'classforajaxtooltip'; - $dataparams = ' data-params='.json_encode($params); - // $label = $langs->trans('Loading'); - } if (empty($notooltip)) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $langs->load("users"); diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index 8d5a054f646..04554b282d0 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -105,6 +105,11 @@ class UserGroup extends CommonObject private $_tab_loaded = array(); // Array of cache of already loaded permissions + /** + * @var int all_permissions_are_loaded + */ + public $all_permissions_are_loaded; + public $oldcopy; // To contains a clone of this when we need to save old properties of object public $fields = array( @@ -767,13 +772,20 @@ class UserGroup extends CommonObject $withpicto = 0; } - $result = ''; $label = ''; - - $label .= '
'; - $label .= img_picto('', 'group').' '.$langs->trans("Group").'
'; - $label .= ''.$langs->trans('Name').': '.$this->name; - $label .= '
'.$langs->trans("Description").': '.$this->note; - $label .= '
'; + $result = ''; + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + 'option' => $option, + ]; + $classfortooltip = 'classfortooltip'; + $dataparams = ''; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); + // $label = $langs->trans('Loading'); + } + $label = implode($this->getTooltipContentArray($params)); if ($option == 'permissions') { $url = DOL_URL_ROOT.'/user/group/perms.php?id='.$this->id; @@ -793,18 +805,6 @@ class UserGroup 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)) { $langs->load("users"); From 769e28e3c0e4d53c506e049889f059d48ac70e13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 6 Feb 2023 23:08:34 +0100 Subject: [PATCH 52/62] clean code --- htdocs/core/class/commonobject.class.php | 5 +++ .../workstation/class/workstation.class.php | 45 +++++++++++++++---- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index b22424d1171..f1b83861ef5 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -593,6 +593,11 @@ abstract class CommonObject protected $labelStatus; protected $labelStatusShort; + /** + * @var int showphoto_on_popup + */ + public $showphoto_on_popup; + /** * @var array nb used in load_stateboard */ diff --git a/htdocs/workstation/class/workstation.class.php b/htdocs/workstation/class/workstation.class.php index ac51aeae1d2..3adf2f3cd8a 100644 --- a/htdocs/workstation/class/workstation.class.php +++ b/htdocs/workstation/class/workstation.class.php @@ -683,6 +683,29 @@ class Workstation extends CommonObject return $this->setStatusCommon($user, self::STATUS_DISABLED, $notrigger, 'WORKSTATION_DISABLED'); } + /** + * getTooltipContentArray + * + * @param array $params ex option, infologin + * @since v18 + * @return array + */ + public function getTooltipContentArray($params) + { + global $conf, $langs; + + $langs->load('holiday'); + + $datas = []; + $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("Workstation").''; + $datas['ref'] = '
'.$langs->trans('Ref').': '.$this->ref; + if (isset($this->status)) { + $datas['status'] = '
'.$langs->trans("Status").": ".$this->getLibStatut(5); + } + + return $datas; + } + /** * Return a link to the object card (with optionaly the picto) * @@ -703,12 +726,18 @@ class Workstation extends CommonObject $result = ''; - $label = img_picto('', $this->picto).' '.$langs->trans("Workstation").''; - $label .= '
'; - $label .= ''.$langs->trans('Ref').': '.$this->ref; - if (isset($this->status)) { - $label .= '
'.$langs->trans("Status").": ".$this->getLibStatut(5); + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + ]; + $classfortooltip = 'classfortooltip'; + $dataparams = ''; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); + // $label = $langs->trans('Loading'); } + $label = implode($this->getTooltipContentArray($params)); $url = dol_buildpath('/workstation/workstation_card.php', 1).'?id='.$this->id; @@ -729,8 +758,8 @@ class Workstation extends CommonObject $label = $langs->trans("ShowWorkstation"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + $linkclose .= $dataparams.' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"'; } else { $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); } @@ -743,7 +772,7 @@ class Workstation extends CommonObject if (empty($this->showphoto_on_popup)) { if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'mrp'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'mrp'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); } } else { if ($withpicto) { From 31d5547e33e96dde2e74b0ca2e18dfaea5dca479 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 7 Feb 2023 13:48:07 +0100 Subject: [PATCH 53/62] clean code --- .../class/supplier_proposal.class.php | 44 ++++++------------- 1 file changed, 13 insertions(+), 31 deletions(-) diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index d7013c596b0..fbd95b25738 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -2529,26 +2529,20 @@ class SupplierProposal extends CommonObject $url = ''; $result = ''; + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + 'option' => $option, + ]; + $classfortooltip = 'classfortooltip'; + $dataparams = ''; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); + // $label = $langs->trans('Loading'); + } - $label = img_picto('', $this->picto).' '.$langs->trans("SupplierProposal").''; - if (isset($this->status)) { - $label .= ' '.$this->getLibStatut(5); - } - if (!empty($this->ref)) { - $label .= '
'.$langs->trans('Ref').': '.$this->ref; - } - if (!empty($this->ref_fourn)) { - $label .= '
'.$langs->trans('RefSupplier').': '.$this->ref_fourn; - } - if (!empty($this->total_ht)) { - $label .= '
'.$langs->trans('AmountHT').': '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); - } - if (!empty($this->total_tva)) { - $label .= '
'.$langs->trans('VAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); - } - if (!empty($this->total_ttc)) { - $label .= '
'.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); - } + $label = implode($this->getTooltipContentArray($params)); if ($option == '') { $url = DOL_URL_ROOT.'/supplier_proposal/card.php?id='.$this->id.$get_params; @@ -2569,18 +2563,6 @@ class SupplierProposal 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) && $user->rights->propal->lire) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("ShowSupplierProposal"); From 2fd6b9438fb835bd865d86cc32e3c67ae62abc5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 7 Feb 2023 13:55:36 +0100 Subject: [PATCH 54/62] add ajax tooltip on ticket --- htdocs/ticket/class/ticket.class.php | 57 +++++++++++++++++++++------- 1 file changed, 43 insertions(+), 14 deletions(-) diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 5faea34ad6c..3be6e282875 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -1400,6 +1400,34 @@ class Ticket extends CommonObject return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode, '', $params); } + /** + * getTooltipContentArray + * + * @param array $params ex option, infologin + * @since v18 + * @return array + */ + public function getTooltipContentArray($params) + { + global $langs; + + $langs->load('ticket'); + + $datas = []; + $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("Ticket").''; + $datas['picto'] .= ' '.$this->getLibStatut(4); + $datas['ref'] = '
'.$langs->trans('Ref').': '.$this->ref; + $datas['track_id'] = '
'.$langs->trans('TicketTrackId').': '.$this->track_id; + $datas['subject'] = '
'.$langs->trans('Subject').': '.$this->subject; + if ($this->date_creation) { + $datas['date_creation'] = '
'.$langs->trans('DateCreation').': '.$this->date_creation; + } + if ($this->date_modification) { + $datas['date_modification'] = '
'.$langs->trans('DateModification').': '.$this->date_modification; + } + + return $datas; + } /** * Return a link to the object card (with optionaly the picto) @@ -1423,18 +1451,19 @@ class Ticket extends CommonObject $result = ''; - $label = img_picto('', $this->picto).' '.$langs->trans("Ticket").''; - $label .= ' '.$this->getLibStatut(4); - $label .= '
'; - $label .= ''.$langs->trans('Ref').': '.$this->ref.'
'; - $label .= ''.$langs->trans('TicketTrackId').': '.$this->track_id.'
'; - $label .= ''.$langs->trans('Subject').': '.$this->subject; - if ($this->date_creation) { - $label .= '
'.$langs->trans('DateCreation').': '.$this->date_creation; - } - if ($this->date_modification) { - $label .= '
'.$langs->trans('DateModification').': '.$this->date_modification; + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + ]; + $classfortooltip = 'classfortooltip'; + $dataparams = ''; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); + // $label = $langs->trans('Loading'); } + $label = implode($this->getTooltipContentArray($params)); + $url = DOL_URL_ROOT.'/ticket/card.php?id='.$this->id; if ($option != 'nolink') { @@ -1454,8 +1483,8 @@ class Ticket extends CommonObject $label = $langs->trans("ShowTicket"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + $linkclose .= $dataparams.' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"'; } else { $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); } @@ -1466,7 +1495,7 @@ class Ticket extends CommonObject $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->ref; From df411abe414edf82363c00a1346f45e02c7f7218 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 7 Feb 2023 14:07:27 +0100 Subject: [PATCH 55/62] add ajax tooltip on task --- htdocs/core/ajax/ajaxtooltip.php | 3 +- htdocs/projet/class/task.class.php | 56 +++++++++++++++++++++++------- 2 files changed, 44 insertions(+), 15 deletions(-) diff --git a/htdocs/core/ajax/ajaxtooltip.php b/htdocs/core/ajax/ajaxtooltip.php index a72b57c4ebe..7afbc88ae17 100644 --- a/htdocs/core/ajax/ajaxtooltip.php +++ b/htdocs/core/ajax/ajaxtooltip.php @@ -130,8 +130,7 @@ if ($objecttype == 'facture' || $objecttype == 'invoice') { $langs->load('projects'); $classpath = 'projet/class'; $module = 'projet'; -} elseif ($objecttype == 'task') { - $langs->load('projects'); +} elseif ($objecttype == 'project_task') { $classpath = 'projet/class'; $module = 'projet'; $myobject = 'task'; diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 597e680f8f0..1a4f96bacc6 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -2,7 +2,7 @@ /* Copyright (C) 2008-2014 Laurent Destailleur * Copyright (C) 2010-2012 Regis Houssin * Copyright (C) 2014 Marcos García - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2023 Frédéric France * Copyright (C) 2020 Juanjo Menent * Copyright (C) 2022 Charlene Benke * @@ -696,6 +696,34 @@ class Task extends CommonObjectLine } + /** + * getTooltipContentArray + * + * @param array $params ex option, infologin + * @since v18 + * @return array + */ + public function getTooltipContentArray($params) + { + global $langs; + + $langs->load('projects'); + + $datas = []; + $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("Task").''; + if (!empty($this->ref)) { + $datas['ref'] = '
'.$langs->trans('Ref').': '.$this->ref; + } + if (!empty($this->label)) { + $datas['label'] = '
'.$langs->trans('LabelTask').': '.$this->label; + } + if ($this->date_start || $this->date_end) { + $datas['range'] = "
".get_date_range($this->date_start, $this->date_end, '', $langs, 0); + } + + return $datas; + } + /** * Return clicable name (with picto eventually) * @@ -717,16 +745,18 @@ class Task extends CommonObjectLine } $result = ''; - $label = img_picto('', $this->picto).' '.$langs->trans("Task").''; - if (!empty($this->ref)) { - $label .= '
'.$langs->trans('Ref').': '.$this->ref; - } - if (!empty($this->label)) { - $label .= '
'.$langs->trans('LabelTask').': '.$this->label; - } - if ($this->date_start || $this->date_end) { - $label .= "
".get_date_range($this->date_start, $this->date_end, '', $langs, 0); + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + ]; + $classfortooltip = 'classfortooltip'; + $dataparams = ''; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); + // $label = $langs->trans('Loading'); } + $label = implode($this->getTooltipContentArray($params)); $url = DOL_URL_ROOT.'/projet/tasks/'.$mode.'.php?id='.$this->id.($option == 'withproject' ? '&withproject=1' : ''); // Add param to save lastsearch_values or not @@ -744,8 +774,8 @@ class Task extends CommonObjectLine $label = $langs->trans("ShowTask"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip nowraponall"'; + $linkclose .= $dataparams.' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="'.$classfortooltip.' nowraponall"'; } else { $linkclose .= ' class="nowraponall"'; } @@ -758,7 +788,7 @@ class Task extends CommonObjectLine $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), $picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), $picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->ref; From eef350d1d37af2a9d531d73f292956c529d84e1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 7 Feb 2023 21:44:39 +0100 Subject: [PATCH 56/62] add ajax tooltip on dolresource --- .../adherents/class/adherent_type.class.php | 3 +- htdocs/core/ajax/ajaxtooltip.php | 5 +- .../class/emailcollector.class.php | 3 +- htdocs/langs/en_US/dict.lang | 1 + htdocs/resource/class/dolresource.class.php | 55 +++++++++++++++---- 5 files changed, 52 insertions(+), 15 deletions(-) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 9819110e6bc..a744ce71bdc 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -698,8 +698,9 @@ class AdherentType extends CommonObject { global $conf, $langs, $user; - $datas = []; + $langs->load('members'); + $datas = []; $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("MemberType").' '.$this->getLibStatut(4); $datas['label'] = '
'.$langs->trans("Label").': '.$this->label; if (isset($this->subscription)) { diff --git a/htdocs/core/ajax/ajaxtooltip.php b/htdocs/core/ajax/ajaxtooltip.php index 7afbc88ae17..d10b0f1a43e 100644 --- a/htdocs/core/ajax/ajaxtooltip.php +++ b/htdocs/core/ajax/ajaxtooltip.php @@ -154,6 +154,10 @@ if ($objecttype == 'facture' || $objecttype == 'invoice') { $classpath = 'user/class'; $module = 'user'; $myobject = 'usergroup'; +} elseif ($objecttype == 'dolresource') { + $classpath = 'resource/class'; + $module = 'resource'; + $myobject = 'dolresource'; } // Generic case for $classfile and $classname @@ -189,7 +193,6 @@ if ($objecttype == 'invoice_supplier') { $classfile = 'mailing'; $classname = 'Mailing'; } elseif ($objecttype == 'adherent_type') { - $langs->load('members'); $classpath = 'adherents/class'; $classfile = 'adherent_type'; $module = 'adherent'; diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 13fcbfbef6b..f832a6ff842 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -382,11 +382,10 @@ class EmailCollector extends CommonObject // Clear fields $object->ref = "copy_of_".$object->ref; - $object->title = $langs->trans("CopyOf")." ".$object->title; + $object->label = $langs->trans("CopyOf")." ".$object->label; if (empty($object->host)) { $object->host = 'imap.example.com'; } - // ... // Clear extrafields that are unique if (is_array($object->array_options) && count($object->array_options) > 0) { $extrafields->fetch_name_optionals_label($this->table_element); diff --git a/htdocs/langs/en_US/dict.lang b/htdocs/langs/en_US/dict.lang index 00ab5a05f24..e3b159e50de 100644 --- a/htdocs/langs/en_US/dict.lang +++ b/htdocs/langs/en_US/dict.lang @@ -247,6 +247,7 @@ CountryJE=Jersey CountryME=Montenegro CountryBL=Saint Barthelemy CountryMF=Saint Martin +CountryXK=Kosovo ##### Civilities ##### CivilityMME=Mrs. diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index 99cc586cbb9..5d0c0481b98 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -52,6 +52,9 @@ class Dolresource extends CommonObject public $type_label; + /** + * @var string description + */ public $description; public $fk_country; @@ -761,6 +764,33 @@ class Dolresource extends CommonObject } } + /** + * getTooltipContentArray + * + * @param array $params ex option, infologin + * @since v18 + * @return array + */ + public function getTooltipContentArray($params) + { + global $conf, $langs; + + $langs->load('resource'); + + $datas = []; + + $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("Resource").''; + $datas['ref'] = '
'.$langs->trans('Ref').': '.$this->ref; + /*if (isset($this->status)) { + $datas['status'] = '
' . $langs->trans("Status").": ".$this->getLibStatut(5); + }*/ + if (isset($this->type_label)) { + $datas['label'] = '
'.$langs->trans("ResourceType").": ".$this->type_label; + } + + return $datas; + } + /** * Return clicable link of object (with eventually picto) * @@ -777,15 +807,18 @@ class Dolresource extends CommonObject global $conf, $langs, $hookmanager; $result = ''; - $label = img_picto('', $this->picto).' '.$langs->trans("Resource").''; - $label .= '
'; - $label .= ''.$langs->trans('Ref').': '.$this->ref; - /*if (isset($this->status)) { - $label.= '
' . $langs->trans("Status").": ".$this->getLibStatut(5); - }*/ - if (isset($this->type_label)) { - $label .= '
'.$langs->trans("ResourceType").": ".$this->type_label; + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + ]; + $classfortooltip = 'classfortooltip'; + $dataparams = ''; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); + // $label = $langs->trans('Loading'); } + $label = implode($this->getTooltipContentArray($params)); $url = DOL_URL_ROOT.'/resource/card.php?id='.$this->id; @@ -806,8 +839,8 @@ class Dolresource extends CommonObject $label = $langs->trans("ShowMyObject"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + $linkclose .= $dataparams.' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"'; } else { $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); } @@ -820,7 +853,7 @@ class Dolresource extends CommonObject $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->ref; From 019802ec33a75f61530dddc2fbd8adfda37585e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 7 Feb 2023 22:12:47 +0100 Subject: [PATCH 57/62] add ajax tooltip on project --- htdocs/projet/class/project.class.php | 88 ++++++++++++++++++--------- 1 file changed, 60 insertions(+), 28 deletions(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 6eb7384c11d..adc617e55c2 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1244,6 +1244,50 @@ class Project extends CommonObject return dolGetStatus($langs->transnoentitiesnoconv($this->statuts_long[$status]), $langs->transnoentitiesnoconv($this->statuts_short[$status]), '', $statusClass, $mode); } + /** + * getTooltipContentArray + * + * @param array $params ex option, infologin + * @since v18 + * @return array + */ + public function getTooltipContentArray($params) + { + global $conf, $langs; + + $langs->load('projects'); + $option = $params['option'] ?? ''; + $moreinpopup = $params['morinpopup'] ?? ''; + + $datas = []; + if ($option != 'nolink') { + $datas['picto'] = img_picto('', $this->picto, 'class="pictofixedwidth"').' '.$langs->trans("Project").''; + } + if (isset($this->status)) { + $datas['picto'] .= ' '.$this->getLibStatut(5); + } + $datas['ref'] = (isset($datas['picto']) ? '
' : '').''.$langs->trans('Ref').': '.$this->ref; // The space must be after the : to not being explode when showing the title in img_picto + $datas['label'] = '
'.$langs->trans('Label').': '.$this->title; // The space must be after the : to not being explode when showing the title in img_picto + if (isset($this->public)) { + $datas['visibility'] = '
'.$langs->trans("Visibility").": "; + $datas['visibility'] .= ($this->public ? img_picto($langs->trans('SharedProject'), 'world', 'class="pictofixedwidth"').$langs->trans("SharedProject") : img_picto($langs->trans('PrivateProject'), 'private', 'class="pictofixedwidth"').$langs->trans("PrivateProject")); + } + if (!empty($this->thirdparty_name)) { + $datas['thirdparty'] = '
'.$langs->trans('ThirdParty').': '.$this->thirdparty_name; // The space must be after the : to not being explode when showing the title in img_picto + } + if (!empty($this->date_start)) { + $datas['datestart'] = '
'.$langs->trans('DateStart').': '.dol_print_date($this->date_start, 'day'); // The space must be after the : to not being explode when showing the title in img_picto + } + if (!empty($this->date_end)) { + $datas['dateend'] = '
'.$langs->trans('DateEnd').': '.dol_print_date($this->date_end, 'day'); // The space must be after the : to not being explode when showing the title in img_picto + } + if ($moreinpopup) { + $datas['moreinpopup'] = '
'.$moreinpopup; + } + + return $datas; + } + /** * Return clickable name (with picto eventually) * @@ -1269,32 +1313,20 @@ class Project extends CommonObject if (!empty($conf->global->PROJECT_OPEN_ALWAYS_ON_TAB)) { $option = $conf->global->PROJECT_OPEN_ALWAYS_ON_TAB; } - - $label = ''; - if ($option != 'nolink') { - $label = img_picto('', $this->picto, 'class="pictofixedwidth"').' '.$langs->trans("Project").''; - } - if (isset($this->status)) { - $label .= ' '.$this->getLibStatut(5); - } - $label .= ($label ? '
' : '').''.$langs->trans('Ref').': '.$this->ref; // The space must be after the : to not being explode when showing the title in img_picto - $label .= ($label ? '
' : '').''.$langs->trans('Label').': '.$this->title; // The space must be after the : to not being explode when showing the title in img_picto - if (isset($this->public)) { - $label .= '
'.$langs->trans("Visibility").": "; - $label .= ($this->public ? img_picto($langs->trans('SharedProject'), 'world', 'class="pictofixedwidth"').$langs->trans("SharedProject") : img_picto($langs->trans('PrivateProject'), 'private', 'class="pictofixedwidth"').$langs->trans("PrivateProject")); - } - if (!empty($this->thirdparty_name)) { - $label .= ($label ? '
' : '').''.$langs->trans('ThirdParty').': '.$this->thirdparty_name; // The space must be after the : to not being explode when showing the title in img_picto - } - if (!empty($this->date_start)) { - $label .= ($label ? '
' : '').''.$langs->trans('DateStart').': '.dol_print_date($this->date_start, 'day'); // The space must be after the : to not being explode when showing the title in img_picto - } - if (!empty($this->date_end)) { - $label .= ($label ? '
' : '').''.$langs->trans('DateEnd').': '.dol_print_date($this->date_end, 'day'); // The space must be after the : to not being explode when showing the title in img_picto - } - if ($moreinpopup) { - $label .= '
'.$moreinpopup; + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + 'moreinpopup' => $moreinpopup, + 'option' => $option, + ]; + $classfortooltip = 'classfortooltip'; + $dataparams = ''; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); + // $label = $langs->trans('Loading'); } + $label = implode($this->getTooltipContentArray($params)); $url = ''; if ($option != 'nolink') { @@ -1325,8 +1357,8 @@ class Project extends CommonObject $label = $langs->trans("ShowProject"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + $linkclose .= $dataparams.' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"'; } else { $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); } @@ -1342,7 +1374,7 @@ class Project extends CommonObject $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), $picto, ($notooltip ? (($withpicto != 2) ? 'class="pictofixedwidth"' : '') : 'class="'.(($withpicto != 2) ? 'pictofixedwidth ' : '').'classfortooltip pictofixedwidth em088"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), $picto, ($notooltip ? (($withpicto != 2) ? 'class="pictofixedwidth"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'pictofixedwidth ' : '').$classfortooltip.' pictofixedwidth em088"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->ref; From 3f8aaf5cbc3f0f3532a4737e2bf9b97f9d0c674e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 8 Feb 2023 21:30:55 +0100 Subject: [PATCH 58/62] clean code --- .../class/expensereport.class.php | 65 ++++++++++++++----- 1 file changed, 50 insertions(+), 15 deletions(-) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 38c39d96b6f..685626ef6ff 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2015 Laurent Destailleur * Copyright (C) 2015 Alexandre Spangaro * Copyright (C) 2018 Nicolas ZABOURI - * Copyright (c) 2018-2021 Frédéric France + * Copyright (c) 2018-2023 Frédéric France * Copyright (C) 2016-2020 Ferran Marcet * * This program is free software; you can redistribute it and/or modify @@ -60,8 +60,16 @@ class ExpenseReport extends CommonObject */ public $picto = 'trip'; + /** + * @var ExpenseReportLine[] array of expensereport lines + */ public $lines = array(); + /** + * @var ExpenseReportLine expensereport lines + */ + public $line; + public $date_debut; public $date_fin; @@ -93,6 +101,15 @@ class ExpenseReport extends CommonObject // Create public $date_create; + + /** + * @var int ID of user creator + */ + public $fk_user_creat; + + /** + * @var int ID of user who reclaim expense report + */ public $fk_user_author; // Note fk_user_author is not the 'author' but the guy the expense report is for. // Update @@ -107,15 +124,34 @@ class ExpenseReport extends CommonObject // Annulation public $date_cancel; public $detail_cancel; + + /** + * @var int ID of user who cancel expense report + */ public $fk_user_cancel; - public $fk_user_validator; // User that is defined to approve + /** + * @var int User that is defined to approve + */ + public $fk_user_validator; - // Validation - /* @deprecated */ + /** + * Validation date + * @var int + * @deprecated + * @see $date_valid + */ public $datevalid; - public $date_valid; // User making validation + /** + * Validation date + * @var int + */ + public $date_valid; + + /** + * @var int ID of User making validation + */ public $fk_user_valid; public $user_valid_infos; @@ -154,16 +190,15 @@ class ExpenseReport extends CommonObject */ const STATUS_APPROVED = 5; - /** - * Classified refused - */ - const STATUS_REFUSED = 99; - /** * Classified paid. */ const STATUS_CLOSED = 6; + /** + * Classified refused + */ + const STATUS_REFUSED = 99; public $fields = array( 'rowid' =>array('type'=>'integer', 'label'=>'ID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), @@ -434,12 +469,12 @@ class ExpenseReport extends CommonObject $this->fk_statut = 0; // deprecated // Clear fields - $this->fk_user_creat = $user->id; - $this->fk_user_author = $fk_user_author; // Note fk_user_author is not the 'author' but the guy the expense report is for. - $this->fk_user_valid = ''; + $this->fk_user_creat = $user->id; + $this->fk_user_author = $fk_user_author; // Note fk_user_author is not the 'author' but the guy the expense report is for. + $this->fk_user_valid = ''; $this->date_create = ''; - $this->date_creation = ''; - $this->date_validation = ''; + $this->date_creation = ''; + $this->date_validation = ''; // Remove link on lines to a joined file if (is_array($this->lines) && count($this->lines) > 0) { From 2c7a01848c9c5a70d7ebd71473e02946a9a9bb7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 8 Feb 2023 22:12:28 +0100 Subject: [PATCH 59/62] add ajax tooltip on partnership --- .../partnership/class/partnership.class.php | 48 +++++++++++++++---- 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index a9645efaae2..a202bdbd284 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -145,6 +145,7 @@ class Partnership extends CommonObject public $last_check_backlink; public $reason_decline_or_cancel; public $fk_soc; + public $fk_member; // END MODULEBUILDER PROPERTIES @@ -938,6 +939,29 @@ class Partnership extends CommonObject return $this->setStatusCommon($user, self::STATUS_APPROVED, $notrigger, 'PARTNERSHIP_REOPEN'); } + /** + * getTooltipContentArray + * + * @param array $params ex option, infologin + * @since v18 + * @return array + */ + public function getTooltipContentArray($params) + { + global $langs; + + $langs->load('partnership'); + + $datas = []; + $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("Partnership").''; + if (isset($this->status)) { + $datas['picto'] .= ' '.$this->getLibStatut(5); + } + $datas['ref'] = '
'.$langs->trans('Ref').': '.$this->ref; + + return $datas; + } + /** * Return a link to the object card (with optionaly the picto) * @@ -957,13 +981,19 @@ class Partnership extends CommonObject } $result = ''; - - $label = img_picto('', $this->picto).' '.$langs->trans("Partnership").''; - if (isset($this->status)) { - $label .= ' '.$this->getLibStatut(5); + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + 'option' => $option, + ]; + $classfortooltip = 'classfortooltip'; + $dataparams = ''; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); + // $label = $langs->trans('Loading'); } - $label .= '
'; - $label .= ''.$langs->trans('Ref').': '.$this->ref; + $label = implode($this->getTooltipContentArray($params)); $url = DOL_URL_ROOT.'/partnership/partnership_card.php?id='.$this->id; @@ -984,8 +1014,8 @@ class Partnership extends CommonObject $label = $langs->trans("ShowPartnership"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + $linkclose .= $dataparams.' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"'; } else { $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); } @@ -1006,7 +1036,7 @@ class Partnership extends CommonObject if (empty($this->showphoto_on_popup)) { if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); } } else { if ($withpicto) { From dc97584f87638d8591664f21023c7b2e31933e53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 8 Feb 2023 22:20:46 +0100 Subject: [PATCH 60/62] add ajax tooltip on intervention --- htdocs/fichinter/class/fichinter.class.php | 52 +++++++++++++++------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 66645583216..428f0f0767b 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -770,6 +770,29 @@ class Fichinter extends CommonObject return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statuscode, $mode); } + /** + * getTooltipContentArray + * + * @param array $params ex option, infologin + * @since v18 + * @return array + */ + public function getTooltipContentArray($params) + { + global $conf, $langs; + + $langs->load('fichinter'); + + $datas = []; + $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("Intervention").''; + if (isset($this->status)) { + $datas['picto'] .= ' '.$this->getLibStatut(5); + } + $datas['ref'] = '
'.$langs->trans('Ref').': '.$this->ref; + + return $datas; + } + /** * Return clicable name (with picto eventually) * @@ -784,12 +807,18 @@ class Fichinter extends CommonObject global $conf, $langs, $hookmanager; $result = ''; - - $label = img_picto('', $this->picto).' '.$langs->trans("Intervention").''; - if (isset($this->status)) { - $label .= ' '.$this->getLibStatut(5); + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + ]; + $classfortooltip = 'classfortooltip'; + $dataparams = ''; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); + // $label = $langs->trans('Loading'); } - $label .= '
'.$langs->trans('Ref').': '.$this->ref; + $label = implode($this->getTooltipContentArray($params)); $url = DOL_URL_ROOT.'/fichinter/card.php?id='.$this->id; @@ -810,15 +839,8 @@ class Fichinter extends CommonObject $label = $langs->trans("ShowIntervention"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip"'; - - /* - $hookmanager->initHooks(array('fichinterdao')); - $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; - */ + $linkclose .= $dataparams.' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="'.$classfortooltip.'"'; } $linkstart = '
picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->ref; From 3e7b74557a7e20b9e68603bfcf8153d4be1a4cae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 8 Feb 2023 22:23:40 +0100 Subject: [PATCH 61/62] add ajax tooltip on intervention --- htdocs/fichinter/class/fichinter.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 428f0f0767b..7070f94ab23 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -159,7 +159,7 @@ class Fichinter extends CommonObject public $extraparams = array(); /** - * @var array lines + * @var FichinterLigne[] lines */ public $lines = array(); From eee645bb0655bba2512618b139741ef02886ff30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 8 Feb 2023 23:01:04 +0100 Subject: [PATCH 62/62] add ajax tooltip on opensurvey --- htdocs/core/ajax/ajaxtooltip.php | 7 ++- .../class/opensurveysondage.class.php | 44 +++++++++++++++---- 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/htdocs/core/ajax/ajaxtooltip.php b/htdocs/core/ajax/ajaxtooltip.php index d10b0f1a43e..60220a221ff 100644 --- a/htdocs/core/ajax/ajaxtooltip.php +++ b/htdocs/core/ajax/ajaxtooltip.php @@ -41,7 +41,8 @@ include_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; top_httphead(); -$id = GETPOST('id', 'int'); +// opensurvey as aZ09 id +$id = GETPOST('id', 'aZ09'); $objecttype = GETPOST('objecttype', 'aZ09'); $html = ''; @@ -158,6 +159,10 @@ if ($objecttype == 'facture' || $objecttype == 'invoice') { $classpath = 'resource/class'; $module = 'resource'; $myobject = 'dolresource'; +} elseif ($objecttype == 'opensurvey_sondage') { + $classpath = 'opensurvey/class'; + $module = 'opensurvey'; + $myobject = 'opensurveysondage'; } // Generic case for $classfile and $classname diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php index f5dadd90f2e..e928c2f3cd6 100644 --- a/htdocs/opensurvey/class/opensurveysondage.class.php +++ b/htdocs/opensurvey/class/opensurveysondage.class.php @@ -420,6 +420,27 @@ class Opensurveysondage extends CommonObject } } + /** + * getTooltipContentArray + * + * @param array $params ex option, infologin + * @since v18 + * @return array + */ + public function getTooltipContentArray($params) + { + global $conf, $langs; + + $langs->load('opensurvey'); + + $datas = []; + $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("ShowSurvey").''; + $datas['ref'] = '
'.$langs->trans('Ref').': '.$this->ref; + $datas['title'] = '
'.$langs->trans('Title').': '.$this->title; + + return $datas; + } + /** * Return a link to the object card (with optionaly the picto) * @@ -440,11 +461,18 @@ class Opensurveysondage extends CommonObject } $result = ''; - - $label = img_picto('', $this->picto).' '.$langs->trans("ShowSurvey").''; - $label .= '
'; - $label .= ''.$langs->trans('Ref').': '.$this->ref.'
'; - $label .= ''.$langs->trans('Title').': '.$this->title.'
'; + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + ]; + $classfortooltip = 'classfortooltip'; + $dataparams = ''; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); + // $label = $langs->trans('Loading'); + } + $label = implode($this->getTooltipContentArray($params)); $url = DOL_URL_ROOT.'/opensurvey/card.php?id='.$this->id; @@ -463,8 +491,8 @@ class Opensurveysondage extends CommonObject $label = $langs->trans("ShowMyObject"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + $linkclose .= $dataparams.' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"'; } else { $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); } @@ -475,7 +503,7 @@ class Opensurveysondage extends CommonObject $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->ref;