[freeside-commits] freeside/httemplate/config config-download.cgi, 1.3, 1.4 config-image.cgi, 1.2, 1.3 config-process.cgi, 1.28, 1.29 config-view.cgi, 1.44, 1.45 config.cgi, 1.37, 1.38
Mark Wells
mark at wavetail.420.am
Thu Sep 15 03:18:57 PDT 2011
Update of /home/cvs/cvsroot/freeside/httemplate/config
In directory wavetail.420.am:/tmp/cvs-serv16658/httemplate/config
Modified Files:
config-download.cgi config-image.cgi config-process.cgi
config-view.cgi config.cgi
Log Message:
invoice template and config localization, #12367
Index: config-download.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/config/config-download.cgi,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -w -d -r1.3 -r1.4
--- config-download.cgi 18 Jul 2007 18:07:38 -0000 1.3
+++ config-download.cgi 15 Sep 2011 10:18:53 -0000 1.4
@@ -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 @@
$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>
Index: config.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/config/config.cgi,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -w -d -r1.37 -r1.38
--- config.cgi 16 Jun 2011 20:21:41 -0000 1.37
+++ config.cgi 15 Sep 2011 10:18:55 -0000 1.38
@@ -24,6 +24,7 @@
<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 @@
<% $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 @@
</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 @@
$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) {
Index: config-image.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/config/config-image.cgi,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -d -r1.2 -r1.3
--- config-image.cgi 17 Mar 2009 09:58:17 -0000 1.2
+++ config-image.cgi 15 Sep 2011 10:18:54 -0000 1.3
@@ -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 @@
$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;
Index: config-view.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/config/config-view.cgi,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -w -d -r1.44 -r1.45
--- config-view.cgi 1 Jul 2011 06:54:03 -0000 1.44
+++ config-view.cgi 15 Sep 2011 10:18:55 -0000 1.45
@@ -16,6 +16,38 @@
% }
%
% }
+% 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 @@
% 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 @@
</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 @@
<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 @@
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;
Index: config-process.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/config/config-process.cgi,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -w -d -r1.28 -r1.29
--- config-process.cgi 16 Jun 2011 20:21:41 -0000 1.28
+++ config-process.cgi 15 Sep 2011 10:18:54 -0000 1.29
@@ -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 $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'));
More information about the freeside-commits
mailing list