diff --git a/htdocs/product/canvas/default/product.default.class.php b/htdocs/product/canvas/default/product.default.class.php
index 1755195db32..a77714bd04e 100644
--- a/htdocs/product/canvas/default/product.default.class.php
+++ b/htdocs/product/canvas/default/product.default.class.php
@@ -81,36 +81,7 @@ class ProductDefault extends Product
global $html;
global $formproduct;
- // canvas
- $this->tpl['canvas'] = $this->canvas;
-
- // id
- $this->tpl['id'] = $this->id;
-
- // Ref
- $this->tpl['ref'] = $this->ref;
-
- // Label
- $this->tpl['label'] = $this->libelle;
-
- // Description
- $this->tpl['description'] = nl2br($this->description);
-
- // Statut
- $this->tpl['status'] = $this->getLibStatut(2);
-
- // Note
- $this->tpl['note'] = nl2br($this->note);
-
- // Hidden
- if ($this->user->rights->produit->hidden)
- {
- $this->tpl['hidden'] = yn($this->hidden);
- }
- else
- {
- $this->tpl['hidden'] = yn("No");
- }
+ parent::assign_values($action);
// Stock alert
$this->tpl['seuil_stock_alerte'] = $this->seuil_stock_alerte;
@@ -119,14 +90,6 @@ class ProductDefault extends Product
{
// Title
$this->tpl['title'] = load_fiche_titre($langs->trans("NewProduct"));
-
- // Price
- $this->tpl['price'] = $this->price;
- $this->tpl['price_min'] = $this->price_min;
- $this->tpl['price_base_type'] = $html->load_PriceBaseType($this->price_base_type, "price_base_type");
-
- // VAT
- $this->tpl['tva_tx'] = $html->load_tva("tva_tx",$conf->defaulttx,$mysoc,'');
}
if ($action == 'edit')
@@ -136,10 +99,6 @@ class ProductDefault extends Product
if ($action == 'create' || $action == 'edit')
{
- // Status
- $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell"));
- $this->tpl['status'] = $html->selectarray('statut',$statutarray,$this->status);
-
// Finished
$statutarray=array('1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial"));
$this->tpl['finished'] = $html->selectarray('finished',$statutarray,$this->finished);
@@ -159,43 +118,10 @@ class ProductDefault extends Product
// Volume
$this->tpl['volume'] = $this->volume;
$this->tpl['volume_units'] = $formproduct->load_measuring_units("volume_units","volume",$this->volume_units);
-
- // Hidden
- if ($this->user->rights->produit->hidden)
- {
- $this->tpl['hidden'] = $html->selectyesno('hidden',$this->hidden);
- }
-
- // TODO creer fonction
- if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC)
- {
- require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
-
- $doleditor=new DolEditor('desc',$this->description,160,'dolibarr_notes','',false);
- $this->tpl['doleditor_description'] = $doleditor;
-
- $doleditor=new DolEditor('note',$this->note,180,'dolibarr_notes','',false);
- $this->tpl['doleditor_note'] = $doleditor;
- }
- else
- {
- $textarea = '';
- $this->tpl['textarea_description'] = $textarea;
-
- $textarea = '';
- $this->tpl['textarea_note'] = $textarea;
- }
}
if ($action == 'view')
- {
- // Ref
- $this->tpl['ref'] = $html->showrefnav($this,'ref','',1,'ref');
-
+ {
// Photo
$this->tpl['nblignes'] = 4;
if ($this->is_photo_available($conf->produit->dir_output))
@@ -203,14 +129,6 @@ class ProductDefault extends Product
$this->tpl['photos'] = $this->show_photos($conf->produit->dir_output,1,1,0,0,0,80);
}
- // Accountancy buy code
- $this->tpl['accountancyBuyCodeKey'] = $html->editfieldkey("ProductAccountancyBuyCode",'productaccountancycodesell',$this->accountancy_code_sell,'id',$this->id,$user->rights->produit->creer);
- $this->tpl['accountancyBuyCodeVal'] = $html->editfieldval("ProductAccountancyBuyCode",'productaccountancycodesell',$this->accountancy_code_sell,'id',$this->id,$user->rights->produit->creer);
-
- // Accountancy sell code
- $this->tpl['accountancySellCodeKey'] = $html->editfieldkey("ProductAccountancySellCode",'productaccountancycodebuy',$this->accountancy_code_buy,'id',$this->id,$user->rights->produit->creer);
- $this->tpl['accountancySellCodeVal'] = $html->editfieldval("ProductAccountancySellCode",'productaccountancycodebuy',$this->accountancy_code_buy,'id',$this->id,$user->rights->produit->creer);
-
// Nature
$this->tpl['finished'] = $this->getLibFinished();
diff --git a/htdocs/product/canvas/service/product.service.class.php b/htdocs/product/canvas/service/product.service.class.php
index 60535cd807a..d3472420b0c 100644
--- a/htdocs/product/canvas/service/product.service.class.php
+++ b/htdocs/product/canvas/service/product.service.class.php
@@ -75,58 +75,13 @@ class ProductService extends Product
function assign_values($action='')
{
global $conf,$langs;
- global $html;
- global $formproduct;
- // canvas
- $this->tpl['canvas'] = $this->canvas;
-
- // id
- $this->tpl['id'] = $this->id;
-
- // Ref
- $this->tpl['ref'] = $this->ref;
-
- // Label
- $this->tpl['label'] = $this->libelle;
-
- // Description
- $this->tpl['description'] = nl2br($this->description);
-
- // Statut
- $this->tpl['status'] = $this->getLibStatut(2);
-
- // Note
- $this->tpl['note'] = nl2br($this->note);
-
- // Duration
- $this->tpl['duration_value'] = $this->duration_value;
-
- // Hidden
- if ($this->user->rights->service->hidden)
- {
- $this->tpl['hidden'] = yn($this->hidden);
- }
- else
- {
- $this->tpl['hidden'] = yn("No");
- }
-
- // Stock alert
- $this->tpl['seuil_stock_alerte'] = $this->seuil_stock_alerte;
+ parent::assign_values($action);
if ($action == 'create')
{
// Title
$this->tpl['title'] = load_fiche_titre($langs->trans("NewService"));
-
- // Price
- $this->tpl['price'] = $this->price;
- $this->tpl['price_min'] = $this->price_min;
- $this->tpl['price_base_type'] = $html->load_PriceBaseType($this->price_base_type, "price_base_type");
-
- // VAT
- $this->tpl['tva_tx'] = $html->load_tva("tva_tx",$conf->defaulttx,$mysoc,'');
}
if ($action == 'edit')
@@ -135,17 +90,7 @@ class ProductService extends Product
}
if ($action == 'create' || $action == 'edit')
- {
- // Status
- $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell"));
- $this->tpl['status'] = $html->selectarray('statut',$statutarray,$this->status);
-
- // Hidden
- if ($this->user->rights->service->hidden)
- {
- $this->tpl['hidden'] = $html->selectyesno('hidden',$this->hidden);
- }
-
+ {
// Duration unit
// TODO creer fonction
$duration_unit = 'duration_unit=='h'?' checked':'').'>'.$langs->trans("Hour");
@@ -158,52 +103,17 @@ class ProductService extends Product
$duration_unit.= ' ';
$duration_unit.= 'duration_unit=='y'?' checked':'').'>'.$langs->trans("Year");
$this->tpl['duration_unit'] = $duration_unit;
-
- // TODO creer fonction
- if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC)
- {
- require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
-
- $doleditor=new DolEditor('desc',$this->description,160,'dolibarr_notes','',false);
- $this->tpl['doleditor_description'] = $doleditor;
-
- $doleditor=new DolEditor('note',$this->note,180,'dolibarr_notes','',false);
- $this->tpl['doleditor_note'] = $doleditor;
- }
- else
- {
- $textarea = '';
- $this->tpl['textarea_description'] = $textarea;
-
- $textarea = '';
- $this->tpl['textarea_note'] = $textarea;
- }
}
if ($action == 'view')
- {
- // Ref
- $this->tpl['ref'] = $html->showrefnav($this,'ref','',1,'ref');
-
+ {
// Photo
$this->tpl['nblignes'] = 4;
- if ($this->is_photo_available($conf->produit->dir_output))
+ if ($this->is_photo_available($conf->service->dir_output))
{
- $this->tpl['photos'] = $this->show_photos($conf->produit->dir_output,1,1,0,0,0,80);
+ $this->tpl['photos'] = $this->show_photos($conf->service->dir_output,1,1,0,0,0,80);
}
- // Accountancy buy code
- $this->tpl['accountancyBuyCodeKey'] = $html->editfieldkey("ProductAccountancyBuyCode",'productaccountancycodesell',$this->accountancy_code_sell,'id',$this->id,$user->rights->produit->creer);
- $this->tpl['accountancyBuyCodeVal'] = $html->editfieldval("ProductAccountancyBuyCode",'productaccountancycodesell',$this->accountancy_code_sell,'id',$this->id,$user->rights->produit->creer);
-
- // Accountancy sell code
- $this->tpl['accountancySellCodeKey'] = $html->editfieldkey("ProductAccountancySellCode",'productaccountancycodebuy',$this->accountancy_code_buy,'id',$this->id,$user->rights->produit->creer);
- $this->tpl['accountancySellCodeVal'] = $html->editfieldval("ProductAccountancySellCode",'productaccountancycodebuy',$this->accountancy_code_buy,'id',$this->id,$user->rights->produit->creer);
-
// Duration
if ($this->duration_value > 1)
{
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index f91b0f444e0..91a3fc17656 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -2830,6 +2830,108 @@ class Product extends CommonObject
return -1;
}
}
+
+ /**
+ * \brief Affecte les valeurs communes
+ */
+ function assign_values($action='')
+ {
+ global $conf,$langs;
+ global $html;
+
+ // canvas
+ $this->tpl['canvas'] = $this->canvas;
+
+ // id
+ $this->tpl['id'] = $this->id;
+
+ // Ref
+ $this->tpl['ref'] = $this->ref;
+
+ // Label
+ $this->tpl['label'] = $this->libelle;
+
+ // Description
+ $this->tpl['description'] = nl2br($this->description);
+
+ // Statut
+ $this->tpl['status'] = $this->getLibStatut(2);
+
+ // Note
+ $this->tpl['note'] = nl2br($this->note);
+
+ // Hidden
+ if ($this->user->rights->produit->hidden)
+ {
+ $this->tpl['hidden'] = yn($this->hidden);
+ }
+ else
+ {
+ $this->tpl['hidden'] = yn("No");
+ }
+
+ if ($action == 'create')
+ {
+ // Price
+ $this->tpl['price'] = $this->price;
+ $this->tpl['price_min'] = $this->price_min;
+ $this->tpl['price_base_type'] = $html->load_PriceBaseType($this->price_base_type, "price_base_type");
+
+ // VAT
+ $this->tpl['tva_tx'] = $html->load_tva("tva_tx",$conf->defaulttx,$mysoc,'');
+ }
+
+ if ($action == 'create' || $action == 'edit')
+ {
+ // Status
+ $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell"));
+ $this->tpl['status'] = $html->selectarray('statut',$statutarray,$this->status);
+
+ // Hidden
+ if ($this->user->rights->produit->hidden)
+ {
+ $this->tpl['hidden'] = $html->selectyesno('hidden',$this->hidden);
+ }
+
+ // TODO creer fonction
+ if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC)
+ {
+ require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
+
+ $doleditor=new DolEditor('desc',$this->description,160,'dolibarr_notes','',false);
+ $this->tpl['doleditor_description'] = $doleditor;
+
+ $doleditor=new DolEditor('note',$this->note,180,'dolibarr_notes','',false);
+ $this->tpl['doleditor_note'] = $doleditor;
+ }
+ else
+ {
+ $textarea = '';
+ $this->tpl['textarea_description'] = $textarea;
+
+ $textarea = '';
+ $this->tpl['textarea_note'] = $textarea;
+ }
+ }
+
+ if ($action == 'view')
+ {
+ // Ref
+ $this->tpl['ref'] = $html->showrefnav($this,'ref','',1,'ref');
+
+ // Accountancy buy code
+ $this->tpl['accountancyBuyCodeKey'] = $html->editfieldkey("ProductAccountancyBuyCode",'productaccountancycodesell',$this->accountancy_code_sell,'id',$this->id,$user->rights->produit->creer);
+ $this->tpl['accountancyBuyCodeVal'] = $html->editfieldval("ProductAccountancyBuyCode",'productaccountancycodesell',$this->accountancy_code_sell,'id',$this->id,$user->rights->produit->creer);
+
+ // Accountancy sell code
+ $this->tpl['accountancySellCodeKey'] = $html->editfieldkey("ProductAccountancySellCode",'productaccountancycodebuy',$this->accountancy_code_buy,'id',$this->id,$user->rights->produit->creer);
+ $this->tpl['accountancySellCodeVal'] = $html->editfieldval("ProductAccountancySellCode",'productaccountancycodebuy',$this->accountancy_code_buy,'id',$this->id,$user->rights->produit->creer);
+ }
+ }
/**
* \brief Affecte les valeurs smarty