From 474d82b19c957fa42b0bf929b46061b31cd982db Mon Sep 17 00:00:00 2001 From: Christian Humpel Date: Wed, 17 Aug 2022 11:02:26 +0200 Subject: [PATCH 1/2] Clean Code: Remove duplicate code form bom_card.php --- htdocs/bom/bom_card.php | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index ee619a589e3..6743ec3c761 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -181,24 +181,11 @@ if (empty($reshook)) { } if (!$error) { - $bomline = new BOMLine($db); - $bomline->fk_bom = $id; - $bomline->fk_product = $idprod; - $bomline->fk_bom_child = $bom_child_id; - $bomline->qty = $qty; - $bomline->qty_frozen = (int) $qty_frozen; - $bomline->disable_stock_change = (int) $disable_stock_change; - $bomline->efficiency = $efficiency; - // Rang to use - $rangmax = $object->line_max(0); - $ranktouse = $rangmax + 1; + $result = $object->addLine($idprod,$qty,$qty_frozen,$disable_stock_change,$efficiency,-1,$bom_child_id,null); - $bomline->position = ($ranktouse + 1); - - $result = $bomline->create($user); if ($result <= 0) { - setEventMessages($bomline->error, $bomline->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); $action = ''; } else { unset($_POST['idprod']); @@ -207,8 +194,6 @@ if (empty($reshook)) { unset($_POST['disable_stock_change']); $object->fetchLines(); - - $object->calculateCosts(); } } } From 01d7f558ba56cf3085327eeea9dd3317f6dfdfee Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 17 Aug 2022 09:11:09 +0000 Subject: [PATCH 2/2] Fixing style errors. --- htdocs/bom/bom_card.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 6743ec3c761..2eff03dce82 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -181,8 +181,7 @@ if (empty($reshook)) { } if (!$error) { - - $result = $object->addLine($idprod,$qty,$qty_frozen,$disable_stock_change,$efficiency,-1,$bom_child_id,null); + $result = $object->addLine($idprod, $qty, $qty_frozen, $disable_stock_change, $efficiency, -1, $bom_child_id, null); if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors');