Works on product canvas and templates
!! WARNING : not stable !!
This commit is contained in:
parent
01b46068e6
commit
cd27d9463b
@ -81,36 +81,7 @@ class ProductDefault extends Product
|
|||||||
global $html;
|
global $html;
|
||||||
global $formproduct;
|
global $formproduct;
|
||||||
|
|
||||||
// canvas
|
parent::assign_values($action);
|
||||||
$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");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stock alert
|
// Stock alert
|
||||||
$this->tpl['seuil_stock_alerte'] = $this->seuil_stock_alerte;
|
$this->tpl['seuil_stock_alerte'] = $this->seuil_stock_alerte;
|
||||||
@ -119,14 +90,6 @@ class ProductDefault extends Product
|
|||||||
{
|
{
|
||||||
// Title
|
// Title
|
||||||
$this->tpl['title'] = load_fiche_titre($langs->trans("NewProduct"));
|
$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')
|
if ($action == 'edit')
|
||||||
@ -136,10 +99,6 @@ class ProductDefault extends Product
|
|||||||
|
|
||||||
if ($action == 'create' || $action == 'edit')
|
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
|
// Finished
|
||||||
$statutarray=array('1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial"));
|
$statutarray=array('1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial"));
|
||||||
$this->tpl['finished'] = $html->selectarray('finished',$statutarray,$this->finished);
|
$this->tpl['finished'] = $html->selectarray('finished',$statutarray,$this->finished);
|
||||||
@ -159,43 +118,10 @@ class ProductDefault extends Product
|
|||||||
// Volume
|
// Volume
|
||||||
$this->tpl['volume'] = $this->volume;
|
$this->tpl['volume'] = $this->volume;
|
||||||
$this->tpl['volume_units'] = $formproduct->load_measuring_units("volume_units","volume",$this->volume_units);
|
$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 = '<textarea name="desc" rows="4" cols="90">';
|
|
||||||
$textarea.= $this->description;
|
|
||||||
$textarea.= '</textarea>';
|
|
||||||
$this->tpl['textarea_description'] = $textarea;
|
|
||||||
|
|
||||||
$textarea = '<textarea name="note" rows="8" cols="70">';
|
|
||||||
$textarea.= $this->note;
|
|
||||||
$textarea.= '</textarea>';
|
|
||||||
$this->tpl['textarea_note'] = $textarea;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'view')
|
if ($action == 'view')
|
||||||
{
|
{
|
||||||
// Ref
|
|
||||||
$this->tpl['ref'] = $html->showrefnav($this,'ref','',1,'ref');
|
|
||||||
|
|
||||||
// Photo
|
// Photo
|
||||||
$this->tpl['nblignes'] = 4;
|
$this->tpl['nblignes'] = 4;
|
||||||
if ($this->is_photo_available($conf->produit->dir_output))
|
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);
|
$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
|
// Nature
|
||||||
$this->tpl['finished'] = $this->getLibFinished();
|
$this->tpl['finished'] = $this->getLibFinished();
|
||||||
|
|
||||||
|
|||||||
@ -75,58 +75,13 @@ class ProductService extends Product
|
|||||||
function assign_values($action='')
|
function assign_values($action='')
|
||||||
{
|
{
|
||||||
global $conf,$langs;
|
global $conf,$langs;
|
||||||
global $html;
|
|
||||||
global $formproduct;
|
|
||||||
|
|
||||||
// canvas
|
parent::assign_values($action);
|
||||||
$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;
|
|
||||||
|
|
||||||
if ($action == 'create')
|
if ($action == 'create')
|
||||||
{
|
{
|
||||||
// Title
|
// Title
|
||||||
$this->tpl['title'] = load_fiche_titre($langs->trans("NewService"));
|
$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')
|
if ($action == 'edit')
|
||||||
@ -135,17 +90,7 @@ class ProductService extends Product
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'create' || $action == 'edit')
|
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
|
// Duration unit
|
||||||
// TODO creer fonction
|
// TODO creer fonction
|
||||||
$duration_unit = '<input name="duration_unit" type="radio" value="h"'.($this->duration_unit=='h'?' checked':'').'>'.$langs->trans("Hour");
|
$duration_unit = '<input name="duration_unit" type="radio" value="h"'.($this->duration_unit=='h'?' checked':'').'>'.$langs->trans("Hour");
|
||||||
@ -158,52 +103,17 @@ class ProductService extends Product
|
|||||||
$duration_unit.= ' ';
|
$duration_unit.= ' ';
|
||||||
$duration_unit.= '<input name="duration_unit" type="radio" value="y"'.($this->duration_unit=='y'?' checked':'').'>'.$langs->trans("Year");
|
$duration_unit.= '<input name="duration_unit" type="radio" value="y"'.($this->duration_unit=='y'?' checked':'').'>'.$langs->trans("Year");
|
||||||
$this->tpl['duration_unit'] = $duration_unit;
|
$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 = '<textarea name="desc" rows="4" cols="90">';
|
|
||||||
$textarea.= $this->description;
|
|
||||||
$textarea.= '</textarea>';
|
|
||||||
$this->tpl['textarea_description'] = $textarea;
|
|
||||||
|
|
||||||
$textarea = '<textarea name="note" rows="8" cols="70">';
|
|
||||||
$textarea.= $this->note;
|
|
||||||
$textarea.= '</textarea>';
|
|
||||||
$this->tpl['textarea_note'] = $textarea;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'view')
|
if ($action == 'view')
|
||||||
{
|
{
|
||||||
// Ref
|
|
||||||
$this->tpl['ref'] = $html->showrefnav($this,'ref','',1,'ref');
|
|
||||||
|
|
||||||
// Photo
|
// Photo
|
||||||
$this->tpl['nblignes'] = 4;
|
$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
|
// Duration
|
||||||
if ($this->duration_value > 1)
|
if ($this->duration_value > 1)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -2830,6 +2830,108 @@ class Product extends CommonObject
|
|||||||
return -1;
|
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 = '<textarea name="desc" rows="4" cols="90">';
|
||||||
|
$textarea.= $this->description;
|
||||||
|
$textarea.= '</textarea>';
|
||||||
|
$this->tpl['textarea_description'] = $textarea;
|
||||||
|
|
||||||
|
$textarea = '<textarea name="note" rows="8" cols="70">';
|
||||||
|
$textarea.= $this->note;
|
||||||
|
$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
|
* \brief Affecte les valeurs smarty
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user