diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php
index de3b0b89455..c838f5ad1b8 100644
--- a/htdocs/core/lib/product.lib.php
+++ b/htdocs/core/lib/product.lib.php
@@ -44,10 +44,12 @@ function product_prepare_head($object)
$label = $langs->trans('Product');
$usercancreadprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS') ? $user->hasRight('product', 'product_advance', 'read_prices') : $user->hasRight('product', 'read');
+ $usercancreadsupplierprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS') ? $user->hasRight('product', 'product_advance', 'read_supplier_prices') : $user->hasRight('product', 'read');
if ($object->isService()) {
$label = $langs->trans('Service');
$usercancreadprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS') ? $user->hasRight('service', 'service_advance', 'read_prices') : $user->hasRight('service', 'read');
+ $usercancreadsupplierprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS') ? $user->hasRight('service', 'service_advance', 'read_supplier_prices') : $user->hasRight('service', 'read');
}
$h = 0;
@@ -77,7 +79,7 @@ function product_prepare_head($object)
if ((isModEnabled("supplier_proposal") || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && ($user->hasRight('fournisseur', 'lire') || $user->hasRight('supplier_order', 'read') || $user->hasRight('supplier_invoice', 'read'))
|| (isModEnabled('margin') && $user->hasRight("margin", "liretous"))
) {
- if ($usercancreadprice) {
+ if ($usercancreadsupplierprice) {
$head[$h][0] = DOL_URL_ROOT."/product/price_suppliers.php?id=".$object->id;
$head[$h][1] = $langs->trans("BuyingPrices");
$head[$h][2] = 'suppliers';
diff --git a/htdocs/product/list.php b/htdocs/product/list.php
index 15c801446d9..16831d0962c 100644
--- a/htdocs/product/list.php
+++ b/htdocs/product/list.php
@@ -1664,8 +1664,10 @@ while ($i < $imaxinloop) {
$object = $product_static;
$usercancreadprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS') ? $user->hasRight('product', 'product_advance', 'read_prices') : $user->hasRight('product', 'lire');
+ $usercancreadsupplierprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS') ? $user->hasRight('product', 'product_advance', 'read_supplier_prices') : $user->hasRight('product', 'lire');
if ($product_static->isService()) {
$usercancreadprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS') ? $user->hasRight('service', 'service_advance', 'read_prices') : $user->hasRight('service', 'lire');
+ $usercancreadsupplierprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS') ? $user->hasRight('service', 'service_advance', 'read_supplier_prices') : $user->hasRight('service', 'lire');
}
if ($mode == 'kanban') {
@@ -2078,7 +2080,7 @@ while ($i < $imaxinloop) {
// Better buy price
if (!empty($arrayfields['p.minbuyprice']['checked'])) {
print '
';
- if ($product_static->status_buy && $obj->bestpurchaseprice != '' && $usercancreadprice) {
+ if ($product_static->status_buy && $obj->bestpurchaseprice != '' && $usercancreadsupplierprice) {
if ($product_fourn->find_min_price_product_fournisseur($obj->rowid) > 0) {
if ($product_fourn->product_fourn_price_id > 0) {
if ((isModEnabled("fournisseur") && $user->hasRight('fournisseur', 'lire') && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) || (isModEnabled("supplier_order") && $user->hasRight('supplier_order', 'lire')) || (isModEnabled("supplier_invoice") && $user->hasRight('supplier_invoice', 'lire'))) {
@@ -2099,7 +2101,7 @@ while ($i < $imaxinloop) {
// Number of buy prices - Vendor prices
if (!empty($arrayfields['p.numbuyprice']['checked'])) {
print ' | ';
- if ($product_static->status_buy && $usercancreadprice) {
+ if ($product_static->status_buy && $usercancreadsupplierprice) {
if (count($productFournList = $product_fourn->list_product_fournisseur_price($obj->rowid)) > 0) {
$htmltext = $product_fourn->display_price_product_fournisseur(1, 1, 0, 1, $productFournList);
print $form->textwithpicto((string) count($productFournList), $htmltext);
@@ -2124,7 +2126,7 @@ while ($i < $imaxinloop) {
// WAP
if (!empty($arrayfields['p.pmp']['checked'])) {
print ' | ';
- if ($usercancreadprice) {
+ if ($usercancreadsupplierprice) {
print ''.price($product_static->pmp, 1, $langs)."";
}
print ' | ';
@@ -2136,7 +2138,7 @@ while ($i < $imaxinloop) {
if (!empty($arrayfields['p.cost_price']['checked'])) {
print '';
//print $obj->cost_price;
- if ($usercancreadprice) {
+ if ($usercancreadsupplierprice) {
print ''.price($obj->cost_price).' '.$langs->trans("HT").'';
}
print ' | ';
@@ -2182,15 +2184,15 @@ while ($i < $imaxinloop) {
if ($obj->seuil_stock_alerte != '' && $product_static->stock_reel < (float) $obj->seuil_stock_alerte) {
print img_warning($langs->trans("StockLowerThanLimit", $obj->seuil_stock_alerte)).' ';
}
- if ($usercancreadprice) {
- if ($product_static->stock_reel < 0) {
- print '';
- }
- print price(price2num($product_static->stock_reel, 'MS'), 0, $langs, 1, 0);
- if ($product_static->stock_reel < 0) {
- print '';
- }
+ /* why ? if ($usercancreadprice) { */
+ if ($product_static->stock_reel < 0) {
+ print '';
}
+ print price(price2num($product_static->stock_reel, 'MS'), 0, $langs, 1, 0);
+ if ($product_static->stock_reel < 0) {
+ print '';
+ }
+ /* } */
}
print '';
if (!$i) {
@@ -2204,15 +2206,15 @@ while ($i < $imaxinloop) {
if ($obj->seuil_stock_alerte != '' && $product_static->stock_theorique < (float) $obj->seuil_stock_alerte) {
print img_warning($langs->trans("StockLowerThanLimit", $obj->seuil_stock_alerte)).' ';
}
- if ($usercancreadprice) {
- if ($product_static->stock_theorique < 0) {
- print '';
- }
- print price(price2num($product_static->stock_theorique, 'MS'), 0, $langs, 1, 0);
- if ($product_static->stock_theorique < 0) {
- print '';
- }
+ /* why ? if ($usercancreadprice) { */
+ if ($product_static->stock_theorique < 0) {
+ print '';
}
+ print price(price2num($product_static->stock_theorique, 'MS'), 0, $langs, 1, 0);
+ if ($product_static->stock_theorique < 0) {
+ print '';
+ }
+ /* } */
}
print '';
if (!$i) {
diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php
index a3c19abd5d3..a9b2a44be2f 100644
--- a/htdocs/product/stock/product.php
+++ b/htdocs/product/stock/product.php
@@ -127,11 +127,13 @@ $error = 0;
$usercanread = (($object->type == Product::TYPE_PRODUCT && $user->hasRight('produit', 'lire')) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'lire')));
$usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->hasRight('produit', 'creer')) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'creer')));
$usercancreadprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS') ? $user->hasRight('product', 'product_advance', 'read_prices') : $user->hasRight('product', 'lire');
+$usercancreadsupplierprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS') ? $user->hasRight('product', 'product_advance', 'read_supplier_prices') : $user->hasRight('product', 'lire');
$usercanupdatestock = $user->hasRight('stock', 'mouvement', 'creer');
if ($object->isService()) {
$label = $langs->trans('Service');
$usercancreadprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS') ? $user->hasRight('service', 'service_advance', 'read_prices') : $user->hasRight('service', 'lire');
+ $usercancreadsupplierprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS') ? $user->hasRight('service', 'service_advance', 'read_supplier_prices') : $user->hasRight('service', 'lire');
}
if ($object->id > 0) {
@@ -672,7 +674,7 @@ if ($id > 0 || $ref) {
$textdesc = $langs->trans("CostPriceDescription");
$textdesc .= "
".$langs->trans("CostPriceUsage");
$text = $form->textwithpicto($langs->trans("CostPrice"), $textdesc, 1, 'help', '');
- if (!$usercancreadprice) {
+ if (!$usercancreadsupplierprice) {
print $form->editfieldkey($text, 'cost_price', '', $object, 0, 'amount:6');
print '';
print $form->editfieldval($text, 'cost_price', '', $object, 0, 'amount:6');
@@ -690,7 +692,7 @@ if ($id > 0 || $ref) {
print $form->textwithpicto($langs->trans("AverageUnitPricePMPShort"), $langs->trans("AverageUnitPricePMPDesc"));
print ' | ';
print '';
- if ($object->pmp > 0 && $usercancreadprice) {
+ if ($object->pmp > 0 && $usercancreadsupplierprice) {
print price($object->pmp).' '.$langs->trans("HT");
}
print ' | ';
@@ -701,7 +703,7 @@ if ($id > 0 || $ref) {
print '';
$product_fourn = new ProductFournisseur($db);
if ($product_fourn->find_min_price_product_fournisseur($object->id) > 0) {
- if ($product_fourn->product_fourn_price_id > 0 && $usercancreadprice) {
+ if ($product_fourn->product_fourn_price_id > 0 && $usercancreadsupplierprice) {
print $product_fourn->display_price_product_fournisseur();
} else {
print $langs->trans("NotDefined");
@@ -1085,7 +1087,7 @@ if (!$variants || getDolGlobalString('VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PA
print ' | '.(price2num($object->pmp) ? price2num($object->pmp, 'MU') : '').' | ';
// Value purchase
- if ($usercancreadprice) {
+ if ($usercancreadsupplierprice) {
print ''.(price2num($object->pmp) ? price(price2num($object->pmp * $obj->reel, 'MT')) : '').' | ';
} else {
print ' | ';
@@ -1246,13 +1248,13 @@ if (!$variants || getDolGlobalString('VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PA
print '| '.$langs->trans("Total").': | ';
print ''.price2num($total, 'MS').' | ';
print '';
- if ($usercancreadprice) {
+ if ($usercancreadsupplierprice) {
print($totalwithpmp ? price(price2num($totalvalue / $totalwithpmp, 'MU')) : ' '); // This value may have rounding errors
}
print ' | ';
// Value purchase
print '';
- if ($usercancreadprice) {
+ if ($usercancreadsupplierprice) {
print $totalvalue ? price(price2num($totalvalue, 'MT'), 1) : ' ';
}
print ' | ';