Move notes on dedicated tabs like other elements.

Rename also the note available into translation tab into "other" to
avoid confusion because it was not the same usage.
This commit is contained in:
Laurent Destailleur 2016-07-28 13:53:17 +02:00
parent 01417b89c3
commit aae2086ada
7 changed files with 242 additions and 113 deletions

View File

@ -1229,6 +1229,9 @@ abstract class CommonObject
$this->db->begin(); $this->db->begin();
// Special case
if ($table == 'product' && $field == 'note_private') $field='note';
$sql = "UPDATE ".MAIN_DB_PREFIX.$table." SET "; $sql = "UPDATE ".MAIN_DB_PREFIX.$table." SET ";
if ($format == 'text') $sql.= $field." = '".$this->db->escape($value)."'"; if ($format == 'text') $sql.= $field." = '".$this->db->escape($value)."'";
else if ($format == 'date') $sql.= $field." = '".$this->db->idate($value)."'"; else if ($format == 'date') $sql.= $field." = '".$this->db->idate($value)."'";
@ -2112,6 +2115,9 @@ abstract class CommonObject
dol_syslog(get_class($this)."::update_note Parameter suffix must be empty, '_private' or '_public'", LOG_ERR); dol_syslog(get_class($this)."::update_note Parameter suffix must be empty, '_private' or '_public'", LOG_ERR);
return -2; 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 = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET note".$suffix." = ".(!empty($note)?("'".$this->db->escape($note)."'"):"NULL"); $sql.= " SET note".$suffix." = ".(!empty($note)?("'".$this->db->escape($note)."'"):"NULL");
@ -2122,7 +2128,11 @@ abstract class CommonObject
{ {
if ($suffix == '_public') $this->note_public = $note; if ($suffix == '_public') $this->note_public = $note;
else if ($suffix == '_private') $this->note_private = $note; else if ($suffix == '_private') $this->note_private = $note;
else $this->note = $note; else
{
$this->note = $note; // deprecated
$this->note_private = $note;
}
return 1; return 1;
} }
else else

View File

