';
diff --git a/htdocs/langs/en_US/suppliers.lang b/htdocs/langs/en_US/suppliers.lang
index 26f1a35468d..1c506ff4cdb 100644
--- a/htdocs/langs/en_US/suppliers.lang
+++ b/htdocs/langs/en_US/suppliers.lang
@@ -13,4 +13,5 @@ ShowSupplier=Show supplier
OrderDate=Order date
BuyingPrice=Buying price
AddSupplierPrice=Add supplier price
-ChangeSupplierPrice=Change supplier price
\ No newline at end of file
+ChangeSupplierPrice=Change supplier price
+ErrorQtyTooLowForThisSupplier=Quantity too low for this supplier
\ No newline at end of file
diff --git a/htdocs/langs/fr_FR/suppliers.lang b/htdocs/langs/fr_FR/suppliers.lang
index 6352e6dac07..656a06cce59 100644
--- a/htdocs/langs/fr_FR/suppliers.lang
+++ b/htdocs/langs/fr_FR/suppliers.lang
@@ -13,4 +13,5 @@ ShowSupplier=Afficher fournisseur
OrderDate=Date commande
BuyingPrice=Prix d'achat
AddSupplierPrice=Ajouter prix fournisseur
-ChangeSupplierPrice=Modifier prix fournisseur
\ No newline at end of file
+ChangeSupplierPrice=Modifier prix fournisseur
+ErrorQtyTooLowForThisSupplier=Quantité insuffisante pour ce fournisseur
\ No newline at end of file
diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php
index bfacad8f864..3e0882f7d78 100644
--- a/htdocs/main.inc.php
+++ b/htdocs/main.inc.php
@@ -239,6 +239,11 @@ if (! eregi("firefox",$_SERVER["HTTP_USER_AGENT"]))
define('ROWS_2',2);
define('ROWS_3',3);
define('ROWS_4',4);
+ define('ROWS_5',5);
+ define('ROWS_6',6);
+ define('ROWS_7',7);
+ define('ROWS_8',8);
+ define('ROWS_9',9);
}
else
{
@@ -246,6 +251,11 @@ else
define('ROWS_2',1);
define('ROWS_3',2);
define('ROWS_4',3);
+ define('ROWS_5',4);
+ define('ROWS_6',5);
+ define('ROWS_7',6);
+ define('ROWS_8',7);
+ define('ROWS_9',8);
}
diff --git a/htdocs/product.class.php b/htdocs/product.class.php
index c4ac5061fe5..a3cc1095932 100644
--- a/htdocs/product.class.php
+++ b/htdocs/product.class.php
@@ -554,7 +554,7 @@ class Product
/**
* \brief Lit le prix pratiqué par un fournisseur
* \param fourn_id Id du fournisseur
- * \param qty Quantite pour lequel le prix est valide
+ * \param qty Quantite recherchée
* \return int <0 si ko, 0 si ok mais rien trouvé, 1 si ok et trouvé
*/
function get_buyprice($fourn_id, $qty)
@@ -582,12 +582,37 @@ class Product
}
else
{
- return 0;
+ // On refait le meme select mais sans critere de quantite
+ $sql = "SELECT pf.price as price, pf.quantity as quantity";
+ $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pf";
+ $sql.= " WHERE pf.fk_soc = ".$fourn_id;
+ $sql.= " AND pf.fk_product =" .$this->id;
+ //$sql.= " AND quantity <= ".$qty;
+ $sql.= " ORDER BY quantity DESC";
+ $sql.= " LIMIT 1";
+
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $num=$this->db->num_rows($result);
+ if ($num)
+ {
+ return -1; // Ce produit existe chez ce fournisseur mais qté insuffisante
+ }
+ else
+ {
+ return 0; // Ce produit n'existe pas chez ce fournisseur
+ }
+ }
+ else
+ {
+ return -3;
+ }
}
}
else
{
- return -1;
+ return -2;
}
return $result;
}