diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php
index 0d83754dd60..26f4d070876 100644
--- a/htdocs/bom/tpl/objectline_view.tpl.php
+++ b/htdocs/bom/tpl/objectline_view.tpl.php
@@ -89,6 +89,7 @@ print $tmpproduct->getNomUrl(1);
print ' - '.$tmpproduct->label;
print '';
+// To show BOM links in the list
if ($res > 0) {
print '
'.$tmpbom->getNomUrl(1).' | ';
} else {
@@ -179,11 +180,13 @@ if ($action == 'selectlines') {
print '';
+// Select of all the sub-BOM lines
$sql = 'SELECT rowid, fk_bom_child, fk_product FROM '.MAIN_DB_PREFIX.'bom_bomline AS bl';
$sql.= ' WHERE fk_bom = '.$tmpbom->id;
$resql = $object->db->query($sql);
if ($resql){
+ // Loop on all the sub-BOM lines if they exist
while ($obj = $object->db->fetch_object($resql)){
$sub_bom_product = new Product($object->db);
$sub_bom_product->fetch($obj->fk_product);
@@ -194,18 +197,24 @@ if ($resql){
$sub_bom_line = new BOMLine($object->db);
$sub_bom_line->fetch($obj->rowid);
+ //If hidden conf is set, we show directly all the sub-BOM lines
if (empty($conf->global->BOM_SHOW_ALL_BOM_BY_DEFAULT)){
print '';
} else {
print '
';
}
+ // Product
print '| '.$sub_bom_product->getNomUrl(1).' | ';
+
+ // Sub-BOM
if ($sub_bom_line->fk_bom_child > 0) {
print ''.$sub_bom->getNomUrl(1).' | ';
} else {
print ' | ';
}
+
+ // Qty
print ''.price($sub_bom_line->qty * $line->qty, 0, '', 0, 0).' | ';
if ($sub_bom_line->qty_frozen > 0) {
print ''.$sub_bom_line->qty_frozen.' | ';
@@ -213,20 +222,28 @@ if ($resql){
print ' | ';
}
+ // Disable stock change
if ($sub_bom_line->disable_stock_change > 0) {
print ''.$sub_bom_line->disable_stock_change.' | ';
} else {
print ' | ';
}
+ // Efficiency
print ''.$sub_bom_line->efficiency.' | ';
+
+ // Cost price if it's defined
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) {
+ }
+ // PMP if cost price isn't defined
+ else if ($sub_bom_product->pmp > 0) {
print ''.price($sub_bom_product->pmp * $line->qty).' | ';
$total_cost.= $sub_bom_product->pmp * $line->qty;
- } else {
+ }
+ // Minimum purchase price if cost price and PMP aren't defined
+ 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);
@@ -243,6 +260,7 @@ if ($resql){
}
}
+// Replace of the total_cost value by the sum of all sub-BOM lines total_cost
if ($total_cost > 0) {
$line->total_cost = price($total_cost);
?>