summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2013-06-08 01:30:52 -0700
committerIvan Kohler <ivan@freeside.biz>2013-06-08 01:30:52 -0700
commite96a2a6fd3a8885b0fb035ecc55bdf50dbe5a4aa (patch)
tree1be65eac435d9445d71a2c63e33fefe94db96349 /httemplate
parent0f21021fea8f99d28b4507c3cffa55cbdd6f110d (diff)
multi-currency, RT#21565
Diffstat (limited to 'httemplate')
-rwxr-xr-xhttemplate/browse/agent.cgi20
-rw-r--r--httemplate/config/config.cgi4
-rwxr-xr-xhttemplate/edit/agent.cgi21
-rwxr-xr-xhttemplate/edit/currency_exchange.html73
-rw-r--r--httemplate/edit/elements/edit.html1
-rwxr-xr-xhttemplate/edit/part_pkg.cgi43
-rwxr-xr-xhttemplate/edit/process/agent.cgi10
-rw-r--r--httemplate/edit/process/currency_exchange.html36
-rwxr-xr-xhttemplate/edit/process/part_pkg.cgi13
-rw-r--r--httemplate/elements/checkboxes-table-name.html2
-rw-r--r--httemplate/elements/checkboxes.html2
-rw-r--r--httemplate/elements/menu.html8
12 files changed, 222 insertions, 11 deletions
diff --git a/httemplate/browse/agent.cgi b/httemplate/browse/agent.cgi
index fc9ce5413..b9190ecb5 100755
--- a/httemplate/browse/agent.cgi
+++ b/httemplate/browse/agent.cgi
@@ -38,6 +38,10 @@ full offerings (via their type).<BR><BR>
<TH CLASS="grid" BGCOLOR="#cccccc">Ticketing</TH>
% }
+% if ( $conf->config('currencies') ) {
+ <TH CLASS="grid" BGCOLOR="#cccccc">Currencies</TH>
+% }
+
<TH CLASS="grid" BGCOLOR="#cccccc"><FONT SIZE=-1>Payment Gateway Overrides</FONT></TH>
<TH CLASS="grid" BGCOLOR="#cccccc"><FONT SIZE=-1>Configuration Overrides</FONT></TH>
</TR>
@@ -361,19 +365,23 @@ Unused
<BR><A HREF="<%$p%>edit/prepay_credit.cgi?agentnum=<% $agent->agentnum %>">Generate cards</A>
</TD>
-% if ( $conf->config('ticket_system') ) {
-
+% if ( $conf->config('ticket_system') ) {
<TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
-% if ( $agent->ticketing_queueid ) {
-
- Queue: <% $agent->ticketing_queueid %>: <% $agent->ticketing_queue %><BR>
+% if ( $agent->ticketing_queueid ) {
+ Queue: <% $agent->ticketing_queueid %>:
+ <% $agent->ticketing_queue %>
+ <BR>
+% }
+ </TD>
% }
+% if ( $conf->config('currencies') ) {
+ <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
+ <% join('<BR>', sort keys %{ $agent->agent_currency_hashref } ) %>
</TD>
% }
-
<TD CLASS="inv" BGCOLOR="<% $bgcolor %>">
<TABLE CLASS="inv" CELLSPACING=0 CELLPADDING=0>
% foreach my $override (
diff --git a/httemplate/config/config.cgi b/httemplate/config/config.cgi
index 7960d7e38..50b3eba85 100644
--- a/httemplate/config/config.cgi
+++ b/httemplate/config/config.cgi
@@ -156,7 +156,9 @@ Setting <b><% $key %></b>
% }
% my %options = &{$config_item->options_sub};
-% my @options = sort { $a <=> $b } keys %options;
+% my @options = keys %options;
+% my $sortsub = $config_item->sort_sub || sub { $a <=> $b };
+% @options = sort $sortsub @options;
% my %saw;
% foreach my $value ( @options ) {
% local($^W)=0; next if $saw{$value}++;
diff --git a/httemplate/edit/agent.cgi b/httemplate/edit/agent.cgi
index b043d1efe..2eddd30a4 100755
--- a/httemplate/edit/agent.cgi
+++ b/httemplate/edit/agent.cgi
@@ -170,9 +170,30 @@
% }
</TABLE>
+<BR>
+
+% if ( $conf->config('currencies') ) {
+
+ <FONT CLASS="fsinnerbox-title"><% mt('Currencies') |h %></FONT>
+ <TABLE CLASS="fsinnerbox">
+ <TR>
+ <TD>
+ <& /elements/checkboxes-table-name.html,
+ 'link_table' => 'agent_currency',
+ 'name_col' => 'currency',
+ 'names_list' => [ map [ $_, {label=>"$_: ".code2currency($_)} ],
+ $conf->config('currencies')
+ ],
+ &>
+ </TD>
+ </TR>
+ </TABLE>
+% }
<BR>
+
+
<INPUT TYPE="submit" VALUE="<% $agent->agentnum ? "Apply changes" : "Add agent" %>">
</FORM>
diff --git a/httemplate/edit/currency_exchange.html b/httemplate/edit/currency_exchange.html
new file mode 100755
index 000000000..573ace5ee
--- /dev/null
+++ b/httemplate/edit/currency_exchange.html
@@ -0,0 +1,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>
diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html
index 3e6bd5bec..08408297b 100644
--- a/httemplate/edit/elements/edit.html
+++ b/httemplate/edit/elements/edit.html
@@ -282,6 +282,7 @@ Example:
% #text and derivitives
% 'size' => $f->{'size'},
% 'maxlength' => $f->{'maxlength'},
+% 'prefix' => $f->{'prefix'},
% 'postfix' => $f->{'postfix'},
%
% #textarea
diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi
index fadde354e..ef9bc2299 100755
--- a/httemplate/edit/part_pkg.cgi
+++ b/httemplate/edit/part_pkg.cgi
@@ -51,6 +51,12 @@
'setup_show_zero' => 'Show zero setup',
'recur_fee' => 'Recurring fee',
'recur_show_zero' => 'Show zero recurring',
+ ( map { ( "setup_fee_$_" => "Setup fee $_",
+ "recur_fee_$_" => "Recurring fee $_",
+ );
+ }
+ $conf->config('currencies')
+ ),
'discountnum' => 'Offer discounts for longer terms',
'bill_dst_pkgpart' => 'Include line item(s) from package',
'svc_dst_pkgpart' => 'Include services of package',
@@ -118,6 +124,14 @@
value => 'Y',
disabled => sub { $setup_show_zero_disabled },
},
+ ( map { +{ field => "setup_fee_$_",
+ type => 'text',
+ prefix=> currency_symbol($_, SYM_HTML),
+ size => 8,
+ }
+ }
+ sort $conf->config('currencies')
+ ),
{ field => 'freq',
type => 'part_pkg_freq',
onchange => 'freq_changed',
@@ -127,12 +141,19 @@
disabled => sub { $recur_disabled },
onchange => 'recur_changed',
},
-
{ field => 'recur_show_zero',
type => 'checkbox',
value => 'Y',
disabled => sub { $recur_show_zero_disabled },
},
+ ( map { +{ field => "recur_fee_$_",
+ type => 'text',
+ prefix=> currency_symbol($_, SYM_HTML),
+ size => 8,
+ }
+ }
+ sort $conf->config('currencies')
+ ),
#price plan
#setup fee
@@ -460,6 +481,14 @@ my $error_callback = sub {
$object->set($_ => scalar($cgi->param($_)) )
foreach (qw( setup_fee recur_fee disable_line_item_date_ranges ));
+ foreach my $currency ( $conf->config('currencies') ) {
+ my %part_pkg_currency = $object->part_pkg_currency_options($currency);
+ foreach (qw( setup_fee recur_fee )) {
+ my $param = $_.'_'.$currency;
+ $object->set( $param, $cgi->param($param) );
+ }
+ }
+
$pkgpart = $object->pkgpart;
&$splice_locale_fields(
@@ -535,6 +564,12 @@ my $edit_callback = sub {
$object->set($_ => $object->option($_, 1))
foreach (qw( setup_fee recur_fee disable_line_item_date_ranges ));
+ foreach my $currency ( $conf->config('currencies') ) {
+ my %part_pkg_currency = $object->part_pkg_currency_options($currency);
+ $object->set( $_.'_'.$currency, $part_pkg_currency{$_} )
+ foreach keys %part_pkg_currency;
+ }
+
$pkgpart = $object->pkgpart;
&$splice_locale_fields(
@@ -599,6 +634,12 @@ my $clone_callback = sub {
$object->set($_ => $options{$_})
foreach (qw( setup_fee recur_fee disable_line_item_date_ranges ));
+ foreach my $currency ( $conf->config('currencies') ) {
+ my %part_pkg_currency = $object->part_pkg_currency_options($currency);
+ $object->set( $_.'_'.$currency, $part_pkg_currency{$_} )
+ foreach keys %part_pkg_currency;
+ }
+
$recur_disabled = $object->freq ? 0 : 1;
&$splice_locale_fields(
diff --git a/httemplate/edit/process/agent.cgi b/httemplate/edit/process/agent.cgi
index 034c4cc50..554992958 100755
--- a/httemplate/edit/process/agent.cgi
+++ b/httemplate/edit/process/agent.cgi
@@ -5,6 +5,12 @@
'process_m2m' => { 'link_table' => 'access_groupagent',
'target_table' => 'access_group',
},
+ 'process_m2name' => {
+ 'link_table' => 'agent_currency',
+ 'name_col' => 'currency',
+ 'names_list' => [ $conf->config('currencies') ],
+ 'param_style' => 'link_table.value checkboxes',
+ },
'edit_ext' => 'cgi',
'noerror_callback' => $process_agent_pkg_class,
)
@@ -14,7 +20,9 @@
die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
-if ( FS::Conf->new->exists('disable_acl_changes') ) {
+my $conf = new FS::Conf;
+
+if ( $conf->exists('disable_acl_changes') ) {
errorpage('ACL changes disabled in public demo.');
die "shouldn't be reached";
}
diff --git a/httemplate/edit/process/currency_exchange.html b/httemplate/edit/process/currency_exchange.html
new file mode 100644
index 000000000..1f6852299
--- /dev/null
+++ b/httemplate/edit/process/currency_exchange.html
@@ -0,0 +1,36 @@
+%if ( $error ) {
+% errorpage($error); #also not super ideal
+%} else { #or this
+<% include('/elements/header.html', 'Exchange rates updated') %>
+<% include('/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');
+
+#in the best of all possible worlds, i would be a single database transaction
+# but here it isn't terribly important other than offending my sense of elegance
+my $error = '';
+foreach my $currency (@currencies) {
+
+ my %hash = ( 'from_currency' => $currency,
+ 'to_currency' => $to_currency,
+ );
+
+ my $currency_exchange = qsearchs('currency_exchange', \%hash)
+ || new FS::currency_exchange \%hash;
+
+ $currency_exchange->rate( $cgi->param("$currency-$to_currency") );
+
+ my $method = $currency_exchange->currencyratenum ? 'replace' : 'insert';
+ $error = $currency_exchange->$method() and last;
+}
+
+</%init>
diff --git a/httemplate/edit/process/part_pkg.cgi b/httemplate/edit/process/part_pkg.cgi
index 932e33b1d..3b6562f13 100755
--- a/httemplate/edit/process/part_pkg.cgi
+++ b/httemplate/edit/process/part_pkg.cgi
@@ -115,6 +115,19 @@ my $args_callback = sub {
push @args, 'options' => \%options;
###
+ #part_pkg_currency
+ ###
+
+ my %part_pkg_currency = (
+ map { $_ => scalar($cgi->param($_)) }
+ #grep /._[A-Z]{3}$/, #support other options
+ grep /^(setup|recur)_fee_[A-Z]{3}$/,
+ $cgi->param
+ );
+
+ push @args, 'part_pkg_currency' => \%part_pkg_currency;
+
+ ###
#pkg_svc
###
diff --git a/httemplate/elements/checkboxes-table-name.html b/httemplate/elements/checkboxes-table-name.html
index 8ee2f7736..957d8efda 100644
--- a/httemplate/elements/checkboxes-table-name.html
+++ b/httemplate/elements/checkboxes-table-name.html
@@ -11,7 +11,7 @@ Example:
'name_col' => 'name_column',
#or
- 'name_callback' => sub { },
+ #not yet 'name_callback' => sub { },
'names_list' => [ 'value',
'other value',
diff --git a/httemplate/elements/checkboxes.html b/httemplate/elements/checkboxes.html
index 69ef18fb9..ad9d691b9 100644
--- a/httemplate/elements/checkboxes.html
+++ b/httemplate/elements/checkboxes.html
@@ -6,7 +6,7 @@ Example:
# required
- #? 'name_callback' => sub { },
+ #not yet 'name_callback' => sub { },
'names_list' => [ 'value',
'other value',
diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html
index f784d2faf..53fccaf25 100644
--- a/httemplate/elements/menu.html
+++ b/httemplate/elements/menu.html
@@ -587,8 +587,10 @@ $config_billing{'Billing events'} = [ $fsurl.'browse/part_event.html', 'Billing
if ( $curuser->access_right('Configuration') ) {
#$config_billing{'Invoice events'} = [ $fsurl.'browse/part_bill_event.cgi', 'Deprecated, old-style actions for overdue invoices' ];
$config_billing{'Invoice templates'} = [ $fsurl.'browse/invoice_template.html', 'Edit templates for HTML, plaintext and typeset invoices' ];
+ $config_billing{'separator'} = ''; #its a separator!
$config_billing{'Prepaid cards'} = [ $fsurl.'search/prepay_credit.html', 'View outstanding cards, generate new cards' ];
$config_billing{'Call rates and regions'} = [ \%config_billing_rates, 'Manage rate plans, regions and prefixes for VoIP and call billing' ];
+ $config_billing{'separator2'} = ''; #its a separator!
my $config_taxes_name = 'Locales and tax rates'.
( $conf->exists('enable_taxproducts')
@@ -600,6 +602,12 @@ if ( $curuser->access_right('Configuration') ) {
if $conf->exists('enable_taxproducts');
$config_billing{'Tax classes'} = [ $fsurl. 'browse/part_pkg_taxclass.html', 'Tax classes' ];
+ if ( $conf->config('currencies') ) {
+ $config_billing{'separator3'} = ''; #its a separator!
+ $config_billing{'Exchange rates'} = [ $fsurl.'edit/currency_exchange.html', 'Currency exchange rates' ];
+ }
+
+ $config_billing{'separator4'} = ''; #its a separator!
$config_billing{'Credit reasons'} = [ $fsurl.'browse/reason.html?class=R', 'Credit reasons explain why a credit was issued.' ];
$config_billing{'Credit reason types'} = [ $fsurl.'browse/reason_type.html?class=R', 'Credit reason types define groups of reasons.' ];
}