diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 25b593ce120..7d7d1af898f 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -1229,6 +1229,9 @@ abstract class CommonObject
$this->db->begin();
+ // Special case
+ if ($table == 'product' && $field == 'note_private') $field='note';
+
$sql = "UPDATE ".MAIN_DB_PREFIX.$table." SET ";
if ($format == 'text') $sql.= $field." = '".$this->db->escape($value)."'";
else if ($format == 'date') $sql.= $field." = '".$this->db->idate($value)."'";
@@ -2112,7 +2115,10 @@ abstract class CommonObject
dol_syslog(get_class($this)."::update_note Parameter suffix must be empty, '_private' or '_public'", LOG_ERR);
return -2;
}
-
+ // Special cas
+ //var_dump($this->table_element);exit;
+ if ($this->table_element == 'product') $suffix='';
+
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET note".$suffix." = ".(!empty($note)?("'".$this->db->escape($note)."'"):"NULL");
$sql.= " WHERE rowid =". $this->id;
@@ -2122,7 +2128,11 @@ abstract class CommonObject
{
if ($suffix == '_public') $this->note_public = $note;
else if ($suffix == '_private') $this->note_private = $note;
- else $this->note = $note;
+ else
+ {
+ $this->note = $note; // deprecated
+ $this->note_private = $note;
+ }
return 1;
}
else
diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php
index be46f28c498..096a1efbe99 100644
--- a/htdocs/core/lib/product.lib.php
+++ b/htdocs/core/lib/product.lib.php
@@ -65,18 +65,6 @@ function product_prepare_head($object)
$h++;
}
}
-
- // Show category tab
- /* No more required. Replaced with new multiselect component
- if (! empty($conf->categorie->enabled) && $user->rights->categorie->lire)
- {
- require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
- $type = Categorie::TYPE_PRODUCT;
- $head[$h][0] = DOL_URL_ROOT."/categories/categorie.php?id=".$object->id.'&type='.$type;
- $head[$h][1] = $langs->trans('Categories');
- $head[$h][2] = 'category';
- $h++;
- }*/
// Multilangs
if (! empty($conf->global->MAIN_MULTILANGS))
@@ -123,12 +111,18 @@ function product_prepare_head($object)
// $this->tabs = array('entity:-tabname); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'product');
- /* Merged into the Join files tab
- $head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$object->id;
- $head[$h][1] = $langs->trans("Photos");
- $head[$h][2] = 'photos';
- $h++;
- */
+ // Notes
+ if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
+ {
+ $nbNote = 0;
+ if(!empty($object->note_private)) $nbNote++;
+ if(!empty($object->note_public)) $nbNote++;
+ $head[$h][0] = DOL_URL_ROOT.'/product/note.php?id='.$object->id;
+ $head[$h][1] = $langs->trans('Notes');
+ if ($nbNote > 0) $head[$h][1].= ' '.$nbNote.'';
+ $head[$h][2] = 'note';
+ $h++;
+ }
// Attachments
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
diff --git a/htdocs/core/tpl/notes.tpl.php b/htdocs/core/tpl/notes.tpl.php
index 61832720d0e..901756f9bfb 100644
--- a/htdocs/core/tpl/notes.tpl.php
+++ b/htdocs/core/tpl/notes.tpl.php
@@ -50,16 +50,17 @@ if (! empty($conf->global->MAIN_AUTO_TIMESTAMP_IN_PRIVATE_NOTES))
}
// Special cases
-if ($module == 'propal') { $permission=$user->rights->propale->creer;}
+if ($module == 'propal') { $permission=$user->rights->propale->creer;}
elseif ($module == 'supplier_proposal') { $permission=$user->rights->supplier_proposal->creer;}
-elseif ($module == 'fichinter') { $permission=$user->rights->ficheinter->creer;}
-elseif ($module == 'project') { $permission=$user->rights->projet->creer;}
-elseif ($module == 'project_task') { $permission=$user->rights->projet->creer;}
-elseif ($module == 'invoice_supplier') { $permission=$user->rights->fournisseur->facture->creer;}
-elseif ($module == 'order_supplier') { $permission=$user->rights->fournisseur->commande->creer;}
-elseif ($module == 'societe') { $permission=$user->rights->societe->creer;}
-elseif ($module == 'contact') { $permission=$user->rights->societe->creer;}
-elseif ($module == 'shipping') { $permission=$user->rights->expedition->creer;}
+elseif ($module == 'fichinter') { $permission=$user->rights->ficheinter->creer;}
+elseif ($module == 'project') { $permission=$user->rights->projet->creer;}
+elseif ($module == 'project_task') { $permission=$user->rights->projet->creer;}
+elseif ($module == 'invoice_supplier') { $permission=$user->rights->fournisseur->facture->creer;}
+elseif ($module == 'order_supplier') { $permission=$user->rights->fournisseur->commande->creer;}
+elseif ($module == 'societe') { $permission=$user->rights->societe->creer;}
+elseif ($module == 'contact') { $permission=$user->rights->societe->creer;}
+elseif ($module == 'shipping') { $permission=$user->rights->expedition->creer;}
+elseif ($module == 'product') { $permission=$user->rights->produit->creer;}
//else dol_print_error('','Bad value '.$module.' for param module');
if (! empty($conf->global->FCKEDITOR_ENABLE_SOCIETE)) $typeofdata='ckeditor:dolibarr_notes:100%:200::1:12:100'; // Rem: This var is for all notes, not only thirdparties note.
@@ -69,10 +70,12 @@ else $typeofdata='textarea:12:100';
+
>editfieldkey("NotePublic", $note_public, $value_public, $object, $permission, $typeofdata, $moreparam); ?>
editfieldval("NotePublic", $note_public, $value_public, $object, $permission, $typeofdata, '', null, null, $moreparam); ?>
+
societe_id)) { ?>
>editfieldkey("NotePrivate", $note_private, $value_private, $object, $permission, $typeofdata, $moreparam); ?>
diff --git a/htdocs/product/card.php b/htdocs/product/card.php
index 7f338c6dc06..2ff5e2b5b43 100644
--- a/htdocs/product/card.php
+++ b/htdocs/product/card.php
@@ -94,6 +94,7 @@ if ($id > 0 || ! empty($ref))
else $upload_dirold = $conf->service->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos";
}
}
+
$modulepart='product';
// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
@@ -285,7 +286,8 @@ if (empty($reshook))
$object->description = dol_htmlcleanlastbr(GETPOST('desc'));
$object->url = GETPOST('url');
- $object->note = dol_htmlcleanlastbr(GETPOST('note'));
+ $object->note_private = dol_htmlcleanlastbr(GETPOST('note_private'));
+ $object->note = $object->note_private; // deprecated
$object->customcode = GETPOST('customcode');
$object->country_id = GETPOST('country_id');
$object->duration_value = $duration_value;
@@ -371,7 +373,11 @@ if (empty($reshook))
$object->label = GETPOST('label');
$object->description = dol_htmlcleanlastbr(GETPOST('desc'));
$object->url = GETPOST('url');
- $object->note = dol_htmlcleanlastbr(GETPOST('note'));
+ if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB))
+ {
+ $object->note_private = dol_htmlcleanlastbr(GETPOST('note_private'));
+ $object->note = $object->note_private;
+ }
$object->customcode = GETPOST('customcode');
$object->country_id = GETPOST('country_id');
$object->status = GETPOST('statut');
@@ -1063,14 +1069,17 @@ else
}
// Note (private, no output on invoices, propales...)
- print '
| '.$langs->trans("NoteNotVisibleOnBill").' | ';
-
- // We use dolibarr_details as type of DolEditor here, because we must not accept images as description is included into PDF and not accepted by TCPDF.
- $doleditor = new DolEditor('note', GETPOST('note'), '', 140, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 8, '80%');
- $doleditor->Create();
-
- print " |
";
-
+ //if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) available in create mode
+ //{
+ print '
| '.$langs->trans("NoteNotVisibleOnBill").' | ';
+
+ // We use dolibarr_details as type of DolEditor here, because we must not accept images as description is included into PDF and not accepted by TCPDF.
+ $doleditor = new DolEditor('note_private', GETPOST('note_private'), '', 140, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 8, '80%');
+ $doleditor->Create();
+
+ print " |
";
+ //}
+
if($conf->categorie->enabled) {
// Categories
print '
| '.$langs->trans("Categories").' | ';
@@ -1382,14 +1391,17 @@ else
print " |
";
}
- // Note
- print '
| '.$langs->trans("NoteNotVisibleOnBill").' | ';
-
- $doleditor = new DolEditor('note', $object->note, '', 140, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 4, 80);
- $doleditor->Create();
-
- print " |
";
-
+ // Note private
+ if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB))
+ {
+ print '
| '.$langs->trans("NoteNotVisibleOnBill").' | ';
+
+ $doleditor = new DolEditor('note_private', $object->note_private, '', 140, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 4, 80);
+ $doleditor->Create();
+
+ print " |
";
+ }
+
print '';
print '
';
@@ -1695,11 +1707,14 @@ else
print "";
}
- // Note
- print ' '."\n";
- print '
| '.$langs->trans("Note").' | '.(dol_textishtml($object->note)?$object->note:dol_nl2br($object->note,1,true)).' |
'."\n";
- print ' '."\n";
-
+ // Note private
+ if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB))
+ {
+ print ' '."\n";
+ print '
| '.$langs->trans("NotePrivate").' | '.(dol_textishtml($object->note_private)?$object->note_private:dol_nl2br($object->note_private,1,true)).' |
'."\n";
+ print ' '."\n";
+ }
+
print "\n";
print '
';
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index f3f03c65ac6..0a9962ecd7b 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -1014,13 +1014,12 @@ class Product extends CommonObject
/**
* Update or add a translation for a product
*
- * @param User $user Object user making update
- *
- * @return int <0 if KO, >0 if OK
+ * @param User $user Object user making update
+ * @return int <0 if KO, >0 if OK
*/
function setMultiLangs($user)
{
- global $langs;
+ global $conf, $langs;
$langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 0, 2);
$current_lang = $langs->getDefaultLang();
@@ -1039,17 +1038,21 @@ class Product extends CommonObject
if ($this->db->num_rows($result)) // if there is already a description line for this language
{
$sql2 = "UPDATE ".MAIN_DB_PREFIX."product_lang";
- $sql2.= " SET label='".$this->db->escape($this->label)."',";
- $sql2.= " description='".$this->db->escape($this->description)."',";
- $sql2.= " note='".$this->db->escape($this->note)."'";
+ $sql2.= " SET ";
+ $sql2.= " label='".$this->db->escape($this->label)."',";
+ $sql2.= " description='".$this->db->escape($this->description)."'";
+ if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) $sql2.= ", note='".$this->db->escape($this->note)."'";
$sql2.= " WHERE fk_product=".$this->id." AND lang='".$key."'";
}
else
{
- $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."product_lang (fk_product, lang, label, description, note)";
- $sql2.= " VALUES(".$this->id.",'".$key."','". $this->db->escape($this->label);
- $sql2.= "','".$this->db->escape($this->description);
- $sql2.= "','".$this->db->escape($this->note)."')";
+ $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."product_lang (fk_product, lang, label, description";
+ if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) $sql2.=", note";
+ $sql2.= ")";
+ $sql2.= " VALUES(".$this->id.",'".$key."','". $this->db->escape($this->label)."',";
+ $sql2.= " '".$this->db->escape($this->description)."'";
+ if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) $sql2.= ", '".$this->db->escape($this->note)."'";
+ $sql2.= ")";
}
dol_syslog(get_class($this).'::setMultiLangs key = current_lang = '.$key);
if (! $this->db->query($sql2))
@@ -1070,26 +1073,31 @@ class Product extends CommonObject
if ($this->db->num_rows($result)) // if there is already a description line for this language
{
$sql2 = "UPDATE ".MAIN_DB_PREFIX."product_lang";
- $sql2.= " SET label='".$this->db->escape($this->multilangs["$key"]["label"])."',";
- $sql2.= " description='".$this->db->escape($this->multilangs["$key"]["description"])."',";
- $sql2.= " note='".$this->db->escape($this->multilangs["$key"]["note"])."'";
+ $sql2.= " SET ";
+ $sql2.= " label='".$this->db->escape($this->multilangs["$key"]["label"])."',";
+ $sql2.= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'";
+ if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) $sql2.= ", note='".$this->db->escape($this->multilangs["$key"]["note"])."'";
$sql2.= " WHERE fk_product=".$this->id." AND lang='".$key."'";
}
else
{
- $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."product_lang (fk_product, lang, label, description, note)";
- $sql2.= " VALUES(".$this->id.",'".$key."','". $this->db->escape($this->multilangs["$key"]["label"]);
- $sql2.= "','".$this->db->escape($this->multilangs["$key"]["description"]);
- $sql2.= "','".$this->db->escape($this->multilangs["$key"]["note"])."')";
+ $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."product_lang (fk_product, lang, label, description";
+ if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) $sql2.=", note";
+ $sql2.= ")";
+ $sql2.= " VALUES(".$this->id.",'".$key."','". $this->db->escape($this->multilangs["$key"]["label"])."',";
+ $sql2.= " '".$this->db->escape($this->multilangs["$key"]["description"])."'";
+ if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) $sql2.= ", '".$this->db->escape($this->note)."'";
+ $sql2.= ")";
}
- // on ne sauvegarde pas des champs vides
- if ( $this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"] || $this->multilangs["$key"]["note"] )
- dol_syslog(get_class($this).'::setMultiLangs key = '.$key);
- if (! $this->db->query($sql2))
+ // We do not save if main fields are empty
+ if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"])
{
- $this->error=$this->db->lasterror();
- return -1;
+ if (! $this->db->query($sql2))
+ {
+ $this->error=$this->db->lasterror();
+ return -1;
+ }
}
}
else
@@ -1211,7 +1219,7 @@ class Product extends CommonObject
$current_lang = $langs->getDefaultLang();
- $sql = "SELECT lang, label, description, note";
+ $sql = "SELECT lang, label, description, note as other";
$sql.= " FROM ".MAIN_DB_PREFIX."product_lang";
$sql.= " WHERE fk_product=".$this->id;
@@ -1225,12 +1233,11 @@ class Product extends CommonObject
{
$this->label = $obj->label;
$this->description = $obj->description;
- $this->note = $obj->note;
-
+ $this->other = $obj->other;
}
$this->multilangs["$obj->lang"]["label"] = $obj->label;
$this->multilangs["$obj->lang"]["description"] = $obj->description;
- $this->multilangs["$obj->lang"]["note"] = $obj->note;
+ $this->multilangs["$obj->lang"]["other"] = $obj->other;
}
return 1;
}
@@ -1640,7 +1647,7 @@ class Product extends CommonObject
return -1;
}
- $sql = "SELECT rowid, ref, ref_ext, label, description, url, note, customcode, fk_country, price, price_ttc,";
+ $sql = "SELECT rowid, ref, ref_ext, label, description, url, 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, seuil_stock_alerte, canvas,";
$sql.= " weight, weight_units, length, length_units, surface, surface_units, volume, volume_units, barcode, fk_barcode_type, finished,";
@@ -1669,8 +1676,9 @@ class Product extends CommonObject
$this->label = $obj->label;
$this->description = $obj->description;
$this->url = $obj->url;
- $this->note = $obj->note;
-
+ $this->note_private = $obj->note_private;
+ $this->note = $obj->note_private; // deprecated
+
$this->type = $obj->fk_product_type;
$this->status = $obj->tosell;
$this->status_buy = $obj->tobuy;
@@ -1739,7 +1747,6 @@ class Product extends CommonObject
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
$this->fetch_optionals($this->id,$extralabels);
-
// multilangs
if (! empty($conf->global->MAIN_MULTILANGS)) $this->getMultiLangs();
diff --git a/htdocs/product/note.php b/htdocs/product/note.php
new file mode 100644
index 00000000000..ef53946460f
--- /dev/null
+++ b/htdocs/product/note.php
@@ -0,0 +1,99 @@
+
+ * Copyright (C) 2004-2011 Laurent Destailleur
+ * Copyright (C) 2005-2012 Regis Houssin
+ * Copyright (C) 2010 Juanjo Menent
+ * Copyright (C) 2013 Florian Henry
+ * Copyright (C) 2015 Marcos GarcĂa
+ *
+ * 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/product/note.php
+ * \brief Tab for notes on products
+ * \ingroup societe
+ */
+
+require '../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
+
+$action = GETPOST('action');
+
+$langs->load("companies");
+
+// Security check
+$id = GETPOST('id')?GETPOST('id','int'):GETPOST('socid','int');
+if ($user->societe_id) $id=$user->societe_id;
+$result = restrictedArea($user, 'societe', $id, '&societe');
+
+$object = new Product($db);
+if ($id > 0) $object->fetch($id);
+
+$permissionnote=$user->rights->produit->creer; // Used by the include of actions_setnotes.inc.php
+
+
+/*
+ * Actions
+ */
+
+include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once
+
+
+/*
+ * View
+ */
+
+$helpurl='';
+if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
+if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
+
+$form = new Form($db);
+
+llxHeader('', $langs->trans("ThirdParty").' - '.$langs->trans("Notes"), $help_url);
+
+if ($id > 0)
+{
+ /*
+ * Affichage onglets
+ */
+ if (! empty($conf->notification->enabled)) $langs->load("mails");
+
+ $head = product_prepare_head($object);
+ $titre=$langs->trans("CardProduct".$object->type);
+ $picto=($object->type==Product::TYPE_SERVICE?'service':'product');
+
+ dol_fiche_head($head, 'note', $titre, 0, $picto);
+
+
+ print '