@ -66,18 +66,6 @@ function product_prepare_head($object)
} }
} }
// 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 // Multilangs
if (! empty($conf->global->MAIN_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 // $this->tabs = array('entity:-tabname); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'product'); complete_head_from_modules($conf,$langs,$object,$head,$h,'product');
/* Merged into the Join files tab // Notes
$head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$object->id; if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
$head[$h][1] = $langs->trans("Photos"); {
$head[$h][2] = 'photos'; $nbNote = 0;
$h++; 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].= ' <span class="badge">'.$nbNote.'</span>';
$head[$h][2] = 'note';
$h++;
}
// Attachments // Attachments
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';

View File

@ -50,16 +50,17 @@ if (! empty($conf->global->MAIN_AUTO_TIMESTAMP_IN_PRIVATE_NOTES))
} }
// Special cases // 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 == 'supplier_proposal') { $permission=$user->rights->supplier_proposal->creer;}
elseif ($module == 'fichinter') { $permission=$user->rights->ficheinter->creer;} elseif ($module == 'fichinter') { $permission=$user->rights->ficheinter->creer;}
elseif ($module == 'project') { $permission=$user->rights->projet->creer;} elseif ($module == 'project') { $permission=$user->rights->projet->creer;}
elseif ($module == 'project_task') { $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 == 'invoice_supplier') { $permission=$user->rights->fournisseur->facture->creer;}
elseif ($module == 'order_supplier') { $permission=$user->rights->fournisseur->commande->creer;} elseif ($module == 'order_supplier') { $permission=$user->rights->fournisseur->commande->creer;}
elseif ($module == 'societe') { $permission=$user->rights->societe->creer;} elseif ($module == 'societe') { $permission=$user->rights->societe->creer;}
elseif ($module == 'contact') { $permission=$user->rights->societe->creer;} elseif ($module == 'contact') { $permission=$user->rights->societe->creer;}
elseif ($module == 'shipping') { $permission=$user->rights->expedition->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'); //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. 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';
<!-- BEGIN PHP TEMPLATE NOTES --> <!-- BEGIN PHP TEMPLATE NOTES -->
<div class="border table-border centpercent"> <div class="border table-border centpercent">
<?php if ($module != 'product') { // No public note yet on products ?>
<div class="table-border-row"> <div class="table-border-row">
<div class="table-key-border-col<?php echo (empty($cssclass)?'':' '.$cssclass); ?>"<?php echo ($colwidth ? ' style="width: '.$colwidth.'%"' : ''); ?>><?php echo $form->editfieldkey("NotePublic", $note_public, $value_public, $object, $permission, $typeofdata, $moreparam); ?></div> <div class="table-key-border-col<?php echo (empty($cssclass)?'':' '.$cssclass); ?>"<?php echo ($colwidth ? ' style="width: '.$colwidth.'%"' : ''); ?>><?php echo $form->editfieldkey("NotePublic", $note_public, $value_public, $object, $permission, $typeofdata, $moreparam); ?></div>
<div class="table-val-border-col"><?php echo $form->editfieldval("NotePublic", $note_public, $value_public, $object, $permission, $typeofdata, '', null, null, $moreparam); ?></div> <div class="table-val-border-col"><?php echo $form->editfieldval("NotePublic", $note_public, $value_public, $object, $permission, $typeofdata, '', null, null, $moreparam); ?></div>
</div> </div>
<?php } ?>
<?php if (empty($user->societe_id)) { ?> <?php if (empty($user->societe_id)) { ?>
<div class="table-border-row"> <div class="table-border-row">
<div class="table-key-border-col<?php echo (empty($cssclass)?'':' '.$cssclass); ?>"<?php echo ($colwidth ? ' style="width: '.$colwidth.'%"' : ''); ?>><?php echo $form->editfieldkey("NotePrivate", $note_private, $value_private, $object, $permission, $typeofdata, $moreparam); ?></div> <div class="table-key-border-col<?php echo (empty($cssclass)?'':' '.$cssclass); ?>"<?php echo ($colwidth ? ' style="width: '.$colwidth.'%"' : ''); ?>><?php echo $form->editfieldkey("NotePrivate", $note_private, $value_private, $object, $permission, $typeofdata, $moreparam); ?></div>

View File

@ -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"; 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'; $modulepart='product';
// Get object canvas (By default, this is not defined, so standard usage of dolibarr) // 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->description = dol_htmlcleanlastbr(GETPOST('desc'));
$object->url = GETPOST('url'); $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->customcode = GETPOST('customcode');
$object->country_id = GETPOST('country_id'); $object->country_id = GETPOST('country_id');
$object->duration_value = $duration_value; $object->duration_value = $duration_value;
@ -371,7 +373,11 @@ if (empty($reshook))
$object->label = GETPOST('label'); $object->label = GETPOST('label');
$object->description = dol_htmlcleanlastbr(GETPOST('desc')); $object->description = dol_htmlcleanlastbr(GETPOST('desc'));
$object->url = GETPOST('url'); $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->customcode = GETPOST('customcode');
$object->country_id = GETPOST('country_id'); $object->country_id = GETPOST('country_id');
$object->status = GETPOST('statut'); $object->status = GETPOST('statut');
@ -1063,13 +1069,16 @@ else
} }
// Note (private, no output on invoices, propales...) // Note (private, no output on invoices, propales...)
print '<tr><td class="tdtop">'.$langs->trans("NoteNotVisibleOnBill").'</td><td colspan="3">'; //if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) available in create mode
//{
print '<tr><td class="tdtop">'.$langs->trans("NoteNotVisibleOnBill").'</td><td colspan="3">';
// 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. // 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 = new DolEditor('note_private', GETPOST('note_private'), '', 140, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 8, '80%');
$doleditor->Create(); $doleditor->Create();
print "</td></tr>"; print "</td></tr>";
//}
if($conf->categorie->enabled) { if($conf->categorie->enabled) {
// Categories // Categories
@ -1382,13 +1391,16 @@ else
print "</td></tr>"; print "</td></tr>";
} }
// Note // Note private
print '<tr><td class="tdtop">'.$langs->trans("NoteNotVisibleOnBill").'</td><td colspan="3">'; if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{
print '<tr><td class="tdtop">'.$langs->trans("NoteNotVisibleOnBill").'</td><td colspan="3">';
$doleditor = new DolEditor('note', $object->note, '', 140, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 4, 80); $doleditor = new DolEditor('note_private', $object->note_private, '', 140, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 4, 80);
$doleditor->Create(); $doleditor->Create();
print "</td></tr>"; print "</td></tr>";
}
print '</table>'; print '</table>';
@ -1695,10 +1707,13 @@ else
print "</td></tr>"; print "</td></tr>";
} }
// Note // Note private
print '<!-- show Note --> '."\n"; if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB))
print '<tr><td class="tdtop">'.$langs->trans("Note").'</td><td colspan="'.(2+(($showphoto||$showbarcode)?1:0)).'">'.(dol_textishtml($object->note)?$object->note:dol_nl2br($object->note,1,true)).'</td></tr>'."\n"; {
print '<!-- End show Note --> '."\n"; print '<!-- show Note --> '."\n";
print '<tr><td class="tdtop">'.$langs->trans("NotePrivate").'</td><td colspan="'.(2+(($showphoto||$showbarcode)?1:0)).'">'.(dol_textishtml($object->note_private)?$object->note_private:dol_nl2br($object->note_private,1,true)).'</td></tr>'."\n";
print '<!-- End show Note --> '."\n";
}
print "</table>\n"; print "</table>\n";
print '</div>'; print '</div>';

View File

@ -1014,13 +1014,12 @@ class Product extends CommonObject
/** /**
* Update or add a translation for a product * Update or add a translation for a product
* *
* @param User $user Object user making update * @param User $user Object user making update
* * @return int <0 if KO, >0 if OK
* @return int <0 if KO, >0 if OK
*/ */
function setMultiLangs($user) function setMultiLangs($user)
{ {
global $langs; global $conf, $langs;
$langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 0, 2); $langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 0, 2);
$current_lang = $langs->getDefaultLang(); $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 if ($this->db->num_rows($result)) // if there is already a description line for this language
{ {
$sql2 = "UPDATE ".MAIN_DB_PREFIX."product_lang"; $sql2 = "UPDATE ".MAIN_DB_PREFIX."product_lang";
$sql2.= " SET label='".$this->db->escape($this->label)."',"; $sql2.= " SET ";
$sql2.= " description='".$this->db->escape($this->description)."',"; $sql2.= " label='".$this->db->escape($this->label)."',";
$sql2.= " note='".$this->db->escape($this->note)."'"; $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."'"; $sql2.= " WHERE fk_product=".$this->id." AND lang='".$key."'";
} }
else else
{ {
$sql2 = "INSERT INTO ".MAIN_DB_PREFIX."product_lang (fk_product, lang, label, description, note)"; $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."product_lang (fk_product, lang, label, description";
$sql2.= " VALUES(".$this->id.",'".$key."','". $this->db->escape($this->label); if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) $sql2.=", note";
$sql2.= "','".$this->db->escape($this->description); $sql2.= ")";
$sql2.= "','".$this->db->escape($this->note)."')"; $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); dol_syslog(get_class($this).'::setMultiLangs key = current_lang = '.$key);
if (! $this->db->query($sql2)) 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 if ($this->db->num_rows($result)) // if there is already a description line for this language
{ {
$sql2 = "UPDATE ".MAIN_DB_PREFIX."product_lang"; $sql2 = "UPDATE ".MAIN_DB_PREFIX."product_lang";
$sql2.= " SET label='".$this->db->escape($this->multilangs["$key"]["label"])."',"; $sql2.= " SET ";
$sql2.= " description='".$this->db->escape($this->multilangs["$key"]["description"])."',"; $sql2.= " label='".$this->db->escape($this->multilangs["$key"]["label"])."',";
$sql2.= " note='".$this->db->escape($this->multilangs["$key"]["note"])."'"; $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."'"; $sql2.= " WHERE fk_product=".$this->id." AND lang='".$key."'";
} }
else else
{ {
$sql2 = "INSERT INTO ".MAIN_DB_PREFIX."product_lang (fk_product, lang, label, description, note)"; $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."product_lang (fk_product, lang, label, description";
$sql2.= " VALUES(".$this->id.",'".$key."','". $this->db->escape($this->multilangs["$key"]["label"]); if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) $sql2.=", note";
$sql2.= "','".$this->db->escape($this->multilangs["$key"]["description"]); $sql2.= ")";
$sql2.= "','".$this->db->escape($this->multilangs["$key"]["note"])."')"; $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 // We do not save if main fields are empty
if ( $this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"] || $this->multilangs["$key"]["note"] ) if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"])
dol_syslog(get_class($this).'::setMultiLangs key = '.$key);
if (! $this->db->query($sql2))
{ {
$this->error=$this->db->lasterror(); if (! $this->db->query($sql2))
return -1; {
$this->error=$this->db->lasterror();
return -1;
}
} }
} }
else else
@ -1211,7 +1219,7 @@ class Product extends CommonObject
$current_lang = $langs->getDefaultLang(); $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.= " FROM ".MAIN_DB_PREFIX."product_lang";
$sql.= " WHERE fk_product=".$this->id; $sql.= " WHERE fk_product=".$this->id;
@ -1225,12 +1233,11 @@ class Product extends CommonObject
{ {
$this->label = $obj->label; $this->label = $obj->label;
$this->description = $obj->description; $this->description = $obj->description;
$this->note = $obj->note; $this->other = $obj->other;
} }
$this->multilangs["$obj->lang"]["label"] = $obj->label; $this->multilangs["$obj->lang"]["label"] = $obj->label;
$this->multilangs["$obj->lang"]["description"] = $obj->description; $this->multilangs["$obj->lang"]["description"] = $obj->description;
$this->multilangs["$obj->lang"]["note"] = $obj->note; $this->multilangs["$obj->lang"]["other"] = $obj->other;
} }
return 1; return 1;
} }
@ -1640,7 +1647,7 @@ class Product extends CommonObject
return -1; 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.= " 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.= " 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,"; $sql.= " weight, weight_units, length, length_units, surface, surface_units, volume, volume_units, barcode, fk_barcode_type, finished,";
@ -1669,7 +1676,8 @@ class Product extends CommonObject
$this->label = $obj->label; $this->label = $obj->label;
$this->description = $obj->description; $this->description = $obj->description;
$this->url = $obj->url; $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->type = $obj->fk_product_type;
$this->status = $obj->tosell; $this->status = $obj->tosell;
@ -1739,7 +1747,6 @@ class Product extends CommonObject
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
$this->fetch_optionals($this->id,$extralabels); $this->fetch_optionals($this->id,$extralabels);
// multilangs // multilangs
if (! empty($conf->global->MAIN_MULTILANGS)) $this->getMultiLangs(); if (! empty($conf->global->MAIN_MULTILANGS)) $this->getMultiLangs();

