diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php
index 8abddb18ce9..7e3f9d671b1 100644
--- a/htdocs/projet/element.php
+++ b/htdocs/projet/element.php
@@ -623,13 +623,8 @@ foreach ($listofreferent as $key => $value)
$total_ht = $total_ht + $element->total_ht;
$total_ttc = $total_ttc + $element->total_ttc;
}
-
- print '
';
- print '| '.$name.' | ';
- print ''.$i.' | ';
- print ''.price($total_ht).' | ';
- print ''.price($total_ttc).' | ';
- print '
';
+
+ // Calculate margin
if ($margin=="add")
{
$margin_ht+= $total_ht;
@@ -640,8 +635,21 @@ foreach ($listofreferent as $key => $value)
$margin_ht-= $total_ht;
$margin_ttc-= $total_ttc;
}
- }
+
+ // Show $total_ht & $total_ttc -- add a minus when necessary
+ if ($margin!="add")
+ {
+ $total_ht = -$total_ht;
+ $total_ttc = -$total_ttc;
+ }
+ print '';
+ print '| '.$name.' | ';
+ print ''.$i.' | ';
+ print ''.price($total_ht).' | ';
+ print ''.price($total_ttc).' | ';
+ print '
';
+ }
}
}
// and the margin amount total