diff options
Diffstat (limited to 'httemplate/edit')
-rwxr-xr-x | httemplate/edit/agent.cgi | 21 | ||||
-rwxr-xr-x | httemplate/edit/currency_exchange.html | 73 | ||||
-rw-r--r-- | httemplate/edit/elements/edit.html | 1 | ||||
-rwxr-xr-x | httemplate/edit/part_pkg.cgi | 43 | ||||
-rwxr-xr-x | httemplate/edit/process/agent.cgi | 10 | ||||
-rw-r--r-- | httemplate/edit/process/currency_exchange.html | 36 | ||||
-rwxr-xr-x | httemplate/edit/process/part_pkg.cgi | 13 |
7 files changed, 195 insertions, 2 deletions
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 ### |