diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php
index fbfb02576df..0d83754dd60 100644
--- a/htdocs/bom/tpl/objectline_view.tpl.php
+++ b/htdocs/bom/tpl/objectline_view.tpl.php
@@ -123,7 +123,8 @@ $coldisplay++;
echo $line->efficiency;
print '';
-print '
';
+$total_cost = 0;
+print ' | ';
$coldisplay++;
echo price($line->total_cost);
print ' | ';
@@ -199,7 +200,7 @@ if ($resql){
print '';
}
- print '| '.$sub_bom_product->getNomUrl(1).' | ';
+ print ''.$sub_bom_product->getNomUrl(1).' | ';
if ($sub_bom_line->fk_bom_child > 0) {
print ''.$sub_bom->getNomUrl(1).' | ';
} else {
@@ -219,13 +220,39 @@ if ($resql){
}
print ''.$sub_bom_line->efficiency.' | ';
- print ''.price($sub_bom_line->total_cost * $line->qty).' | ';
+ if ($sub_bom_product->cost_price > 0) {
+ print ''.price($sub_bom_product->cost_price * $line->qty).' | ';
+ $total_cost.= $sub_bom_product->cost_price * $line->qty;
+ } else if ($sub_bom_product->pmp > 0) {
+ print ''.price($sub_bom_product->pmp * $line->qty).' | ';
+ $total_cost.= $sub_bom_product->pmp * $line->qty;
+ } else {
+ $sql_supplier_price = 'SELECT MIN(price) AS min_price FROM '.MAIN_DB_PREFIX.'product_fournisseur_price';
+ $sql_supplier_price.= ' WHERE fk_product = '.$sub_bom_product->id;
+ $resql_supplier_price = $object->db->query($sql_supplier_price);
+ if ($resql_supplier_price) {
+ $obj = $object->db->fetch_object($resql_supplier_price);
+ print ''.price($obj->min_price * $line->qty).' | ';
+ $total_cost+= $obj->min_price * $line->qty;
+ }
+ }
+
print ' | ';
print ' | ';
print ' | ';
}
}
+if ($total_cost > 0) {
+ $line->total_cost = price($total_cost);
+ ?>
+
+ showOptionals($extrafields, 'view', array('style'=>'class="drag drop oddeven"', 'colspan'=>$coldisplay), '', '', 1, 'line');