From f4d4733b15fac96d2fe011464fa40ee600900702 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Thu, 19 Aug 2021 15:37:32 +0200 Subject: [PATCH 01/20] NEW : Select for BOM workable + JS to fill it according to the product selected --- htdocs/bom/bom_card.php | 25 ++++++++++++++++++++ htdocs/bom/script/interface.php | 29 ++++++++++++++++++++++++ htdocs/bom/tpl/objectline_create.tpl.php | 4 ++++ htdocs/bom/tpl/objectline_title.tpl.php | 3 +++ htdocs/bom/tpl/objectline_view.tpl.php | 2 ++ htdocs/langs/en_US/mrp.lang | 1 + htdocs/langs/fr_FR/mrp.lang | 1 + 7 files changed, 65 insertions(+) create mode 100644 htdocs/bom/script/interface.php diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index cd530994b9b..7bcbcc19e46 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -570,6 +570,31 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { print ''; } + ?> + + '; print "\n"; diff --git a/htdocs/bom/script/interface.php b/htdocs/bom/script/interface.php new file mode 100644 index 00000000000..d5811db0414 --- /dev/null +++ b/htdocs/bom/script/interface.php @@ -0,0 +1,29 @@ +query($sql); + if ($resql && $db->num_rows($resql) > 0) { + $options = array(); + $cpt=0; + while ($obj = $db->fetch_object($resql)){ + + $options[$obj->rowid] = $obj->ref.' - '.$obj->label; + $cpt++; + } + print json_encode($options); + } + + break; +} diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index 7cc2873b261..5835849e9ff 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -107,6 +107,10 @@ if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { echo ''; } +$coldisplay++; +print ''; +print ''; +print ''; $coldisplay++; print ''; diff --git a/htdocs/bom/tpl/objectline_title.tpl.php b/htdocs/bom/tpl/objectline_title.tpl.php index d1b29ee03b0..6b7f04b58f0 100644 --- a/htdocs/bom/tpl/objectline_title.tpl.php +++ b/htdocs/bom/tpl/objectline_title.tpl.php @@ -52,6 +52,9 @@ if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { // Description print ''.$langs->trans('Description').''; +// Linked BOM +print ''.$langs->trans('BOM').''; + // Qty print ''.$form->textwithpicto($langs->trans('Qty'), $langs->trans("QtyRequiredIfNoLoss")).''; diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index fff9d077a08..d3559857a2a 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -83,6 +83,8 @@ $tmpproduct->fetch($line->fk_product); print $tmpproduct->getNomUrl(1); print ' - '.$tmpproduct->label; print ''; + +print ''; print ''; $coldisplay++; echo price($line->qty, 0, '', 0, 0); // Yes, it is a quantity, not a price, but we just want the formating role of function price diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang index 2414a92cefb..8aaf345feed 100644 --- a/htdocs/langs/en_US/mrp.lang +++ b/htdocs/langs/en_US/mrp.lang @@ -101,3 +101,4 @@ HumanMachine=Human / Machine WorkstationArea=Workstation area Machines=Machines THMEstimatedHelp=This rate makes it possible to define a forecast cost of the item +BOM=Nomenclature diff --git a/htdocs/langs/fr_FR/mrp.lang b/htdocs/langs/fr_FR/mrp.lang index e0a2e73365e..2db57d53bfb 100644 --- a/htdocs/langs/fr_FR/mrp.lang +++ b/htdocs/langs/fr_FR/mrp.lang @@ -101,3 +101,4 @@ HumanMachine=Humain/machine WorkstationArea=Espace Poste de travail Machines=Machines THMEstimatedHelp=Ce taux permet de définir un coût prévisionnel de l'article +BOM=Nomenclature From 6de7d9b0af679fd56f68cebd8d604bbb31e598f3 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Fri, 20 Aug 2021 13:37:28 +0200 Subject: [PATCH 02/20] NEW : Add sub-BOM lines on BOM card --- htdocs/bom/bom_card.php | 11 ++++- htdocs/bom/class/bom.class.php | 6 +++ htdocs/bom/tpl/objectline_view.tpl.php | 56 +++++++++++++++++++++++++- 3 files changed, 71 insertions(+), 2 deletions(-) diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 7bcbcc19e46..1126e04785e 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -140,6 +140,7 @@ if (empty($reshook)) { // Set if we used free entry or predefined product $idprod = (int) GETPOST('idprod', 'int'); + $bom_child = (int) GETPOST('bom_select', 'int'); $qty = price2num(GETPOST('qty', 'alpha'), 'MS'); $qty_frozen = price2num(GETPOST('qty_frozen', 'alpha'), 'MS'); $disable_stock_change = GETPOST('disable_stock_change', 'int'); @@ -163,6 +164,7 @@ if (empty($reshook)) { $bomline = new BOMLine($db); $bomline->fk_bom = $id; $bomline->fk_product = $idprod; + $bomline->fk_bom_child = $bom_child; $bomline->qty = $qty; $bomline->qty_frozen = (int) $qty_frozen; $bomline->disable_stock_change = (int) $disable_stock_change; @@ -574,18 +576,25 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea + + '; */ $coldisplay++; +// For BOM +print ''; print ''; if (($line->info_bits & 2) != 2) { diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 623fdab1474..c869a617b2a 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -81,9 +81,9 @@ $coldisplay++; $tmpproduct = new Product($object->db); $tmpproduct->fetch($line->fk_product); $tmpbom = new BOM($object->db); -$res = $tmpbom->fetch($line->fk_bom_child); +$tmpbom->fetch($line->fk_bom_child); if (!empty($tmpbom->id)){ - print '' . (empty($conf->global->BOM_SHOW_ALL_BOM_BY_DEFAULT) ? '(+)' : '(-)') . ' '; + print '' . (empty($conf->global->BOM_SHOW_ALL_BOM_BY_DEFAULT) ? '(+)' : '(-)') . ' '; } print $tmpproduct->getNomUrl(1); print ' - '.$tmpproduct->label; @@ -193,15 +193,15 @@ if ($resql){ $sub_bom_line = new BOMLine($object->db); $sub_bom_line->fetch($obj->rowid); - print ''; + 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 { print ' '; } - print ''.price($sub_bom_line->qty, 0, '', 0, 0).''; + print ''.price($sub_bom_line->qty * $line->qty, 0, '', 0, 0).''; if ($sub_bom_line->qty_frozen > 0) { print ''.$sub_bom_line->qty_frozen.''; } else { @@ -215,7 +215,7 @@ if ($resql){ } print ''.$sub_bom_line->efficiency.''; - print ''.price($sub_bom_line->total_cost).''; + print ''.price($sub_bom_line->total_cost * $line->qty).''; print ''; print ''; print ''; From 2343ff2ed4a06690230c95204cf0ca7d307870f7 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Mon, 23 Aug 2021 11:58:15 +0200 Subject: [PATCH 04/20] NEW : ShowAll/HideAll Options --- htdocs/bom/bom_card.php | 9 ++++----- htdocs/bom/tpl/objectline_title.tpl.php | 2 ++ htdocs/bom/tpl/objectline_view.tpl.php | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 2df4278ecbe..71c64087419 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -615,7 +615,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $(".collapse_bom").click(function() { var id_bom_line = $(this).attr('id').replace('collapse-', ''); - console.log('tr [parentid="'+ id_bom_line +'"]') if($(this).text().indexOf('+') > 0) { $('[parentid="'+ id_bom_line +'"]').show(); $(this).html('(-) '); @@ -630,14 +629,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea //TODO : SHOW ALL / COLLAPSE ALL $("#show_all").click(function() { - $("[class^=batch_warehouse]").show(); - $("[class^=collapse_batch]").html('(-) '); + $("[class^=sub_bom_lines]").show(); + $("[class^=collapse_bom]").html('(-) '); return false; }); $("#hide_all").click(function() { - $("[class^=batch_warehouse]").hide(); - $("[class^=collapse_batch]").html('(+) '); + $("[class^=sub_bom_lines]").hide(); + $("[class^=collapse_bom]").html('(+) '); return false; }); diff --git a/htdocs/bom/tpl/objectline_title.tpl.php b/htdocs/bom/tpl/objectline_title.tpl.php index 6b7f04b58f0..0656f23aed9 100644 --- a/htdocs/bom/tpl/objectline_title.tpl.php +++ b/htdocs/bom/tpl/objectline_title.tpl.php @@ -43,6 +43,8 @@ print "\n"; print "\n"; print ''; +print ''.img_picto('', 'folder-open', 'class="paddingright"').$langs->trans("ExpandAll").'  '; +print ''.img_picto('', 'folder', 'class="paddingright"').$langs->trans("UndoExpandAll").' '; // Adds a line numbering column if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index c869a617b2a..87013582fac 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -193,7 +193,7 @@ if ($resql){ $sub_bom_line = new BOMLine($object->db); $sub_bom_line->fetch($obj->rowid); - print ''; + print ''; print '     '.$sub_bom_product->getNomUrl(1).''; if ($sub_bom_line->fk_bom_child > 0) { From 6cd92ca82971b3cbf5654a3b8eb35651b0fe9ad5 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Mon, 23 Aug 2021 12:15:09 +0200 Subject: [PATCH 05/20] NEW : Trad + Comments + Adding tooltips for conf --- htdocs/bom/bom_card.php | 4 ++-- htdocs/bom/tpl/objectline_title.tpl.php | 2 ++ htdocs/langs/en_US/mrp.lang | 4 +++- htdocs/langs/fr_FR/mrp.lang | 1 + 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 71c64087419..85ce0a0366d 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -627,13 +627,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea return false; }); - //TODO : SHOW ALL / COLLAPSE ALL + //To Show all the sub bom lines $("#show_all").click(function() { $("[class^=sub_bom_lines]").show(); $("[class^=collapse_bom]").html('(-) '); return false; }); - + //To Hide all the sub bom lines $("#hide_all").click(function() { $("[class^=sub_bom_lines]").hide(); $("[class^=collapse_bom]").html('(+) '); diff --git a/htdocs/bom/tpl/objectline_title.tpl.php b/htdocs/bom/tpl/objectline_title.tpl.php index 0656f23aed9..ce811096d33 100644 --- a/htdocs/bom/tpl/objectline_title.tpl.php +++ b/htdocs/bom/tpl/objectline_title.tpl.php @@ -45,6 +45,8 @@ print "\n"; print ''; print ''.img_picto('', 'folder-open', 'class="paddingright"').$langs->trans("ExpandAll").'  '; print ''.img_picto('', 'folder', 'class="paddingright"').$langs->trans("UndoExpandAll").' '; +$form = new Form($object->db); +print $form->textwithpicto('', $langs->trans('CollapseBOMHelp'), 1, 'help', ''); // Adds a line numbering column if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang index 8aaf345feed..c414a219894 100644 --- a/htdocs/langs/en_US/mrp.lang +++ b/htdocs/langs/en_US/mrp.lang @@ -101,4 +101,6 @@ HumanMachine=Human / Machine WorkstationArea=Workstation area Machines=Machines THMEstimatedHelp=This rate makes it possible to define a forecast cost of the item -BOM=Nomenclature +BOM=Bill Of Materials +CollapseBOMHelp=You can define the default display of the details of the nomenclature in the configuration of the BOM module + diff --git a/htdocs/langs/fr_FR/mrp.lang b/htdocs/langs/fr_FR/mrp.lang index 2db57d53bfb..12873fd5093 100644 --- a/htdocs/langs/fr_FR/mrp.lang +++ b/htdocs/langs/fr_FR/mrp.lang @@ -102,3 +102,4 @@ WorkstationArea=Espace Poste de travail Machines=Machines THMEstimatedHelp=Ce taux permet de définir un coût prévisionnel de l'article BOM=Nomenclature +CollapseBOMHelp=Vous pouvez définir l'affichage par défaut du détail des nomenclature dans la configuration du module "Nomenclature Produits" From e282feb3970ef6f99b89b9ed1ced4364e91bd331 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Mon, 23 Aug 2021 14:43:17 +0200 Subject: [PATCH 06/20] NEW : Delete conf --- htdocs/bom/tpl/objectline_title.tpl.php | 2 -- htdocs/bom/tpl/objectline_view.tpl.php | 8 ++++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/bom/tpl/objectline_title.tpl.php b/htdocs/bom/tpl/objectline_title.tpl.php index ce811096d33..0656f23aed9 100644 --- a/htdocs/bom/tpl/objectline_title.tpl.php +++ b/htdocs/bom/tpl/objectline_title.tpl.php @@ -45,8 +45,6 @@ print "\n"; print ''; print ''.img_picto('', 'folder-open', 'class="paddingright"').$langs->trans("ExpandAll").'  '; print ''.img_picto('', 'folder', 'class="paddingright"').$langs->trans("UndoExpandAll").' '; -$form = new Form($object->db); -print $form->textwithpicto('', $langs->trans('CollapseBOMHelp'), 1, 'help', ''); // Adds a line numbering column if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 87013582fac..fbfb02576df 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -81,7 +81,7 @@ $coldisplay++; $tmpproduct = new Product($object->db); $tmpproduct->fetch($line->fk_product); $tmpbom = new BOM($object->db); -$tmpbom->fetch($line->fk_bom_child); +$res = $tmpbom->fetch($line->fk_bom_child); if (!empty($tmpbom->id)){ print '' . (empty($conf->global->BOM_SHOW_ALL_BOM_BY_DEFAULT) ? '(+)' : '(-)') . ' '; } @@ -193,7 +193,11 @@ if ($resql){ $sub_bom_line = new BOMLine($object->db); $sub_bom_line->fetch($obj->rowid); - print ''; + if (empty($conf->global->BOM_SHOW_ALL_BOM_BY_DEFAULT)){ + print ''; + } else { + print ''; + } print '     '.$sub_bom_product->getNomUrl(1).''; if ($sub_bom_line->fk_bom_child > 0) { From 7474d2eef57aaec32713309ece7f84f7b85d8d88 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Mon, 23 Aug 2021 15:08:32 +0200 Subject: [PATCH 07/20] FIX : Add BOM column for create view --- htdocs/bom/tpl/objectline_create.tpl.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index 5835849e9ff..1a60029c439 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -61,6 +61,8 @@ if ($nolinesbefore) { print ''; print '
'.$langs->trans('AddNewLine').''; print ''; + // Linked BOM + print ''.$langs->trans('BOM').''; print ''.$langs->trans('Qty').''; if (!empty($conf->global->PRODUCT_USE_UNITS)) { print ''; From 2ecc448bc032e626436544c5eb6c7d95598fd480 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Wed, 25 Aug 2021 11:21:54 +0200 Subject: [PATCH 08/20] FIX : Set total_cost for parent line by additionning total_cost of the children lines --- htdocs/bom/tpl/objectline_view.tpl.php | 33 +++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) 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'); From 5bf8685f72182994c38bde5dd35cabe75d516763 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Wed, 25 Aug 2021 16:58:22 +0200 Subject: [PATCH 09/20] NEW : Add comments --- htdocs/bom/tpl/objectline_view.tpl.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) 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); ?> From 3a7d062d7deee5461391351bdb1cbbe6b60c863b Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 25 Aug 2021 15:24:03 +0000 Subject: [PATCH 10/20] Fixing style errors. --- htdocs/bom/script/interface.php | 5 ++--- htdocs/bom/tpl/objectline_view.tpl.php | 10 +++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/htdocs/bom/script/interface.php b/htdocs/bom/script/interface.php index d5811db0414..c93b54fdc33 100644 --- a/htdocs/bom/script/interface.php +++ b/htdocs/bom/script/interface.php @@ -7,7 +7,7 @@ $current_bom_id = GETPOST('current_bom_id', 'alphanohtml'); global $db; -switch ($action){ +switch ($action) { case 'select_BOM': //Selection of nomenclatures corresponding to the selected product $sql = 'SELECT b.rowid, b.ref, b.label, b.fk_product, p.label AS product_label FROM '.MAIN_DB_PREFIX.'bom_bom AS b '; @@ -17,8 +17,7 @@ switch ($action){ if ($resql && $db->num_rows($resql) > 0) { $options = array(); $cpt=0; - while ($obj = $db->fetch_object($resql)){ - + while ($obj = $db->fetch_object($resql)) { $options[$obj->rowid] = $obj->ref.' - '.$obj->label; $cpt++; } diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 26f4d070876..a25cdeb87ec 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -82,7 +82,7 @@ $tmpproduct = new Product($object->db); $tmpproduct->fetch($line->fk_product); $tmpbom = new BOM($object->db); $res = $tmpbom->fetch($line->fk_bom_child); -if (!empty($tmpbom->id)){ +if (!empty($tmpbom->id)) { print '' . (empty($conf->global->BOM_SHOW_ALL_BOM_BY_DEFAULT) ? '(+)' : '(-)') . ' '; } print $tmpproduct->getNomUrl(1); @@ -185,9 +185,9 @@ $sql = 'SELECT rowid, fk_bom_child, fk_product FROM '.MAIN_DB_PREFIX.'bom_bomlin $sql.= ' WHERE fk_bom = '.$tmpbom->id; $resql = $object->db->query($sql); -if ($resql){ +if ($resql) { // Loop on all the sub-BOM lines if they exist - while ($obj = $object->db->fetch_object($resql)){ + while ($obj = $object->db->fetch_object($resql)) { $sub_bom_product = new Product($object->db); $sub_bom_product->fetch($obj->fk_product); @@ -198,7 +198,7 @@ if ($resql){ $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)){ + if (empty($conf->global->BOM_SHOW_ALL_BOM_BY_DEFAULT)) { print ''; } else { print ''; @@ -238,7 +238,7 @@ if ($resql){ $total_cost.= $sub_bom_product->cost_price * $line->qty; } // PMP if cost price isn't defined - else if ($sub_bom_product->pmp > 0) { + elseif ($sub_bom_product->pmp > 0) { print ''.price($sub_bom_product->pmp * $line->qty).''; $total_cost.= $sub_bom_product->pmp * $line->qty; } From 0463846df1c65a23e128e51bb96a5f7a06bc333b Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Thu, 26 Aug 2021 09:27:03 +0200 Subject: [PATCH 11/20] FIX : Stickler --- htdocs/bom/tpl/objectline_view.tpl.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 26f4d070876..3e1922db7fc 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -237,11 +237,13 @@ if ($resql){ print ''.price($sub_bom_product->cost_price * $line->qty).''; $total_cost.= $sub_bom_product->cost_price * $line->qty; } + // 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; } + // 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'; From 578de93dc4e98e3360223ca2053829605e73b676 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 26 Aug 2021 07:30:36 +0000 Subject: [PATCH 12/20] Fixing style errors. --- htdocs/bom/tpl/objectline_view.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 1ee64890384..6aa00e79835 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -243,7 +243,7 @@ if ($resql) { print ''.price($sub_bom_product->pmp * $line->qty).''; $total_cost.= $sub_bom_product->pmp * $line->qty; } - + // 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'; From 0222df7ecc65c0589a32fb911102d9c18facf991 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Thu, 26 Aug 2021 09:34:30 +0200 Subject: [PATCH 13/20] FIX : Expected 1 space after closing brace; newline found --- htdocs/bom/tpl/objectline_view.tpl.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 1ee64890384..b8d054d9ecc 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -236,14 +236,14 @@ if ($resql) { 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; - } + } // PMP if cost price isn't defined elseif ($sub_bom_product->pmp > 0) { print ''.price($sub_bom_product->pmp * $line->qty).''; $total_cost.= $sub_bom_product->pmp * $line->qty; } - + // 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'; From bdcddebb5fdc47084a5279b68ec65957cae47e54 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 26 Aug 2021 07:37:39 +0000 Subject: [PATCH 14/20] Fixing style errors. --- htdocs/bom/tpl/objectline_view.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index b8d054d9ecc..6aa00e79835 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -236,7 +236,7 @@ if ($resql) { 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; - } + } // PMP if cost price isn't defined elseif ($sub_bom_product->pmp > 0) { From 05444078bdffd9fd880fd9b9a7cd537c3d34a58b Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Thu, 26 Aug 2021 09:43:50 +0200 Subject: [PATCH 15/20] FIX : stickler --- htdocs/bom/tpl/objectline_view.tpl.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index b8d054d9ecc..41ff84b4d13 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -236,16 +236,10 @@ if ($resql) { 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; - } - - // PMP if cost price isn't defined - elseif ($sub_bom_product->pmp > 0) { + } 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; - } - - // Minimum purchase price if cost price and PMP aren't defined - else { + } else { // Minimum purchase price if cost price and PMP aren't defined $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); From 8daa1a810a6b51606863e9ba7fad1de504ed16a6 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Tue, 19 Oct 2021 16:44:59 +0200 Subject: [PATCH 16/20] FIX : Move interface.php to ajax/ --- htdocs/bom/{script => ajax}/interface.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename htdocs/bom/{script => ajax}/interface.php (100%) diff --git a/htdocs/bom/script/interface.php b/htdocs/bom/ajax/interface.php similarity index 100% rename from htdocs/bom/script/interface.php rename to htdocs/bom/ajax/interface.php From 48b131b3f08772bf231b9de789bd610007e3b2e3 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Tue, 19 Oct 2021 16:50:15 +0200 Subject: [PATCH 17/20] FIX : Retours --- htdocs/bom/ajax/interface.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/bom/ajax/interface.php b/htdocs/bom/ajax/interface.php index c93b54fdc33..1416f44f922 100644 --- a/htdocs/bom/ajax/interface.php +++ b/htdocs/bom/ajax/interface.php @@ -2,8 +2,8 @@ require '../../main.inc.php'; $action = GETPOST('action', 'alphanohtml'); -$select_product_val = GETPOST('select_product_val', 'alphanohtml'); -$current_bom_id = GETPOST('current_bom_id', 'alphanohtml'); +$select_product_val = GETPOST('select_product_val', 'int'); +$current_bom_id = GETPOST('current_bom_id', 'int'); global $db; @@ -12,7 +12,7 @@ switch ($action) { //Selection of nomenclatures corresponding to the selected product $sql = 'SELECT b.rowid, b.ref, b.label, b.fk_product, p.label AS product_label FROM '.MAIN_DB_PREFIX.'bom_bom AS b '; $sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'product AS p ON b.fk_product=p.rowid'; - $sql.= ' WHERE fk_product='.$select_product_val.' AND b.rowid!='.$current_bom_id; + $sql.= ' WHERE fk_product='.(int)$select_product_val.' AND b.rowid<>'. (int)$current_bom_id; $resql = $db->query($sql); if ($resql && $db->num_rows($resql) > 0) { $options = array(); From d3035975cf038e24b4c1cfa853e97012a8446323 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 19 Oct 2021 14:52:56 +0000 Subject: [PATCH 18/20] Fixing style errors. --- htdocs/bom/ajax/interface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/bom/ajax/interface.php b/htdocs/bom/ajax/interface.php index 1416f44f922..23b208e25ba 100644 --- a/htdocs/bom/ajax/interface.php +++ b/htdocs/bom/ajax/interface.php @@ -12,7 +12,7 @@ switch ($action) { //Selection of nomenclatures corresponding to the selected product $sql = 'SELECT b.rowid, b.ref, b.label, b.fk_product, p.label AS product_label FROM '.MAIN_DB_PREFIX.'bom_bom AS b '; $sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'product AS p ON b.fk_product=p.rowid'; - $sql.= ' WHERE fk_product='.(int)$select_product_val.' AND b.rowid<>'. (int)$current_bom_id; + $sql.= ' WHERE fk_product='.(int) $select_product_val.' AND b.rowid<>'. (int) $current_bom_id; $resql = $db->query($sql); if ($resql && $db->num_rows($resql) > 0) { $options = array(); From a3e8d43cf582063da9acf7efc61879dd90e624bf Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Tue, 19 Oct 2021 17:25:51 +0200 Subject: [PATCH 19/20] FIX : Travis --- htdocs/bom/tpl/objectline_view.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 96653773d65..2fa8b3c70dc 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -182,7 +182,7 @@ 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; +$sql.= ' WHERE fk_bom ='. (int) $tmpbom->id; $resql = $object->db->query($sql); if ($resql) { From 2ae38ff1a99f47710c47f7f2fa5029073f1cacaa Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Wed, 20 Oct 2021 10:15:31 +0200 Subject: [PATCH 20/20] FIX : Travis --- htdocs/bom/tpl/objectline_view.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 2fa8b3c70dc..8256019bd98 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -241,7 +241,7 @@ if ($resql) { $total_cost.= $sub_bom_product->pmp * $line->qty; } else { // Minimum purchase price if cost price and PMP aren't defined $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; + $sql_supplier_price.= ' WHERE fk_product = '. (int) $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);