diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php
index faaf7e346fa..c53454f0fc3 100644
--- a/htdocs/product/stock/product.php
+++ b/htdocs/product/stock/product.php
@@ -117,6 +117,12 @@ $error = 0;
$usercanread = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->lire) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->lire));
$usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer));
+$usercancreadprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS')?$user->hasRight('product', 'product_advance', 'read_prices'):$user->hasRight('product', 'lire');
+
+if ($object->isService()) {
+ $label = $langs->trans('Service');
+ $usercancreadprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS')?$user->hasRight('service', 'service_advance', 'read_prices'):$user->hasRight('service', 'lire');
+}
if ($object->id > 0) {
if ($object->type == $object::TYPE_PRODUCT) {
@@ -643,6 +649,11 @@ if ($id > 0 || $ref) {
$textdesc = $langs->trans("CostPriceDescription");
$textdesc .= "
".$langs->trans("CostPriceUsage");
$text = $form->textwithpicto($langs->trans("CostPrice"), $textdesc, 1, 'help', '');
+ $costprice = $object->cost_price;
+ if (!$usercancreadprice) {
+ $costprice = '';
+ }
+
print $form->editfieldkey($text, 'cost_price', $object->cost_price, $object, $usercancreate, 'amount:6');
print '
';
print $form->editfieldval($text, 'cost_price', $object->cost_price, $object, $usercancreate, 'amount:6');
@@ -653,7 +664,7 @@ if ($id > 0 || $ref) {
print $form->textwithpicto($langs->trans("AverageUnitPricePMPShort"), $langs->trans("AverageUnitPricePMPDesc"));
print ' | ';
print '';
- if ($object->pmp > 0) {
+ if ($object->pmp > 0 && $usercancreadprice) {
print price($object->pmp).' '.$langs->trans("HT");
}
print ' | ';
@@ -664,7 +675,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) {
+ if ($product_fourn->product_fourn_price_id > 0 && $usercancreadprice) {
print $product_fourn->display_price_product_fournisseur();
} else {
print $langs->trans("NotDefined");
@@ -675,19 +686,23 @@ if ($id > 0 || $ref) {
if (empty($conf->global->PRODUIT_MULTIPRICES)) {
// Price
print ' | | '.$langs->trans("SellingPrice").' | ';
- if ($object->price_base_type == 'TTC') {
- print price($object->price_ttc).' '.$langs->trans($object->price_base_type);
- } else {
- print price($object->price).' '.$langs->trans($object->price_base_type);
+ if ($usercancreadprice) {
+ if ($object->price_base_type == 'TTC') {
+ print price($object->price_ttc).' '.$langs->trans($object->price_base_type);
+ } else {
+ print price($object->price).' '.$langs->trans($object->price_base_type);
+ }
}
print ' |
';
// Price minimum
print '| '.$langs->trans("MinPrice").' | ';
- if ($object->price_base_type == 'TTC') {
- print price($object->price_min_ttc).' '.$langs->trans($object->price_base_type);
- } else {
- print price($object->price_min).' '.$langs->trans($object->price_base_type);
+ if ($usercancreadprice) {
+ if ($object->price_base_type == 'TTC') {
+ print price($object->price_min_ttc).' '.$langs->trans($object->price_base_type);
+ } else {
+ print price($object->price_min).' '.$langs->trans($object->price_base_type);
+ }
}
print ' |
';
} else {
@@ -1043,7 +1058,11 @@ if (!$variants) {
print ''.(price2num($object->pmp) ? price2num($object->pmp, 'MU') : '').' | ';
// Value purchase
- print ''.(price2num($object->pmp) ? price(price2num($object->pmp * $obj->reel, 'MT')) : '').' | ';
+ if ($usercancreadprice) {
+ print ''.(price2num($object->pmp) ? price(price2num($object->pmp * $obj->reel, 'MT')) : '').' | ';
+ } else {
+ print ' | ';
+ }
// Sell price
$minsellprice = null; $maxsellprice = null;
@@ -1060,14 +1079,16 @@ if (!$variants) {
}
}
print '';
- if ($minsellprice != $maxsellprice) {
- print price(price2num($minsellprice, 'MU'), 1).' - '.price(price2num($maxsellprice, 'MU'), 1);
- } else {
- print price(price2num($minsellprice, 'MU'), 1);
+ if ($usercancreadprice) {
+ if ($minsellprice != $maxsellprice) {
+ print price(price2num($minsellprice, 'MU'), 1).' - '.price(price2num($maxsellprice, 'MU'), 1);
+ } else {
+ print price(price2num($minsellprice, 'MU'), 1);
+ }
}
print '';
print $form->textwithpicto('', $langs->trans("Variable"));
- } else {
+ } elseif ($usercancreadprice) {
print price(price2num($object->price, 'MU'), 1);
}
print '';
@@ -1076,15 +1097,19 @@ if (!$variants) {
print '';
if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
print '';
- if ($minsellprice != $maxsellprice) {
- print price(price2num($minsellprice * $obj->reel, 'MT'), 1).' - '.price(price2num($maxsellprice * $obj->reel, 'MT'), 1);
- } else {
- print price(price2num($minsellprice * $obj->reel, 'MT'), 1);
+ if ($usercancreadprice) {
+ if ($minsellprice != $maxsellprice) {
+ print price(price2num($minsellprice * $obj->reel, 'MT'), 1).' - '.price(price2num($maxsellprice * $obj->reel, 'MT'), 1);
+ } else {
+ print price(price2num($minsellprice * $obj->reel, 'MT'), 1);
+ }
}
print '';
print $form->textwithpicto('', $langs->trans("Variable"));
} else {
- print price(price2num($object->price * $obj->reel, 'MT'), 1);
+ if ($usercancreadprice) {
+ print price(price2num($object->price * $obj->reel, 'MT'), 1);
+ }
}
print ' | ';
print ' | ';
@@ -1189,11 +1214,15 @@ if (!$variants) {
print '| '.$langs->trans("Total").': | ';
print ''.price2num($total, 'MS').' | ';
print '';
- print ($totalwithpmp ? price(price2num($totalvalue / $totalwithpmp, 'MU')) : ' '); // This value may have rounding errors
+ if ($usercancreadprice) {
+ print ($totalwithpmp ? price(price2num($totalvalue / $totalwithpmp, 'MU')) : ' '); // This value may have rounding errors
+ }
print ' | ';
// Value purchase
print '';
- print $totalvalue ? price(price2num($totalvalue, 'MT'), 1) : ' ';
+ if ($usercancreadprice) {
+ print $totalvalue ? price(price2num($totalvalue, 'MT'), 1) : ' ';
+ }
print ' | ';
print '';
if ($num) {
@@ -1201,7 +1230,7 @@ if (!$variants) {
print '';
if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
print $form->textwithpicto('', $langs->trans("Variable"));
- } else {
+ } elseif ($usercancreadprice) {
print price($totalvaluesell / $total, 1);
}
print '';
@@ -1212,7 +1241,7 @@ if (!$variants) {
print ' | ';
if ($num) {
print '';
- if (empty($conf->global->PRODUIT_MULTIPRICES)) {
+ if (empty($conf->global->PRODUIT_MULTIPRICES) && $usercancreadprice) {
print price(price2num($totalvaluesell, 'MT'), 1);
} else {
print $form->textwithpicto('', $langs->trans("Variable"));
|