Skip to content

Commit

Permalink
Qual: Uniformize code for canvas of product/service with code of canv…
Browse files Browse the repository at this point in the history
…as for company and contact.
  • Loading branch information
eldy committed Aug 31, 2011
1 parent 7723d9e commit 8b3ec4e
Show file tree
Hide file tree
Showing 15 changed files with 330 additions and 324 deletions.
106 changes: 65 additions & 41 deletions .../canvas/default/product.default.class.php → ...as/product/actions_card_product.class.php 100644 → 100755
Expand Up @@ -16,29 +16,32 @@
*/

/**
* \file htdocs/product/canvas/default/product.default.class.php
* \file htdocs/product/canvas/product/actions_card_product.class.php
* \ingroup produit
* \brief Fichier de la classe des produits par defaut
*/
include_once(DOL_DOCUMENT_ROOT.'/product/class/product.class.php');

/**
* \class ProductDefault
* \brief Classe permettant la gestion produits par defaut, cette classe surcharge la classe produit
* \class ActionsCardProduct
* \brief Class with controller methods for product canvas
*/
class ProductDefault extends Product
class ActionsCardProduct
{
//! Numero d'erreur Plage 1280-1535
var $errno = 0;
//! Template container
var $db;
var $targetmodule;
var $canvas;
var $card;

//! Template container
var $tpl = array();

/**
* \brief Constructeur de la classe
* \param DB Handler acces base de donnees
* \param id Id produit (0 par defaut)
*/
function ProductDefault($DB=0, $id=0, $user=0)
function ActionsCardProduct($DB=0, $id=0, $user=0)
{
$this->db = $DB;
$this->id = $id ;
Expand Down Expand Up @@ -71,89 +74,110 @@ function fetch($id='', $ref='', $action='')
}

/**
* \brief Assigne les valeurs pour les templates
* \param object object
* Assign custom values for canvas (for example into this->tpl to be used by templates)
*
* @param action Type of action
*/
function assign_values($action='')
{
global $conf,$langs;
global $html;
global $formproduct;

parent::assign_values($action);
global $conf,$langs,$user;
global $html, $formproduct;

// Stock alert
$this->tpl['seuil_stock_alerte'] = $this->seuil_stock_alerte;
$this->tpl['finished'] = $this->object->finished;
$this->tpl['ref'] = $this->object->ref;
$this->tpl['label'] = $this->object->label;
$this->tpl['id'] = $this->object->id;
$this->tpl['type'] = $this->object->type;
$this->tpl['note'] = $this->object->note;
$this->tpl['seuil_stock_alerte'] = $this->object->seuil_stock_alerte;

if ($action == 'create')
{
// Title
$this->tpl['title'] = load_fiche_titre($langs->trans("NewProduct"));
$this->tpl['title'] = $langs->trans("NewProduct");
}

if ($action == 'edit')
{
$this->tpl['title'] = load_fiche_titre($langs->trans('Modify').' '.$langs->trans('Product').' : '.$this->ref, "");
$this->tpl['title'] = $langs->trans('Modify').' '.$langs->trans('Product').' : '.$this->object->ref;
}

if ($action == 'create' || $action == 'edit')
{
// Finished
// Status
$statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell"));
$this->tpl['status'] = $html->selectarray('statut',$statutarray,$_POST["statut"]);

$statutarray=array('1' => $langs->trans("ProductStatusOnBuy"), '0' => $langs->trans("ProductStatusNotOnBuy"));
$this->tpl['status_buy'] = $html->selectarray('statut_buy',$statutarray,$_POST["statut_buy"]);

// Finished
$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->object->finished);

// Weight
$this->tpl['weight'] = $this->weight;
$this->tpl['weight_units'] = $formproduct->load_measuring_units("weight_units","weight",$this->weight_units);
$this->tpl['weight'] = $this->object->weight;
$this->tpl['weight_units'] = $formproduct->load_measuring_units("weight_units","weight",$this->object->weight_units);

// Length
$this->tpl['length'] = $this->length;
$this->tpl['length_units'] = $formproduct->load_measuring_units("length_units","size",$this->length_units);
$this->tpl['length'] = $this->object->length;
$this->tpl['length_units'] = $formproduct->load_measuring_units("length_units","size",$this->object->length_units);

// Surface
$this->tpl['surface'] = $this->surface;
$this->tpl['surface_units'] = $formproduct->load_measuring_units("surface_units","surface",$this->surface_units);
$this->tpl['surface'] = $this->object->surface;
$this->tpl['surface_units'] = $formproduct->load_measuring_units("surface_units","surface",$this->object->surface_units);

// Volume
$this->tpl['volume'] = $this->volume;
$this->tpl['volume_units'] = $formproduct->load_measuring_units("volume_units","volume",$this->volume_units);
$this->tpl['volume'] = $this->object->volume;
$this->tpl['volume_units'] = $formproduct->load_measuring_units("volume_units","volume",$this->object->volume_units);
}

if ($action == 'view')
{
// Photo
$head=product_prepare_head($this->object, $user);
$titre=$langs->trans("CardProduct".$this->object->type);
$picto=($this->object->type==1?'service':'product');
$this->tpl['fiche_head']=dol_get_fiche_head($head, 'card', $titre, 0, $picto);

// Status
$this->tpl['status'] = $this->object->getLibStatut(2,0);
$this->tpl['status_buy'] = $this->object->getLibStatut(2,1);

// Photo
$this->tpl['nblignes'] = 4;
if ($this->is_photo_available($conf->product->dir_output))
if ($this->object->is_photo_available($conf->product->dir_output))
{
$this->tpl['photos'] = $this->show_photos($conf->product->dir_output,1,1,0,0,0,80);
$this->tpl['photos'] = $this->object->show_photos($conf->product->dir_output,1,1,0,0,0,80);
}

// Nature
$this->tpl['finished'] = $this->getLibFinished();
$this->tpl['finished'] = $this->object->getLibFinished();

// Weight
if ($this->weight != '')
if ($this->object->weight != '')
{
$this->tpl['weight'] = $this->weight." ".measuring_units_string($this->weight_units,"weight");
$this->tpl['weight'] = $this->object->weight." ".measuring_units_string($this->object->weight_units,"weight");
}

// Length
if ($this->length != '')
if ($this->object->length != '')
{
$this->tpl['length'] = $this->length." ".measuring_units_string($this->length_units,"size");
$this->tpl['length'] = $this->object->length." ".measuring_units_string($this->object->length_units,"size");
}

// Surface
if ($this->surface != '')
if ($this->object->surface != '')
{
$this->tpl['surface'] = $this->surface." ".measuring_units_string($this->surface_units,"surface");
$this->tpl['surface'] = $this->object->surface." ".measuring_units_string($this->object->surface_units,"surface");
}

// Volume
if ($this->volume != '')
if ($this->object->volume != '')
{
$this->tpl['volume'] = $this->volume." ".measuring_units_string($this->volume_units,"volume");
$this->tpl['volume'] = $this->object->volume." ".measuring_units_string($this->object->volume_units,"volume");
}

$this->tpl['fiche_end']=dol_get_fiche_end();
}
}

