X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fui%2Fui_view.inc;h=5925579be558ed33433bbbf9d50e31d91c864972;hb=37da0ea920fdff712ccef4e1324aa822e981c8fc;hp=ddd62fef061c4a720122da39805cb9415ebf9c0b;hpb=c2d8171259968d683568f3a5915b541f075fd194;p=fa-stable.git diff --git a/includes/ui/ui_view.inc b/includes/ui/ui_view.inc index ddd62fef..5925579b 100644 --- a/includes/ui/ui_view.inc +++ b/includes/ui/ui_view.inc @@ -271,31 +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; + 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; - } + $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):"")); + label_row(_("Exchange Rate:"),"1 " . $from_currency + . " = " . $rate . " " . $to_currency ); + $Ajax->addUpdate('_ex_rate','_ex_rate', $rate); } } @@ -313,7 +322,7 @@ function is_voided_display($type, $id, $label) echo "$label
"; echo "" . _("Date Voided:") . " " . sql2date($void_entry["date_"]) . "
"; if (strlen($void_entry["memo_"]) > 0) - echo "
" . _("Memo:") . " " . $void_entry["memo_"] . "
"; + echo "
" . _("Memo:") . " " . $void_entry["memo_"] . "

"; echo ""; end_table(1); @@ -454,7 +463,6 @@ function display_edit_tax_items($taxes, $columns, $tax_included, $leftspan=0) function display_footer_exit() { - global $path_to_root; br(2); end_page(); exit; @@ -523,22 +531,6 @@ function display_allocations_from($person_type, $person_id, $type, $type_no, $to } } -function get_js_go_back() -{ - $js = "\n\n"; - return $js; -} - function get_js_open_window($width, $height) { $js = "\n\n"; return $js; } -//$focus_on = array(); /* Setting focus on element $name in $form. If $form<0 $name is element id. */ function set_focus($name, $form_no=0) { -// global $focus_on; -// $focus_on['name'] = $name; -// $focus_on['form'] = $form_no; + global $Ajax; + $Ajax->addFocus(true, $name); $_POST['_focus'] = $name; } // // Set default focus on first field $name if not set yet // function default_focus($name, $form_no=0) { -// global $focus_on; -// if (!isset($focus_on['name']) && (!isset($_POST['_focus']) || $_POST['_focus']=='') ) { -//echo "

$name

"; -// $focus_on['name'] = $name; -// $focus_on['form'] = $form_no; -// } if (!isset($_POST['_focus'])) { - $_POST['_focus'] = $name; + set_focus($name); } } -/* -function set_js_focus() { - global $focus_on; - $js = ''; - -// if (isset($focus_on['name'])) { - - $js = ""; -// } - return $js; -} -*/ + function get_js_png_fix() { $js = "