diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php
index faaf7e346fa..b0771bc39d9 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,17 +649,25 @@ if ($id > 0 || $ref) {
$textdesc = $langs->trans("CostPriceDescription");
$textdesc .= "
".$langs->trans("CostPriceUsage");
$text = $form->textwithpicto($langs->trans("CostPrice"), $textdesc, 1, 'help', '');
- 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');
+ if (!$usercancreadprice) {
+ print $form->editfieldkey($text, 'cost_price', '', $object, 0, 'amount:6');
+ print ' | ';
+ print $form->editfieldval($text, 'cost_price', '', $object, 0, 'amount:6');
+ } else {
+ 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');
+ }
print ' | ';
+
+
// AWP
print '| ';
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 +678,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 +689,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 +1061,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 +1082,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 +1100,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 +1217,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 +1233,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 +1244,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"));
|