From d74af432a0b47b807684c72bf5177eec8406efb9 Mon Sep 17 00:00:00 2001 From: Maximilien Valenzano Date: Wed, 24 Jan 2024 18:15:51 +0100 Subject: [PATCH 01/16] fix: add product line update fields price --- htdocs/core/tpl/objectline_create.tpl.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 42377634ff9..f6afeeb8457 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -640,6 +640,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) { if (event.which != 9 && (event.which < 37 ||event.which > 40) && jQuery("#price_ht").val() != '') { jQuery("#price_ttc").val(''); jQuery("#multicurrency_subprice").val(''); + jQuery("#multicurrency_price_ht").val(''); } }); jQuery("#price_ttc").keyup(function(event) { @@ -647,11 +648,19 @@ if (!empty($usemargins) && $user->rights->margins->creer) { if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#price_ttc").val() != '') { jQuery("#price_ht").val(''); jQuery("#multicurrency_subprice").val(''); + jQuery("#multicurrency_price_ht").val(''); } }); jQuery("#multicurrency_subprice").keyup(function(event) { // console.log(event.which); // discard event tag and arrows - if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#price_ttc").val() != '') { + if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#multicurrency_subprice").val() != '') { + jQuery("#price_ht").val(''); + jQuery("#price_ttc").val(''); + } + }); + jQuery("#multicurrency_price_ht").keyup(function(event) { + // console.log(event.which); // discard event tag and arrows + if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#multicurrency_price_ht").val() != '') { jQuery("#price_ht").val(''); jQuery("#price_ttc").val(''); } From ea7e7456a5884471c13e1c0c2c9b538bc84969f0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 25 Jan 2024 01:50:38 +0100 Subject: [PATCH 02/16] Fix cloning of projects --- htdocs/projet/card.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 801129da8e6..6bd1de90ffb 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -499,8 +499,11 @@ if (empty($reshook)) { $newobject->fetch_optionals(); $newobject->fetch_thirdparty(); // Load new object $object = $newobject; - $action = 'edit'; + $action = 'view'; $comefromclone = true; + + setEventMessages($langs->trans("ProjectCreatedInDolibarr", $newobject->ref), "", 'mesgs'); + //var_dump($newobject); exit; } } From c98325693789eff3195636da4b53723da63ecf7c Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Thu, 25 Jan 2024 09:53:51 +0100 Subject: [PATCH 03/16] Improve doc of loadWarehouses --- htdocs/product/class/html.formproduct.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index b6ec2cb629f..3d5ead67cc5 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -68,7 +68,7 @@ class FormProduct * 'warehouseinternal' = select products from warehouses for internal correct/transfer only * @param boolean $sumStock sum total stock of a warehouse, default true * @param array $exclude warehouses ids to exclude - * @param bool|int $stockMin [=false] Value of minimum stock to filter or false not not filter by minimum stock + * @param bool|int $stockMin [=false] Value of minimum stock to filter (only warehouse with stock > stockMin are loaded) or false not not filter by minimum stock * @param string $orderBy [='e.ref'] Order by * @return int Nb of loaded lines, 0 if already loaded, <0 if KO * @throws Exception From 5f694a11734f212cf019b66100afd27fe51021e8 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Thu, 25 Jan 2024 10:16:22 +0100 Subject: [PATCH 04/16] also for selectWarehouses --- htdocs/product/class/html.formproduct.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 3d5ead67cc5..f336303b813 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -276,7 +276,7 @@ class FormProduct * @param string $morecss Add more css classes to HTML select * @param array $exclude Warehouses ids to exclude * @param int $showfullpath 1=Show full path of name (parent ref into label), 0=Show only ref of current warehouse - * @param bool|int $stockMin [=false] Value of minimum stock to filter or false not not filter by minimum stock + * @param bool|int $stockMin [=false] Value of minimum stock to filter (only warehouse with stock > stockMin are loaded) or false not not filter by minimum stock * @param string $orderBy [='e.ref'] Order by * @param int $multiselect 1=Allow multiselect * @return string HTML select From 2886c688f0f77c23b23802d2f9333b21d740f98e Mon Sep 17 00:00:00 2001 From: Maximilien Valenzano Date: Thu, 25 Jan 2024 11:52:35 +0100 Subject: [PATCH 05/16] fix: invoice line save devise --- htdocs/compta/facture/card.php | 8 +++++--- htdocs/fourn/facture/card.php | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 810bba691c4..8e92b1c56dd 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2284,8 +2284,10 @@ if (empty($reshook)) { $type = $prod->type; $fk_unit = $prod->fk_unit; } else { - $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num($price_ttc, 'MU'); + if (!empty($price_ht)) $pu_ht = price2num($price_ht, 'MU'); + else $pu_ht = ''; + if (!empty($price_ttc)) $pu_ttc = price2num($price_ttc, 'MU'); + else $pu_ttc = ''; $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); $tva_tx = str_replace('*', '', $tva_tx); if (empty($tva_tx)) { @@ -2311,7 +2313,7 @@ if (empty($reshook)) { $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty, $mysoc, $tva_npr); $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty, $mysoc, $tva_npr); - $pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2); + $pu_ht_devise = price2num($price_ht_devise, '', 2); $pu_ttc_devise = price2num(GETPOST('multicurrency_subprice_ttc'), '', 2); // Prepare a price equivalent for minimum price check diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 6837d1dad9c..a9418197592 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1722,7 +1722,7 @@ if (empty($reshook)) { $pu_ht = price2num($pu_ttc / (1 + ($tva_tx / 100)), 'MU'); // $pu_ht must be rounded according to settings } $price_base_type = 'HT'; - $pu_devise = price2num($price_devise, 'CU'); + $pu_devise = price2num($price_ht_devise, 'CU'); $result = $object->addline($product_desc, $pu_ht, $tva_tx, $localtax1_tx, $localtax2_tx, $qty, 0, $remise_percent, $date_start, $date_end, 0, $tva_npr, $price_base_type, $type, -1, 0, $array_options, $fk_unit, 0, $pu_devise, $ref_supplier); } From da625fc8472c5d7b324e3bb262a242f2ac553fa1 Mon Sep 17 00:00:00 2001 From: Maximilien Valenzano Date: Thu, 25 Jan 2024 12:06:13 +0100 Subject: [PATCH 06/16] fix: propal use devise changes --- htdocs/comm/propal/card.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 1bc57c89698..1156df8a2c6 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1171,6 +1171,10 @@ if (empty($reshook)) { if (!empty($price_ht) || (string) $price_ht === '0') { $pu_ht = price2num($price_ht, 'MU'); $pu_ttc = price2num($pu_ht * (1 + ((float) $tmpvat / 100)), 'MU'); + } elseif (!empty($price_ht_devise) || (string) $price_ht_devise === '0') { + $pu_ht_devise = price2num($price_ht_devise, 'MU'); + $pu_ht = ''; + $pu_ttc = ''; } elseif (!empty($price_ttc) || (string) $price_ttc === '0') { $pu_ttc = price2num($price_ttc, 'MU'); $pu_ht = price2num($pu_ttc / (1 + ((float) $tmpvat / 100)), 'MU'); From 505841b1948b42cf02af6a4968ddc659e5ed1299 Mon Sep 17 00:00:00 2001 From: Maximilien Valenzano Date: Thu, 25 Jan 2024 12:38:06 +0100 Subject: [PATCH 07/16] fix: save change from product too --- htdocs/compta/facture/card.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 8e92b1c56dd..408a570656f 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2193,6 +2193,10 @@ if (empty($reshook)) { if (!empty($price_ht) || $price_ht === '0') { $pu_ht = price2num($price_ht, 'MU'); $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); + } elseif (!empty($price_ht_devise) || $price_ht_devise === '0') { + $pu_ht_devise = price2num($price_ht_devise, 'MU'); + $pu_ht = ''; + $pu_ttc = ''; } elseif (!empty($price_ttc) || $price_ttc === '0') { $pu_ttc = price2num($price_ttc, 'MU'); $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); From 49b5c081d68b3caf3cb4fe094f09dcf50c816e34 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 25 Jan 2024 17:51:09 +0100 Subject: [PATCH 08/16] FIX HTML injection vulnerability in Dolibarr Application Home Page FIX #GHSA-7947-48q7-cp5m --- htdocs/filefunc.inc.php | 2 +- htdocs/main.inc.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index c3fd4705b6d..cba47566c2b 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -34,7 +34,7 @@ if (!defined('DOL_APPLICATION_TITLE')) { define('DOL_APPLICATION_TITLE', 'Dolibarr'); } if (!defined('DOL_VERSION')) { - define('DOL_VERSION', '18.0.4'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c + define('DOL_VERSION', '18.0.5'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c } if (!defined('EURO')) { diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index ab78b4bd5f7..0c6ecd25933 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2164,6 +2164,7 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead if (isset($_POST) && is_array($_POST)) { foreach ($_POST as $key => $value) { + $key = preg_replace('/[^a-z0-9_\-\[\]/i', '', $key); if (in_array($key, array('action', 'massaction', 'password'))) { continue; } From 088c1606df38f9b48334be7bf45d8cefa8c20f64 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 25 Jan 2024 17:57:44 +0100 Subject: [PATCH 09/16] Clean url --- htdocs/main.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 0c6ecd25933..6b20c79e37c 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2170,12 +2170,12 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead } if (!is_array($value)) { if ($value !== '') { - $qs .= '&'.$key.'='.urlencode($value); + $qs .= '&'.urlencode($key).'='.urlencode($value); } } else { foreach ($value as $value2) { if (($value2 !== '') && (!is_array($value2))) { - $qs .= '&'.$key.'[]='.urlencode($value2); + $qs .= '&'.urlencode($key).'[]='.urlencode($value2); } } } From 4d971a9c337b2919cf8197a8c5eb99561f368089 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 25 Jan 2024 18:02:56 +0100 Subject: [PATCH 10/16] Fix regresion on print link --- htdocs/main.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 6b20c79e37c..9aede3af25a 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2164,7 +2164,7 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead if (isset($_POST) && is_array($_POST)) { foreach ($_POST as $key => $value) { - $key = preg_replace('/[^a-z0-9_\-\[\]/i', '', $key); + $key = preg_replace('/[^a-z0-9_\.\-\[\]]/i', '', $key); if (in_array($key, array('action', 'massaction', 'password'))) { continue; } From 6a3c5cce697bb3b4bc3d2a7d5628f356dcc339c1 Mon Sep 17 00:00:00 2001 From: Can Arslan <138895927+mc2rcanarslan@users.noreply.github.com> Date: Thu, 25 Jan 2024 11:14:55 -0700 Subject: [PATCH 11/16] FIX: wrong alias --- htdocs/core/lib/project.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 9f2dbc0f13e..d9a71380aa9 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -1116,7 +1116,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t // Check if Extrafields is totalizable if (!empty($extrafields->attributes['projet_task']['totalizable'])) { foreach ($extrafields->attributes['projet_task']['totalizable'] as $key => $value) { - if (!empty($arrayfields['efpt.'.$key]['checked']) && $arrayfields['ef.'.$key]['checked'] == 1) { + if (!empty($arrayfields['efpt.'.$key]['checked']) && $arrayfields['efpt.'.$key]['checked'] == 1) { print ''; if ($value == 1) { print empty($totalarray['totalizable'][$key]['total']) ? '' : $totalarray['totalizable'][$key]['total']; From fe7140304699a917db1d490c05dccd1bfabb38b5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 25 Jan 2024 23:08:46 +0100 Subject: [PATCH 12/16] Fix from #27807 added manually to fix one bug at time --- htdocs/fourn/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 6837d1dad9c..a9418197592 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1722,7 +1722,7 @@ if (empty($reshook)) { $pu_ht = price2num($pu_ttc / (1 + ($tva_tx / 100)), 'MU'); // $pu_ht must be rounded according to settings } $price_base_type = 'HT'; - $pu_devise = price2num($price_devise, 'CU'); + $pu_devise = price2num($price_ht_devise, 'CU'); $result = $object->addline($product_desc, $pu_ht, $tva_tx, $localtax1_tx, $localtax2_tx, $qty, 0, $remise_percent, $date_start, $date_end, 0, $tva_npr, $price_base_type, $type, -1, 0, $array_options, $fk_unit, 0, $pu_devise, $ref_supplier); } From 5448261947bf5ad20ae2afb31c9992a5f47fa2fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 25 Jan 2024 23:32:53 +0100 Subject: [PATCH 13/16] fix pre-commit --- htdocs/admin/receiptprinter.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/receiptprinter.php b/htdocs/admin/receiptprinter.php index dd946c6a8ee..85ef7aeb067 100644 --- a/htdocs/admin/receiptprinter.php +++ b/htdocs/admin/receiptprinter.php @@ -322,7 +322,7 @@ if ($mode == 'config' && $user->admin) { print load_fiche_titre($langs->trans("ReceiptPrinterDesc"), '', '')."\n"; - print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print '
'; // You can use div-table-responsive-no-min if you don't need reserved height for your table print ''."\n"; print ''; print ''; @@ -416,7 +416,7 @@ if ($mode == 'config' && $user->admin) { print ''.$langs->trans("ReceiptPrinterTypeDesc").'...

'."\n"; - print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print '
'; // You can use div-table-responsive-no-min if you don't need reserved height for your table print '
'.$langs->trans("Name").'
'."\n"; print ''; print ''; @@ -445,7 +445,7 @@ if ($mode == 'template' && $user->admin) { print ''; } - print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print '
'; // You can use div-table-responsive-no-min if you don't need reserved height for your table print '
'.$langs->trans("CONNECTOR_DUMMY").''.$langs->trans("CONNECTOR_DUMMY_HELP").'
'.$form->textwithpicto($langs->trans("CONNECTOR_NETWORK_PRINT"), $langs->trans("FromServerPointOfView")).''.$langs->trans("CONNECTOR_NETWORK_PRINT_HELP").'
'."\n"; print ''; print ''; @@ -512,7 +512,7 @@ if ($mode == 'template' && $user->admin) { print '
'; - print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print '
'; // You can use div-table-responsive-no-min if you don't need reserved height for your table print '
'.$langs->trans("Name").'
'."\n"; print ''; print ''; From eb3a6e22972590f7cdf34ab4cd43da9291f8d31d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 26 Jan 2024 00:20:14 +0100 Subject: [PATCH 14/16] Clean code --- htdocs/compta/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 408a570656f..a65358b7d58 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2318,7 +2318,7 @@ if (empty($reshook)) { $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty, $mysoc, $tva_npr); $pu_ht_devise = price2num($price_ht_devise, '', 2); - $pu_ttc_devise = price2num(GETPOST('multicurrency_subprice_ttc'), '', 2); + $pu_ttc_devise = price2num($price_ttc_devise, '', 2); // Prepare a price equivalent for minimum price check $pu_equivalent = $pu_ht; From 66a628b306e04bbbecbd1b0b6b2cbb0f312699f3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 26 Jan 2024 01:08:59 +0100 Subject: [PATCH 15/16] Removed useless initHook. Must use the context of main calling page. --- htdocs/product/class/product.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 4a5b413177d..f448edfd3d8 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5852,7 +5852,6 @@ class Product extends CommonObject $this->stock_theorique += ($stock_commande_fournisseur - $stock_reception_fournisseur); } - $hookmanager->initHooks(array('productdao')); $parameters = array('id'=>$this->id, 'includedraftpoforvirtual' => $includedraftpoforvirtual); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('loadvirtualstock', $parameters, $this, $action); From 8795e58c252b7219e1c1764e225929d584b3427d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 26 Jan 2024 01:42:33 +0100 Subject: [PATCH 16/16] Doc --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 9cdbbb06e38..1e66b4ee536 100644 --- a/ChangeLog +++ b/ChangeLog @@ -253,7 +253,7 @@ The following changes may create regressions for some external modules, but were * Hidden option ACCOUNTANCY_AUTOFIX_MISSING_LINK_TO_USEr_ON_SALARY_BANK_PAYMENT has been renamed into ACCOUNTANCY_AUTOFIX_MISSING_LINK_TO_USER_ON_SALARY_BANK_PAYMENT * The delete() method of AdherentType, Contact, Delivery, MultiCurrency, CurrencyRate now need $user as first parameter. * A very high number of class properties (with old name in french) are now deprecated in favor of the property name in english. - +* The load of hook context productdao has been removed before calling loadvirtualstock. Modules must use the context of main parent page or 'all' for all cases. ***** ChangeLog for 18.0.4 compared to 18.0.3 ***** FIX: $this->newref already exists and could have been modified by trigger but we still use a local variable for the filesystem-based renaming
'.$langs->trans("Tag").'