mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-07 16:41:48 +01:00
Manage supplier prices permission (#33636)
* WIP : manage read_supplier_prices * WIP : manage read_supplier_prices --------- Co-authored-by: Christophe Battarel <christophe@altairis.fr> Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
committed by
GitHub
parent
67dff53958
commit
36bd2c7a5b
@@ -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';
|
||||
|
||||
@@ -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 '<td class="right nowraponall">';
|
||||
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 '<td class="right">';
|
||||
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 '<td class="nowrap right">';
|
||||
if ($usercancreadprice) {
|
||||
if ($usercancreadsupplierprice) {
|
||||
print '<span class="amount">'.price($product_static->pmp, 1, $langs)."</span>";
|
||||
}
|
||||
print '</td>';
|
||||
@@ -2136,7 +2138,7 @@ while ($i < $imaxinloop) {
|
||||
if (!empty($arrayfields['p.cost_price']['checked'])) {
|
||||
print '<td class="nowrap right">';
|
||||
//print $obj->cost_price;
|
||||
if ($usercancreadprice) {
|
||||
if ($usercancreadsupplierprice) {
|
||||
print '<span class="amount">'.price($obj->cost_price).' '.$langs->trans("HT").'</span>';
|
||||
}
|
||||
print '</td>';
|
||||
@@ -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 '<span class="warning">';
|
||||
}
|
||||
print price(price2num($product_static->stock_reel, 'MS'), 0, $langs, 1, 0);
|
||||
if ($product_static->stock_reel < 0) {
|
||||
print '</span>';
|
||||
}
|
||||
/* why ? if ($usercancreadprice) { */
|
||||
if ($product_static->stock_reel < 0) {
|
||||
print '<span class="warning">';
|
||||
}
|
||||
print price(price2num($product_static->stock_reel, 'MS'), 0, $langs, 1, 0);
|
||||
if ($product_static->stock_reel < 0) {
|
||||
print '</span>';
|
||||
}
|
||||
/* } */
|
||||
}
|
||||
print '</td>';
|
||||
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 '<span class="warning">';
|
||||
}
|
||||
print price(price2num($product_static->stock_theorique, 'MS'), 0, $langs, 1, 0);
|
||||
if ($product_static->stock_theorique < 0) {
|
||||
print '</span>';
|
||||
}
|
||||
/* why ? if ($usercancreadprice) { */
|
||||
if ($product_static->stock_theorique < 0) {
|
||||
print '<span class="warning">';
|
||||
}
|
||||
print price(price2num($product_static->stock_theorique, 'MS'), 0, $langs, 1, 0);
|
||||
if ($product_static->stock_theorique < 0) {
|
||||
print '</span>';
|
||||
}
|
||||
/* } */
|
||||
}
|
||||
print '</td>';
|
||||
if (!$i) {
|
||||
|
||||
@@ -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 .= "<br>".$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 '</td><td>';
|
||||
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 '</td>';
|
||||
print '<td>';
|
||||
if ($object->pmp > 0 && $usercancreadprice) {
|
||||
if ($object->pmp > 0 && $usercancreadsupplierprice) {
|
||||
print price($object->pmp).' '.$langs->trans("HT");
|
||||
}
|
||||
print '</td>';
|
||||
@@ -701,7 +703,7 @@ if ($id > 0 || $ref) {
|
||||
print '<td>';
|
||||
$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 '<td class="right nowraponall">'.(price2num($object->pmp) ? price2num($object->pmp, 'MU') : '').'</td>';
|
||||
|
||||
// Value purchase
|
||||
if ($usercancreadprice) {
|
||||
if ($usercancreadsupplierprice) {
|
||||
print '<td class="right amount nowraponall">'.(price2num($object->pmp) ? price(price2num($object->pmp * $obj->reel, 'MT')) : '').'</td>';
|
||||
} else {
|
||||
print '<td class="right amount nowraponall"></td>';
|
||||
@@ -1246,13 +1248,13 @@ if (!$variants || getDolGlobalString('VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PA
|
||||
print '<tr class="liste_total"><td class="right liste_total" colspan="4">'.$langs->trans("Total").':</td>';
|
||||
print '<td class="liste_total right">'.price2num($total, 'MS').'</td>';
|
||||
print '<td class="liste_total right">';
|
||||
if ($usercancreadprice) {
|
||||
if ($usercancreadsupplierprice) {
|
||||
print($totalwithpmp ? price(price2num($totalvalue / $totalwithpmp, 'MU')) : ' '); // This value may have rounding errors
|
||||
}
|
||||
print '</td>';
|
||||
// Value purchase
|
||||
print '<td class="liste_total right">';
|
||||
if ($usercancreadprice) {
|
||||
if ($usercancreadsupplierprice) {
|
||||
print $totalvalue ? price(price2num($totalvalue, 'MT'), 1) : ' ';
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
Reference in New Issue
Block a user