From dddd4186a864b53574b61d65d850c28ccf5c2fb0 Mon Sep 17 00:00:00 2001 From: lvessiller Date: Mon, 13 Jun 2022 15:37:43 +0200 Subject: [PATCH 1/2] NEW show product label on inventory --- htdocs/core/class/commonobject.class.php | 11 ++++++++- .../fourn/class/fournisseur.product.class.php | 20 ++++++++++++---- htdocs/product/class/product.class.php | 24 ++++++++++++------- .../inventory/class/inventory.class.php | 2 +- 4 files changed, 41 insertions(+), 16 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 1f64741385f..1f258fa2ba4 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7556,11 +7556,20 @@ abstract class CommonObject if ($classname && class_exists($classname)) { $object = new $classname($this->db); if ($object->element === 'product') { // Special cas for product because default valut of fetch are wrong + $getnomurlparam3 = (!isset($InfoFieldList[5]) ? 0 : $InfoFieldList[5]); + $getnomurlparam4 = (!isset($InfoFieldList[6]) ? -1 : $InfoFieldList[6]); + $getnomurlparam5 = (!isset($InfoFieldList[7]) ? 0 : $InfoFieldList[7]); + $getnomurlparam6 = (!isset($InfoFieldList[8]) ? 0 : $InfoFieldList[8]); + + /** + * @var Product $object + */ $object->fetch($value, '', '', '', 0, 1, 1); + $value = $object->getNomUrl($getnomurlparam, $getnomurlparam2, $getnomurlparam3, $getnomurlparam4, $getnomurlparam5, $getnomurlparam6); } else { $object->fetch($value); + $value = $object->getNomUrl($getnomurlparam, $getnomurlparam2); } - $value = $object->getNomUrl($getnomurlparam, $getnomurlparam2); } } else { dol_syslog('Error bad setup of extrafield', LOG_WARNING); diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index d113eadd8a7..774dd192659 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -1091,12 +1091,15 @@ class ProductFournisseur extends Product * * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) * @param string $option On what the link point to ('nolink', ...) - * @param int $notooltip 1=Disable tooltip - * @param string $morecss Add more css on link + * @param int $maxlength Maxlength of ref * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param int $notooltip No tooltip + * @param int $add_label 0=Default, 1=Add label into string, >1=Add first chars into string + * @param string $sep ' - '=Separator between ref and label if option 'add_label' is set + * @param string $morecss ''=Add more css on link * @return string String with URL */ - public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $maxlength = 0, $save_lastsearch_value = -1, $notooltip = 0, $add_label = 0, $sep = ' - ', $morecss = '') { global $db, $conf, $langs, $hookmanager; @@ -1107,6 +1110,11 @@ class ProductFournisseur extends Product $result = ''; $label = ''; + $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) { @@ -1228,10 +1236,12 @@ class ProductFournisseur extends Product $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); } if ($withpicto != 2) { - $result .= $this->ref.($this->ref_supplier ? ' ('.$this->ref_supplier.')' : ''); + $result .= $newref.($this->ref_supplier ? ' ('.$this->ref_supplier.')' : ''); } $result .= $linkend; - //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + if ($withpicto != 2) { + $result .= (($add_label && $this->label) ? $sep.dol_trunc($this->label, ($add_label > 1 ? $add_label : 0)) : ''); + } global $action; $hookmanager->initHooks(array($this->element . 'dao')); diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 5a7990cd0a7..c5eb211de2c 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4882,14 +4882,17 @@ class Product extends CommonObject /** * Return clicable link of object (with eventually picto) * - * @param int $withpicto Add picto into link - * @param string $option Where point the link ('stock', 'composition', 'category', 'supplier', '') - * @param int $maxlength Maxlength of ref - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @param int $notooltip No tooltip - * @return string String with URL + * @param int $withpicto Add picto into link + * @param string $option Where point the link ('stock', 'composition', 'category', 'supplier', '') + * @param int $maxlength Maxlength of ref + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param int $notooltip No tooltip + * @param int $add_label 0=Default, 1=Add label into string, >1=Add first chars into string + * @param string $sep ' - '=Separator between ref and label if option 'add_label' is set + * @param string $morecss ''=Add more css on link + * @return string String with URL */ - public function getNomUrl($withpicto = 0, $option = '', $maxlength = 0, $save_lastsearch_value = -1, $notooltip = 0) + public function getNomUrl($withpicto = 0, $option = '', $maxlength = 0, $save_lastsearch_value = -1, $notooltip = 0, $add_label = 0, $sep = ' - ', $morecss = '') { global $conf, $langs, $hookmanager; include_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; @@ -4997,9 +5000,9 @@ class Product extends CommonObject } $linkclose .= ' title="'.dol_escape_htmltag($label, 1, 1).'"'; - $linkclose .= ' class="nowraponall classfortooltip"'; + $linkclose .= ' class="nowraponall classfortooltip'.($morecss ? ' '.$morecss : '').'"'; } else { - $linkclose = ' class="nowraponall"'; + $linkclose = ' class="nowraponall'.($morecss ? ' '.$morecss : '').'"'; } if ($option == 'supplier' || $option == 'category') { @@ -5038,6 +5041,9 @@ class Product extends CommonObject } $result .= $newref; $result .= $linkend; + if ($withpicto != 2) { + $result .= (($add_label && $this->label) ? $sep.dol_trunc($this->label, ($add_label > 1 ? $add_label : 0)) : ''); + } global $action; $hookmanager->initHooks(array('productdao')); diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index 80823c7ba5a..c755b92b3e4 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -101,7 +101,7 @@ class Inventory extends CommonObject 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,), 'title' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>25, 'css'=>'minwidth300', 'csslist'=>'tdoverflowmax200'), 'fk_warehouse' => array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php', 'label'=>'Warehouse', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'index'=>1, 'help'=>'InventoryForASpecificWarehouse', 'picto'=>'stock', 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'csslist'=>'tdoverflowmax200'), - 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'visible'=>1, 'enabled'=>1, 'position'=>32, 'index'=>1, 'help'=>'InventoryForASpecificProduct', 'picto'=>'product', 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'csslist'=>'tdoverflowmax200'), + 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php::::0:-1:0:1', 'label'=>'Product', 'visible'=>1, 'enabled'=>1, 'position'=>32, 'index'=>1, 'help'=>'InventoryForASpecificProduct', 'picto'=>'product', 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'csslist'=>'tdoverflowmax200'), 'date_inventory' => array('type'=>'date', 'label'=>'DateValue', 'visible'=>1, 'enabled'=>'$conf->global->STOCK_INVENTORY_ADD_A_VALUE_DATE', 'position'=>35), // This date is not used so disabled by default. 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), From 61a9521e3c7f48ac29e4df7bec471c586eecb0e3 Mon Sep 17 00:00:00 2001 From: lvessiller Date: Fri, 17 Jun 2022 17:32:22 +0200 Subject: [PATCH 2/2] NEW Changelog and reorder getNomUrl parameters --- ChangeLog | 7 +++++++ htdocs/core/class/commonobject.class.php | 5 +++-- htdocs/fourn/class/fournisseur.product.class.php | 4 ++-- htdocs/product/class/product.class.php | 4 ++-- htdocs/product/inventory/class/inventory.class.php | 2 +- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 37957f61c1d..5813c185885 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,13 @@ English Dolibarr ChangeLog -------------------------------------------------------------- +***** ChangeLog for 17.0.0 compared to 16.0.0 ***** + +For developers or integrators: +------------------------------ + +Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: +* The signature of method getNomUrl() of class ProductFournisseur has been modified to match the signature of method Product ***** ChangeLog for 16.0.0 compared to 15.0.0 ***** diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 10b6fd5e690..a9b7edf6078 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7565,12 +7565,13 @@ abstract class CommonObject $getnomurlparam3 = (!isset($InfoFieldList[5]) ? 0 : $InfoFieldList[5]); $getnomurlparam4 = (!isset($InfoFieldList[6]) ? -1 : $InfoFieldList[6]); $getnomurlparam5 = (!isset($InfoFieldList[7]) ? 0 : $InfoFieldList[7]); - $getnomurlparam6 = (!isset($InfoFieldList[8]) ? 0 : $InfoFieldList[8]); + $getnomurlparam6 = (!isset($InfoFieldList[8]) ? '' : $InfoFieldList[8]); + $getnomurlparam7 = (!isset($InfoFieldList[9]) ? 0 : $InfoFieldList[9]); /** * @var Product $object */ - $value = $object->getNomUrl($getnomurlparam, $getnomurlparam2, $getnomurlparam3, $getnomurlparam4, $getnomurlparam5, $getnomurlparam6); + $value = $object->getNomUrl($getnomurlparam, $getnomurlparam2, $getnomurlparam3, $getnomurlparam4, $getnomurlparam5, $getnomurlparam6, $getnomurlparam7); } else { $value = $object->getNomUrl($getnomurlparam, $getnomurlparam2); } diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 774dd192659..349a317b1d2 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -1094,12 +1094,12 @@ class ProductFournisseur extends Product * @param int $maxlength Maxlength of ref * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @param int $notooltip No tooltip + * @param string $morecss ''=Add more css on link * @param int $add_label 0=Default, 1=Add label into string, >1=Add first chars into string * @param string $sep ' - '=Separator between ref and label if option 'add_label' is set - * @param string $morecss ''=Add more css on link * @return string String with URL */ - public function getNomUrl($withpicto = 0, $option = '', $maxlength = 0, $save_lastsearch_value = -1, $notooltip = 0, $add_label = 0, $sep = ' - ', $morecss = '') + public function getNomUrl($withpicto = 0, $option = '', $maxlength = 0, $save_lastsearch_value = -1, $notooltip = 0, $morecss = '', $add_label = 0, $sep = ' - ') { global $db, $conf, $langs, $hookmanager; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index c5eb211de2c..c268929d59c 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4887,12 +4887,12 @@ class Product extends CommonObject * @param int $maxlength Maxlength of ref * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @param int $notooltip No tooltip + * @param string $morecss ''=Add more css on link * @param int $add_label 0=Default, 1=Add label into string, >1=Add first chars into string * @param string $sep ' - '=Separator between ref and label if option 'add_label' is set - * @param string $morecss ''=Add more css on link * @return string String with URL */ - public function getNomUrl($withpicto = 0, $option = '', $maxlength = 0, $save_lastsearch_value = -1, $notooltip = 0, $add_label = 0, $sep = ' - ', $morecss = '') + public function getNomUrl($withpicto = 0, $option = '', $maxlength = 0, $save_lastsearch_value = -1, $notooltip = 0, $morecss = '', $add_label = 0, $sep = ' - ') { global $conf, $langs, $hookmanager; include_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index c755b92b3e4..ddf7d582fba 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -101,7 +101,7 @@ class Inventory extends CommonObject 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,), 'title' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>25, 'css'=>'minwidth300', 'csslist'=>'tdoverflowmax200'), 'fk_warehouse' => array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php', 'label'=>'Warehouse', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'index'=>1, 'help'=>'InventoryForASpecificWarehouse', 'picto'=>'stock', 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'csslist'=>'tdoverflowmax200'), - 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php::::0:-1:0:1', 'label'=>'Product', 'visible'=>1, 'enabled'=>1, 'position'=>32, 'index'=>1, 'help'=>'InventoryForASpecificProduct', 'picto'=>'product', 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'csslist'=>'tdoverflowmax200'), + 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php::::0:-1:0::1', 'label'=>'Product', 'visible'=>1, 'enabled'=>1, 'position'=>32, 'index'=>1, 'help'=>'InventoryForASpecificProduct', 'picto'=>'product', 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'csslist'=>'tdoverflowmax200'), 'date_inventory' => array('type'=>'date', 'label'=>'DateValue', 'visible'=>1, 'enabled'=>'$conf->global->STOCK_INVENTORY_ADD_A_VALUE_DATE', 'position'=>35), // This date is not used so disabled by default. 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501),