diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php
index f6e40b511f1..96fb68b6e9b 100644
--- a/htdocs/bom/bom_card.php
+++ b/htdocs/bom/bom_card.php
@@ -519,7 +519,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$keyforbreak = 'duration';
include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
$object->calculateCosts();
- print '
| '.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCost")).' | '.price($object->total_cost).' |
';
+ print '| '.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCost")).' | '.price($object->total_cost).' |
';
print '| '.$langs->trans("UnitCost").' | '.price($object->unit_cost).' |
';
// Other attributes
diff --git a/htdocs/bom/bom_net_needs.php b/htdocs/bom/bom_net_needs.php
index b0e8b544cb0..30cd6792c55 100644
--- a/htdocs/bom/bom_net_needs.php
+++ b/htdocs/bom/bom_net_needs.php
@@ -170,7 +170,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$keyforbreak = 'duration';
include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
- print '| '.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCost")).' | '.price($object->total_cost).' |
';
+ print '| '.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCost")).' | '.price($object->total_cost).' |
';
print '| '.$langs->trans("UnitCost").' | '.price($object->unit_cost).' |
';
// Other attributes
diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php
index 8040310ea53..61b394a3b0f 100644
--- a/htdocs/bom/tpl/objectline_view.tpl.php
+++ b/htdocs/bom/tpl/objectline_view.tpl.php
@@ -126,7 +126,7 @@ print '';
$total_cost = 0;
print '';
$coldisplay++;
-echo price($line->total_cost);
+echo ''.price($line->total_cost).'';
print ' | ';
if ($this->status == 0 && ($object_rights->write) && $action != 'selectlines') {
@@ -152,12 +152,12 @@ if ($this->status == 0 && ($object_rights->write) && $action != 'selectlines') {
print '';
$coldisplay++;
if ($i > 0) {
- print 'id.'&action=up&rowid='.$line->id.'">';
+ print 'id.'&action=up&token='.newToken().'&rowid='.$line->id.'">';
echo img_up('default', 0, 'imgupforline');
print '';
}
if ($i < $num - 1) {
- print 'id.'&action=down&rowid='.$line->id.'">';
+ print 'id.'&action=down&token='.newToken().'&rowid='.$line->id.'">';
echo img_down('default', 0, 'imgdownforline');
print '';
}
@@ -236,15 +236,16 @@ if ($resql) {
// Efficiency
print ' | '.$sub_bom_line->efficiency.' | ';
+ // Cost
if (!empty($sub_bom->id)) {
$sub_bom->calculateCosts();
- print ''.price($sub_bom->total_cost * $sub_bom_line->qty * $line->qty).' | ';
+ print ''.price($sub_bom->total_cost * $sub_bom_line->qty * $line->qty).' | ';
$total_cost+= $sub_bom->total_cost * $sub_bom_line->qty * $line->qty;
} elseif ($sub_bom_product->cost_price > 0) {
- print ''.price($sub_bom_product->cost_price * $sub_bom_line->qty * $line->qty).' | ';
+ print ''.price($sub_bom_product->cost_price * $sub_bom_line->qty * $line->qty).' | ';
$total_cost+= $sub_bom_product->cost_price * $sub_bom_line->qty * $line->qty;
} elseif ($sub_bom_product->pmp > 0) { // PMP if cost price isn't defined
- print ''.price($sub_bom_product->pmp * $sub_bom_line->qty * $line->qty).' | ';
+ print ''.price($sub_bom_product->pmp * $sub_bom_line->qty * $line->qty).' | ';
$total_cost.= $sub_bom_product->pmp * $sub_bom_line->qty * $line->qty;
} else { // Minimum purchase price if cost price and PMP aren't defined
$sql_supplier_price = 'SELECT MIN(price) AS min_price, quantity AS qty FROM '.MAIN_DB_PREFIX.'product_fournisseur_price';
@@ -254,7 +255,7 @@ if ($resql) {
$obj = $object->db->fetch_object($resql_supplier_price);
$line_cost = $obj->min_price/$obj->qty * $sub_bom_line->qty * $line->qty;
- print ''.price($line_cost).' | ';
+ print ''.price($line_cost).' | ';
$total_cost+= $line_cost;
}
}
@@ -266,11 +267,12 @@ if ($resql) {
}
// Replace of the total_cost value by the sum of all sub-BOM lines total_cost
+// TODO Remove this bad practice. We should not replace content of ouput using javascript but value should be good during generation of output.
if ($total_cost > 0) {
$line->total_cost = price($total_cost);
?>