Works on product canvas and templates

!! WARNING : not stable !!
This commit is contained in:
Regis Houssin 2010-05-02 05:39:43 +00:00
parent fa73ddf93c
commit 5cc40ab6f4
3 changed files with 74 additions and 55 deletions

View File

@ -80,19 +80,72 @@ class ProductDefault extends Product
global $conf,$langs,$html;
// Ref
$this->tpl['showrefnav'] = $html->showrefnav($this,'ref','',1,'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 ($user->rights->produit->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')
{
$this->tpl['cardTitle'] = load_fiche_titre($langs->trans("NewProduct"));
// Title
$this->tpl['title'] = load_fiche_titre($langs->trans("NewProduct"));
// 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);
}
if ($action == 'create' || $action == 'edit')
{
// 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',$product->description,160,'dolibarr_notes','',false);
$this->tpl['doleditor'] = $doleditor;
}
else
{
$textarea = '<textarea name="desc" rows="4" cols="90">';
$textarea.= $product->description;
$textarea.= '</textarea>';
$this->tpl['textarea'] = $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))
{
@ -107,11 +160,8 @@ class ProductDefault extends Product
$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);
// Description
$this->tpl['description'] = nl2br($this->description);
// Nature
$this->tpl['finishedLabel'] = $this->getLibFinished();
$this->tpl['finished'] = $this->getLibFinished();
// Weight
if ($this->weight != '')
@ -136,19 +186,6 @@ class ProductDefault extends Product
{
$this->tpl['volume'] = $this->volume." ".measuring_units_string($this->volume_units,"volume");
}
// Hidden
if ($user->rights->produit->hidden)
{
$this->tpl['hidden'] = yn($this->hidden);
}
else
{
$this->tpl['hidden'] = yn("No");
}
// Note
$this->tpl['note'] = nl2br($this->note);
}
}

View File

@ -26,62 +26,44 @@
<input type="hidden" name="action" value="add">
<input type="hidden" name="canvas" value="<?php echo $_GET['canvas']; ?>">
<?php echo $product->tpl['cardTitle']; ?>
<?php echo $product->tpl['title']; ?>
<table class="border" width="100%">
<tr>
<td class="fieldrequired" width="20%"><?php echo $langs->trans("Ref"); ?></td>
<td><input name="ref" size="40" maxlength="32" value="<?php echo $_POST["ref"]; ?>">
if ($_error == 1)
{
print $langs->trans("RefAlreadyExists");
}
<td><input name="ref" size="40" maxlength="32" value="<?php echo $product->tpl['ref']; ?>">
<?php if ($_error == 1) echo $langs->trans("RefAlreadyExists"); ?>
</td></tr>
<tr>
<td class="fieldrequired"><?php echo $langs->trans("Label"); ?></td>
<td><input name="libelle" size="40" value="<?php echo $_POST["libelle"]; ?>"></td>
<td><input name="libelle" size="40" value="<?php echo $product->tpl['label']; ?>"></td>
</tr>
<tr>
<td class="fieldrequired"><?php echo $langs->trans("Status"); ?></td><td>
$statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell"));
$html->select_array('statut',$statutarray,$_POST["statut"]);
</td>
<td class="fieldrequired"><?php echo $langs->trans("Status"); ?></td>
<td><?php echo $product->tpl['status']; ?></td>
</tr>
if ($_GET["type"] != 1 && $conf->stock->enabled)
{
<?php if ($conf->stock->enabled) { ?>
<tr><td><?php echo $langs->trans("StockLimit"); ?></td><td>
<input name="seuil_stock_alerte" size="4" value="<?php echo $_POST["seuil_stock_alerte"]; ?>">
<input name="seuil_stock_alerte" size="4" value="<?php echo $product->tpl['seuil_stock_alerte']; ?>">
</td></tr>
}
else
{
<?php } else { ?>
<input name="seuil_stock_alerte" type="hidden" value="0">
}
<?php } ?>
<tr><td valign="top"><?php echo $langs->trans("Description"); ?></td><td>
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC)
{
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('desc',$_POST["desc"],160,'dolibarr_notes','',false);
$doleditor->Create();
}
else
{
print '<textarea name="desc" rows="4" cols="90">';
print $_POST["desc"];
print '</textarea>';
}
<?php if (! $product->tpl['textarea']) {
$product->tpl['doleditor']->Create();
}else{
echo $product->tpl['textarea'];
}?>
</td></tr>
<tr><td><?php echo $langs->trans("Nature"); ?></td><td>
$statutarray=array('1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial"));
$html->select_array('finished',$statutarray,$_POST["finished"]);
<?php echo $product->tpl['finished']; ?>
</td></tr>
<tr><td><?php echo $langs->trans("Weight"); ?></td><td>

View File

@ -25,7 +25,7 @@
<tr>
<td width="15%"><?php echo $langs->trans("Ref"); ?></td>
<td colspan="2"><?php echo $product->tpl['showrefnav']; ?></td>
<td colspan="2"><?php echo $product->tpl['ref']; ?></td>
</tr>
<tr>
@ -62,7 +62,7 @@
<tr>
<td><?php echo $langs->trans("Nature"); ?></td>
<td colspan="2"><?php echo $product->tpl['finishedLabel']; ?></td>
<td colspan="2"><?php echo $product->tpl['finished']; ?></td>
</tr>
<tr>