';
diff --git a/htdocs/comm/propal/apercu.php b/htdocs/comm/propal/apercu.php
index 607a8e93c63..0f0fef88bd7 100644
--- a/htdocs/comm/propal/apercu.php
+++ b/htdocs/comm/propal/apercu.php
@@ -87,7 +87,7 @@ if ($_GET["propalid"] > 0)
print '';
- print ''.$langs->trans('Ref').' '.$propal->ref_url.' ';
+ print ''.$langs->trans('Ref').' '.$propal->ref.' ';
$rowspan=3;
diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php
index d673588e88f..61767a46073 100644
--- a/htdocs/comm/propal/contact.php
+++ b/htdocs/comm/propal/contact.php
@@ -169,7 +169,7 @@ if ($id > 0)
// Ref
print ''.$langs->trans("Ref").' ';
- print $propal->ref_url;
+ print $propal->ref;
print " ";
// Customer
diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php
index 8423a558bc1..e25a8dc0d63 100644
--- a/htdocs/comm/propal/document.php
+++ b/htdocs/comm/propal/document.php
@@ -145,7 +145,7 @@ if ($propalid > 0)
print '';
// Ref
- print ''.$langs->trans('Ref').' '.$propal->ref_url.' ';
+ print ''.$langs->trans('Ref').' '.$propal->ref.' ';
// Société
print ''.$langs->trans('Company').' '.$societe->getNomUrl(1).' ';
diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php
index b9bd7bf927c..4d0b0d58f45 100644
--- a/htdocs/comm/propal/note.php
+++ b/htdocs/comm/propal/note.php
@@ -109,7 +109,7 @@ if ($_GET['propalid'])
print '';
- print ''.$langs->trans('Ref').' '.$propal->ref_url.' ';
+ print ''.$langs->trans('Ref').' '.$propal->ref.' ';
// Société
print ''.$langs->trans('Company').' '.$societe->getNomUrl(1).' ';
diff --git a/htdocs/compta/fiche.php b/htdocs/compta/fiche.php
index 77def9e621d..cfdbd65bd87 100644
--- a/htdocs/compta/fiche.php
+++ b/htdocs/compta/fiche.php
@@ -123,8 +123,8 @@ if ($socid > 0)
dolibarr_fiche_head($head, 'compta', $societe->nom);
- print "\n";
- print '';
+ print '';
+ print '';
print '';
@@ -218,7 +218,7 @@ if ($socid > 0)
print "\n";
- print '';
+ print ' ';
// Nbre max d'éléments des petites listes
$MAXLIST=5;
diff --git a/htdocs/compta/propal.php b/htdocs/compta/propal.php
index 9087143cb66..f39d06a122e 100644
--- a/htdocs/compta/propal.php
+++ b/htdocs/compta/propal.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2004-2006 Destailleur Laurent
+ * Copyright (C) 2004-2007 Destailleur Laurent
* Copyright (C) 2004 Eric Seigne
* Copyright (C) 2005-2006 Regis Houssin
*
@@ -145,7 +145,7 @@ if ($_GET["propalid"] > 0)
print '';
// Ref
- print ''.$langs->trans('Ref').' '.$propal->ref_url.' ';
+ print ''.$langs->trans('Ref').' '.$propal->ref.' ';
// Ref client
print '';
diff --git a/htdocs/fichinter/contact.php b/htdocs/fichinter/contact.php
index f6c018664e0..6a4584f24a4 100644
--- a/htdocs/fichinter/contact.php
+++ b/htdocs/fichinter/contact.php
@@ -168,7 +168,7 @@ if ($id > 0)
// Ref
print ' '.$langs->trans("Ref").' ';
- print $fichinter->ref_url;
+ print $fichinter->ref;
print " ";
// Customer
diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php
index 4668447b9dc..acc13c386b7 100644
--- a/htdocs/fichinter/fiche.php
+++ b/htdocs/fichinter/fiche.php
@@ -363,13 +363,13 @@ elseif ($_GET["id"] > 0)
print '';
// Ref
- print ''.$langs->trans("Ref").' '.$fichinter->ref.' ';
+ print ''.$langs->trans("Ref").' '.$fichinter->ref.' ';
// Societe
print "".$langs->trans("Company")." ".$fichinter->client->getNomUrl(1)." ";
// Date
- print ''.$langs->trans("Date").' '.dolibarr_print_date($fichinter->date,"daytext").' ';
+ print ''.$langs->trans("Date").' '.dolibarr_print_date($fichinter->date,"daytext").' ';
// Durée
print ''.$langs->trans("Duration").' '.$fichinter->duree.' ';
diff --git a/htdocs/fichinter/fichinter.class.php b/htdocs/fichinter/fichinter.class.php
index 9768a98a5c2..e5771bd5ba8 100644
--- a/htdocs/fichinter/fichinter.class.php
+++ b/htdocs/fichinter/fichinter.class.php
@@ -185,8 +185,6 @@ class Fichinter extends CommonObject
$this->note_public = $obj->note_public;
$this->note_private = $obj->note_private;
- $this->ref_url = ''.$this->ref.' ';
-
$this->db->free($resql);
return 1;
}
diff --git a/htdocs/fichinter/note.php b/htdocs/fichinter/note.php
index 9082bf84ea1..afd69e8b44a 100644
--- a/htdocs/fichinter/note.php
+++ b/htdocs/fichinter/note.php
@@ -104,7 +104,7 @@ if ($_GET['id'])
print '';
- print ''.$langs->trans('Ref').' '.$fichinter->ref_url.' ';
+ print ''.$langs->trans('Ref').' '.$fichinter->ref.' ';
// Société
print ''.$langs->trans('Company').' '.$societe->getNomUrl(1).' ';
diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php
index 38febdd76f0..a384556b7a6 100644
--- a/htdocs/fourn/commande/fiche.php
+++ b/htdocs/fourn/commande/fiche.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2004-2006 Laurent Destailleur
+ * Copyright (C) 2004-2007 Laurent Destailleur
* Copyright (C) 2005 Eric Seigne
*
* This program is free software; you can redistribute it and/or modify
@@ -23,9 +23,9 @@
/**
\file htdocs/fourn/commande/fiche.php
- \ingroup commande
+ \ingroup commande
\brief Fiche commande
- \version $Revision$
+ \version $Revision$
*/
require('./pre.inc.php');
@@ -425,12 +425,12 @@ else
/* *************************************************************************** */
/* */
- /* Mode vue et edition */
+ /* Mode vue et edition */
/* */
/* *************************************************************************** */
- $id = $_GET['id'];
- if ($id > 0)
+ $id = $_GET['id'];
+ if ($id > 0)
{
//if ($mesg) print $mesg.' ';
diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php
index 4ced48b3433..38a677d0a19 100644
--- a/htdocs/fourn/facture/fiche.php
+++ b/htdocs/fourn/facture/fiche.php
@@ -547,8 +547,8 @@ else
print ' ';
}
- print '';
- print '';
+ print '';
+ print '';
/*
* Facture
@@ -586,10 +586,10 @@ else
print '
';
- print ' ';
+ print ' ';
- print '';
+ print '';
/*
* Liste des paiements
diff --git a/htdocs/fourn/fiche.php b/htdocs/fourn/fiche.php
index f391f0cd85a..720e20c202a 100644
--- a/htdocs/fourn/fiche.php
+++ b/htdocs/fourn/fiche.php
@@ -1,7 +1,7 @@
* Copyright (C) 2003 Éric Seigne
- * Copyright (C) 2004-2006 Laurent Destailleur
+ * Copyright (C) 2004-2007 Laurent Destailleur
*
* 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
@@ -88,10 +88,10 @@ if ( $societe->fetch($socid) )
dolibarr_fiche_head($head, 'supplier', $societe->nom);
- print '';
- print '';
+ print '';
+ print '';
- print '';
+ print '';
print ''.$langs->trans("Name").' '.$societe->nom.' ';
print ''.$langs->trans('Prefix').' '.$societe->prefix_comm.' ';
@@ -123,7 +123,7 @@ if ( $societe->fetch($socid) )
print '
';
- print '';
+ print ' ';
$var=true;
$MAXLIST=4;
diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php
index f39f5cffa6e..24b2b391949 100644
--- a/htdocs/html.form.class.php
+++ b/htdocs/html.form.class.php
@@ -1080,30 +1080,30 @@ class Form
}
}
- /**
- \brief Retourne la liste des produits fournisseurs en Ajax si ajax activé ou renvoie à select_produits_fournisseurs_do
- \param selected Produit présélectionné
- \param htmlname Nom de la zone select
- \param filtretype Pour filtre sur type de produit
- \param limit Limite sur le nombre de lignes retournées
- */
- function select_produits_fournisseurs($socid,$selected='',$htmlname='productid',$filtretype='',$filtre='')
- {
- global $langs,$conf;
- if ($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)
- {
- print $langs->trans("RefOrLabel").' : ';
- print ajax_updater($htmlname,'keysearch','/product/ajaxproducts.php','&socid='.$socid.'&type=2','working');
- }
- else
- {
- $this->select_produits_fournisseurs_do($socid,$selected,$htmlname,$filtretype,$filtre);
- }
- }
+ /**
+ \brief Retourne la liste des produits fournisseurs en Ajax si ajax activé ou renvoie à select_produits_fournisseurs_do
+ \param selected Produit présélectionné
+ \param htmlname Nom de la zone select
+ \param filtretype Pour filtre sur type de produit
+ \param limit Limite sur le nombre de lignes retournées
+ */
+ function select_produits_fournisseurs($socid,$selected='',$htmlname='productid',$filtretype='',$filtre='')
+ {
+ global $langs,$conf;
+ if ($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)
+ {
+ print $langs->trans("RefOrLabel").' : ';
+ print ajax_updater($htmlname,'keysearch','/product/ajaxproducts.php','&socid='.$socid.'&type=2','working');
+ }
+ else
+ {
+ $this->select_produits_fournisseurs_do($socid,$selected,$htmlname,$filtretype,$filtre);
+ }
+ }
/**
\brief Retourne la liste des produits de fournisseurs
- \param socid Id société (0 pour aucun filtre)
+ \param socid Id société (0 pour aucun filtre)
\param selected Produit présélectionné
\param htmlname Nom de la zone select
\param filtretype Pour filtre sur type de produit
@@ -1136,42 +1136,50 @@ class Form
$num = $this->db->num_rows($result);
if ($conf->use_ajax)
- {
- if (! $num)
- {
- print '';
- print '-- '.$langs->trans("NoProductMatching").' -- ';
- }
- else
- {
- print '';
- print '-- '.$langs->trans("MatchingProducts").' -- ';
- }
- }
- else
- {
- print '';
- if (! $selected) print ' ';
- else print ' ';
- }
+ {
+ if (! $num)
+ {
+ print '';
+ print '-- '.$langs->trans("NoProductMatching").' -- ';
+ }
+ else
+ {
+ print '';
+ print '-- '.$langs->trans("MatchingProducts").' -- ';
+ }
+ }
+ else
+ {
+ print '';
+ if (! $selected) print ' ';
+ else print ' ';
+ }
$i = 0;
while ($i < $num)
{
$objp = $this->db->fetch_object($result);
-
+
$opt = 'rowid) $opt.= ' selected="true"';
- //$opt.= '>'.$objp->ref.' ('.$objp->ref_fourn.') - ';
+ if ($objp->fprice == '') $opt.=' disabled="disabled"';
$opt.= '>'.$objp->ref.' - ';
- $opt.= dolibarr_trunc($objp->label,24).' - ';
- $opt.= $objp->fprice.$langs->trans("Currency".$conf->monnaie)."/".$objp->quantity.$langs->trans("Units");
- if ($objp->quantity > 1)
+ $opt.= dolibarr_trunc($objp->label,18).' - ';
+ if ($objp->fprice != '')
{
- $opt.=" - ";
- $opt.= round($objp->fprice/$objp->quantity,4).$langs->trans("Currency".$conf->monnaie)."/".$langs->trans("Unit");
+ $opt.= $objp->fprice;
+ $opt.= $langs->trans("Currency".$conf->monnaie)."/".$objp->quantity.$langs->trans("Units");
+ if ($objp->quantity > 1)
+ {
+ $opt.=" - ";
+ $opt.= round($objp->fprice/$objp->quantity,4).$langs->trans("Currency".$conf->monnaie)."/".$langs->trans("Unit");
+ }
+ if ($objp->duration) $opt .= " - ".$objp->duration;
+ }
+ else
+ {
+ $opt.= $langs->trans("NoPriceDefinedForThisSupplier");
}
- if ($objp->duration) $opt .= " - ".$objp->duration;
$opt .= " \n";
print $opt;
diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang
index 02b66f06023..67cb9ef8507 100644
--- a/htdocs/langs/en_US/main.lang
+++ b/htdocs/langs/en_US/main.lang
@@ -191,6 +191,8 @@ DefaultValue=Default value
DefaultGlobalValue=Global value
Price=Price
UnitPrice=Unit price
+UnitPriceHT=Unit price HT
+UnitPriceTTC=Unit price TTC
PriceU=U.P.
PriceUHT=U.P. HT
PriceUTTC=U.P. TTC
diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang
index ce14bf98767..bbcffcecfbb 100644
--- a/htdocs/langs/en_US/products.lang
+++ b/htdocs/langs/en_US/products.lang
@@ -110,5 +110,7 @@ NoStockForThisProduct=No stock for this product
Restock=Restock
ProductSpecial=Special
QtyMin=Quantity minimum
-PriceHTQty=Price HT for this quantity
-
+PriceQty=Price for this quantity
+PriceQtyHT=Price for this quantity HT
+PriceQtyTTC=Price for this quantity TTC
+NoPriceDefinedForThisSupplier=No price/qty defined for this supplier/product
diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang
index 85badc9b6ca..ba2536c7f24 100644
--- a/htdocs/langs/fr_FR/main.lang
+++ b/htdocs/langs/fr_FR/main.lang
@@ -192,6 +192,8 @@ DefaultValue=Valeur par d
DefaultGlobalValue=Valeur globale
Price=Prix
UnitPrice=Prix unitaire
+UnitPriceHT=Prix unitaire HT
+UnitPriceTTC=Prix unitaire TTC
PriceU=P.U.
PriceUHT=P.U. HT
PriceUTTC=P.U. TTC
diff --git a/htdocs/langs/fr_FR/products.lang b/htdocs/langs/fr_FR/products.lang
index 322cade7c57..167f75c7543 100644
--- a/htdocs/langs/fr_FR/products.lang
+++ b/htdocs/langs/fr_FR/products.lang
@@ -110,4 +110,7 @@ NoStockForThisProduct=Pas de stock pour ce produit
Restock=Réassort
ProductSpecial=Special
QtyMin=Quantité minimum
-PriceHTQty=Prix HT pour la quantité
+PriceQty=Prix pour la quantité
+PriceQtyHT=Prix pour la quantité HT
+PriceQtyTTC=Prix pour la quantité TTC
+NoPriceDefinedForThisSupplier=Aucun prix/qté défini pour ce fournisseur/produit
diff --git a/htdocs/product.class.php b/htdocs/product.class.php
index 2464000a09e..cb9350dcff8 100644
--- a/htdocs/product.class.php
+++ b/htdocs/product.class.php
@@ -719,104 +719,110 @@ class Product
}
- /**
- * \brief Modifie le prix d'achat pour un fournisseur
- * \param id_fourn Id du fournisseur
- * \param qty Quantite pour lequel le prix est valide
- * \param buyprice Prix d'achat pour la quantité
- * \param user Objet user de l'utilisateur qui modifie
- */
- function update_buyprice($id_fourn, $qty, $buyprice, $user)
- {
- $error=0;
- $this->db->begin();
+ /**
+ * \brief Modifie le prix d'achat pour un fournisseur
+ * \param id_fourn Id du fournisseur
+ * \param qty Quantite pour lequel le prix est valide
+ * \param buyprice Prix d'achat pour la quantité
+ * \param user Objet user de l'utilisateur qui modifie
+ * \param price_base_type HT or TTC
+ */
+ function update_buyprice($id_fourn, $qty, $buyprice, $user, $price_base_type='HT')
+ {
+ $error=0;
+ $this->db->begin();
- // Supprime prix courant du fournisseur pour cette quantité
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price ";
- $sql .= " WHERE ";
- $sql .= " fk_product = ".$this->id;
- $sql .= " AND fk_soc = ".$id_fourn;
- $sql .= " AND quantity = ".$qty;
+ // Supprime prix courant du fournisseur pour cette quantité
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price ";
+ $sql .= " WHERE ";
+ $sql .= " fk_product = ".$this->id;
+ $sql .= " AND fk_soc = ".$id_fourn;
+ $sql .= " AND quantity = ".$qty;
- if ($this->db->query($sql))
- {
- // Ajoute prix courant du fournisseur pour cette quantité
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price ";
- $sql .= " SET datec = now()";
- $sql .= " ,fk_product = ".$this->id;
- $sql .= " ,fk_soc = ".$id_fourn;
- $sql .= " ,fk_user = ".$user->id;
- $sql .= " ,price = ".price2num($buyprice);
- $sql .= " ,quantity = ".$qty;
+ if ($this->db->query($sql))
+ {
+ // Ajoute prix courant du fournisseur pour cette quantité
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price";
+ $sql .= " SET datec = now()";
+ $sql .= " ,fk_product = ".$this->id;
+ $sql .= " ,fk_soc = ".$id_fourn;
+ $sql .= " ,fk_user = ".$user->id;
+ $sql .= " ,price = ".price2num($buyprice);
+ $sql .= " ,quantity = ".$qty;
- if (! $this->db->query($sql))
- {
- $error++;
- }
+ if (! $this->db->query($sql))
+ {
+ $error++;
+ }
- if (! $error) {
- // Ajoute modif dans table log
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price_log ";
- $sql .= " SET datec = now()";
- $sql .= " ,fk_product = ".$this->id;
- $sql .= " ,fk_soc = ".$id_fourn;
- $sql .= " ,fk_user = ".$user->id;
- $sql .= " ,price = ".price2num($buyprice);
- $sql .= " ,quantity = ".$qty;
+ if (! $error) {
+ // Ajoute modif dans table log
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price_log ";
+ $sql .= " SET datec = now()";
+ $sql .= " ,fk_product = ".$this->id;
+ $sql .= " ,fk_soc = ".$id_fourn;
+ $sql .= " ,fk_user = ".$user->id;
+ $sql .= " ,price = ".price2num($buyprice);
+ $sql .= " ,quantity = ".$qty;
- if (! $this->db->query($sql))
- {
- $error++;
- }
+ if (! $this->db->query($sql))
+ {
+ $error++;
+ }
+ }
+
+ if (! $error)
+ {
+ $this->db->commit();
+ return 0;
+ }
+ else
+ {
+ $this->error=$this->db->error()." sql=".$sql;
+ $this->db->rollback();
+ return -2;
+ }
+ }
+ else
+ {
+ $this->error=$this->db->error()." sql=".$sql;
+ $this->db->rollback();
+ return -1;
+ }
}
- if (! $error)
- {
- $this->db->commit();
- return 0;
- }
- else
- {
- $this->error=$this->db->error()." ($sql)";
- $this->db->rollback();
- return -2;
- }
- }
- else
- {
- $this->error=$this->db->error()." ($sql)";
- $this->db->rollback();
- return -1;
- }
- }
- /**
- \brief Modifie le prix d'achat pour un fournisseur par la référecne du produit chez le fournisseur
- \param id_fourn Id du fournisseur
- \param product_fourn_ref Reference du produit chez le fournisseur
- \param qty Quantite pour lequel le prix est valide
- \param buyprice Prix d'achat pour la quantité
- \param user Objet user de l'utilisateur qui modifie
- */
- function UpdateBuyPriceByFournRef($id_fourn, $product_fourn_ref, $qty, $buyprice, $user)
- {
- $errno=0;
- // Supprime prix courant du fournisseur pour cette quantité
- $sql = "SELECT fk_product FROM ".MAIN_DB_PREFIX."product_fournisseur";
- $sql.= " WHERE fk_soc ='".$id_fourn."'";
- $sql.= " AND ref_fourn='".$product_fourn_ref."';";
+ /**
+ \brief Modifie le prix d'achat pour un fournisseur par la référecne du produit chez le fournisseur
+ \param id_fourn Id du fournisseur
+ \param product_fourn_ref Ref du produit chez le fournisseur
+ \param qty Quantite pour lequel le prix est valide
+ \param buyprice Prix d'achat pour la quantité
+ \param user Objet user de l'utilisateur qui modifie
+ \return int <0 si KO, >0 si OK
+ */
+ function UpdateBuyPriceByFournRef($id_fourn, $product_fourn_ref, $qty, $buyprice, $user, $price_base_type='HT')
+ {
+ $result=0;
- if ($this->db->query($sql))
- {
- if ($row = $this->db->fetch_row($resql) )
- {
- $this->id = $row[0];
- $errno = $this->update_buyprice($id_fourn, $qty, $buyprice, $user);
- }
- }
+ // Recherche id produit pour cette ref et fournisseur
+ $sql = "SELECT fk_product";
+ $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur";
+ $sql.= " WHERE fk_soc ='".$id_fourn."'";
+ $sql.= " AND ref_fourn='".$product_fourn_ref."'";
- return $errno;
- }
+ if ($this->db->query($sql))
+ {
+ if ($obj = $this->db->fetch_object($resql))
+ {
+ // Met a jour prix pour la qté
+ $this->id = $obj->fk_product;
+ $result = $this->update_buyprice($id_fourn, $qty, $buyprice, $user, $price_base_type);
+ }
+ }
+
+ return $result;
+ }
/**
diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php
index 2456293eb65..fffef74de0b 100644
--- a/htdocs/product/fournisseurs.php
+++ b/htdocs/product/fournisseurs.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2004-2006 Laurent Destailleur
+ * Copyright (C) 2004-2007 Laurent Destailleur
* Copyright (C) 2004 Eric Seigne
* Copyright (C) 2005 Regis Houssin
*
@@ -90,63 +90,63 @@ if ($_GET["action"] == 'remove_fourn')
if ($_POST["action"] == 'updateprice' && $_POST["cancel"] <> $langs->trans("Cancel"))
{
- $product = new Product($db);
- if( $product->fetch($_GET["id"]) )
- {
- $db->begin();
-
- $error=0;
-
- if ($_POST["ref_fourn"])
- {
- $ret=$product->add_fournisseur($user, $_POST["id_fourn"], $_POST["ref_fourn"]);
- if ($ret < 0)
- {
- $error++;
- $mesg=''.$product->error.'
';
- }
- }
- else
- {
- $error++;
- $mesg=''.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")).'
';
- }
-
- if ($_POST["qty"])
- {
- if ($_POST["price"] >= 0)
- {
- $ret=$product->update_buyprice($_POST["id_fourn"], $_POST["qty"], $_POST["price"], $user);
- if ($ret < 0)
+ $product = new Product($db);
+ if( $product->fetch($_GET["id"]) )
+ {
+ $db->begin();
+
+ $error=0;
+
+ if ($_POST["ref_fourn"])
{
- $error++;
- $mesg=''.$product->error.'
';
- if ($ret == -2)
- {
- $mesg=''.$langs->trans("ProductHasAlreadyReferenceInThisSupplier").'
';
- }
+ $ret=$product->add_fournisseur($user, $_POST["id_fourn"], $_POST["ref_fourn"]);
+ if ($ret < 0)
+ {
+ $error++;
+ $mesg=''.$product->error.'
';
+ }
}
- }
- else
- {
- $error++;
- $mesg=''.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Price")).'
';
- }
- }
- else
- {
- $error++;
- $mesg=''.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Qty")).'
';
- }
-
- if (! $error)
- {
- $db->commit();
- }
- else {
- $db->rollback();
- }
- }
+ else
+ {
+ $error++;
+ $mesg=''.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")).'
';
+ }
+
+ if (! $error && $_POST["qty"])
+ {
+ if ($_POST["price"] >= 0)
+ {
+ $ret=$product->update_buyprice($_POST["id_fourn"], $_POST["qty"], $_POST["price"], $user);
+ if ($ret < 0)
+ {
+ $error++;
+ $mesg=''.$product->error.'
';
+ if ($ret == -2)
+ {
+ $mesg=''.$langs->trans("ProductHasAlreadyReferenceInThisSupplier").'
';
+ }
+ }
+ }
+ else
+ {
+ $error++;
+ $mesg=''.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Price")).'
';
+ }
+ }
+ else
+ {
+ $error++;
+ $mesg=''.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Qty")).'
';
+ }
+
+ if (! $error)
+ {
+ $db->commit();
+ }
+ else {
+ $db->rollback();
+ }
+ }
}
if ($_POST["cancel"] == $langs->trans("Cancel"))
@@ -249,7 +249,7 @@ if ($_GET["id"] || $_GET["ref"])
print ''.$langs->trans("QtyMin").' ';
$quantity = $_GET["qty"] ? $_GET["qty"] : "1";
print ' ';
- print ''.$langs->trans("PriceHTQty").' ';
+ print ''.$langs->trans("PriceQtyHT").' ';
print ' ';
print ' ';
@@ -290,13 +290,14 @@ if ($_GET["id"] || $_GET["ref"])
print $langs->trans("Suppliers").' ';
print ''.$langs->trans("Ref").' ';
print ''.$langs->trans("QtyMin").' ';
- print ''.$langs->trans("PriceHTQty").' ';
- print ''.$langs->trans("UnitPrice").' ';
+ print ''.$langs->trans("PriceQtyHT").' ';
+ print ''.$langs->trans("UnitPriceHT").' ';
print ' ';
print ' ';
// Liste des fournisseurs
- $sql = "SELECT s.nom, s.rowid as socid, pf.ref_fourn, pfp.price, pfp.quantity";
+ $sql = "SELECT s.nom, s.rowid as socid,";
+ $sql.= "pf.ref_fourn, pfp.price, pfp.quantity";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur as pf";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
$sql.= " ON pf.fk_soc = pfp.fk_soc AND pf.fk_product = pfp.fk_product";
diff --git a/htdocs/propal.class.php b/htdocs/propal.class.php
index c11c48a4a25..73901346ed7 100644
--- a/htdocs/propal.class.php
+++ b/htdocs/propal.class.php
@@ -851,8 +851,6 @@ class Propal extends CommonObject
$this->lignes = array();
$this->db->free($resql);
- $this->ref_url = ''.$this->ref.' ';
-
/*
* Lignes propales liées à un produit ou non
*/