X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fui%2Fui_view.inc;h=5925579be558ed33433bbbf9d50e31d91c864972;hb=361aac31df66f513fc014aee6adc9f1e30dd18a7;hp=dce9fff41c88066886ef9d0b4664c0302c9ab7b6;hpb=c678e0167be0d6773ae1b3da6ab8f2750c21f757;p=fa-stable.git diff --git a/includes/ui/ui_view.inc b/includes/ui/ui_view.inc index dce9fff4..5925579b 100644 --- a/includes/ui/ui_view.inc +++ b/includes/ui/ui_view.inc @@ -271,37 +271,40 @@ function get_trans_view_str($type, $trans_no, $label="") } //-------------------------------------------------------------------------------------- - -function exchange_rate_display($from_currency, $to_currency, $date_, $buttons=true) +// Displays currency exchange rate for given date. +// When there is no exrate for today, +// gets it form ECB and stores in local database. +// +function exchange_rate_display($from_currency, $to_currency, $date_) { global $Ajax; - $hint = _('Get daily ECB exchange rate and save for later use in invoicing process'); + if ($from_currency != $to_currency) { - 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 (get_date_exchange_rate($currency, $date_)) - update_exchange_rate($currency, $date_, $rate, $rate); - else - add_exchange_rate($currency, $date_, $rate, $rate); - if ($from_currency == $comp_currency) - $rate = 1 / $rate; - $Ajax->activate('get_rate'); - } + $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) + add_exchange_rate($currency, $date_, $rate, $rate); + } + } + if (!$rate) $rate = get_exchange_rate_from_to($to_currency, $from_currency, $date_); + + if ($from_currency == $comp_currency) + $rate = 1 / $rate; + $rate = number_format2($rate, user_exrate_dec()); - label_row(_("Exchange Rate:"),"1 " . $from_currency . " = " . $rate . " " . $to_currency . - ($buttons?" " . submit('get_rate',_("Get"), false, $hint, true):"")); - if($buttons) { - $Ajax->addUpdate('get_rate','_ex_rate', $rate); - } + label_row(_("Exchange Rate:"),"1 " . $from_currency + . " = " . $rate . " " . $to_currency ); + $Ajax->addUpdate('_ex_rate','_ex_rate', $rate); } } @@ -548,6 +551,8 @@ function get_js_open_window($width, $height) If $form<0 $name is element id. */ function set_focus($name, $form_no=0) { + global $Ajax; + $Ajax->addFocus(true, $name); $_POST['_focus'] = $name; } // @@ -588,7 +593,7 @@ function get_js_png_fix() function get_js_date_picker() { - global $comp_path; + global $comp_path, $go_debug; $fpath = $comp_path.'/'.user_company().'/js_cache/'.'date_picker.js'; $js = "