Works on product canvas and templates
!! WARNING : not stable !!
This commit is contained in:
parent
968addfad3
commit
f2dc99dc7f
@ -64,9 +64,9 @@ class ProductDefault extends Product
|
||||
* \brief Lecture des donnees dans la base
|
||||
* \param id Product id
|
||||
*/
|
||||
function fetchCanvas($id='', $action='')
|
||||
function fetch($id='', $action='')
|
||||
{
|
||||
$result = $this->fetch($id);
|
||||
$result = parent::fetch($id);
|
||||
|
||||
return $result;
|
||||
}
|
||||
@ -106,54 +106,34 @@ class ProductDefault extends Product
|
||||
$this->tpl['description'] = nl2br($this->description);
|
||||
|
||||
// Nature
|
||||
if($this->type!=1)
|
||||
$this->tpl['finishedLabel'] = $this->getLibFinished();
|
||||
|
||||
// Weight
|
||||
if ($this->weight != '')
|
||||
{
|
||||
$this->tpl['finishedLabel'] = $this->getLibFinished();
|
||||
$this->tpl['weight'] = $this->weight." ".measuring_units_string($this->weight_units,"weight");
|
||||
}
|
||||
|
||||
if ($this->isservice())
|
||||
// Length
|
||||
if ($this->length != '')
|
||||
{
|
||||
// Duration
|
||||
if ($this->duration_value > 1)
|
||||
{
|
||||
$dur=array("h"=>$langs->trans("Hours"),"d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years"));
|
||||
}
|
||||
else if ($this->duration_value > 0)
|
||||
{
|
||||
$dur=array("h"=>$langs->trans("Hour"),"d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year"));
|
||||
}
|
||||
$this->tpl['duration'] = $langs->trans($dur[$this->duration_unit]);
|
||||
$this->tpl['length'] = $this->length." ".measuring_units_string($this->length_units,"size");
|
||||
}
|
||||
else
|
||||
|
||||
// Surface
|
||||
if ($this->surface != '')
|
||||
{
|
||||
// Weight
|
||||
if ($this->weight != '')
|
||||
{
|
||||
$this->tpl['weight'] = $this->weight." ".measuring_units_string($this->weight_units,"weight");
|
||||
}
|
||||
$this->tpl['surface'] = $this->surface." ".measuring_units_string($this->surface_units,"surface");
|
||||
}
|
||||
|
||||
// Length
|
||||
if ($this->length != '')
|
||||
{
|
||||
$this->tpl['length'] = $this->length." ".measuring_units_string($this->length_units,"size");
|
||||
}
|
||||
|
||||
// Surface
|
||||
if ($this->surface != '')
|
||||
{
|
||||
$this->tpl['surface'] = $this->surface." ".measuring_units_string($this->surface_units,"surface");
|
||||
}
|
||||
|
||||
// Volume
|
||||
if ($this->volume != '')
|
||||
{
|
||||
$this->tpl['volume'] = $this->volume." ".measuring_units_string($this->volume_units,"volume");
|
||||
}
|
||||
// Volume
|
||||
if ($this->volume != '')
|
||||
{
|
||||
$this->tpl['volume'] = $this->volume." ".measuring_units_string($this->volume_units,"volume");
|
||||
}
|
||||
|
||||
// Hidden
|
||||
if ((! $this->isservice() && $user->rights->produit->hidden)
|
||||
|| ($this->isservice() && $user->rights->service->hidden))
|
||||
if ($user->rights->produit->hidden)
|
||||
{
|
||||
$this->tpl['hidden'] = yn($this->hidden);
|
||||
}
|
||||
|
||||
174
htdocs/product/canvas/default/tpl/create.tpl.php
Normal file
174
htdocs/product/canvas/default/tpl/create.tpl.php
Normal file
@ -0,0 +1,174 @@
|
||||
<?php
|
||||
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
?>
|
||||
|
||||
<!-- BEGIN PHP TEMPLATE -->
|
||||
|
||||
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">
|
||||
<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>">
|
||||
<input type="hidden" name="action" value="add">
|
||||
<input type="hidden" name="canvas" value="<?php echo $_GET['canvas']; ?>">
|
||||
|
||||
|
||||
else $title=$langs->trans("NewProduct");
|
||||
print_fiche_titre($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></tr>
|
||||
|
||||
<tr>
|
||||
<td class="fieldrequired"><?php echo $langs->trans("Label"); ?></td>
|
||||
<td><input name="libelle" size="40" value="<?php echo $_POST["libelle"]; ?>"></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>
|
||||
</tr>
|
||||
|
||||
if ($_GET["type"] != 1 && $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"]; ?>">
|
||||
</td></tr>
|
||||
}
|
||||
else
|
||||
{
|
||||
<input name="seuil_stock_alerte" type="hidden" value="0">
|
||||
}
|
||||
|
||||
<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>';
|
||||
}
|
||||
|
||||
</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"]);
|
||||
</td></tr>
|
||||
|
||||
<tr><td><?php echo $langs->trans("Weight"); ?></td><td>
|
||||
<input name="weight" size="4" value="<?php echo $_POST["weight"]; ?>">
|
||||
print $formproduct->select_measuring_units("weight_units","weight");
|
||||
</td></tr>
|
||||
|
||||
<tr><td><?php echo $langs->trans("Length"); ?></td><td>
|
||||
<input name="size" size="4" value="<?php echo $_POST["size"]; ?>">
|
||||
print $formproduct->select_measuring_units("size_units","size");
|
||||
</td></tr>
|
||||
|
||||
<tr><td><?php echo $langs->trans("Surface"); ?></td><td>
|
||||
<input name="surface" size="4" value="<?php echo $_POST["surface"]; ?>">
|
||||
print $formproduct->select_measuring_units("surface_units","surface");
|
||||
</td></tr>
|
||||
|
||||
<tr><td><?php echo $langs->trans("Volume"); ?></td><td>
|
||||
<input name="volume" size="4" value="<?php echo $_POST["volume"]; ?>">
|
||||
print $formproduct->select_measuring_units("volume_units","volume");
|
||||
</td></tr>
|
||||
|
||||
// Hidden
|
||||
if (($_GET["type"] != 1 && $user->rights->produit->hidden)
|
||||
|| ($_GET["type"] == 1 && $user->rights->service->hidden))
|
||||
{
|
||||
<tr><td><?php echo $langs->trans("Hidden"); ?></td><td>
|
||||
print $html->selectyesno('hidden',$product->hidden);
|
||||
</td></tr>
|
||||
}
|
||||
else
|
||||
{
|
||||
print yn("No");
|
||||
}
|
||||
|
||||
<tr><td valign="top"><?php echo $langs->trans("NoteNotVisibleOnBill"); ?></td><td>
|
||||
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC)
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
|
||||
$doleditor=new DolEditor('note',$_POST["note"],180,'dolibarr_notes','',false);
|
||||
$doleditor->Create();
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<textarea name="note" rows="8" cols="70">';
|
||||
print $_POST["note"];
|
||||
print '</textarea>';
|
||||
}
|
||||
</td></tr>
|
||||
</table>
|
||||
|
||||
<br>
|
||||
|
||||
if ($conf->global->PRODUIT_MULTIPRICES)
|
||||
{
|
||||
// We do no show price array on create when multiprices enabled.
|
||||
// We must set them on prices tab.
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// PRIX
|
||||
print '<tr><td>'.$langs->trans("SellingPrice").'</td>';
|
||||
print '<td><input name="price" size="10" value="'.$product->price.'">';
|
||||
print $html->select_PriceBaseType($product->price_base_type, "price_base_type");
|
||||
print '</td></tr>';
|
||||
|
||||
// MIN PRICE
|
||||
print '<tr><td>'.$langs->trans("MinPrice").'</td>';
|
||||
print '<td><input name="price_min" size="10" value="'.$product->price_min.'">';
|
||||
print '</td></tr>';
|
||||
|
||||
// VAT
|
||||
print '<tr><td width="20%">'.$langs->trans("VATRate").'</td><td>';
|
||||
print $html->select_tva("tva_tx",$conf->defaulttx,$mysoc,'');
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
<center><input type="submit" class="button" value="<?php echo $langs->trans("Create"); ?>"></center>
|
||||
|
||||
</form>
|
||||
|
||||
<!-- END PHP TEMPLATE -->
|
||||
@ -55,6 +55,77 @@ class ProductService extends Product
|
||||
return 'Services';
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Lecture des donnees dans la base
|
||||
* \param id Product id
|
||||
*/
|
||||
function fetch($id='', $action='')
|
||||
{
|
||||
$result = parent::fetch($id);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Assigne les valeurs pour les templates
|
||||
* \param object object
|
||||
*/
|
||||
function assign_values($action='')
|
||||
{
|
||||
global $conf,$html;
|
||||
|
||||
// Ref
|
||||
$this->tpl['showrefnav'] = $html->showrefnav($this,'ref','',1,'ref');
|
||||
// Label
|
||||
$this->tpl['label'] = $this->libelle;
|
||||
// Statut
|
||||
$this->tpl['status'] = $this->getLibStatut(2);
|
||||
|
||||
if ($action == 'view')
|
||||
{
|
||||
$this->tpl['nblignes'] = 4;
|
||||
if ($this->is_photo_available($conf->produit->dir_output))
|
||||
{
|
||||
$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);
|
||||
|
||||
// Description
|
||||
$this->tpl['description'] = nl2br($this->description);
|
||||
|
||||
// Duration
|
||||
if ($this->duration_value > 1)
|
||||
{
|
||||
$dur=array("h"=>$langs->trans("Hours"),"d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years"));
|
||||
}
|
||||
else if ($this->duration_value > 0)
|
||||
{
|
||||
$dur=array("h"=>$langs->trans("Hour"),"d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year"));
|
||||
}
|
||||
$this->tpl['duration'] = $langs->trans($dur[$this->duration_unit]);
|
||||
|
||||
// Hidden
|
||||
if ($user->rights->service->hidden)
|
||||
{
|
||||
$this->tpl['hidden'] = yn($this->hidden);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->tpl['hidden'] = yn("No");
|
||||
}
|
||||
|
||||
// Note
|
||||
$this->tpl['note'] = nl2br($this->note);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Fetch datas list
|
||||
*/
|
||||
|
||||
@ -620,7 +620,7 @@ $formproduct = new FormProduct($db);
|
||||
*/
|
||||
if ($_GET["action"] == 'create' && ($user->rights->produit->creer || $user->rights->service->creer))
|
||||
{
|
||||
if ($_GET["canvas"] <> '' && file_exists('canvas/'.$_GET["canvas"].'/product.'.$_GET["canvas"].'.class.php'))
|
||||
if ($_GET["canvas"] <> '' && file_exists(DOL_DOCUMENT_ROOT.'/product/canvas/'.$_GET["canvas"].'/product.'.$_GET["canvas"].'.class.php'))
|
||||
{
|
||||
if (! isset($product))
|
||||
{
|
||||
@ -855,7 +855,7 @@ if ($_GET["id"] || $_GET["ref"])
|
||||
include_once(DOL_DOCUMENT_ROOT.'/product/canvas/'.$productstatic->canvas.'/product.'.$productstatic->canvas.'.class.php');
|
||||
$product = new $classname($db);
|
||||
|
||||
$result = $product->fetchCanvas($productstatic->id,'',$_GET["action"]);
|
||||
$result = $product->fetch($productstatic->id,'',$_GET["action"]);
|
||||
|
||||
$template_dir = DOL_DOCUMENT_ROOT.'/product/canvas/'.$product->canvas.'/tpl/';
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user