2 % errorpage($error); #also not super ideal
4 <% include('/elements/header.html', 'Exchange rates updated') %>
5 <% include('/elements/footer.html') %>
10 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
12 my $conf = new FS::Conf;
14 my $to_currency = $conf->config('currency') || 'USD';
16 my @currencies = sort { $a cmp $b } $conf->config('currencies');
18 #in the best of all possible worlds, i would be a single database transaction
19 # but here it isn't terribly important other than offending my sense of elegance
21 foreach my $currency (@currencies) {
23 my %hash = ( 'from_currency' => $currency,
24 'to_currency' => $to_currency,
27 my $currency_exchange = qsearchs('currency_exchange', \%hash)
28 || new FS::currency_exchange \%hash;
30 $currency_exchange->rate( $cgi->param("$currency-$to_currency") );
32 my $method = $currency_exchange->currencyratenum ? 'replace' : 'insert';
33 $error = $currency_exchange->$method() and last;