Skip to content

Commit

Permalink
Fix: differentiate customer prices from supplier prices sharing
Browse files Browse the repository at this point in the history
  • Loading branch information
hregis committed Jul 7, 2018
1 parent 4db7e04 commit 1522a5b
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion htdocs/core/class/html.form.class.php
Expand Up @@ -2654,7 +2654,7 @@ function select_product_fourn_price($productid, $htmlname='productfournpriceid',
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON pfp.fk_soc = s.rowid";
$sql.= " WHERE pfp.entity IN (".getEntity('productprice').")";
$sql.= " WHERE pfp.entity IN (".getEntity('productresellerprice').")";
$sql.= " AND p.tobuy = 1";
$sql.= " AND s.fournisseur = 1";
$sql.= " AND p.rowid = ".$productid;
Expand Down
2 changes: 1 addition & 1 deletion htdocs/fourn/class/fournisseur.product.class.php
Expand Up @@ -530,7 +530,7 @@ function list_product_fournisseur_price($prodid, $sortfield='', $sortorder='', $
$sql.= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code";
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
$sql.= " WHERE pfp.entity IN (".getEntity('productprice').")";
$sql.= " WHERE pfp.entity IN (".getEntity('productresellerprice').")";
$sql.= " AND pfp.fk_soc = s.rowid";
$sql.= " AND s.status=1"; // only enabled company selected
$sql.= " AND pfp.fk_product = ".$prodid;
Expand Down
4 changes: 2 additions & 2 deletions htdocs/product/class/product.class.php
Expand Up @@ -3081,7 +3081,7 @@ function add_fournisseur($user, $id_fourn, $ref_fourn, $quantity)
$sql.= " WHERE fk_soc = ".$id_fourn;
$sql.= " AND ref_fourn = '".$this->db->escape($ref_fourn)."'";
$sql.= " AND fk_product != ".$this->id;
$sql.= " AND entity IN (".getEntity('productprice').")";
$sql.= " AND entity IN (".getEntity('productresellerprice').")";

$resql=$this->db->query($sql);
if ($resql)
Expand All @@ -3104,7 +3104,7 @@ function add_fournisseur($user, $id_fourn, $ref_fourn, $quantity)
else $sql.= " AND (ref_fourn = '' OR ref_fourn IS NULL)";
$sql.= " AND quantity = '".$quantity."'";
$sql.= " AND fk_product = ".$this->id;
$sql.= " AND entity IN (".getEntity('productprice').")";
$sql.= " AND entity IN (".getEntity('productresellerprice').")";

$resql=$this->db->query($sql);
if ($resql)
Expand Down
4 changes: 4 additions & 0 deletions htdocs/product/class/productcustomerprice.class.php
Expand Up @@ -341,6 +341,8 @@ function fetch_all($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $f
$sql .= " WHERE soc.rowid=t.fk_soc ";
$sql .= " AND prod.rowid=t.fk_product ";
$sql .= " AND prod.entity IN (" . getEntity('product') . ")";
$sql .= " AND t.entity IN (" . getEntity('productprice') . ")";
$sql .= " AND soc.entity IN (" . getEntity('societe') . ")";

// Manage filter
if (count($filter) > 0) {
Expand Down Expand Up @@ -450,6 +452,8 @@ function fetch_all_log($sortorder, $sortfield, $limit, $offset, $filter = array(
$sql .= " WHERE soc.rowid=t.fk_soc ";
$sql .= " AND prod.rowid=t.fk_product ";
$sql .= " AND prod.entity IN (" . getEntity('product') . ")";
$sql .= " AND t.entity IN (" . getEntity('productprice') . ")";
$sql .= " AND soc.entity IN (" . getEntity('societe') . ")";

// Manage filter
if (count($filter) > 0) {
Expand Down
2 changes: 1 addition & 1 deletion htdocs/product/stock/productlot_list.php
Expand Up @@ -218,7 +218,7 @@ function init_myfunc()
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot_extrafields as ef on (t.rowid = ef.fk_object)";
$sql.= ", ".MAIN_DB_PREFIX."product as p";
$sql.= " WHERE p.rowid = t.fk_product";
//$sql.= " WHERE u.entity IN (".getEntity('productlot').")";
$sql.= " WHERE p.entity IN (".getEntity('product').")";

if ($search_entity) $sql.= natural_search("entity",$search_entity);
if ($search_product) $sql.= natural_search("p.ref",$search_product);
Expand Down

0 comments on commit 1522a5b

Please sign in to comment.