From 08d830f4501c959129d8b48156f73bec23659478 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Tue, 25 Jan 2022 16:40:28 +0100 Subject: [PATCH] FIX : Fixing total_cost, qty_frozen and display problems --- htdocs/bom/tpl/objectline_view.tpl.php | 36 +++++++++++++++++++------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index f62143188eb..0c74cee43ce 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -41,7 +41,7 @@ if (empty($object) || !is_object($object)) { } -global $forceall, $senderissupplier, $inputalsopricewithtax, $outputalsopricetotalwithtax; +global $forceall, $senderissupplier, $inputalsopricewithtax, $outputalsopricetotalwithtax, $langs; if (empty($dateSelector)) { $dateSelector = 0; @@ -83,8 +83,10 @@ $tmpproduct->fetch($line->fk_product); $tmpbom = new BOM($object->db); $res = $tmpbom->fetch($line->fk_bom_child); if ($tmpbom->id > 0) { - print $tmpbom->getNomUrl(1); print '' . (empty($conf->global->BOM_SHOW_ALL_BOM_BY_DEFAULT) ? '(+)' : '(-)') . ' '; + print $tmpproduct->getNomUrl(1); + print ' '.$langs->trans('OR').' '; + print $tmpbom->getNomUrl(1); } else { print $tmpproduct->getNomUrl(1); print ' - '.$tmpproduct->label; @@ -176,7 +178,7 @@ 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 = 'SELECT rowid, fk_bom_child, fk_product, qty FROM '.MAIN_DB_PREFIX.'bom_bomline AS bl'; $sql.= ' WHERE fk_bom ='. (int) $tmpbom->id; $resql = $object->db->query($sql); @@ -199,14 +201,23 @@ if ($resql) { print ''; } - // Product - print ''.$sub_bom_product->getNomUrl(1).''; + // Product OR BOM + print ''; + if(!empty($obj->fk_bom_child)){ + print $sub_bom_product->getNomUrl(1); + print ' '.$langs->trans('OR').' '; + print $sub_bom->getNomUrl(1); + } else { + print $sub_bom_product->getNomUrl(1); + 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.''; + print ''.price($sub_bom_line->qty, 0, '', 0, 0).''; + print ''.$langs->trans('Yes').''; } else { + print ''.price($sub_bom_line->qty * $line->qty, 0, '', 0, 0).''; print ' '; } @@ -221,9 +232,16 @@ if ($resql) { print ''.$sub_bom_line->efficiency.''; // Cost price if it's defined - if ($sub_bom_product->cost_price > 0) { + if (!empty($obj->fk_bom_child)) { + $bom = new BOM($object->db); + $bom->fetch($obj->fk_bom_child); + $bom->calculateCosts(); + $bom->total_cost * $line->qty; + print ''.price($bom->total_cost * $line->qty).''; + $total_cost+= $bom->total_cost * $line->qty; + } elseif ($sub_bom_product->cost_price > 0) { print ''.price($sub_bom_product->cost_price * $line->qty).''; - $total_cost.= $sub_bom_product->cost_price * $line->qty; + $total_cost+= $sub_bom_product->cost_price * $line->qty; } elseif ($sub_bom_product->pmp > 0) { // PMP if cost price isn't defined print ''.price($sub_bom_product->pmp * $line->qty).''; $total_cost.= $sub_bom_product->pmp * $line->qty;