From 770a160b8baa92d261ff57e0f826dc69d69c31e5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 29 Jun 2022 14:31:21 +0200 Subject: [PATCH] Debug v16 --- htdocs/admin/multicurrency.php | 15 ++++++++--- htdocs/core/class/conf.class.php | 2 +- htdocs/core/class/html.form.class.php | 12 ++++++--- htdocs/core/lib/functions.lib.php | 3 ++- .../core/modules/modMultiCurrency.class.php | 2 +- htdocs/multicurrency/multicurrency_rate.php | 27 ++++++++++++++----- 6 files changed, 43 insertions(+), 18 deletions(-) diff --git a/htdocs/admin/multicurrency.php b/htdocs/admin/multicurrency.php index c91af2fcc36..d6487093e41 100644 --- a/htdocs/admin/multicurrency.php +++ b/htdocs/admin/multicurrency.php @@ -76,10 +76,15 @@ if ($action == 'add_currency') { $currency->code = $code; $currency->name = !empty($langs->cache_currencies[$code]['label']) ? $langs->cache_currencies[$code]['label'].' ('.$langs->getCurrencySymbol($code).')' : $code; + if (empty($currency->code) || $currency->code == '-1') { + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Currency")), null, 'errors'); + $error++; + } if (empty($rate)) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Rate")), null, 'errors'); $error++; } + if (!$error) { if ($currency->create($user) > 0) { if ($currency->addRate($rate)) { @@ -296,7 +301,7 @@ print ''; print ''; print ''."\n"; -print ''."\n"; +print ''."\n"; print ''; print ''; @@ -304,17 +309,19 @@ print ''; print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; print ''; -print ''; +print ''; print ''; print ''; diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 0a996018e97..1345d2116f6 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -51,7 +51,7 @@ class Conf public $use_javascript_ajax; //! To store if javascript/ajax is enabked public $disable_compute; - //! Used to store current currency (ISO code like 'USD', 'EUR', ...) + //! Used to store current currency (ISO code like 'USD', 'EUR', ...). To get the currency symbol: $langs->getCurrencySymbol($this->currency) public $currency; //! Used to store current css (from theme) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 88f7f7aaa9a..3f8205f899e 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5848,12 +5848,13 @@ class Form /** * Retourne la liste des devises, dans la langue de l'utilisateur * - * @param string $selected preselected currency code - * @param string $htmlname name of HTML select list - * @param string $mode 0 = Add currency symbol into label, 1 = Add 3 letter iso code + * @param string $selected preselected currency code + * @param string $htmlname name of HTML select list + * @param string $mode 0 = Add currency symbol into label, 1 = Add 3 letter iso code + * @param string $useempty '1'=Allow empty value * @return string */ - public function selectCurrency($selected = '', $htmlname = 'currency_id', $mode = 0) + public function selectCurrency($selected = '', $htmlname = 'currency_id', $mode = 0, $useempty = '') { global $conf, $langs, $user; @@ -5866,6 +5867,9 @@ class Form } $out .= ''; print ''; - print ' '; + print ' '; print ' '; print '\n"; if (! $i) $totalarray['nbfield']++;
'.$form->textwithpicto($langs->trans("CurrenciesUsed"), $langs->transnoentitiesnoconv("CurrenciesUsed_help_to_add")).''.$langs->trans("Rate").''.$langs->trans("Rate").' / '.$langs->getCurrencySymbol($conf->currency).'
'.$form->selectCurrency('', 'code', 1).''.$form->selectCurrency('', 'code', 1, '1').''; print ' '; -print ''; +print ''; print '
'.$conf->currency.$form->textwithpicto(' ', $langs->trans("BaseCurrency")).''.$conf->currency; +print ' ('.$langs->getCurrencySymbol($conf->currency).')'; +print $form->textwithpicto(' ', $langs->trans("BaseCurrency")).'1
'.$langs->trans('Currency').''.$form->selectMultiCurrency((GETPOSTISSET('multicurrency_code') ? GETPOST('multicurrency_code', 'alpha') : $multicurrency_code), 'multicurrency_code', 1, " code != '".$db->escape($conf->currency)."'", true).''.$langs->trans('Rate').''.$langs->trans('Rate').' / '.$langs->getCurrencySymbol($conf->currency).''; @@ -280,7 +292,7 @@ if (!in_array($action, array("updateRate", "deleteRate"))) { -$sql = 'SELECT cr.rowid, cr.date_sync, cr.rate, cr.entity, m.code, m.name '; +$sql = 'SELECT cr.rowid, cr.date_sync, cr.rate, cr.entity, m.code, m.name'; // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook @@ -496,7 +508,8 @@ if ($resql) { // code if (! empty($arrayfields['m.code']['checked'])) { print ''; - print $obj->code." ".$obj->name; + print $obj->code; + print ' - '.$obj->name.''; print "