diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 0a4ff814ec8..74566100f89 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1015,6 +1015,18 @@ if (empty($reshook)) if (! $error) { $db->begin(); + if (empty($user->rights->margins->creer)) + { + foreach ($object->lines as &$line) + { + if ($line->id == GETPOST('lineid')) + { + $fournprice = $line->fk_fournprice; + $buyingprice = $line->pa_ht; + break; + } + } + } $result = $object->updateline(GETPOST('lineid'), $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, $description, 'HT', $info_bits, $special_code, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $type, $date_start, $date_end, $array_options, $_POST["units"], $pu_ht_devise); if ($result >= 0) { diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index efd6af16f70..db11214803d 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -968,6 +968,19 @@ if (empty($reshook)) } if (! $error) { + + if (empty($user->rights->margins->creer)) + { + foreach ($object->lines as &$line) + { + if ($line->id == GETPOST('lineid')) + { + $fournprice = $line->fk_fournprice; + $buyingprice = $line->pa_ht; + break; + } + } + } $result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $date_start, $date_end, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $special_code, $array_options, GETPOST('units'),$pu_ht_devise); if ($result >= 0) { diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 9708d8e6360..cd44122b981 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1688,6 +1688,19 @@ if (empty($reshook)) // Update line if (! $error) { + if (empty($user->rights->margins->creer)) + { + foreach ($object->lines as &$line) + { + if ($line->id == GETPOST('lineid')) + { + $fournprice = $line->fk_fournprice; + $buyingprice = $line->pa_ht; + break; + } + } + } + $result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, $qty, GETPOST('remise_percent'), $date_start, $date_end, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $special_code, $array_options, GETPOST('progress'), diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 1afae6875ae..7b25ad8be92 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3336,11 +3336,14 @@ abstract class CommonObject if ($usemargins && ! empty($conf->margin->enabled) && empty($user->societe_id)) { - if ($conf->global->MARGIN_TYPE == "1") - print ''.$langs->trans('BuyingPrice').''; - else - print ''.$langs->trans('CostPrice').''; - + if (!empty($user->rights->margins->creer)) + { + if ($conf->global->MARGIN_TYPE == "1") + print ''.$langs->trans('BuyingPrice').''; + else + print ''.$langs->trans('CostPrice').''; + } + if (! empty($conf->global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous) print ''.$langs->trans('MarginRate').''; if (! empty($conf->global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 30027560140..c7ebe5b7b8b 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -88,9 +88,13 @@ if ($nolinesbefore) { } if (! empty($usemargins)) { + if (!empty($user->rights->margins->creer)) { ?> global->MARGIN_TYPE == "1") echo $langs->trans('BuyingPrice'); else @@ -289,6 +293,7 @@ else { } if (! empty($usemargins)) { + if (!empty($user->rights->margins->creer)) { ?> @@ -299,8 +304,9 @@ else { "> rights->margins->creer) { if (! empty($conf->global->DISPLAY_MARGIN_RATES)) @@ -398,7 +404,7 @@ if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $da if (! empty($usemargins)) { - $colspan++; // For the buying price + if (!empty($user->rights->margins->creer)) $colspan++; // For the buying price if (! empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++; if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++; } diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index e684e3c2750..c89b8ce4589 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -45,6 +45,7 @@ if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0; $colspan = 3; // Col total ht + col edit + col delete if (! empty($inputalsopricewithtax)) $colspan++; // We add 1 if col total ttc if (in_array($object->element,array('propal','supplier_proposal','facture','invoice','commande','order','order_supplier','invoice_supplier'))) $colspan++; // With this, there is a column move button +if (empty($user->rights->margins->creer)) $colspan++; ?> @@ -174,6 +175,7 @@ $coldisplay=-1; // We remove first td if (! empty($usemargins)) { ?> + rights->margins->creer)) { ?> product->enabled) || ! empty($conf->service->enabled)) { ?> @@ -182,6 +184,7 @@ $coldisplay=-1; // We remove first td + rights->margins->creer) { if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index d38a3d761e4..62d4b0007ed 100755 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -186,7 +186,10 @@ if (empty($usemargins)) $usemargins=0; { $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT); ?> + + rights->margins->creer)) { ?> pa_ht); ?> + global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous) { ?> pa_ht == 0)?'n/a':price($line->marge_tx, null, null, null, null, $rounding).'%'); ?>