99
htdocs/product/note.php Normal file
View File

@ -0,0 +1,99 @@
<?php
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
/**
* \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&oacute;dulo_Productos';
if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) $helpurl='EN:Module_Services_En|FR:Module_Services|ES:M&oacute;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 '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom');
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
//$colwidth='25';
$cssclass='titlefield';
include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
dol_fiche_end();
}
llxFooter();
$db->close();

View File

@ -77,13 +77,13 @@ $cancel != $langs->trans("Cancel") &&
{ {
$object->label = $_POST["libelle"]; $object->label = $_POST["libelle"];
$object->description = dol_htmlcleanlastbr($_POST["desc"]); $object->description = dol_htmlcleanlastbr($_POST["desc"]);
$object->note = dol_htmlcleanlastbr($_POST["note"]); $object->other = dol_htmlcleanlastbr($_POST["other"]);
} }
else else
{ {
$object->multilangs[$_POST["forcelangprod"]]["label"] = $_POST["libelle"]; $object->multilangs[$_POST["forcelangprod"]]["label"] = $_POST["libelle"];
$object->multilangs[$_POST["forcelangprod"]]["description"] = dol_htmlcleanlastbr($_POST["desc"]); $object->multilangs[$_POST["forcelangprod"]]["description"] = dol_htmlcleanlastbr($_POST["desc"]);
$object->multilangs[$_POST["forcelangprod"]]["note"] = dol_htmlcleanlastbr($_POST["note"]); $object->multilangs[$_POST["forcelangprod"]]["other"] = dol_htmlcleanlastbr($_POST["other"]);
} }
// sauvegarde en base // sauvegarde en base
@ -113,13 +113,13 @@ $cancel != $langs->trans("Cancel") &&
{ {
$object->label = $_POST["libelle-".$key]; $object->label = $_POST["libelle-".$key];
$object->description = dol_htmlcleanlastbr($_POST["desc-".$key]); $object->description = dol_htmlcleanlastbr($_POST["desc-".$key]);
$object->note = dol_htmlcleanlastbr($_POST["note-".$key]); $object->other = dol_htmlcleanlastbr($_POST["other-".$key]);
} }
else else
{ {
$object->multilangs[$key]["label"] = $_POST["libelle-".$key]; $object->multilangs[$key]["label"] = $_POST["libelle-".$key];
$object->multilangs[$key]["description"] = dol_htmlcleanlastbr($_POST["desc-".$key]); $object->multilangs[$key]["description"] = dol_htmlcleanlastbr($_POST["desc-".$key]);
$object->multilangs[$key]["note"] = dol_htmlcleanlastbr($_POST["note-".$key]); $object->multilangs[$key]["other"] = dol_htmlcleanlastbr($_POST["other-".$key]);
} }
} }
@ -201,18 +201,17 @@ if ($action == 'edit')
print "<br>".($s?$s.' ':'')." <b>".$langs->trans('Language_'.$key).":</b> ".'<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&langtodelete='.$key.'">'.img_delete('', '')."</a><br>"; print "<br>".($s?$s.' ':'')." <b>".$langs->trans('Language_'.$key).":</b> ".'<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&langtodelete='.$key.'">'.img_delete('', '')."</a><br>";
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td valign="top" width="15%" class="fieldrequired">'.$langs->trans('Label').'</td><td><input name="libelle-'.$key.'" size="40" value="'.$object->multilangs[$key]["label"].'"></td></tr>'; print '<tr><td valign="top" class="titlefieldcreate fieldrequired">'.$langs->trans('Label').'</td><td><input name="libelle-'.$key.'" size="40" value="'.$object->multilangs[$key]["label"].'"></td></tr>';
print '<tr><td valign="top" width="15%">'.$langs->trans('Description').'</td><td>'; print '<tr><td valign="top">'.$langs->trans('Description').'</td><td>';
$doleditor = new DolEditor("desc-$key", $object->multilangs[$key]["description"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 3, 80); $doleditor = new DolEditor("desc-$key", $object->multilangs[$key]["description"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 3, 80);
$doleditor->Create(); $doleditor->Create();
print '</td></tr>'; print '</td></tr>';
print '<tr><td valign="top" width="15%">'.$langs->trans('Note').'</td><td>'; if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION))
{
$doleditor = new DolEditor("note-$key", $object->multilangs[$key]["note"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 3, 80); print '<tr><td valign="top">'.$langs->trans('Other').' ('.$langs->trans("NotUsed").')</td><td>';
$doleditor->Create(); $doleditor = new DolEditor("other-$key", $object->multilangs[$key]["other"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 3, 80);
$doleditor->Create();
}
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
} }
@ -246,9 +245,12 @@ else
$s=picto_from_langcode($key); $s=picto_from_langcode($key);
print "<br>".($s?$s.' ':'')." <b>".$langs->trans('Language_'.$key).":</b> ".'<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&langtodelete='.$key.'">'.img_delete('', '')."</a><br>"; print "<br>".($s?$s.' ':'')." <b>".$langs->trans('Language_'.$key).":</b> ".'<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&langtodelete='.$key.'">'.img_delete('', '')."</a><br>";
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td width="15%">'.$langs->trans('Label').'</td><td>'.$object->multilangs[$key]["label"].'</td></tr>'; print '<tr><td class="titlefieldcreate">'.$langs->trans('Label').'</td><td>'.$object->multilangs[$key]["label"].'</td></tr>';
print '<tr><td width="15%">'.$langs->trans('Description').'</td><td>'.$object->multilangs[$key]["description"].'</td></tr>'; print '<tr><td>'.$langs->trans('Description').'</td><td>'.$object->multilangs[$key]["description"].'</td></tr>';
print '<tr><td width="15%">'.$langs->trans('Note').'</td><td>'.$object->multilangs[$key]["note"].'</td></tr>'; if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION))
{
print '<tr><td>'.$langs->trans('Other').' ('.$langs->trans("NotUsed").')</td><td>'.$object->multilangs[$key]["other"].'</td></tr>';
}
print '</table>'; print '</table>';
} }
} }
@ -293,23 +295,22 @@ if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service
print '<input type="hidden" name="id" value="'.$_GET["id"].'">'; print '<input type="hidden" name="id" value="'.$_GET["id"].'">';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td valign="top" width="15%" class="fieldrequired">'.$langs->trans('Language').'</td><td>'; print '<tr><td valign="top" class="titlefieldcreate fieldrequired">'.$langs->trans('Language').'</td><td>';
print $formadmin->select_language('','forcelangprod',0,$object->multilangs,1); print $formadmin->select_language('','forcelangprod',0,$object->multilangs,1);
print '</td></tr>'; print '</td></tr>';
print '<tr><td valign="top" width="15%" class="fieldrequired">'.$langs->trans('Label').'</td><td><input name="libelle" size="40"></td></tr>'; print '<tr><td valign="top" class="fieldrequired">'.$langs->trans('Label').'</td><td><input name="libelle" size="40"></td></tr>';
print '<tr><td valign="top" width="15%">'.$langs->trans('Description').'</td><td>'; print '<tr><td valign="top">'.$langs->trans('Description').'</td><td>';
$doleditor = new DolEditor('desc', '', '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 3, 80); $doleditor = new DolEditor('desc', '', '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 3, 80);
$doleditor->Create(); $doleditor->Create();
print '</td></tr>'; print '</td></tr>';
print '<tr><td valign="top" width="15%">'.$langs->trans('Note').'</td><td>'; // Other field (not used)
if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION))
$doleditor = new DolEditor('note', '', '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 3, 80); {
$doleditor->Create(); print '<tr><td valign="top">'.$langs->trans('Other').' ('.$langs->trans("NotUsed").'</td><td>';
$doleditor = new DolEditor('other', '', '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 3, 80);
print '</td></tr>'; $doleditor->Create();
print '</tr>'; print '</td></tr>';
}
print '</table>'; print '</table>';
print '<br><div class="center">'; print '<br><div class="center">';