- if ($buttons && isset($_POST['get_rate']))
- {
- $comp_currency = get_company_currency();
- if ($from_currency == $comp_currency)
- $currency = $to_currency;
- else
- $currency = $from_currency;
- $rate = get_ecb_rate($currency);
- if ($rate==0)
- {
- display_error(_("Cannot get exchange rate for this currency. Please add exchange rate manually on Exchange Rates page.") );
- $rate = get_exchange_rate_from_to($to_currency, $from_currency, $date_);
- } else
- {
- if (get_date_exchange_rate($currency, $date_))
- update_exchange_rate($currency, $date_, $rate, $rate);
- else
+ $comp_currency = get_company_currency();
+ if ($from_currency == $comp_currency)
+ $currency = $to_currency;
+ else
+ $currency = $from_currency;
+ $rate = 0;
+ if ($date_ == Today()) {
+ $rate = get_date_exchange_rate($currency, $date_);
+ if (!$rate) {
+ $rate = get_ecb_rate($currency);
+ if ($rate)