Skip to content

Commit

Permalink
NEW Add public note on products. This also partially fix the #14342
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Aug 2, 2020
1 parent 7239232 commit 7149cbb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
8 changes: 5 additions & 3 deletions htdocs/core/class/commonobject.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
19 changes: 8 additions & 11 deletions htdocs/core/tpl/notes.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,14 @@

print '<!-- BEGIN PHP TEMPLATE NOTES -->'."\n";
print '<div class="tagtable border table-border tableforfield centpercent">'."\n";
if ($module != 'product') {
// No public note yet on products
print '<div class="tagtr table-border-row">'."\n";
print '<div class="tagtd tagtdnote tdtop sensiblehtmlcontent table-key-border-col'.(empty($cssclass) ? '' : ' '.$cssclass).'"'.($colwidth ? ' style="width: '.$colwidth.'%"' : '').'>'."\n";
print $form->editfieldkey("NotePublic", $note_public, $value_public, $object, $permission, $typeofdata, $moreparam, '', 0);
print '</div>'."\n";
print '<div class="tagtd table-val-border-col sensiblehtmlcontent">'."\n";
print $form->editfieldval("NotePublic", $note_public, $value_public, $object, $permission, $typeofdata, '', null, null, $moreparam, 1)."\n";
print '</div>'."\n";
print '</div>'."\n";
}
print '<div class="tagtr table-border-row">'."\n";
print '<div class="tagtd tagtdnote tdtop sensiblehtmlcontent table-key-border-col'.(empty($cssclass) ? '' : ' '.$cssclass).'"'.($colwidth ? ' style="width: '.$colwidth.'%"' : '').'>'."\n";
print $form->editfieldkey("NotePublic", $note_public, $value_public, $object, $permission, $typeofdata, $moreparam, '', 0);
print '</div>'."\n";
print '<div class="tagtd table-val-border-col sensiblehtmlcontent">'."\n";
print $form->editfieldval("NotePublic", $note_public, $value_public, $object, $permission, $typeofdata, '', null, null, $moreparam, 1)."\n";
print '</div>'."\n";
print '</div>'."\n";
if (empty($user->socid)) {
// Private notes (always hidden to external users)
print '<div class="tagtr table-border-row">'."\n";
Expand Down
7 changes: 4 additions & 3 deletions htdocs/product/class/product.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,";
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 7149cbb

Please sign in to comment.