Merge pull request #22012 from bb2a/FIX---Add-an-advanced-permission-to-read-price

FIX - Advanced permission to read price
This commit is contained in:
Laurent Destailleur 2022-09-02 10:02:16 +02:00 committed by GitHub
commit d4c3537188
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 20 deletions

View File

@ -150,6 +150,11 @@ class box_produits extends ModeleBoxes
$productstatic->accountancy_code_buy_export = $objp->accountancy_code_buy_export; $productstatic->accountancy_code_buy_export = $objp->accountancy_code_buy_export;
$productstatic->date_modification = $datem; $productstatic->date_modification = $datem;
$usercancreadprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS')?$user->hasRight('product', 'product_advance', 'read_prices'):$user->hasRight('product', 'lire');
if ($productstatic->isService()) {
$usercancreadprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS')?$user->hasRight('service', 'service_advance', 'read_prices'):$user->hasRight('service', 'lire');
}
$this->info_box_contents[$line][] = array( $this->info_box_contents[$line][] = array(
'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', 'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"',
'text' => $productstatic->getNomUrl(1), 'text' => $productstatic->getNomUrl(1),
@ -162,6 +167,7 @@ class box_produits extends ModeleBoxes
); );
$price = ''; $price = '';
$price_base_type = ''; $price_base_type = '';
if ($usercancreadprice) {
if (empty($conf->dynamicprices->enabled) || empty($objp->fk_price_expression)) { if (empty($conf->dynamicprices->enabled) || empty($objp->fk_price_expression)) {
$price_base_type = $langs->trans($objp->price_base_type); $price_base_type = $langs->trans($objp->price_base_type);
$price = ($objp->price_base_type == 'HT') ?price($objp->price) : $price = price($objp->price_ttc); $price = ($objp->price_base_type == 'HT') ?price($objp->price) : $price = price($objp->price_ttc);
@ -180,6 +186,7 @@ class box_produits extends ModeleBoxes
$price = price($price_result); $price = price($price_result);
} }
} }
}
$this->info_box_contents[$line][] = array( $this->info_box_contents[$line][] = array(
'td' => 'class="nowraponall right amount"', 'td' => 'class="nowraponall right amount"',
'text' => $price, 'text' => $price,

View File

@ -341,6 +341,11 @@ if ((isModEnabled("product") || isModEnabled("service")) && ($user->rights->prod
$product_static->status_buy = $objp->tobuy; $product_static->status_buy = $objp->tobuy;
$product_static->status_batch = $objp->tobatch; $product_static->status_batch = $objp->tobatch;
$usercancreadprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS')?$user->hasRight('product', 'product_advance', 'read_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');
}
// Multilangs // Multilangs
if (!empty($conf->global->MAIN_MULTILANGS)) { if (!empty($conf->global->MAIN_MULTILANGS)) {
$sql = "SELECT label"; $sql = "SELECT label";
@ -378,11 +383,13 @@ if ((isModEnabled("product") || isModEnabled("service")) && ($user->rights->prod
} }
} }
print '<td class="nowraponall amount right">'; print '<td class="nowraponall amount right">';
if ($usercancreadprice) {
if (isset($objp->price_base_type) && $objp->price_base_type == 'TTC') { if (isset($objp->price_base_type) && $objp->price_base_type == 'TTC') {
print price($objp->price_ttc).' '.$langs->trans("TTC"); print price($objp->price_ttc).' '.$langs->trans("TTC");
} else { } else {
print price($objp->price).' '.$langs->trans("HT"); print price($objp->price).' '.$langs->trans("HT");
} }
}
print '</td>'; print '</td>';
} }
print '<td class="right nowrap width25"><span class="statusrefsell">'; print '<td class="right nowrap width25"><span class="statusrefsell">';
@ -410,7 +417,7 @@ if ((isModEnabled("product") || isModEnabled("service")) && ($user->rights->prod
// TODO Move this into a page that should be available into menu "accountancy - report - turnover - per quarter" // TODO Move this into a page that should be available into menu "accountancy - report - turnover - per quarter"
// Also method used for counting must provide the 2 possible methods like done by all other reports into menu "accountancy - report - turnover": // Also method used for counting must provide the 2 possible methods like done by all other reports into menu "accountancy - report - turnover":
// "commitment engagment" method and "cash accounting" method // "commitment engagment" method and "cash accounting" method
if (!empty($conf->global->MAIN_SHOW_PRODUCT_ACTIVITY_TRIM)) { if (isModEnabled("invoice") && $user->hasRight('facture', 'lire') && getDolGlobalString('MAIN_SHOW_PRODUCT_ACTIVITY_TRIM')) {
if (isModEnabled("product")) { if (isModEnabled("product")) {
activitytrim(0); activitytrim(0);
} }