diff --git a/htdocs/comm/addpropal.php b/htdocs/comm/addpropal.php
index 07165e4ed09..538e6b97781 100644
--- a/htdocs/comm/addpropal.php
+++ b/htdocs/comm/addpropal.php
@@ -281,7 +281,7 @@ if ($_GET["action"] == 'create')
{
print '
';
// multiprix
- if($conf->global->PRODUIT_MULTIPRICES)
+ if($conf->global->PRODUIT_MULTIPRICES && $soc->price_level)
$html->select_produits('',"idprod".$i,'',$conf->produit->limit_size,$soc->price_level);
else
$html->select_produits('',"idprod".$i,'',$conf->produit->limit_size);
diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index f7f3f3997ad..1bc8c10f283 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -642,7 +642,7 @@ if ($_POST['action'] == "addline" && $user->rights->propale->creer)
$tva_npr = get_default_npr($mysoc,$propal->client,$prod->tva_tx);
// On defini prix unitaire
- if ($conf->global->PRODUIT_MULTIPRICES && isset($prod->multiprices_base_type[$propal->client->price_level]))
+ if ($conf->global->PRODUIT_MULTIPRICES && $propal->client->price_level)
{
$pu_ht = $prod->multiprices[$propal->client->price_level];
$pu_ttc = $prod->multiprices_ttc[$propal->client->price_level];
diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php
index 152cade2970..e36b10f4cef 100644
--- a/htdocs/commande/commande.class.php
+++ b/htdocs/commande/commande.class.php
@@ -853,48 +853,48 @@ class Commande extends CommonObject
$tva_tx = get_default_tva($mysoc,$this->client,$prod->tva_tx);
// multiprix
- if($conf->global->PRODUIT_MULTIPRICES)
- $price = $prod->multiprices[$this->client->price_level];
- else
- $price = $prod->price;
+ if($conf->global->PRODUIT_MULTIPRICES && $this->client->price_level)
+ $price = $prod->multiprices[$this->client->price_level];
+ else
+ $price = $prod->price;
- $line=new CommandeLigne($this->db);
- $line->fk_product=$idproduct;
- $line->desc=$prod->description;
- $line->qty=$qty;
- $line->subprice=$price;
- $line->remise_percent=$remise_percent;
- $line->tva_tx=$tva_tx;
- $line->ref=$prod->ref;
- $line->libelle=$prod->libelle;
- $line->product_desc=$prod->description;
+ $line=new CommandeLigne($this->db);
+ $line->fk_product=$idproduct;
+ $line->desc=$prod->description;
+ $line->qty=$qty;
+ $line->subprice=$price;
+ $line->remise_percent=$remise_percent;
+ $line->tva_tx=$tva_tx;
+ $line->ref=$prod->ref;
+ $line->libelle=$prod->libelle;
+ $line->product_desc=$prod->description;
- // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
- // Save the start and end date of the line in the object
- if ($date_start) { $line->date_start = $date_start; }
- if ($date_end) { $line->date_end = $date_end; }
+ // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
+ // Save the start and end date of the line in the object
+ if ($date_start) { $line->date_start = $date_start; }
+ if ($date_end) { $line->date_end = $date_end; }
- $this->lines[] = $line;
+ $this->lines[] = $line;
- /** POUR AJOUTER AUTOMATIQUEMENT LES SOUSPRODUITS a LA COMMANDE
- if (! empty($conf->global->PRODUIT_SOUSPRODUITS))
- {
- $prod = new Product($this->db, $idproduct);
- $prod -> get_sousproduits_arbo ();
- $prods_arbo = $prod->get_each_prod();
- if(sizeof($prods_arbo) > 0)
- {
- foreach($prods_arbo as $key => $value)
- {
- // print "id : ".$value[1].' :qty: '.$value[0].' ';
- if(! in_array($value[1],$this->products))
- $this->add_product($value[1], $value[0]);
+ /** POUR AJOUTER AUTOMATIQUEMENT LES SOUSPRODUITS a LA COMMANDE
+ if (! empty($conf->global->PRODUIT_SOUSPRODUITS))
+ {
+ $prod = new Product($this->db, $idproduct);
+ $prod -> get_sousproduits_arbo ();
+ $prods_arbo = $prod->get_each_prod();
+ if(sizeof($prods_arbo) > 0)
+ {
+ foreach($prods_arbo as $key => $value)
+ {
+ // print "id : ".$value[1].' :qty: '.$value[0].' ';
+ if(! in_array($value[1],$this->products))
+ $this->add_product($value[1], $value[0]);
- }
- }
+ }
+ }
- }
- **/
+ }
+ **/
}
}
diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php
index 1cc71ee1103..53be4783bcc 100644
--- a/htdocs/commande/fiche.php
+++ b/htdocs/commande/fiche.php
@@ -354,7 +354,7 @@ if ($_POST['action'] == 'addline' && $user->rights->commande->creer)
$tva_tx = get_default_tva($mysoc,$commande->client,$prod->tva_tx);
// multiprix
- if ($conf->global->PRODUIT_MULTIPRICES)
+ if ($conf->global->PRODUIT_MULTIPRICES && $commande->client->price_level)
{
$pu_ht = $prod->multiprices[$commande->client->price_level];
$pu_ttc = $prod->multiprices_ttc[$commande->client->price_level];
diff --git a/htdocs/commonobject.class.php b/htdocs/commonobject.class.php
index 75519b0db61..4d3ab13cc4b 100644
--- a/htdocs/commonobject.class.php
+++ b/htdocs/commonobject.class.php
@@ -18,21 +18,20 @@
*/
/**
- \file htdocs/commonobject.class.php
- \ingroup core
- \brief Fichier de la classe mere des classes metiers (facture, contrat, propal, commande, etc...)
- \version $Id$
+ * \file htdocs/commonobject.class.php
+ * \ingroup core
+ * \brief Fichier de la classe mere des classes metiers (facture, contrat, propal, commande, etc...)
+ * \version $Id$
*/
/**
- \class CommonObject
- \brief Classe mere pour heritage des classes metiers
+ * \class CommonObject
+ * \brief Classe mere pour heritage des classes metiers
*/
class CommonObject
{
-
/**
* \brief Ajoute un contact associe au l'entite definie dans $this->element
* \param fk_socpeople Id du contact a ajouter
@@ -352,9 +351,15 @@ class CommonObject
*/
function fetch_client()
{
+ global $conf;
+
$client = new Societe($this->db);
$result=$client->fetch($this->socid);
$this->client = $client;
+
+ // Use first price level if level not defined for third party
+ if ($conf->global->PRODUIT_MULTIPRICES && empty($this->client->price_level)) $this->client->price_level=1;
+
return $result;
}
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index fb39bd564e2..1b063f76423 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -885,7 +885,7 @@ if (($_POST['action'] == 'addline' || $_POST['action'] == 'addline_predef') && $
$tva_npr = get_default_npr($mysoc,$fac->client,$prod->tva_tx);
// We define price for product
- if ($conf->global->PRODUIT_MULTIPRICES)
+ if ($conf->global->PRODUIT_MULTIPRICES && $fac->client->price_level)
{
$pu_ht = $prod->multiprices[$fac->client->price_level];
$pu_ttc = $prod->multiprices_ttc[$fac->client->price_level];
diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php
index 4a585610710..93a9a1b9ed8 100644
--- a/htdocs/contrat/fiche.php
+++ b/htdocs/contrat/fiche.php
@@ -226,7 +226,7 @@ if ($_POST["action"] == 'addligne' && $user->rights->contrat->creer)
$tva_npr = get_default_npr($mysoc,$contrat->client,$prod->tva_npr);
// On defini prix unitaire
- if ($conf->global->PRODUIT_MULTIPRICES)
+ if ($conf->global->PRODUIT_MULTIPRICES && $contrat->client->price_level)
{
$pu_ht = $prod->multiprices[$contrat->client->price_level];
$pu_ttc = $prod->multiprices_ttc[$contrat->client->price_level];
diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php
index 65305cbf72b..abed301c55b 100644
--- a/htdocs/html.form.class.php
+++ b/htdocs/html.form.class.php
@@ -870,8 +870,12 @@ class Form
$opt.= '>'.$objp->ref.' - ';
$opt.= dol_trunc($objp->label,32).' - ';
+ $found=0;
+ $currencytext=$langs->trans("Currency".$conf->monnaie);
+ if (strlen($currencytext) > 10) $currencytext=$conf->monnaie; // If text is too long, we use the short code
+
// Multiprice
- if ($price_level > 1)
+ if ($price_level >= 1) // If we need a particular price level (from 1 to 6)
{
$sql= "SELECT price, price_ttc, price_base_type ";
$sql.= "FROM ".MAIN_DB_PREFIX."product_price ";
@@ -887,10 +891,11 @@ class Form
$objp2 = $this->db->fetch_object($result2);
if ($objp2)
{
+ $found=1;
if ($objp2->price_base_type == 'HT')
- $opt.= price($objp2->price,1).' '.$langs->trans("Currency".$conf->monnaie).' '.$langs->trans("HT");
+ $opt.= price($objp2->price,1).' '.$currencytext.' '.$langs->trans("HT");
else
- $opt.= price($objp2->price_ttc,1).' '.$langs->trans("Currency".$conf->monnaie).' '.$langs->trans("TTC");
+ $opt.= price($objp2->price_ttc,1).' '.$currencytext.' '.$langs->trans("TTC");
}
}
else
@@ -898,13 +903,14 @@ class Form
dol_print_error($this->db);
}
}
- //si il n'y a pas de prix multiple on prend le prix de base du produit/service
- else
+
+ // If level no defined or multiprice not found, we used the default price
+ if (! $found)
{
if ($objp->price_base_type == 'HT')
- $opt.= price($objp->price,1).' '.$langs->trans("Currency".$conf->monnaie).' '.$langs->trans("HT");
+ $opt.= price($objp->price,1).' '.$currencytext.' '.$langs->trans("HT");
else
- $opt.= price($objp->price_ttc,1).' '.$langs->trans("Currency".$conf->monnaie).' '.$langs->trans("TTC");
+ $opt.= price($objp->price_ttc,1).' '.$currencytext.' '.$langs->trans("TTC");
}
if ($conf->stock->enabled && isset($objp->stock) && $objp->fk_product_type == 0)
diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php
index c8b10e4c12f..18904669e48 100644
--- a/htdocs/product/fiche.php
+++ b/htdocs/product/fiche.php
@@ -338,7 +338,7 @@ if ($_POST["action"] == 'addinpropal')
$price_base_type = 'HT';
// multiprix
- if ($conf->global->PRODUIT_MULTIPRICES)
+ if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level)
{
$pu_ht = $prod->multiprices[$soc->price_level];
$pu_ttc = $prod->multiprices_ttc[$soc->price_level];
@@ -417,7 +417,7 @@ if ($_POST["action"] == 'addincommande')
$tva_tx = get_default_tva($mysoc,$soc,$prod->tva_tx);
// multiprix
- if ($conf->global->PRODUIT_MULTIPRICES)
+ if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level)
{
$pu_ht = $prod->multiprices[$soc->price_level];
$pu_ttc = $prod->multiprices_ttc[$soc->price_level];
@@ -497,7 +497,7 @@ if ($_POST["action"] == 'addinfacture' && $user->rights->facture->creer)
$tva_tx = get_default_tva($mysoc,$soc,$prod->tva_tx);
// multiprix
- if ($conf->global->PRODUIT_MULTIPRICES)
+ if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level)
{
$pu_ht = $prod->multiprices[$soc->price_level];
$pu_ttc = $prod->multiprices_ttc[$soc->price_level];
diff --git a/htdocs/propal.class.php b/htdocs/propal.class.php
index 2b5262a870a..b6838b4b28f 100644
--- a/htdocs/propal.class.php
+++ b/htdocs/propal.class.php
@@ -155,7 +155,7 @@ class Propal extends CommonObject
$tva_tx = get_default_tva($mysoc,$this->client,$prod->tva_tx);
// multiprix
- if($conf->global->PRODUIT_MULTIPRICES)
+ if($conf->global->PRODUIT_MULTIPRICES && $this->client->price_level)
{
$price = $prod->multiprices[$this->client->price_level];
}
diff --git a/htdocs/societe.class.php b/htdocs/societe.class.php
index 7255ff6e20b..97b8c4db2d6 100644
--- a/htdocs/societe.class.php
+++ b/htdocs/societe.class.php
@@ -633,6 +633,9 @@ class Societe extends CommonObject
$result = -3;
}
+ // Use first price level if level not defined for third party
+ if ($conf->global->PRODUIT_MULTIPRICES && empty($this->price_level)) $this->price_level=1;
+
return $result;
}
|