Merge pull request #6182 from atm-ph/fix_develop_user_right_write_margin
Fix user right write margin
This commit is contained in:
commit
12e919b99d
@ -1015,6 +1015,18 @@ if (empty($reshook))
|
|||||||
if (! $error) {
|
if (! $error) {
|
||||||
$db->begin();
|
$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);
|
$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) {
|
if ($result >= 0) {
|
||||||
|
|||||||
@ -968,6 +968,19 @@ if (empty($reshook))
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (! $error) {
|
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);
|
$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) {
|
if ($result >= 0) {
|
||||||
|
|||||||
@ -1688,6 +1688,19 @@ if (empty($reshook))
|
|||||||
|
|
||||||
// Update line
|
// Update line
|
||||||
if (! $error) {
|
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'),
|
$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,
|
$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'),
|
GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $special_code, $array_options, GETPOST('progress'),
|
||||||
|
|||||||
@ -3336,10 +3336,13 @@ abstract class CommonObject
|
|||||||
|
|
||||||
if ($usemargins && ! empty($conf->margin->enabled) && empty($user->societe_id))
|
if ($usemargins && ! empty($conf->margin->enabled) && empty($user->societe_id))
|
||||||
{
|
{
|
||||||
if ($conf->global->MARGIN_TYPE == "1")
|
if (!empty($user->rights->margins->creer))
|
||||||
print '<td class="linecolmargin1 margininfos" align="right" width="80">'.$langs->trans('BuyingPrice').'</td>';
|
{
|
||||||
else
|
if ($conf->global->MARGIN_TYPE == "1")
|
||||||
print '<td class="linecolmargin1 margininfos" align="right" width="80">'.$langs->trans('CostPrice').'</td>';
|
print '<td class="linecolmargin1 margininfos" align="right" width="80">'.$langs->trans('BuyingPrice').'</td>';
|
||||||
|
else
|
||||||
|
print '<td class="linecolmargin1 margininfos" align="right" width="80">'.$langs->trans('CostPrice').'</td>';
|
||||||
|
}
|
||||||
|
|
||||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous)
|
if (! empty($conf->global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous)
|
||||||
print '<td class="linecolmargin2 margininfos" align="right" width="50">'.$langs->trans('MarginRate').'</td>';
|
print '<td class="linecolmargin2 margininfos" align="right" width="50">'.$langs->trans('MarginRate').'</td>';
|
||||||
|
|||||||
@ -88,9 +88,13 @@ if ($nolinesbefore) {
|
|||||||
}
|
}
|
||||||
if (! empty($usemargins))
|
if (! empty($usemargins))
|
||||||
{
|
{
|
||||||
|
if (!empty($user->rights->margins->creer)) {
|
||||||
?>
|
?>
|
||||||
<td align="right" class="margininfos linecolmargin1">
|
<td align="right" class="margininfos linecolmargin1">
|
||||||
<?php
|
<?php
|
||||||
|
}
|
||||||
|
else $colspan++;
|
||||||
|
|
||||||
if ($conf->global->MARGIN_TYPE == "1")
|
if ($conf->global->MARGIN_TYPE == "1")
|
||||||
echo $langs->trans('BuyingPrice');
|
echo $langs->trans('BuyingPrice');
|
||||||
else
|
else
|
||||||
@ -289,6 +293,7 @@ else {
|
|||||||
}
|
}
|
||||||
if (! empty($usemargins))
|
if (! empty($usemargins))
|
||||||
{
|
{
|
||||||
|
if (!empty($user->rights->margins->creer)) {
|
||||||
?>
|
?>
|
||||||
<td align="right" class="nobottom margininfos linecolmargin">
|
<td align="right" class="nobottom margininfos linecolmargin">
|
||||||
<!-- For predef product -->
|
<!-- For predef product -->
|
||||||
@ -299,8 +304,9 @@ else {
|
|||||||
<input type="text" size="5" id="buying_price" name="buying_price" class="flat" value="<?php echo (isset($_POST["buying_price"])?GETPOST("buying_price",'alpha',2):''); ?>">
|
<input type="text" size="5" id="buying_price" name="buying_price" class="flat" value="<?php echo (isset($_POST["buying_price"])?GETPOST("buying_price",'alpha',2):''); ?>">
|
||||||
</td>
|
</td>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$coldisplay++;
|
$coldisplay++;
|
||||||
|
}
|
||||||
|
|
||||||
if ($user->rights->margins->creer)
|
if ($user->rights->margins->creer)
|
||||||
{
|
{
|
||||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
|
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
|
||||||
@ -398,7 +404,7 @@ if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $da
|
|||||||
|
|
||||||
if (! empty($usemargins))
|
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_MARGIN_RATES)) $colspan++;
|
||||||
if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
|
if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,6 +45,7 @@ if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0;
|
|||||||
$colspan = 3; // Col total ht + col edit + col delete
|
$colspan = 3; // Col total ht + col edit + col delete
|
||||||
if (! empty($inputalsopricewithtax)) $colspan++; // We add 1 if col total ttc
|
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 (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++;
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!-- BEGIN PHP TEMPLATE objectline_edit.tpl.php -->
|
<!-- BEGIN PHP TEMPLATE objectline_edit.tpl.php -->
|
||||||
@ -174,6 +175,7 @@ $coldisplay=-1; // We remove first td
|
|||||||
if (! empty($usemargins))
|
if (! empty($usemargins))
|
||||||
{
|
{
|
||||||
?>
|
?>
|
||||||
|
<?php if (!empty($user->rights->margins->creer)) { ?>
|
||||||
<td align="right" class="margininfos"><?php $coldisplay++; ?>
|
<td align="right" class="margininfos"><?php $coldisplay++; ?>
|
||||||
<!-- For predef product -->
|
<!-- For predef product -->
|
||||||
<?php if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { ?>
|
<?php if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { ?>
|
||||||
@ -182,6 +184,7 @@ $coldisplay=-1; // We remove first td
|
|||||||
<!-- For free product -->
|
<!-- For free product -->
|
||||||
<input type="text" size="5" id="buying_price" name="buying_price" class="hideobject" value="<?php echo price($line->pa_ht,0,'',0); ?>">
|
<input type="text" size="5" id="buying_price" name="buying_price" class="hideobject" value="<?php echo price($line->pa_ht,0,'',0); ?>">
|
||||||
</td>
|
</td>
|
||||||
|
<?php } ?>
|
||||||
<?php if ($user->rights->margins->creer) {
|
<?php if ($user->rights->margins->creer) {
|
||||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
|
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -186,7 +186,10 @@ if (empty($usemargins)) $usemargins=0;
|
|||||||
{
|
{
|
||||||
$rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT);
|
$rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT);
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
<?php if (!empty($user->rights->margins->creer)) { ?>
|
||||||
<td align="right" class="linecolmargin1 nowrap margininfos"><?php $coldisplay++; ?><?php echo price($line->pa_ht); ?></td>
|
<td align="right" class="linecolmargin1 nowrap margininfos"><?php $coldisplay++; ?><?php echo price($line->pa_ht); ?></td>
|
||||||
|
<?php } ?>
|
||||||
<?php if (! empty($conf->global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous) { ?>
|
<?php if (! empty($conf->global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous) { ?>
|
||||||
<td align="right" class="linecolmargin2 nowrap margininfos"><?php $coldisplay++; ?><?php echo (($line->pa_ht == 0)?'n/a':price($line->marge_tx, null, null, null, null, $rounding).'%'); ?></td>
|
<td align="right" class="linecolmargin2 nowrap margininfos"><?php $coldisplay++; ?><?php echo (($line->pa_ht == 0)?'n/a':price($line->marge_tx, null, null, null, null, $rounding).'%'); ?></td>
|
||||||
<?php }
|
<?php }
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user