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->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(
'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"',
'text' => $productstatic->getNomUrl(1),
@ -162,22 +167,24 @@ class box_produits extends ModeleBoxes
);
$price = '';
$price_base_type = '';
if (empty($conf->dynamicprices->enabled) || empty($objp->fk_price_expression)) {
$price_base_type = $langs->trans($objp->price_base_type);
$price = ($objp->price_base_type == 'HT') ?price($objp->price) : $price = price($objp->price_ttc);
} else {
//Parse the dynamic price
$productstatic->fetch($objp->rowid, '', '', 1);
$priceparser = new PriceParser($this->db);
$price_result = $priceparser->parseProduct($productstatic);
if ($price_result >= 0) {
if ($objp->price_base_type == 'HT') {
$price_base_type = $langs->trans("HT");
} else {
$price_result = $price_result * (1 + ($productstatic->tva_tx / 100));
$price_base_type = $langs->trans("TTC");
if ($usercancreadprice) {
if (empty($conf->dynamicprices->enabled) || empty($objp->fk_price_expression)) {
$price_base_type = $langs->trans($objp->price_base_type);
$price = ($objp->price_base_type == 'HT') ?price($objp->price) : $price = price($objp->price_ttc);
} else {
//Parse the dynamic price
$productstatic->fetch($objp->rowid, '', '', 1);
$priceparser = new PriceParser($this->db);
$price_result = $priceparser->parseProduct($productstatic);
if ($price_result >= 0) {
if ($objp->price_base_type == 'HT') {
$price_base_type = $langs->trans("HT");
} else {
$price_result = $price_result * (1 + ($productstatic->tva_tx / 100));
$price_base_type = $langs->trans("TTC");
}
$price = price($price_result);
}
$price = price($price_result);
}
}
$this->info_box_contents[$line][] = array(

View File

@ -341,6 +341,11 @@ if ((isModEnabled("product") || isModEnabled("service")) && ($user->rights->prod
$product_static->status_buy = $objp->tobuy;
$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
if (!empty($conf->global->MAIN_MULTILANGS)) {
$sql = "SELECT label";
@ -378,10 +383,12 @@ if ((isModEnabled("product") || isModEnabled("service")) && ($user->rights->prod
}
}
print '<td class="nowraponall amount right">';
if (isset($objp->price_base_type) && $objp->price_base_type == 'TTC') {
print price($objp->price_ttc).' '.$langs->trans("TTC");
} else {
print price($objp->price).' '.$langs->trans("HT");
if ($usercancreadprice) {
if (isset($objp->price_base_type) && $objp->price_base_type == 'TTC') {
print price($objp->price_ttc).' '.$langs->trans("TTC");
} else {
print price($objp->price).' '.$langs->trans("HT");
}
}
print '</td>';
}
@ -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"
// 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
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")) {
activitytrim(0);
}