diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php
index 9fd690fade5..27e881019c4 100644
--- a/htdocs/html.form.class.php
+++ b/htdocs/html.form.class.php
@@ -2070,25 +2070,26 @@ class Form
*/
function select_weight_units($name='weight_units', $default='0', $adddefault=0)
{
- global $langs,$conf,$mysoc;
-
- $units[3] = "Tonne";
- $units[0] = "kg";
- $units[-3] = "g";
-
- print '';
+ global $langs,$conf,$mysoc;
+ $langs->load("other");
+
+ $units[3] = $langs->trans("WeightUnitmg");
+ $units[0] = $langs->trans("WeightUnitkg");
+ $units[-3] = $langs->trans("WeightUnitg");
+
+ print '';
}
function load_tva($name='tauxtva', $defaulttx='', $societe_vendeuse='', $societe_acheteuse='', $taux_produit='')
diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang
index 9cac1b3f3c3..3043310b548 100644
--- a/htdocs/langs/en_US/other.lang
+++ b/htdocs/langs/en_US/other.lang
@@ -59,6 +59,10 @@ FeatureNotYetAvailable=Feature not yet available in this version
FeaturesSupported=Features supported
Width=Width
Height=Height
+Weight=Weight
+WeightUnitmg=tonnes
+WeightUnitkg=kg
+WeightUnitg=g
##### Webcal #####
LoginWebcal=Login for Webcalendar
AddCalendarEntry=Add entry in calendar
diff --git a/htdocs/langs/fr_FR/other.lang b/htdocs/langs/fr_FR/other.lang
index 307eab2a43a..8dc6ffb9807 100644
--- a/htdocs/langs/fr_FR/other.lang
+++ b/htdocs/langs/fr_FR/other.lang
@@ -59,6 +59,10 @@ FeatureNotYetAvailable=Fonctionnalit
FeaturesSupported=Fonctionnalités supportées
Width=Largeur
Height=Hauteur
+Weight=Poids
+WeightUnitmg=tonnes
+WeightUnitkg=kg
+WeightUnitg=g
##### Webcal #####
LoginWebcal=Login Webcalendar
AddCalendarEntry=Ajouter entrée dans le calendrier
diff --git a/htdocs/lib/product.lib.php b/htdocs/lib/product.lib.php
index 2a6763a31aa..2f331db06fd 100644
--- a/htdocs/lib/product.lib.php
+++ b/htdocs/lib/product.lib.php
@@ -44,6 +44,11 @@ function product_prepare_head($product)
$head[$h][2] = 'price';
$h++;
+ $head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id;
+ $head[$h][1] = $langs->trans("Photos");
+ $head[$h][2] = 'photos';
+ $h++;
+
//affichage onglet catégorie
if ($conf->categorie->enabled)
{
@@ -77,6 +82,15 @@ function product_prepare_head($product)
$h++;
}
+ // sousproduits
+ if($conf->global->PRODUIT_SOUSPRODUITS == 1)
+ {
+ $head[$h][0] = DOL_URL_ROOT."/product/sousproduits/fiche.php?id=".$product->id;
+ $head[$h][1] = $langs->trans('AssociatedProducts');
+ $head[$h][2] = 'subproduct';
+ $h++;
+ }
+
if ($conf->fournisseur->enabled)
{
$head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$product->id;
@@ -90,26 +104,11 @@ function product_prepare_head($product)
$head[$h][2] = 'stats';
$h++;
- // sousproduits
- if($conf->global->PRODUIT_SOUSPRODUITS == 1)
- {
- $head[$h][0] = DOL_URL_ROOT."/product/sousproduits/fiche.php?id=".$product->id;
- $head[$h][1] = $langs->trans('AssociatedProducts');
- $head[$h][2] = 'subproduct';
- $h++;
- }
-
-
$head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$product->id;
$head[$h][1] = $langs->trans('Referers');
$head[$h][2] = 'referers';
$h++;
- $head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id;
- $head[$h][1] = $langs->trans("Photos");
- $head[$h][2] = 'photos';
- $h++;
-
$head[$h][0] = DOL_URL_ROOT.'/product/document.php?id='.$product->id;
$head[$h][1] = $langs->trans('Documents');
$head[$h][2] = 'documents';
diff --git a/htdocs/product.class.php b/htdocs/product.class.php
index a496f98888a..a98412fbdab 100644
--- a/htdocs/product.class.php
+++ b/htdocs/product.class.php
@@ -201,6 +201,7 @@ class Product
$this->db->rollback();
return -1;
}
+
/**
* \brief Mise à jour du produit en base
* \param id id du produit
@@ -219,7 +220,7 @@ class Product
$this->libelle = trim($this->libelle);
$this->description = trim($this->description);
$this->note = trim($this->note);
- $this->new_weight = trim(ereg_replace(",",".",$this->new_weight));
+ $this->new_weight = price2num($this->new_weight);
$this->new_weight_units = trim($this->new_weight_units);
$sql = "UPDATE ".MAIN_DB_PREFIX."product ";
@@ -227,12 +228,12 @@ class Product
if ($this->ref) $sql .= ",ref = '" . $this->ref ."'";
$sql .= ",tva_tx = '" . $this->tva_tx."'";
$sql .= ",envente = " . $this->status;
- $sql .= ",weight = '" . $this->new_weight."'";
+ $sql .= ",weight = " . ($this->new_weight!='' ? "'".$this->new_weight."'" : 'null');
$sql .= ",weight_units = '" . $this->new_weight_units."'";
$sql .= ",seuil_stock_alerte = '" . $this->seuil_stock_alerte."'";
$sql .= ",description = '" . addslashes($this->description) ."'";
$sql .= ",stock_loc = '" . addslashes($this->stock_loc) ."'";
- $sql .= ",note = '" . addslashes($this->note) ."'";
+ $sql .= ",note = '" . addslashes($this->note) ."'";
$sql .= ",duration = '" . $this->duration_value . $this->duration_unit ."'";
$sql .= " WHERE rowid = " . $id;
diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php
index 59889c2a443..8e08f46cab1 100644
--- a/htdocs/product/fiche.php
+++ b/htdocs/product/fiche.php
@@ -24,10 +24,10 @@
*/
/**
- \file htdocs/product/fiche.php
- \ingroup product
- \brief Page de la fiche produit
- \version $Revision$
+* \file htdocs/product/fiche.php
+* \ingroup product
+* \brief Page de la fiche produit
+* \version $Revision$
*/
require("./pre.inc.php");
@@ -47,795 +47,801 @@ $types[0] = $langs->trans("Product");
$types[1] = $langs->trans("Service");
/*
- *
- */
+*
+*/
if ($_GET["action"] == 'fastappro')
{
- $product = new Product($db);
- $product->fetch($_GET["id"]);
- $result = $product->fastappro($user);
- Header("Location: fiche.php?id=".$_GET["id"]);
- exit;
+ $product = new Product($db);
+ $product->fetch($_GET["id"]);
+ $result = $product->fastappro($user);
+ Header("Location: fiche.php?id=".$_GET["id"]);
+ exit;
}
// Action ajout d'un produit ou service
if ($_POST["action"] == 'add' && $user->rights->produit->creer)
{
- if ($_POST["canvas"] <> '' && file_exists('canvas/product.'.$_POST["canvas"].'.class.php') )
- {
- $class = 'Product'.ucfirst($_POST["canvas"]);
- include_once('canvas/product.'.$_POST["canvas"].'.class.php');
- $product = new $class($db);
- }
- else
- {
- $product = new Product($db);
- }
+ if ($_POST["canvas"] <> '' && file_exists('canvas/product.'.$_POST["canvas"].'.class.php') )
+ {
+ $class = 'Product'.ucfirst($_POST["canvas"]);
+ include_once('canvas/product.'.$_POST["canvas"].'.class.php');
+ $product = new $class($db);
+ }
+ else
+ {
+ $product = new Product($db);
+ }
- $product->ref = $_POST["ref"];
- $product->libelle = $_POST["libelle"];
- $product->price = $_POST["price"];
- $product->tva_tx = $_POST["tva_tx"];
- $product->type = $_POST["type"];
- $product->status = $_POST["statut"];
- $product->description = $_POST["desc"];
- $product->note = $_POST["note"];
- $product->duration_value = $_POST["duration_value"];
- $product->duration_unit = $_POST["duration_unit"];
- $product->seuil_stock_alerte = $_POST["seuil_stock_alerte"];
- $product->canvas = $_POST["canvas"];
- $product->new_weight = $_POST["weight"];
- $product->new_weight_units = $_POST["weight_units"];
- // MultiPrix
- if($conf->global->PRODUIT_MULTIPRICES == 1)
- {
- for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++)
- {
- if($_POST["price_".$i])
- $product->multiprices["$i"]=ereg_replace(" ","",$_POST["price_".$i]);
- else
- $product->multiprices["$i"] = "";
- }
- }
-
- if ( $value != $current_lang ) $e_product = $product;
-
- // Produit spécifique
- // $_POST n'est pas utilise dans la classe Product
- // mais dans des classes qui hérite de Product
- $id = $product->Create($user, $_POST);
-
- if ($id > 0)
- {
- Header("Location: fiche.php?id=$id");
- exit;
- }
- else
- {
- $mesg='
'.$product->error.'
';
- $_GET["action"] = "create";
- $_GET["type"] = $_POST["type"];
- }
+ $product->ref = $_POST["ref"];
+ $product->libelle = $_POST["libelle"];
+ $product->price = $_POST["price"];
+ $product->tva_tx = $_POST["tva_tx"];
+ $product->type = $_POST["type"];
+ $product->status = $_POST["statut"];
+ $product->description = $_POST["desc"];
+ $product->note = $_POST["note"];
+ $product->duration_value = $_POST["duration_value"];
+ $product->duration_unit = $_POST["duration_unit"];
+ $product->seuil_stock_alerte = $_POST["seuil_stock_alerte"];
+ $product->canvas = $_POST["canvas"];
+ $product->new_weight = $_POST["weight"];
+ $product->new_weight_units = $_POST["weight_units"];
+ // MultiPrix
+ if($conf->global->PRODUIT_MULTIPRICES == 1)
+ {
+ for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++)
+ {
+ if($_POST["price_".$i])
+ $product->multiprices["$i"]=ereg_replace(" ","",$_POST["price_".$i]);
+ else
+ $product->multiprices["$i"] = "";
+ }
+ }
+
+ if ( $value != $current_lang ) $e_product = $product;
+
+ // Produit spécifique
+ // $_POST n'est pas utilise dans la classe Product
+ // mais dans des classes qui hérite de Product
+ $id = $product->Create($user, $_POST);
+
+ if ($id > 0)
+ {
+ Header("Location: fiche.php?id=$id");
+ exit;
+ }
+ else
+ {
+ $mesg=''.$product->error.'
';
+ $_GET["action"] = "create";
+ $_GET["type"] = $_POST["type"];
+ }
}
// Action mise a jour d'un produit ou service
if ($_POST["action"] == 'update' &&
- $_POST["cancel"] <> $langs->trans("Cancel") &&
- $user->rights->produit->creer)
+$_POST["cancel"] <> $langs->trans("Cancel") &&
+$user->rights->produit->creer)
{
- $product = new Product($db);
- if ($product->fetch($_POST["id"]))
- {
- $product->ref = $_POST["ref"];
- $product->libelle = $_POST["libelle"];
- if ( isset( $_POST["price"] ) )
- $product->price = $_POST["price"];
- $product->tva_tx = $_POST["tva_tx"];
- $product->description = $_POST["desc"];
- $product->note = $_POST["note"];
- $product->status = $_POST["statut"];
- $product->seuil_stock_alerte = $_POST["seuil_stock_alerte"];
- $product->stock_loc = $_POST["stock_loc"];
- $product->duration_value = $_POST["duration_value"];
- $product->duration_unit = $_POST["duration_unit"];
- $product->canvas = $_POST["canvas"];
- $product->new_weight = $_POST["weight"];
- $product->new_weight_units = $_POST["weight_units"];
-
- if ($product->check())
- {
- if ($product->update($product->id, $user) > 0)
- {
- $_GET["action"] = '';
- $_GET["id"] = $_POST["id"];
- }
- else
- {
- $_GET["action"] = 'edit';
- $_GET["id"] = $_POST["id"];
- $mesg = $product->error;
- }
- }
- else
- {
- $_GET["action"] = 'edit';
- $_GET["id"] = $_POST["id"];
- $mesg = $langs->trans("ErrorProductBadRefOrLabel");
- }
-
-
- // Produit spécifique
- if ($product->canvas <> '' && file_exists('canvas/product.'.$product->canvas.'.class.php') )
+ $product = new Product($db);
+ if ($product->fetch($_POST["id"]))
{
- $class = 'Product'.ucfirst($product->canvas);
- include_once('canvas/product.'.$product->canvas.'.class.php');
-
- $product = new $class($db);
- if ($product->FetchCanvas($_POST["id"]))
- {
- $product->UpdateCanvas($_POST);
- }
- }
- }
+ $product->ref = $_POST["ref"];
+ $product->libelle = $_POST["libelle"];
+ if ( isset( $_POST["price"] ) )
+ $product->price = $_POST["price"];
+ $product->tva_tx = $_POST["tva_tx"];
+ $product->description = $_POST["desc"];
+ $product->note = $_POST["note"];
+ $product->status = $_POST["statut"];
+ $product->seuil_stock_alerte = $_POST["seuil_stock_alerte"];
+ $product->stock_loc = $_POST["stock_loc"];
+ $product->duration_value = $_POST["duration_value"];
+ $product->duration_unit = $_POST["duration_unit"];
+ $product->canvas = $_POST["canvas"];
+ $product->new_weight = $_POST["weight"];
+ $product->new_weight_units = $_POST["weight_units"];
+
+ if ($product->check())
+ {
+ if ($product->update($product->id, $user) > 0)
+ {
+ $_GET["action"] = '';
+ $_GET["id"] = $_POST["id"];
+ }
+ else
+ {
+ $_GET["action"] = 'edit';
+ $_GET["id"] = $_POST["id"];
+ $mesg = $product->error;
+ }
+ }
+ else
+ {
+ $_GET["action"] = 'edit';
+ $_GET["id"] = $_POST["id"];
+ $mesg = $langs->trans("ErrorProductBadRefOrLabel");
+ }
+
+
+ // Produit spécifique
+ if ($product->canvas <> '' && file_exists('canvas/product.'.$product->canvas.'.class.php') )
+ {
+ $class = 'Product'.ucfirst($product->canvas);
+ include_once('canvas/product.'.$product->canvas.'.class.php');
+
+ $product = new $class($db);
+ if ($product->FetchCanvas($_POST["id"]))
+ {
+ $product->UpdateCanvas($_POST);
+ }
+ }
+ }
}
// clone d'un produit
if ($_GET["action"] == 'clone' && $user->rights->produit->creer)
{
- $db->begin();
+ $db->begin();
- $product = new Product($db);
- $originalId = $_GET["id"];
- if ($product->fetch($_GET["id"]) > 0)
- {
- $product->ref = "Clone ".$product->ref;
- $product->status = 0;
- $product->id = null;
+ $product = new Product($db);
+ $originalId = $_GET["id"];
+ if ($product->fetch($_GET["id"]) > 0)
+ {
+ $product->ref = "Clone ".$product->ref;
+ $product->status = 0;
+ $product->id = null;
- if ($product->check())
- {
- $id = $product->create($user);
- if ($id > 0)
- {
- // $product->clone_fournisseurs($originalId, $id);
-
- $db->commit();
-
- Header("Location: fiche.php?id=$id");
- $db->close();
- exit;
- }
- else if ($id == -3)
- {
- $db->rollback();
-
- $_error = 1;
- $_GET["action"] = "";
- dolibarr_print_error($product->db);
- }
- else
- {
- $db->rollback();
- dolibarr_print_error($product->db);
- }
- }
- }
- else
- {
- $db->rollback();
-
- dolibarr_print_error($product->db);
- }
+ if ($product->check())
+ {
+ $id = $product->create($user);
+ if ($id > 0)
+ {
+ // $product->clone_fournisseurs($originalId, $id);
+
+ $db->commit();
+
+ Header("Location: fiche.php?id=$id");
+ $db->close();
+ exit;
+ }
+ else if ($id == -3)
+ {
+ $db->rollback();
+
+ $_error = 1;
+ $_GET["action"] = "";
+ dolibarr_print_error($product->db);
+ }
+ else
+ {
+ $db->rollback();
+ dolibarr_print_error($product->db);
+ }
+ }
+ }
+ else
+ {
+ $db->rollback();
+
+ dolibarr_print_error($product->db);
+ }
}
/*
- * Suppression d'un produit/service pas encore affecté
- */
+* Suppression d'un produit/service pas encore affect
+*/
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes' && $user->rights->produit->supprimer)
{
- $product = new Product($db);
- $product->fetch($_GET["id"]);
- $result = $product->delete($_GET["id"]);
-
- if ($result == 0)
- {
- llxHeader();
- print ''.$langs->trans("ProductDeleted",$product->ref).'
';
- llxFooter();
- exit ;
- }
- else
- {
- $reload = 0;
- $_GET["action"]='';
- }
+ $product = new Product($db);
+ $product->fetch($_GET["id"]);
+ $result = $product->delete($_GET["id"]);
+
+ if ($result == 0)
+ {
+ llxHeader();
+ print ''.$langs->trans("ProductDeleted",$product->ref).'
';
+ llxFooter();
+ exit ;
+ }
+ else
+ {
+ $reload = 0;
+ $_GET["action"]='';
+ }
}
/*
- * Ajout du produit dans une propal
- */
+* Ajout du produit dans une propal
+*/
if ($_POST["action"] == 'addinpropal')
{
- $propal = New Propal($db);
- $result=$propal->fetch($_POST["propalid"]);
- if ($result <= 0)
- {
- dolibarr_print_error($db,$propal->error);
- exit;
- }
-
- $soc = new Societe($db);
- $soc->fetch($propal->socid,$user);
+ $propal = New Propal($db);
+ $result=$propal->fetch($_POST["propalid"]);
+ if ($result <= 0)
+ {
+ dolibarr_print_error($db,$propal->error);
+ exit;
+ }
- $prod = new Product($db, $_GET['id']);
- $result=$prod->fetch($_GET['id']);
- if ($result <= 0)
- {
- dolibarr_print_error($db,$prod->error);
- exit;
- }
-
- // multiprix
- if ($conf->global->PRODUIT_MULTIPRICES == 1)
- {
- $pu = $prod->multiprices[$soc->price_level];
- }
- else
- {
- $pu=$prod->price;
- }
-
- $desc = $prod->description;
- $tva_tx = get_default_tva($mysoc,$soc,$prod->tva_tx);
-
- $result = $propal->addline($propal->id,
- $desc,
- $pu,
- $_POST["qty"],
- $tva_tx,
- $prod->id,
- $_POST["remise_percent"]);
- if ($result > 0)
- {
- Header("Location: ../comm/propal.php?propalid=".$propal->id);
- return;
- }
-
- $mesg = $langs->trans("ErrorUnknown").": $result";
+ $soc = new Societe($db);
+ $soc->fetch($propal->socid,$user);
+
+ $prod = new Product($db, $_GET['id']);
+ $result=$prod->fetch($_GET['id']);
+ if ($result <= 0)
+ {
+ dolibarr_print_error($db,$prod->error);
+ exit;
+ }
+
+ // multiprix
+ if ($conf->global->PRODUIT_MULTIPRICES == 1)
+ {
+ $pu = $prod->multiprices[$soc->price_level];
+ }
+ else
+ {
+ $pu=$prod->price;
+ }
+
+ $desc = $prod->description;
+ $tva_tx = get_default_tva($mysoc,$soc,$prod->tva_tx);
+
+ $result = $propal->addline($propal->id,
+ $desc,
+ $pu,
+ $_POST["qty"],
+ $tva_tx,
+ $prod->id,
+ $_POST["remise_percent"]);
+ if ($result > 0)
+ {
+ Header("Location: ../comm/propal.php?propalid=".$propal->id);
+ return;
+ }
+
+ $mesg = $langs->trans("ErrorUnknown").": $result";
}
/*
- * Ajout du produit dans une commande
- */
+* Ajout du produit dans une commande
+*/
if ($_POST["action"] == 'addincommande')
{
- $product = new Product($db);
- $result = $product->fetch($_GET["id"]);
-
- $commande = New Commande($db);
- $commande->fetch($_POST["commandeid"]);
-
- $soc = new Societe($db);
- $soc->fetch($commande->socid,$user);
-
- // multiprix
- if ($conf->global->PRODUIT_MULTIPRICES == 1)
- {
- $pu = $product->multiprices[$soc->price_level];
- }
- else
- {
- $pu=$product->price;
- }
-
- $tva_tx = get_default_tva($mysoc,$soc,$product->tva_tx);
-
- $result = $commande->addline($commande->id,
- $product->description,
- $pu,
- $_POST["qty"],
- $tva_tx,
- $product->id,
- $_POST["remise_percent"]);
-
- Header("Location: ../commande/fiche.php?id=".$commande->id);
- exit;
+ $product = new Product($db);
+ $result = $product->fetch($_GET["id"]);
+
+ $commande = New Commande($db);
+ $commande->fetch($_POST["commandeid"]);
+
+ $soc = new Societe($db);
+ $soc->fetch($commande->socid,$user);
+
+ // multiprix
+ if ($conf->global->PRODUIT_MULTIPRICES == 1)
+ {
+ $pu = $product->multiprices[$soc->price_level];
+ }
+ else
+ {
+ $pu=$product->price;
+ }
+
+ $tva_tx = get_default_tva($mysoc,$soc,$product->tva_tx);
+
+ $result = $commande->addline($commande->id,
+ $product->description,
+ $pu,
+ $_POST["qty"],
+ $tva_tx,
+ $product->id,
+ $_POST["remise_percent"]);
+
+ Header("Location: ../commande/fiche.php?id=".$commande->id);
+ exit;
}
/*
- * Ajout du produit dans une facture
- */
+* Ajout du produit dans une facture
+*/
if ($_POST["action"] == 'addinfacture' && $user->rights->facture->creer)
{
- $product = new Product($db);
- $result = $product->fetch($_GET["id"]);
-
- $facture = New Facture($db);
- $facture->fetch($_POST["factureid"]);
-
- $soc = new Societe($db);
- $soc->fetch($facture->socid,$user);
-
- // multiprix
- if ($conf->global->PRODUIT_MULTIPRICES == 1)
- {
- $pu = $product->multiprices[$soc->price_level];
- }
- else
- {
- $pu=$product->price;
- }
-
- $tva_tx = get_default_tva($mysoc,$soc,$product->tva_tx);
-
- $facture->addline($facture->id,
- $product->description,
- $pu,
- $_POST["qty"],
- $tva_tx,
- $product->id,
- $_POST["remise_percent"]);
-
- Header("Location: ../compta/facture.php?facid=".$facture->id);
- exit;
+ $product = new Product($db);
+ $result = $product->fetch($_GET["id"]);
+
+ $facture = New Facture($db);
+ $facture->fetch($_POST["factureid"]);
+
+ $soc = new Societe($db);
+ $soc->fetch($facture->socid,$user);
+
+ // multiprix
+ if ($conf->global->PRODUIT_MULTIPRICES == 1)
+ {
+ $pu = $product->multiprices[$soc->price_level];
+ }
+ else
+ {
+ $pu=$product->price;
+ }
+
+ $tva_tx = get_default_tva($mysoc,$soc,$product->tva_tx);
+
+ $facture->addline($facture->id,
+ $product->description,
+ $pu,
+ $_POST["qty"],
+ $tva_tx,
+ $product->id,
+ $_POST["remise_percent"]);
+
+ Header("Location: ../compta/facture.php?facid=".$facture->id);
+ exit;
}
if ($_POST["cancel"] == $langs->trans("Cancel"))
{
- $action = '';
- Header("Location: fiche.php?id=".$_POST["id"]);
- exit;
+ $action = '';
+ Header("Location: fiche.php?id=".$_POST["id"]);
+ exit;
}
$html = new Form($db);
/*
- * Action création du produit
- */
+* Action création du produit
+*/
if ($_GET["action"] == 'create' && $user->rights->produit->creer)
{
- $product = new Product($db);
-
- if ($_error == 1)
- {
- $product = $e_product;
- }
-
- llxHeader("","",$langs->trans("CardProduct".$product->type));
+ $product = new Product($db);
- if ($mesg) print "$mesg\n";
-
- if ($_GET["canvas"] == '')
- {
- print '';
- }
- else
- {
- //RODO
- $smarty->template_dir = DOL_DOCUMENT_ROOT.'/product/canvas/'.$_GET["canvas"].'/';
- $null = $html->load_tva("tva_tx",$conf->defaulttx,$mysoc,'');
- $smarty->assign('tva_taux_value', $html->tva_taux_value);
- $smarty->assign('tva_taux_libelle', $html->tva_taux_libelle);
- $smarty->display($_GET["canvas"].'-create.tpl');
- }
}
/**
- *
- * Fiche produit
- *
- */
+*
+* Fiche produit
+*
+*/
if ($_GET["id"] || $_GET["ref"])
{
- $product = new Product($db);
+ $product = new Product($db);
- if ($_GET["ref"])
- {
- $result = $product->fetch('',$_GET["ref"]);
- $_GET["id"] = $product->id;
- }
- elseif ($_GET["id"])
- {
- $result = $product->fetch($_GET["id"]);
- }
-
- // Gestion des produits specifiques
- if ($product->canvas <> '' && file_exists('canvas/product.'.$product->canvas.'.class.php') )
- {
- $class = 'Product'.ucfirst($product->canvas);
- include_once('canvas/product.'.$product->canvas.'.class.php');
-
- $product = new $class($db);
-
- $result = $product->FetchCanvas($_GET["id"]);
-
- $smarty->template_dir = DOL_DOCUMENT_ROOT.'/product/canvas/'.$product->canvas.'/';
-
- $product->assign_values($smarty);
- }
- else
- {
- $product->canvas = '';
- }
- // END TODO RODO FINISH THIS PART
-
- llxHeader("","",$langs->trans("CardProduct".$product->type));
-
- if ( $result )
- {
- if ($_GET["action"] <> 'edit')
- {
- $head=product_prepare_head($product);
- $titre=$langs->trans("CardProduct".$product->type);
- dolibarr_fiche_head($head, 'card', $titre);
- print "\n\n";
- // Confirmation de la suppression de la facture
- if ($_GET["action"] == 'delete')
- {
- $html = new Form($db);
- $html->form_confirm("fiche.php?id=".$product->id,$langs->trans("DeleteProduct"),$langs->trans("ConfirmDeleteProduct"),"confirm_delete");
- print "
\n";
- }
-
- print($mesg);
-
- $product->load_previous_next_ref();
- $previous_ref = $product->ref_previous?'ref_previous.'">'.img_previous().'':'';
- $next_ref = $product->ref_next?'ref_next.'">'.img_next().'':'';
- }
- if ($_GET["action"] <> 'edit' && $product->canvas <> '')
- {
- /*
- * Smarty en mode visu
- */
- $smarty->assign('fiche_cursor_prev',$previous_ref);
- $smarty->assign('fiche_cursor_next',$next_ref);
-
- // Photo
- //$nbphoto=$product->show_photos($conf->produit->dir_output,1,1,0);
-
- $smarty->display($product->canvas.'-view.tpl');
-
- print "\n\n";
- }
-
- if ($_GET["action"] <> 'edit' && $product->canvas == '')
- {
- /*
- * En mode visu
- */
- print '';
-
- // Reference
- print '| '.$langs->trans("Ref").' | ';
- if ($previous_ref || $next_ref) print '';
- print ' | ';
-
-
- $nblignes=6;
- if ($product->type == 0 && $conf->stock->enabled) $nblignes++;
- if ($product->type == 1) $nblignes++;
- if ($product->is_photo_available($conf->produit->dir_output))
- {
- // Photo
- print '';
- $nbphoto=$product->show_photos($conf->produit->dir_output,1,1,0);
- print ' | ';
- }
- print '
';
-
- // Libelle
- print '| '.$langs->trans("Label").' | '.$product->libelle.' |
';
-
- // MultiPrix
- if($conf->global->PRODUIT_MULTIPRICES == 1)
- {
- print '| '.$langs->trans("SellingPrice").' 1 | '.price($product->price).' | ';
- print '
';
- for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++)
- {
- print '| '.$langs->trans("SellingPrice").' '.$i.' | '.price($product->multiprices["$i"]).' | ';
- print '
';
- }
- }
- // Prix
- else
- {
- print '| '.$langs->trans("SellingPrice").' | '.price($product->price).' | ';
- print '
';
- }
- // Statut
- print '| '.$langs->trans("Status").' | ';
- print $product->getLibStatut(2);
- print ' |
';
-
- // TVA
- print '| '.$langs->trans("VATRate").' | '.$product->tva_tx.'% |
';
-
- // Stock
- if ($product->type == 0 && $conf->stock->enabled)
- {
- print '| '.$langs->trans("Stock").' | ';
- if ($product->no_stock)
- {
- print "".$langs->trans("NoStockDefined");
- }
- else
- {
- if ($product->stock_reel <= $product->seuil_stock_alerte)
- {
- print ' | '.$product->stock_reel.' Seuil : '.$product->seuil_stock_alerte;
- }
- else
- {
- print " | ".$product->stock_reel;
- }
- }
- print ' |
';
- }
-
- // Description
- print '| '.$langs->trans("Description").' | '.nl2br($product->description).' |
';
-
- // Durée
- if ($product->type == 1)
- {
- print '| '.$langs->trans("Duration").' | '.$product->duration_value.' ';
- if ($product->duration_value > 1)
- {
- $dur=array("d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years"));
- }
- else {
- $dur=array("d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year"));
- }
- print $langs->trans($dur[$product->duration_unit])." ";
-
- print ' |
';
- }
- else
- {
- print '| '.$langs->trans("Weight").' | ';
- print $product->weight." ";
- print weight_units_string($product->weight_units);
- print " |
\n";
- }
- // Note
- print '| '.$langs->trans("Note").' | '.nl2br($product->note).' |
';
- print "
\n";
- print "\n\n";
- }
- }
-
- /*
- * Fiche en mode edition
- */
- if ($_GET["action"] == 'edit' && $user->rights->produit->creer)
- {
- print_fiche_titre($langs->trans('Edit').' '.$types[$product->type].' : '.$product->ref, "");
-
- if ($mesg) {
- print '
'.$mesg.'
';
- }
-
- if ( $product->canvas == '')
- {
- print "\n";
- print "';
- print "\n";
- }
+ // Gestion des produits specifiques
+ if ($product->canvas <> '' && file_exists('canvas/product.'.$product->canvas.'.class.php') )
+ {
+ $class = 'Product'.ucfirst($product->canvas);
+ include_once('canvas/product.'.$product->canvas.'.class.php');
+
+ $product = new $class($db);
+
+ $result = $product->FetchCanvas($_GET["id"]);
+
+ $smarty->template_dir = DOL_DOCUMENT_ROOT.'/product/canvas/'.$product->canvas.'/';
+
+ $product->assign_values($smarty);
+ }
else
- {
- $null = $html->load_tva("tva_tx",$conf->defaulttx,$mysoc,'');
- $smarty->assign('tva_taux_value', $html->tva_taux_value);
- $smarty->assign('tva_taux_libelle', $html->tva_taux_libelle);
- $smarty->display($product->canvas.'-edit.tpl');
- }
- }
+ {
+ $product->canvas = '';
+ }
+ // END TODO RODO FINISH THIS PART
+
+ llxHeader("","",$langs->trans("CardProduct".$product->type));
+
+ if ( $result )
+ {
+ if ($_GET["action"] <> 'edit')
+ {
+ $head=product_prepare_head($product);
+ $titre=$langs->trans("CardProduct".$product->type);
+ dolibarr_fiche_head($head, 'card', $titre);
+ print "\n\n";
+ // Confirmation de la suppression de la facture
+ if ($_GET["action"] == 'delete')
+ {
+ $html = new Form($db);
+ $html->form_confirm("fiche.php?id=".$product->id,$langs->trans("DeleteProduct"),$langs->trans("ConfirmDeleteProduct"),"confirm_delete");
+ print "
\n";
+ }
+
+ print($mesg);
+
+ $product->load_previous_next_ref();
+ $previous_ref = $product->ref_previous?'ref_previous.'">'.img_previous().'':'';
+ $next_ref = $product->ref_next?'ref_next.'">'.img_next().'':'';
+ }
+ if ($_GET["action"] <> 'edit' && $product->canvas <> '')
+ {
+ /*
+ * Smarty en mode visu
+ */
+ $smarty->assign('fiche_cursor_prev',$previous_ref);
+ $smarty->assign('fiche_cursor_next',$next_ref);
+
+ // Photo
+ //$nbphoto=$product->show_photos($conf->produit->dir_output,1,1,0);
+
+ $smarty->display($product->canvas.'-view.tpl');
+
+ print "\n\n";
+ }
+
+ if ($_GET["action"] <> 'edit' && $product->canvas == '')
+ {
+ /*
+ * En mode visu
+ */
+ print '';
+
+ // Reference
+ print '| '.$langs->trans("Ref").' | ';
+ if ($previous_ref || $next_ref) print '';
+ print ' | ';
+
+
+ $nblignes=6;
+ if ($product->type == 0 && $conf->stock->enabled) $nblignes++;
+ if ($product->type == 1) $nblignes++;
+ if ($product->is_photo_available($conf->produit->dir_output))
+ {
+ // Photo
+ print '';
+ $nbphoto=$product->show_photos($conf->produit->dir_output,1,1,0);
+ print ' | ';
+ }
+ print '
';
+
+ // Libelle
+ print '| '.$langs->trans("Label").' | '.$product->libelle.' |
';
+
+ // MultiPrix
+ if($conf->global->PRODUIT_MULTIPRICES == 1)
+ {
+ print '| '.$langs->trans("SellingPrice").' 1 | '.price($product->price).' | ';
+ print '
';
+ for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++)
+ {
+ print '| '.$langs->trans("SellingPrice").' '.$i.' | '.price($product->multiprices["$i"]).' | ';
+ print '
';
+ }
+ }
+ // Prix
+ else
+ {
+ print '| '.$langs->trans("SellingPrice").' | '.price($product->price).' | ';
+ print '
';
+ }
+ // Statut
+ print '| '.$langs->trans("Status").' | ';
+ print $product->getLibStatut(2);
+ print ' |
';
+
+ // TVA
+ print '| '.$langs->trans("VATRate").' | '.$product->tva_tx.'% |
';
+
+ // Stock
+ if ($product->type == 0 && $conf->stock->enabled)
+ {
+ print '| '.$langs->trans("Stock").' | ';
+ if ($product->no_stock)
+ {
+ print "".$langs->trans("NoStockDefined");
+ }
+ else
+ {
+ if ($product->stock_reel <= $product->seuil_stock_alerte)
+ {
+ print ' | '.$product->stock_reel.' Seuil : '.$product->seuil_stock_alerte;
+ }
+ else
+ {
+ print " | ".$product->stock_reel;
+ }
+ }
+ print ' |
';
+ }
+
+ // Description
+ print '| '.$langs->trans("Description").' | '.nl2br($product->description).' |
';
+
+ // Durée
+ if ($product->type == 1)
+ {
+ print '| '.$langs->trans("Duration").' | '.$product->duration_value.' ';
+ if ($product->duration_value > 1)
+ {
+ $dur=array("d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years"));
+ }
+ else {
+ $dur=array("d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year"));
+ }
+ print $langs->trans($dur[$product->duration_unit])." ";
+
+ print ' |
';
+ }
+ else
+ {
+ print '| '.$langs->trans("Weight").' | ';
+ if ($product->weight != '')
+ {
+ print $product->weight." ".weight_units_string($product->weight_units);
+ }
+ else
+ {
+ print ' ';
+ }
+ print " |
\n";
+ }
+ // Note
+ print '| '.$langs->trans("Note").' | '.nl2br($product->note).' |
';
+ print "
\n";
+ print "\n\n";
+ }
+ }
+
+ /*
+ * Fiche en mode edition
+ */
+ if ($_GET["action"] == 'edit' && $user->rights->produit->creer)
+ {
+ print_fiche_titre($langs->trans('Edit').' '.$types[$product->type].' : '.$product->ref, "");
+
+ if ($mesg) {
+ print '
'.$mesg.'
';
+ }
+
+ if ( $product->canvas == '')
+ {
+ print "\n";
+ print "';
+ print "\n";
+ }
+ else
+ {
+ $null = $html->load_tva("tva_tx",$conf->defaulttx,$mysoc,'');
+ $smarty->assign('tva_taux_value', $html->tva_taux_value);
+ $smarty->assign('tva_taux_libelle', $html->tva_taux_libelle);
+ $smarty->display($product->canvas.'-edit.tpl');
+ }
+ }
}
@@ -849,34 +855,34 @@ print "\n