From 11100b3017a8ff9c3ab3ddbaae8d4ab71290eeaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 13 Jan 2021 15:16:43 +0100 Subject: [PATCH 1/5] missing default value --- htdocs/product/card.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index d6f62b34769..d74cab0ada4 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -16,7 +16,7 @@ * Copyright (C) 2016 Charlie Benke * Copyright (C) 2016 Meziane Sof * Copyright (C) 2017 Josep Lluís Amador - * Copyright (C) 2019 Frédéric France + * Copyright (C) 2019-2021 Frédéric France * Copyright (C) 2019-2020 Thibault FOUCART * * This program is free software; you can redistribute it and/or modify @@ -1297,11 +1297,10 @@ else // Accountancy_code_buy print ''.$langs->trans("ProductAccountancyBuyCode").''; print ''; - if ($type == 0) - { + if ($type == 0) { $accountancy_code_buy = (GETPOST('accountancy_code_buy', 'alpha') ? (GETPOST('accountancy_code_buy', 'alpha')) : $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT); } else { - $accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha'); + $accountancy_code_buy = (GETPOST('accountancy_code_buy', 'alpha') ? (GETPOST('accountancy_code_buy', 'alpha')) : $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT); } print $formaccounting->select_account($accountancy_code_buy, 'accountancy_code_buy', 1, null, 1, 1, ''); print ''; From 727751e0c1512d2621d7def8c07e41f9f5c645d8 Mon Sep 17 00:00:00 2001 From: zuiko Date: Thu, 14 Jan 2021 14:44:32 +0100 Subject: [PATCH 2/5] Update functions.lib.php Fix #15820 function price2num add underscore in the pattern in instruction $amount = preg_replace('/[a-zA-Z\/\\\*\(\)\<\>]/', '', $amount); as this: $amount = preg_replace('/[a-zA-Z\/\\\*\(\)\<\>\_]/', '', $amount); in order to cover some constantes cases as 20% (TX_NORMAL) or 10% (TX_REDUIT) where underscore is used. I don't know if other characters have to be added to this pattern. --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 023ade28052..6921f9f967a 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4725,7 +4725,7 @@ function price2num($amount, $rounding = '', $option = 0) if ($option != 1) { // If not a PHP number or unknown, we change or clean format //print 'PP'.$amount.' - '.$dec.' - '.$thousand.' - '.intval($amount).'
'; if (!is_numeric($amount)) { - $amount = preg_replace('/[a-zA-Z\/\\\*\(\)\<\>]/', '', $amount); + $amount = preg_replace('/[a-zA-Z\/\\\*\(\)\<\>\_]/', '', $amount); } if ($option == 2 && $thousand == '.' && preg_match('/\.(\d\d\d)$/', (string) $amount)) { // It means the . is used as a thousand separator and string come frominput data, so 1.123 is 1123 From fd5948f71637815bd0cc0a988d41961c8f538c32 Mon Sep 17 00:00:00 2001 From: zuiko Date: Thu, 14 Jan 2021 15:00:53 +0100 Subject: [PATCH 3/5] Update functions.lib.php Fix #15820 Fix #15820 function price2num add underscore in the pattern in instruction $amount = preg_replace('/[a-zA-Z\/\\\*\(\)\<\>]/', '', $amount); as this: $amount = preg_replace('/[a-zA-Z\/\\\*\(\)\<\>\_\-]/', '', $amount); in order to cover some constantes cases as 20% (TX_NORMAL) or 10% (TX_REDUIT) where underscore is used. it seems that some constantes use also "-" so I added it in the pattern. I don't know if other characters have to be added to this pattern. --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 6921f9f967a..7c562357d9a 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4725,7 +4725,7 @@ function price2num($amount, $rounding = '', $option = 0) if ($option != 1) { // If not a PHP number or unknown, we change or clean format //print 'PP'.$amount.' - '.$dec.' - '.$thousand.' - '.intval($amount).'
'; if (!is_numeric($amount)) { - $amount = preg_replace('/[a-zA-Z\/\\\*\(\)\<\>\_]/', '', $amount); + $amount = preg_replace('/[a-zA-Z\/\\\*\(\)\<\>\_\-]/', '', $amount); } if ($option == 2 && $thousand == '.' && preg_match('/\.(\d\d\d)$/', (string) $amount)) { // It means the . is used as a thousand separator and string come frominput data, so 1.123 is 1123 From 871691bf69dba1ed973b74957341b93e6a967bc7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Jan 2021 16:34:49 +0100 Subject: [PATCH 4/5] Fix missing popup --- htdocs/admin/accountant.php | 1 + htdocs/admin/company.php | 1 + htdocs/admin/openinghours.php | 1 + 3 files changed, 3 insertions(+) diff --git a/htdocs/admin/accountant.php b/htdocs/admin/accountant.php index c8c082db6ae..b017230c677 100644 --- a/htdocs/admin/accountant.php +++ b/htdocs/admin/accountant.php @@ -66,6 +66,7 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha')) if ($action != 'updateedit' && !$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); header("Location: ".$_SERVER["PHP_SELF"]); exit; } diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 00bd17e865f..02091124b15 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -256,6 +256,7 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha')) if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); $db->commit(); } else diff --git a/htdocs/admin/openinghours.php b/htdocs/admin/openinghours.php index d4886bb2a57..05e0658d1d7 100644 --- a/htdocs/admin/openinghours.php +++ b/htdocs/admin/openinghours.php @@ -57,6 +57,7 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha')) if ($action != 'updateedit' && !$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); header("Location: ".$_SERVER["PHP_SELF"]); exit; } From 8b9287055e48390227a6e3a660dc1ee25d78cd83 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Jan 2021 18:34:25 +0100 Subject: [PATCH 5/5] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7c562357d9a..6921f9f967a 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4725,7 +4725,7 @@ function price2num($amount, $rounding = '', $option = 0) if ($option != 1) { // If not a PHP number or unknown, we change or clean format //print 'PP'.$amount.' - '.$dec.' - '.$thousand.' - '.intval($amount).'
'; if (!is_numeric($amount)) { - $amount = preg_replace('/[a-zA-Z\/\\\*\(\)\<\>\_\-]/', '', $amount); + $amount = preg_replace('/[a-zA-Z\/\\\*\(\)\<\>\_]/', '', $amount); } if ($option == 2 && $thousand == '.' && preg_match('/\.(\d\d\d)$/', (string) $amount)) { // It means the . is used as a thousand separator and string come frominput data, so 1.123 is 1123