Expand Down
File renamed without changes.
63 changes: 29 additions & 34 deletions ...product/canvas/default/tpl/create.tpl.php → ...ct/canvas/product/tpl/card_create.tpl.php 100644 → 100755
Expand Up @@ -19,85 +19,80 @@

<!-- BEGIN PHP TEMPLATE -->

<?php echo $this->object->tpl['title']; ?>
<?php print_fiche_titre($this->control->tpl['title']); ?>

<?php if ($mesg) { ?>
<br><div class="error"><?php echo $mesg; ?></div><br>
<?php } ?>
<?php dol_htmloutput_errors($this->control->tpl['error'],$this->control->tpl['errors']); ?>

<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="type" value="0">
<input type="hidden" name="canvas" value="<?php echo $_GET['canvas']; ?>">
<input type="hidden" name="canvas" value="<?php echo $canvas; ?>">

<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 $this->object->tpl['ref']; ?>">
<td><input name="ref" size="40" maxlength="32" value="<?php echo $this->control->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 $this->object->tpl['label']; ?>"></td>
<td><input name="libelle" size="40" value="<?php echo $this->control->tpl['label']; ?>"></td>
</tr>

<tr>
<td class="fieldrequired"><?php echo $langs->trans("Status").' ('.$langs->trans("Sell").')'; ?></td>
<td><?php echo $this->control->tpl['status']; ?></td>
</tr>

<tr>
<td class="fieldrequired"><?php echo $langs->trans("Status"); ?></td>
<td><?php echo $this->object->tpl['status']; ?></td>
<td class="fieldrequired"><?php echo $langs->trans("Status").' ('.$langs->trans("Buy").')'; ?></td>
<td><?php echo $this->control->tpl['status_buy']; ?></td>
</tr>

