Merge pull request #6182 from atm-ph/fix_develop_user_right_write_margin

Fix user right write margin
This commit is contained in:
Laurent Destailleur 2016-12-18 10:53:34 +01:00 committed by GitHub
commit 12e919b99d
7 changed files with 60 additions and 7 deletions

View File

@ -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) {

View File

@ -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) {

View File

@ -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'),

View File

@ -3336,11 +3336,14 @@ abstract class CommonObject
if ($usemargins && ! empty($conf->margin->enabled) && empty($user->societe_id))
{
if ($conf->global->MARGIN_TYPE == "1")
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($user->rights->margins->creer))
{
if ($conf->global->MARGIN_TYPE == "1")
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)
print '<td class="linecolmargin2 margininfos" align="right" width="50">'.$langs->trans('MarginRate').'</td>';
if (! empty($conf->global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous)

View File

@ -88,9 +88,13 @@ if ($nolinesbefore) {
}
if (! empty($usemargins))
{
if (!empty($user->rights->margins->creer)) {
?>
<td align="right" class="margininfos linecolmargin1">
<?php
}
else $colspan++;
if ($conf->global->MARGIN_TYPE == "1")
echo $langs->trans('BuyingPrice');
else
@ -289,6 +293,7 @@ else {
}
if (! empty($usemargins))
{
if (!empty($user->rights->margins->creer)) {
?>
<td align="right" class="nobottom margininfos linecolmargin">
<!-- 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):''); ?>">
</td>
<?php
$coldisplay++;
}
if ($user->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++;
}

View File

@ -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++;
?>
<!-- BEGIN PHP TEMPLATE objectline_edit.tpl.php -->
@ -174,6 +175,7 @@ $coldisplay=-1; // We remove first td
if (! empty($usemargins))
{
?>
<?php if (!empty($user->rights->margins->creer)) { ?>
<td align="right" class="margininfos"><?php $coldisplay++; ?>
<!-- For predef product -->
<?php if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { ?>
@ -182,6 +184,7 @@ $coldisplay=-1; // We remove first td
<!-- 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); ?>">
</td>
<?php } ?>
<?php if ($user->rights->margins->creer) {
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
{

View File

@ -186,7 +186,10 @@ if (empty($usemargins)) $usemargins=0;
{
$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>
<?php } ?>
<?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>
<?php }