summaryrefslogtreecommitdiff
path: root/httemplate/edit/currency_exchange.html
blob: 573ace5eedc9c80377215d9f494c479f01c99d62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<& /elements/header.html, 'Exchange rates' &>

<FORM METHOD="POST" ACTION="process/currency_exchange.html">

<& /elements/table-grid.html &>
% my $bgcolor1 = '#eeeeee';
%   my $bgcolor2 = '#ffffff';
%   my $bgcolor = '';

<TR>
  <TH CLASS="grid" BGCOLOR="#cccccc">From</TH>
  <TH CLASS="grid" BGCOLOR="#cccccc">Rate</TH>
  <TH CLASS="grid" BGCOLOR="#cccccc">To</TH>
</TR>

%foreach my $currency (@currencies) {
%
%  if ( $bgcolor eq $bgcolor1 ) {
%    $bgcolor = $bgcolor2;
%  } else {
%    $bgcolor = $bgcolor1;
%  }
%
%  my %hash = ( 'from_currency' => $currency,
%               'to_currency'   => $to_currency,
%             );
%
%  my $currency_exchange = qsearchs('currency_exchange', \%hash)
%                         || new FS::currency_exchange   \%hash;
%
% $currency_exchange->rate('1.000000') if length($currency_exchange->rate) == 0;

      <TR>

        <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
          <% $currency %>: <% code2currency($currency) %>
        </TD>

        <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ALIGN="right">
          <INPUT TYPE      = "text"
                 NAME      = "<% "$currency-$to_currency" %>"
                 VALUE     = "<% $currency_exchange->rate %>"
                 SIZE      = 14
                 MAXLENGTH = 14
          >
        </TD>

        <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
          <% $to_currency %>: <% code2currency($to_currency) %>
        </TD>

      </TR>
% } 

    </TABLE>

<BR>
<INPUT TYPE="submit" VALUE="Update rates">
</FORM>

<& /elements/footer.html &>
<%init>

die "access denied"
  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');

my $conf = new FS::Conf;

my $to_currency = $conf->config('currency') || 'USD';

my @currencies = sort { $a cmp $b } $conf->config('currencies');

</%init>