diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index 29b57839d56..637a88f7468 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -978,6 +978,19 @@ 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"]);
if ($result >= 0) {
diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php
index ee576ed48e5..9b10f17668c 100644
--- a/htdocs/commande/card.php
+++ b/htdocs/commande/card.php
@@ -909,6 +909,20 @@ 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'));
if ($result >= 0) {
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 34ed1383e14..f1d2b7b1123 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -1612,6 +1612,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 3279d372a0e..093652ade1e 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -3090,11 +3090,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 1c82b1501d5..6ed8c2b8a4f 100644
--- a/htdocs/core/tpl/objectline_create.tpl.php
+++ b/htdocs/core/tpl/objectline_create.tpl.php
@@ -81,9 +81,13 @@ if (in_array($object->element,array('propal', 'supplier_proposal','facture','inv
}
if (! empty($usemargins))
{
+ if (!empty($user->rights->margins->creer)) {
?>
global->MARGIN_TYPE == "1")
echo $langs->trans('BuyingPrice');
else
@@ -256,6 +260,7 @@ else {
}
if (! empty($usemargins))
{
+ if (!empty($user->rights->margins->creer)) {
?>
@@ -266,8 +271,9 @@ else {
">
rights->margins->creer)
{
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
@@ -362,7 +368,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 83d596dbd61..8b621b1886a 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++;
?>
@@ -169,6 +170,7 @@ $coldisplay=-1; // We remove first td
if (! empty($usemargins))
{
?>
+ rights->margins->creer)) { ?>
product->enabled) || ! empty($conf->service->enabled)) { ?>
@@ -177,6 +179,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 7162ac66cb9..1b51aa8ac1c 100644
--- a/htdocs/core/tpl/objectline_view.tpl.php
+++ b/htdocs/core/tpl/objectline_view.tpl.php
@@ -178,7 +178,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).'%'); ?>