FIX #7486 Empty value for multicurrency rate must be forbidden
This commit is contained in:
parent
cef7b9c92d
commit
4c7b39f49e
@ -78,34 +78,54 @@ if (preg_match('/del_(.*)/',$action,$reg))
|
|||||||
|
|
||||||
if ($action == 'add_currency')
|
if ($action == 'add_currency')
|
||||||
{
|
{
|
||||||
|
$error=0;
|
||||||
|
|
||||||
$langs->loadCacheCurrencies('');
|
$langs->loadCacheCurrencies('');
|
||||||
|
|
||||||
$code = GETPOST('code', 'alpha');
|
$code = GETPOST('code', 'alpha');
|
||||||
$rate = GETPOST('rate', 'alpha');
|
$rate = price2num(GETPOST('rate', 'alpha'));
|
||||||
$currency = new MultiCurrency($db);
|
$currency = new MultiCurrency($db);
|
||||||
$currency->code = $code;
|
$currency->code = $code;
|
||||||
$currency->name = !empty($langs->cache_currencies[$code]['label']) ? $langs->cache_currencies[$code]['label'].' ('.$langs->getCurrencySymbol($code).')' : $code;
|
$currency->name = !empty($langs->cache_currencies[$code]['label']) ? $langs->cache_currencies[$code]['label'].' ('.$langs->getCurrencySymbol($code).')' : $code;
|
||||||
|
|
||||||
if ($currency->create($user) > 0)
|
if (empty($rate))
|
||||||
{
|
{
|
||||||
if ($currency->addRate($rate)) setEventMessages($langs->trans('RecordSaved'), array());
|
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Rate")), null, 'errors');
|
||||||
else setEventMessages($langs->trans('ErrorAddRateFail'), array(), 'errors');
|
$error++;
|
||||||
|
}
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
if ($currency->create($user) > 0)
|
||||||
|
{
|
||||||
|
if ($currency->addRate($rate)) setEventMessages($langs->trans('RecordSaved'), array());
|
||||||
|
else setEventMessages($langs->trans('ErrorAddRateFail'), array(), 'errors');
|
||||||
|
}
|
||||||
|
else setEventMessages($langs->trans('ErrorAddCurrencyFail'), $currency->errors, 'errors');
|
||||||
}
|
}
|
||||||
else setEventMessages($langs->trans('ErrorAddCurrencyFail'), $currency->errors, 'errors');
|
|
||||||
}
|
}
|
||||||
elseif ($action == 'update_currency')
|
elseif ($action == 'update_currency')
|
||||||
{
|
{
|
||||||
|
$error = 0;
|
||||||
|
|
||||||
$submit = GETPOST('submit', 'alpha');
|
$submit = GETPOST('submit', 'alpha');
|
||||||
|
|
||||||
if ($submit == $langs->trans('Modify'))
|
if ($submit == $langs->trans('Modify'))
|
||||||
{
|
{
|
||||||
$fk_multicurrency = GETPOST('fk_multicurrency', 'int');
|
$fk_multicurrency = GETPOST('fk_multicurrency', 'int');
|
||||||
$rate = GETPOST('rate', 'float');
|
$rate = price2num(GETPOST('rate', 'alpha'));
|
||||||
$currency = new MultiCurrency($db);
|
$currency = new MultiCurrency($db);
|
||||||
|
|
||||||
if ($currency->fetch($fk_multicurrency) > 0)
|
if (empty($rate))
|
||||||
{
|
{
|
||||||
$currency->updateRate($rate);
|
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Rate")), null, 'errors');
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
if ($currency->fetch($fk_multicurrency) > 0)
|
||||||
|
{
|
||||||
|
$currency->updateRate($rate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($submit == $langs->trans('Delete'))
|
elseif ($submit == $langs->trans('Delete'))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user