From a87d9cd740f2399f5d24e13e0f7791eadde19976 Mon Sep 17 00:00:00 2001 From: Anthony Berton Date: Fri, 8 May 2020 22:41:49 +0200 Subject: [PATCH 1/6] Update list.php --- htdocs/product/list.php | 68 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 90464742839..0b1c0d19aff 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -211,6 +211,17 @@ $arrayfields = array( 'p.tosell'=>array('label'=>$langs->trans("Status").' ('.$langs->trans("Sell").')', 'checked'=>1, 'position'=>1000), 'p.tobuy'=>array('label'=>$langs->trans("Status").' ('.$langs->trans("Buy").')', 'checked'=>1, 'position'=>1000) ); + +// MultiPrices +if ($conf->global->PRODUIT_MULTIPRICES){ + for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) + { + $arrayfields['p.sellprice'.$i] = array('label'=>$langs->trans("SellingPrice")." ".$i, 'checked'=>1, 'enabled'=>$conf->global->PRODUIT_MULTIPRICES, 'position'=>40); + $arraypricelevel[$i] = array($i); + } +} + +//var_dump($arraypricelevel); // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { @@ -733,6 +744,19 @@ if ($resql) print ''; print ''; } + + // Multiprice + if ($conf->global->PRODUIT_MULTIPRICES){ + foreach ($arraypricelevel as $key => $value) + { + if (!empty($arrayfields['p.sellprice'.$key]['checked'])) + { + print ''; + print ''; + } + } + } + // Minimum buying Price if (!empty($arrayfields['p.minbuyprice']['checked'])) { @@ -865,6 +889,18 @@ if ($resql) if (!empty($arrayfields['p.sellprice']['checked'])) { print_liste_field_titre($arrayfields['p.sellprice']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right '); } + + // Multiprices + if ($conf->global->PRODUIT_MULTIPRICES){ + foreach ($arraypricelevel as $key => $value) + { + if (!empty($arrayfields['p.sellprice'.$key]['checked'])) + { + print_liste_field_titre($arrayfields['p.sellprice'.$key]['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right '); + } + } + } + if (!empty($arrayfields['p.minbuyprice']['checked'])) { print_liste_field_titre($arrayfields['p.minbuyprice']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right '); } @@ -1200,6 +1236,38 @@ if ($resql) if (!$i) $totalarray['nbfield']++; } + + // Multiprices + if ($conf->global->PRODUIT_MULTIPRICES){ + foreach ($arraypricelevel as $key => $value) + { + if (!empty($arrayfields['p.sellprice'.$key]['checked'])) + { + $resultp = "SELECT p.rowid, p.fk_product, p.price, p.price_ttc, p.price_level, p.date_price"; + $resultp .= " FROM ".MAIN_DB_PREFIX."product_price as p"; + $resultp .= " WHERE fk_product = ".$obj->rowid; + if (!empty($conf->global->PRODUIT_MULTIPRICES)) $resultp .= " AND p.price_level = ".$key; + $resultp .= " ORDER BY p.date_price DESC, p.rowid DESC, p.price_level ASC"; + $resultp = $db->query($resultp); + if ($resultp) + { + $objp = $db->fetch_object($resultp); + print ''; + if ($obj->tosell) + { + if ($obj->price_base_type == 'TTC') print price($objp->price_ttc).' '.$langs->trans("TTC"); + else print price($objp->price).' '.$langs->trans("HT"); + } + print ''; + $db->free($resultp); + } else { + dol_print_error($db); + } + if (!$i) $totalarray['nbfield']++; + } + } + } + // Better buy price if (!empty($arrayfields['p.minbuyprice']['checked'])) { From c2dff7dfed6077cba99165aa9dcc1ee86eab0785 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 8 May 2020 20:46:06 +0000 Subject: [PATCH 2/6] Fixing style errors. --- htdocs/product/list.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 0b1c0d19aff..d666caad80c 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -1253,11 +1253,11 @@ if ($resql) { $objp = $db->fetch_object($resultp); print ''; - if ($obj->tosell) + if ($obj->tosell) { - if ($obj->price_base_type == 'TTC') print price($objp->price_ttc).' '.$langs->trans("TTC"); - else print price($objp->price).' '.$langs->trans("HT"); - } + if ($obj->price_base_type == 'TTC') print price($objp->price_ttc).' '.$langs->trans("TTC"); + else print price($objp->price).' '.$langs->trans("HT"); + } print ''; $db->free($resultp); } else { From 52b47fd5988832725fd75c50d38e208a0095bcff Mon Sep 17 00:00:00 2001 From: Anthony Berton Date: Sat, 9 May 2020 00:28:23 +0200 Subject: [PATCH 3/6] Update list.php --- htdocs/product/list.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index d666caad80c..f818d2f475a 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -216,7 +216,16 @@ $arrayfields = array( if ($conf->global->PRODUIT_MULTIPRICES){ for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { - $arrayfields['p.sellprice'.$i] = array('label'=>$langs->trans("SellingPrice")." ".$i, 'checked'=>1, 'enabled'=>$conf->global->PRODUIT_MULTIPRICES, 'position'=>40); + $keyforlabel = 'PRODUIT_MULTIPRICES_LABEL'.$i; + if (!empty($conf->global->$keyforlabel)) + { + $labelp = $i.' - '.$langs->trans($conf->global->$keyforlabel); + } + else + { + $labelp = $langs->trans("SellingPrice")." ".$i; + } + $arrayfields['p.sellprice'.$i] = array('label'=>$labelp, 'checked'=>1, 'enabled'=>$conf->global->PRODUIT_MULTIPRICES, 'position'=>40); $arraypricelevel[$i] = array($i); } } From 36b63ed921b555b297da38c2467b1e32037c9c1f Mon Sep 17 00:00:00 2001 From: Anthony Berton Date: Thu, 14 May 2020 11:37:26 +0200 Subject: [PATCH 4/6] Update list.php --- htdocs/product/list.php | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index f818d2f475a..d6b3def0967 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -1252,26 +1252,26 @@ if ($resql) { if (!empty($arrayfields['p.sellprice'.$key]['checked'])) { - $resultp = "SELECT p.rowid, p.fk_product, p.price, p.price_ttc, p.price_level, p.date_price"; - $resultp .= " FROM ".MAIN_DB_PREFIX."product_price as p"; - $resultp .= " WHERE fk_product = ".$obj->rowid; - if (!empty($conf->global->PRODUIT_MULTIPRICES)) $resultp .= " AND p.price_level = ".$key; - $resultp .= " ORDER BY p.date_price DESC, p.rowid DESC, p.price_level ASC"; - $resultp = $db->query($resultp); - if ($resultp) + print ''; + if ($obj->tosell) { - $objp = $db->fetch_object($resultp); - print ''; - if ($obj->tosell) - { - if ($obj->price_base_type == 'TTC') print price($objp->price_ttc).' '.$langs->trans("TTC"); - else print price($objp->price).' '.$langs->trans("HT"); + $resultp = "SELECT p.rowid, p.fk_product, p.price, p.price_ttc, p.price_level, p.date_price"; + $resultp .= " FROM ".MAIN_DB_PREFIX."product_price as p"; + $resultp .= " WHERE fk_product = ".$obj->rowid; + $resultp .= " AND p.price_level = ".$key; + $resultp .= " ORDER BY p.date_price DESC, p.rowid DESC, p.price_level ASC"; + $resultp = $db->query($resultp); + if ($resultp) + { + $objp = $db->fetch_object($resultp); + if ($obj->price_base_type == 'TTC') print price($objp->price_ttc).' '.$langs->trans("TTC"); + else print price($objp->price).' '.$langs->trans("HT"); + $db->free($resultp); + } else { + dol_print_error($db); } - print ''; - $db->free($resultp); - } else { - dol_print_error($db); } + print ''; if (!$i) $totalarray['nbfield']++; } } From e3afa658808b856b4afe576787f5835b020c0998 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 14 May 2020 09:38:27 +0000 Subject: [PATCH 5/6] Fixing style errors. --- 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 d6b3def0967..97d08477946 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -1265,7 +1265,7 @@ if ($resql) { $objp = $db->fetch_object($resultp); if ($obj->price_base_type == 'TTC') print price($objp->price_ttc).' '.$langs->trans("TTC"); - else print price($objp->price).' '.$langs->trans("HT"); + else print price($objp->price).' '.$langs->trans("HT"); $db->free($resultp); } else { dol_print_error($db); From 49c4ed5a085dc32a143220d80b21017018cc71ab Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 25 May 2020 22:50:00 +0200 Subject: [PATCH 6/6] Update list.php --- htdocs/product/list.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 97d08477946..064ac2dce4f 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -1255,6 +1255,8 @@ if ($resql) print ''; if ($obj->tosell) { + // TODO Make 1 request for all price levels (without filter on price_level) and saved result into an cache array + // then reuse the cache array if we need prices for other price levels $resultp = "SELECT p.rowid, p.fk_product, p.price, p.price_ttc, p.price_level, p.date_price"; $resultp .= " FROM ".MAIN_DB_PREFIX."product_price as p"; $resultp .= " WHERE fk_product = ".$obj->rowid;