diff options
Diffstat (limited to 'httemplate')
-rw-r--r-- | httemplate/config/config-download.cgi | 38 | ||||
-rw-r--r-- | httemplate/config/config-image.cgi | 9 | ||||
-rw-r--r-- | httemplate/config/config-process.cgi | 6 | ||||
-rw-r--r-- | httemplate/config/config-view.cgi | 75 | ||||
-rw-r--r-- | httemplate/config/config.cgi | 17 | ||||
-rw-r--r-- | httemplate/edit/cust_main/billing.html | 18 | ||||
-rwxr-xr-x | httemplate/view/cust_bill-logo.cgi | 3 | ||||
-rw-r--r-- | httemplate/view/cust_main/billing.html | 9 |
8 files changed, 138 insertions, 37 deletions
diff --git a/httemplate/config/config-download.cgi b/httemplate/config/config-download.cgi index 6979246db..c071f2a6d 100644 --- a/httemplate/config/config-download.cgi +++ b/httemplate/config/config-download.cgi @@ -1,21 +1,3 @@ -% -% -%my $conf=new FS::Conf; -% -%http_header('Content-Type' => 'application/x-unknown' ); -% -%die "No configuration variable specified (bad URL)!" # umm -% unless $cgi->param('key'); -%$cgi->param('key') =~ /^([-\w.]+)$/; -%my $name = $1; -% -%my $agentnum; -%if ($cgi->param('agentnum') =~ /^(\d+)$/) { -% $agentnum = $1; -%} -% -%http_header('Content-Disposition' => "attachment; filename=$name" ); -% print $conf->config_binary($name, $agentnum); <%init> die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); @@ -25,4 +7,24 @@ if ($cgi->param('agentnum') =~ /^(\d+)$/) { $agentnum = $1; } +http_header('Content-Type' => 'application/x-unknown' ); + +die "No configuration variable specified (bad URL)!" # umm + unless $cgi->param('key'); +$cgi->param('key') =~ /^([-\w.]+)$/; +my $name = $1; + +my $agentnum; +if ($cgi->param('agentnum') =~ /^(\d+)$/) { + $agentnum = $1; +} + +my $locale = ''; +if ($cgi->param('locale') =~ /^(\w+)$/) { + $locale = $1; +} +my $conf=new FS::Conf { 'locale' => $locale }; + +http_header('Content-Disposition' => "attachment; filename=$name" ); +print $conf->config_binary($name, $agentnum); </%init> diff --git a/httemplate/config/config-image.cgi b/httemplate/config/config-image.cgi index 0de9d4278..0e04ab5bc 100644 --- a/httemplate/config/config-image.cgi +++ b/httemplate/config/config-image.cgi @@ -4,8 +4,6 @@ die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); -my $conf = new FS::Conf; - http_header( 'Content-Type' => 'image/png' ); #just png for now $cgi->param('key') =~ /^([-\w.]+)$/ or die "illegal config option"; @@ -16,6 +14,13 @@ if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) { $agentnum = $1; } +my $locale = ''; +if ( $cgi->param('locale') =~ /^(\w+)$/ ) { + $locale = $1; +} + +my $conf = new FS::Conf { 'locale' => $locale }; + my $logo = $conf->config_binary($name, $agentnum); $logo = eps2png($logo) if $name =~ /\.eps$/i; diff --git a/httemplate/config/config-process.cgi b/httemplate/config/config-process.cgi index 4a84c0dd1..c62a8c784 100644 --- a/httemplate/config/config-process.cgi +++ b/httemplate/config/config-process.cgi @@ -25,7 +25,7 @@ % } % %} else { -<% header('Configuration set') %> +<& /elements/header.html, 'Configuration set' &> <SCRIPT TYPE="text/javascript"> % my $n = 0; % foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) { @@ -103,7 +103,9 @@ my %namecol = ( my $curuser = $FS::CurrentUser::CurrentUser; die "access denied\n" unless $curuser->access_right('Configuration'); -my $conf = new FS::Conf; +my $locale = $cgi->param('locale') || ''; + +my $conf = new FS::Conf { 'locale' => $locale }; if ( $conf->exists('disable_settings_changes') ) { my @changers = split(/\s*,\s*/, $conf->config('disable_settings_changes')); diff --git a/httemplate/config/config-view.cgi b/httemplate/config/config-view.cgi index e7cadbe99..59646896e 100644 --- a/httemplate/config/config-view.cgi +++ b/httemplate/config/config-view.cgi @@ -16,6 +16,38 @@ Click on a configuration value to change it. % } % % } +% if ( @locales ) { +( +% if ( $locale ) { +% $cgi->delete('locale'); + <a href="<%$cgi->self_url%>">global settings</a> | +% } +<script type='text/javascript'> +function changeLocale(what) { + //var what = document.getElementById('select-locale'); + if(what.selectedIndex > 0) { + what.form.submit(); + } +} +</script> +invoice language options: +<form action="<% $cgi->self_url %>" method="GET" style="display:inline;"> +<& /elements/select.html, + 'field' => 'locale', + 'options' => [ '', @locales ], + 'labels' => { map { + my %info = FS::Locales->locale_info($_); + $_ => "$info{name} ($info{country})" + } @locales }, + 'curr_value' => $locale, + 'id' => 'select-locale', + 'onchange' => 'changeLocale' + &> + ) +% $cgi->param('locale', $locale); +% } +</form> + <BR><BR> <% include('/elements/init_overlib.html') %> @@ -89,11 +121,12 @@ Click on a configuration value to change it. % if $agent && $cgi->param('showagent'); % % #indentation :/ +% my $action = 'config.cgi?key=' . $i->key . +% ";agentnum=$agentnum" . ($locale ? ";locale=$locale" : ''); <tr> <td><% include('/elements/popup_link.html', - 'action' => 'config.cgi?key='. $i->key. - ';agentnum='. $agentnum, + 'action' => $action, 'width' => $width, 'height' => $height, 'actionlabel' => 'Enter configuration value', @@ -128,12 +161,12 @@ Click on a configuration value to change it. </tr> % } elsif ( $type eq 'image' ) { +% my $args = 'key=' . $i->key . ";agentnum=$agentnum;locale=$locale"; <tr> <td bgcolor='#ffffff'> <% $conf->exists($i->key, $agentnum) - ? '<img src="config-image.cgi?key='. $i->key. - ';agentnum='. $agentnum. '">' + ? '<img src="config-image.cgi?'.$args.'">' : 'empty' %> </td> @@ -141,18 +174,19 @@ Click on a configuration value to change it. <tr> <td> <% $conf->exists($i->key, $agentnum) - ? qq!<a href="config-download.cgi?key=!. $i->key. ';agentnum='. $agentnum. qq!">download</a>! + ? '<a href="config-download.cgi?'.$args.'">download</a>' : '' %> </td> </tr> % } elsif ( $type eq 'binary' ) { +% my $args = 'key=' . $i->key . ";agentnum=$agentnum;locale=$locale"; <tr> <td> <% $conf->exists($i->key, $agentnum) - ? qq!<a href="config-download.cgi?key=!. $i->key. ';agentnum='. $agentnum. qq!">download</a>! + ? '<a href="config-download.cgi?'.$args.'">download</a>' : 'empty' %> </td> @@ -344,14 +378,37 @@ if ($cgi->param('agentnum') =~ /^(\d+)$/) { die "Agent $page_agentnum not found!" unless $page_agent; push @menubar, 'View all agents' => $p.'browse/agent.cgi'; +} + +my $conf = new FS::Conf; +my $conf_global = $conf; + +my @locales = $conf_global->config('available-locales'); + +# if this is set, we are in locale mode, so limit the displayed items +# to those with per_locale. +my $locale; +my $locale_desc; +if ( $cgi->param('locale') =~ /^\w+_\w+$/ ) { + $locale = $cgi->param('locale'); + # and set the context on $conf + $conf = new FS::Conf { 'locale' => $locale, 'localeonly' => 1 }; + my %locale_info = FS::Locales->locale_info($locale); + $locale_desc = "$locale_info{name} ($locale_info{country})"; + + $title = 'Invoice Configuration'; #for now it is only invoicing + $title .= ' for '.$page_agent->agent if $page_agent; + $title .= ', '.$locale_desc; + +} elsif ($page_agent) { $title = 'Agent Configuration for '. $page_agent->agent; + $title .= ", $locale_desc" if $locale; } else { $title = 'Global Configuration'; } -my $conf = new FS::Conf; - -my @config_items = grep { $page_agent ? $_->per_agent : 1 } +my @config_items = grep { !defined($locale) or $_->per_locale } + grep { $page_agent ? $_->per_agent : 1 } grep { $page_agent ? 1 : !$_->agentonly } $conf->config_items; diff --git a/httemplate/config/config.cgi b/httemplate/config/config.cgi index 040ed0403..6a1eaecf7 100644 --- a/httemplate/config/config.cgi +++ b/httemplate/config/config.cgi @@ -24,6 +24,7 @@ function SafeOnsubmit() { <FORM NAME="OneTrueForm" ACTION="config-process.cgi" METHOD="POST" enctype="multipart/form-data" onSubmit="SafeOnsubmit()"> <INPUT TYPE="hidden" NAME="agentnum" VALUE="<% $agentnum %>"> +<INPUT TYPE="hidden" NAME="locale" VALUE="<% $locale %>"> <INPUT TYPE="hidden" NAME="key" VALUE="<% $key %>"> Setting <b><% $key %></b> @@ -49,7 +50,8 @@ Setting <b><% $key %></b> <% $conf->exists($key, $agentnum) ? 'Current image<br>'. '<img src="config-image.cgi?key='. $key. - ';agentnum='. $agentnum. '"><br>' + ';agentnum='. $agentnum. + ';locale='. $locale .'"><br>' : '' %> @@ -318,10 +320,6 @@ Setting <b><% $key %></b> </HTML> <%once> -my $conf = new FS::Conf; -my @config_items = $conf->config_items; -my %confitems = map { $_->key => $_ } @config_items; - my %element_types = map { $_ => 1 } qw( select-part_svc select-part_pkg select-pkg_class select-agent ); @@ -339,6 +337,15 @@ if ($cgi->param('agentnum') =~ /(\d+)$/) { $agentnum=$1; } +my $locale = ''; +if ( $cgi->param('locale') =~ /^(\w+_\w+)$/) { + $locale = $1; +} + +my $conf = new FS::Conf { 'locale' => $locale, 'localeonly' => 1 }; +my @config_items = $conf->config_items; +my %confitems = map { $_->key => $_ } @config_items; + my $agent = ''; my $title; if ($agentnum) { diff --git a/httemplate/edit/cust_main/billing.html b/httemplate/edit/cust_main/billing.html index f2d6271d0..294104b09 100644 --- a/httemplate/edit/cust_main/billing.html +++ b/httemplate/edit/cust_main/billing.html @@ -555,6 +555,24 @@ function toggle(obj) { <INPUT TYPE="hidden" NAME="cdr_termination_percentage" VALUE="<% $cust_main->cdr_termination_percentage %>"> % } +%my @available_locales = $conf->config('available-locales'); +%if ( scalar(@available_locales) ) { +% push @available_locales, ''; +% my %locale_labels = map { +% my %ll; +% my %info = FS::Locales->locale_info($_); +% $ll{$_} = $info{name} . " (" . $info{country} . ")"; +% %ll; +% } FS::Locales->locales; + <& /elements/tr-select.html, + 'label' => emt('Invoicing locale'), + 'field' => 'locale', + 'options' => \@available_locales, + 'labels' => \%locale_labels, + 'curr_value' => $cust_main->locale, + &> +% } + </TABLE> <% $r %> <% mt('required fields') |h %> diff --git a/httemplate/view/cust_bill-logo.cgi b/httemplate/view/cust_bill-logo.cgi index ad2ff5430..75321ef82 100755 --- a/httemplate/view/cust_bill-logo.cgi +++ b/httemplate/view/cust_bill-logo.cgi @@ -5,7 +5,7 @@ die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('View invoices') or $FS::CurrentUser::CurrentUser->access_right('Configuration'); -my $conf = new FS::Conf; +my $conf; my $templatename; my $agentnum = ''; @@ -13,6 +13,7 @@ if ( $cgi->param('invnum') ) { $templatename = $cgi->param('template') || $cgi->param('templatename'); my $cust_bill = qsearchs('cust_bill', { 'invnum' => $cgi->param('invnum') } ) or die 'unknown invnum'; + $conf = $cust_bill->conf; $agentnum = $cust_bill->cust_main->agentnum; } else { my($query) = $cgi->keywords; diff --git a/httemplate/view/cust_main/billing.html b/httemplate/view/cust_main/billing.html index cf22ff701..09c0b4d1d 100644 --- a/httemplate/view/cust_main/billing.html +++ b/httemplate/view/cust_main/billing.html @@ -273,6 +273,15 @@ </TR> % } +% if ( $cust_main->locale ) { +% my %locale_info = FS::Locales->locale_info($cust_main->locale); + <TR> + <TD ALIGN="right"><% mt('Invoicing locale') |h %></TD> + <TD BGCOLOR="#ffffff"><% $locale_info{name} . " (" . $locale_info{country} .")" %></TD> + </TR> +% } + + </TABLE></TD></TR></TABLE> <%once> |