<?php if ($conf->stock->enabled) { ?>
<tr><td><?php echo $langs->trans("StockLimit"); ?></td><td>
<input name="seuil_stock_alerte" size="4" value="<?php echo $this->object->tpl['seuil_stock_alerte']; ?>">
<input name="seuil_stock_alerte" size="4" value="<?php echo $this->control->tpl['seuil_stock_alerte']; ?>">
</td></tr>
<?php } else { ?>
<input name="seuil_stock_alerte" type="hidden" value="0">
<?php } ?>

<tr><td valign="top"><?php echo $langs->trans("Description"); ?></td><td>
<?php if (! $this->object->tpl['textarea_description']) {
$this->object->tpl['doleditor_description']->Create();
}else{
echo $this->object->tpl['textarea_description'];
}?>
<?php echo $this->control->tpl['textarea_description']; ?>
</td></tr>

<tr><td><?php echo $langs->trans("Nature"); ?></td><td>
<?php echo $this->object->tpl['finished']; ?>
<?php echo $this->control->tpl['finished']; ?>
</td></tr>

<tr><td><?php echo $langs->trans("Weight"); ?></td><td>
<input name="weight" size="4" value="<?php echo $this->object->tpl['weight']; ?>">
<?php echo $this->object->tpl['weight_units']; ?>
<input name="weight" size="4" value="<?php echo $this->control->tpl['weight']; ?>">
<?php echo $this->control->tpl['weight_units']; ?>
</td></tr>

<tr><td><?php echo $langs->trans("Length"); ?></td><td>
<input name="size" size="4" value="<?php echo $this->object->tpl['length']; ?>">
<?php echo $this->object->tpl['length_units']; ?>
<input name="size" size="4" value="<?php echo $this->control->tpl['length']; ?>">
<?php echo $this->control->tpl['length_units']; ?>
</td></tr>

<tr><td><?php echo $langs->trans("Surface"); ?></td><td>
<input name="surface" size="4" value="<?php echo $this->object->tpl['surface']; ?>">
<?php echo $this->object->tpl['surface_units']; ?>
<input name="surface" size="4" value="<?php echo $this->control->tpl['surface']; ?>">
<?php echo $this->control->tpl['surface_units']; ?>
</td></tr>

<tr><td><?php echo $langs->trans("Volume"); ?></td><td>
<input name="volume" size="4" value="<?php echo $this->object->tpl['volume']; ?>">
<?php echo $this->object->tpl['volume_units']; ?>
<input name="volume" size="4" value="<?php echo $this->control->tpl['volume']; ?>">
<?php echo $this->control->tpl['volume_units']; ?>
</td></tr>

<tr><td><?php echo $langs->trans("Hidden"); ?></td>
<td><?php echo $this->object->tpl['hidden']; ?></td></tr>
<td><?php echo $this->control->tpl['hidden']; ?></td></tr>

<tr><td valign="top"><?php echo $langs->trans("NoteNotVisibleOnBill"); ?></td><td>
<?php if (! $this->object->tpl['textarea_note']) {
$this->object->tpl['doleditor_note']->Create();
}else{
echo $this->object->tpl['textarea_note'];
}?>
<?php echo $this->control->tpl['textarea_note']; ?>
</td></tr>
</table>

Expand All @@ -108,16 +103,16 @@
<table class="border" width="100%">

<tr><td><?php echo $langs->trans("SellingPrice"); ?></td>
<td><input name="price" size="10" value="<?php echo $this->object->tpl['price']; ?>">
<?php echo $this->object->tpl['price_base_type']; ?>
<td><input name="price" size="10" value="<?php echo $this->control->tpl['price']; ?>">
<?php echo $this->control->tpl['price_base_type']; ?>
</td></tr>

<tr><td><?php echo $langs->trans("MinPrice"); ?></td>
<td><input name="price_min" size="10" value="<?php echo $this->object->tpl['price_min']; ?>">
<td><input name="price_min" size="10" value="<?php echo $this->control->tpl['price_min']; ?>">
</td></tr>

<tr><td width="20%"><?php echo $langs->trans("VATRate"); ?></td><td>
<?php echo $this->object->tpl['tva_tx']; ?>
<?php echo $this->control->tpl['tva_tx']; ?>
</td></tr>

</table>
Expand Down

0 comments on commit 8b3ec4e

Please sign in to comment.