From 7149cbb532bf516ebeee4cfecdde7c56a205a61b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 2 Aug 2020 17:09:21 +0200 Subject: [PATCH] NEW Add public note on products. This also partially fix the #14342 --- htdocs/core/class/commonobject.class.php | 8 +++++--- htdocs/core/tpl/notes.tpl.php | 19 ++++++++----------- htdocs/product/class/product.class.php | 7 ++++--- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 711707414a25f..c15c074a35193 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2847,12 +2847,14 @@ public function update_note($note, $suffix = '') dol_syslog(get_class($this)."::update_note Parameter suffix must be empty, '_private' or '_public'", LOG_ERR); return -2; } + + $newsuffix = $suffix; + // Special cas - //var_dump($this->table_element);exit; - if ($this->table_element == 'product') $suffix = ''; + if ($this->table_element == 'product' && $newsuffix == '_private') $newsuffix = ''; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= " SET note".$suffix." = ".(!empty($note) ? ("'".$this->db->escape($note)."'") : "NULL"); + $sql .= " SET note".$newsuffix." = ".(!empty($note) ? ("'".$this->db->escape($note)."'") : "NULL"); $sql .= " ,".(in_array($this->table_element, array('actioncomm', 'adherent', 'advtargetemailing', 'cronjob', 'establishment')) ? "fk_user_mod" : "fk_user_modif")." = ".$user->id; $sql .= " WHERE rowid =".$this->id; diff --git a/htdocs/core/tpl/notes.tpl.php b/htdocs/core/tpl/notes.tpl.php index f387725becee3..e646be4842a68 100644 --- a/htdocs/core/tpl/notes.tpl.php +++ b/htdocs/core/tpl/notes.tpl.php @@ -87,17 +87,14 @@ print ''."\n"; print '
'."\n"; -if ($module != 'product') { - // No public note yet on products - print '
'."\n"; - print '
'."\n"; - print $form->editfieldkey("NotePublic", $note_public, $value_public, $object, $permission, $typeofdata, $moreparam, '', 0); - print '
'."\n"; - print '
'."\n"; - print $form->editfieldval("NotePublic", $note_public, $value_public, $object, $permission, $typeofdata, '', null, null, $moreparam, 1)."\n"; - print '
'."\n"; - print '
'."\n"; -} +print '
'."\n"; +print '
'."\n"; +print $form->editfieldkey("NotePublic", $note_public, $value_public, $object, $permission, $typeofdata, $moreparam, '', 0); +print '
'."\n"; +print '
'."\n"; +print $form->editfieldval("NotePublic", $note_public, $value_public, $object, $permission, $typeofdata, '', null, null, $moreparam, 1)."\n"; +print '
'."\n"; +print '
'."\n"; if (empty($user->socid)) { // Private notes (always hidden to external users) print '
'."\n"; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 28ca230a56bf7..055a0702cabe7 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2025,7 +2025,7 @@ public function fetch($id = '', $ref = '', $ref_ext = '', $barcode = '', $ignore return -1; } - $sql = "SELECT rowid, ref, ref_ext, label, description, url, note as note_private, customcode, fk_country, price, price_ttc,"; + $sql = "SELECT rowid, ref, ref_ext, label, description, url, note_public, note as note_private, customcode, fk_country, price, price_ttc,"; $sql .= " price_min, price_min_ttc, price_base_type, cost_price, default_vat_code, tva_tx, recuperableonly as tva_npr, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, tosell,"; $sql .= " tobuy, fk_product_type, duration, fk_default_warehouse, seuil_stock_alerte, canvas, net_measure, net_measure_units, weight, weight_units,"; $sql .= " length, length_units, width, width_units, height, height_units,"; @@ -2061,8 +2061,9 @@ public function fetch($id = '', $ref = '', $ref_ext = '', $barcode = '', $ignore $this->label = $obj->label; $this->description = $obj->description; $this->url = $obj->url; - $this->note_private = $obj->note_private; - $this->note = $obj->note_private; // deprecated + $this->note_public = $obj->note_public; + $this->note_private = $obj->note_private; + $this->note = $obj->note_private; // deprecated $this->type = $obj->fk_product_type; $this->status = $obj->tosell;