diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 0d0a1857427..8113d95a201 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1470,6 +1470,7 @@ class Form $sql = "SELECT price, price_ttc, price_base_type, tva_tx"; $sql.= " FROM ".MAIN_DB_PREFIX."product_price"; $sql.= " WHERE fk_product='".$objp->rowid."'"; + $sql.= " AND entity IN (".getEntity('productprice', 1).")"; $sql.= " AND price_level=".$price_level; $sql.= " ORDER BY date_price"; $sql.= " DESC LIMIT 1"; diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index 61ef111bddf..456551568ab 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2005-2013 Regis Houssin * Copyright (C) 2007-2011 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify @@ -70,7 +70,7 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) $outdiscount=0; $found=false; - + // Price by qty if (!empty($price_by_qty_rowid) && $price_by_qty_rowid >= 1) // If we need a particular price related to qty { @@ -101,6 +101,7 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) $sql = "SELECT price, price_ttc, price_base_type, tva_tx"; $sql.= " FROM ".MAIN_DB_PREFIX."product_price "; $sql.= " WHERE fk_product='".$id."'"; + $sql.= " AND entity IN (".getEntity('productprice', 1).")"; $sql.= " AND price_level=".$price_level; $sql.= " ORDER BY date_price"; $sql.= " DESC LIMIT 1"; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 4de761f6e79..2c086b42608 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2005-2013 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2007-2011 Jean Heimburger * Copyright (C) 2010-2011 Juanjo Menent @@ -822,13 +822,15 @@ class Product extends CommonObject */ function _log_price($user,$level=0) { + global $conf; + $now=dol_now(); // Add new price $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_price(price_level,date_price,fk_product,fk_user_author,price,price_ttc,price_base_type,tosell,tva_tx,recuperableonly,"; - $sql.= " localtax1_tx, localtax2_tx, price_min,price_min_ttc,price_by_qty) "; + $sql.= " localtax1_tx, localtax2_tx, price_min,price_min_ttc,price_by_qty,entity) "; $sql.= " VALUES(".($level?$level:1).", '".$this->db->idate($now)."',".$this->id.",".$user->id.",".$this->price.",".$this->price_ttc.",'".$this->price_base_type."',".$this->status.",".$this->tva_tx.",".$this->tva_npr.","; - $sql.= " ".$this->localtax1_tx.",".$this->localtax2_tx.",".$this->price_min.",".$this->price_min_ttc.",".$this->price_by_qty; + $sql.= " ".$this->localtax1_tx.",".$this->localtax2_tx.",".$this->price_min.",".$this->price_min_ttc.",".$this->price_by_qty.",".$conf->entity; $sql.= ")"; dol_syslog(get_class($this)."_log_price sql=".$sql); @@ -1199,7 +1201,8 @@ class Product extends CommonObject $sql = "SELECT price, price_ttc, price_min, price_min_ttc,"; $sql.= " price_base_type, tva_tx, tosell, price_by_qty, rowid, recuperableonly"; $sql.= " FROM ".MAIN_DB_PREFIX."product_price"; - $sql.= " WHERE price_level=".$i; + $sql.= " WHERE entity IN (".getEntity('productprice', 1).")"; + $sql.= " AND price_level=".$i; $sql.= " AND fk_product = '".$this->id."'"; $sql.= " ORDER BY date_price DESC"; $sql.= " LIMIT 1"; diff --git a/htdocs/product/price.php b/htdocs/product/price.php index c8e3d262c21..cba87ea6e45 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -2,7 +2,7 @@ /* Copyright (C) 2001-2007 Rodolphe Quiedeville * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005 Eric Seigne - * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2005-2013 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * * This program is free software; you can redistribute it and/or modify @@ -667,6 +667,7 @@ $sql.= " p.date_price as dp, u.rowid as user_id, u.login"; $sql.= " FROM ".MAIN_DB_PREFIX."product_price as p,"; $sql.= " ".MAIN_DB_PREFIX."user as u"; $sql.= " WHERE fk_product = ".$object->id; +$sql.= " AND p.entity IN (".getEntity('productprice', 1).")"; $sql.= " AND p.fk_user_author = u.rowid"; if (! empty($socid) && ! empty($conf->global->PRODUIT_MULTIPRICES)) $sql.= " AND p.price_level = ".$soc->price_level; $sql.= " ORDER BY p.date_price DESC, p.price_level ASC";