From ac81bacb4ffa46dfe5bdf232b93e1a5a58f1b8d1 Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Wed, 20 Apr 2022 13:57:09 +0200 Subject: [PATCH 1/2] ADD : add parent product column on list if show_child products is enabled, add a column who contains the parent product --- htdocs/product/list.php | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index de5e4f278b7..bb64f5a8d3e 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -12,6 +12,7 @@ * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2016 Ferran Marcet * Copyright (C) 2020-2021 Open-DSI + * Copyright (C) 2022 Charlene Benke * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -209,6 +210,7 @@ $arrayfields = array( 'p.fk_product_type'=>array('label'=>"Type", 'checked'=>0, 'enabled'=>(!empty($conf->product->enabled) && !empty($conf->service->enabled)), 'position'=>11), 'p.barcode'=>array('label'=>"Gencod", 'checked'=>1, 'enabled'=>(!empty($conf->barcode->enabled)), 'position'=>12), 'p.duration'=>array('label'=>"Duration", 'checked'=>($contextpage != 'productlist'), 'enabled'=>(!empty($conf->service->enabled) && (string) $type == '1'), 'position'=>13), + 'pac.fk_product_parent' => array('label'=>"ParentProduct", 'checked'=> 1, 'enabled'=>(!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && $show_childproducts)), 'position'=>14), 'p.finished'=>array('label'=>"Nature", 'checked'=>0, 'enabled'=>(!empty($conf->product->enabled) && $type != '1'), 'position'=>19), 'p.weight'=>array('label'=>'Weight', 'checked'=>0, 'enabled'=>(!empty($conf->product->enabled) && $type != '1'), 'position'=>20), 'p.weight_units'=>array('label'=>'WeightUnits', 'checked'=>0, 'enabled'=>(!empty($conf->product->enabled) && $type != '1'), 'position'=>21), @@ -413,8 +415,9 @@ if (!empty($conf->global->PRODUCT_USE_UNITS)) { $sql .= ' p.fk_unit, cu.label as cu_label,'; } $sql .= ' MIN(pfp.unitprice) as minsellprice'; -if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) { - $sql .= ', pac.rowid prod_comb_id'; +if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) )) { + $sql .= ', pac.rowid as prod_comb_id'; + $sql .= ', pac.fk_product_parent'; } // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { @@ -442,7 +445,7 @@ if (!empty($conf->global->MAIN_MULTILANGS)) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lang as pl ON pl.fk_product = p.rowid AND pl.lang = '".$db->escape($langs->getDefaultLang())."'"; } -if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) { +if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD))) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_attribute_combination pac ON pac.fk_product_child = p.rowid"; } if (!empty($conf->global->PRODUCT_USE_UNITS)) { @@ -574,8 +577,9 @@ if (!empty($conf->global->PRODUCT_USE_UNITS)) { $sql .= ', p.fk_unit, cu.label'; } -if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) { +if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD))) { $sql .= ', pac.rowid'; + $sql .= ', pac.fk_product_parent'; } // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { @@ -901,7 +905,11 @@ if ($resql) { print ''; print ''; } - + // Parent + if (!empty($arrayfields['pac.fk_product_parent']['checked'])) { + print ''; + print ''; + } // Finished if (!empty($arrayfields['p.finished']['checked'])) { print ''; @@ -1143,6 +1151,9 @@ if ($resql) { if (!empty($arrayfields['p.duration']['checked'])) { print_liste_field_titre($arrayfields['p.duration']['label'], $_SERVER["PHP_SELF"], "p.duration", "", $param, '', $sortfield, $sortorder, 'center '); } + if (!empty($arrayfields['pac.fk_product_parent']['checked'])) { + print_liste_field_titre($arrayfields['pac.fk_product_parent']['label'], $_SERVER["PHP_SELF"], "pac.fk_product_parent", "", $param, '', $sortfield, $sortorder, 'center '); + } if (!empty($arrayfields['p.finished']['checked'])) { print_liste_field_titre($arrayfields['p.finished']['label'], $_SERVER["PHP_SELF"], "p.finished", "", $param, '', $sortfield, $sortorder, 'center '); } @@ -1450,7 +1461,19 @@ if ($resql) { $totalarray['nbfield']++; } } - + + if (!empty($arrayfields['pac.fk_product_parent']['checked'])) { + print ''; + if ($obj->fk_product_parent > 0) { + $product_parent_static= new Product($db); + $product_parent_static->fetch($obj->fk_product_parent); + print $product_parent_static->getNomUrl(1); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } // Finished if (!empty($arrayfields['p.finished']['checked'])) { print ''; From 09bd38ae55585ac774787ba874c301e5eaea4d2a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 26 Aug 2023 21:47:05 +0200 Subject: [PATCH 2/2] Update list.php --- htdocs/product/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 8092a9621c7..fe9506c2f2a 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -626,7 +626,7 @@ if (isModEnabled('workstation')) { $sql .= ', p.fk_default_workstation, ws.status, ws.ref '; } -if (isModEnabled('variants') && !$show_childproducts)) { +if (isModEnabled('variants')) { $sql .= ', pac.rowid'; $sql .= ', pac.fk_product_parent'; }