+<%once>
+#false laziness w/config-process.cgi
+my %namecol = (
+ 'part_svc' => 'svc',
+ 'part_pkg' => 'pkg',
+ 'pkg_class' => 'classname',
+ 'agent' => 'agent',
+);
+</%once>
+<%init>
+
+my $curuser = $FS::CurrentUser::CurrentUser;
+
+die "access denied" unless $curuser->access_right('Configuration');
+
+my $page_agent = '';
+my $title;
+my @menubar = ();
+if ($cgi->param('agentnum') =~ /^(\d+)$/) {
+ my $page_agentnum = $1;
+ $page_agent = qsearchs('agent', { 'agentnum' => $page_agentnum } );
+ 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;
+} elsif ( $cgi->param('showagent') ) {
+ $title = 'Agent Configuration Overrides'
+} else {
+ $title = 'Global Configuration';
+}
+
+my $show_over = $page_agent || $cgi->param('showagent');
+
+my @config_items = grep { !defined($locale) or $_->per_locale }
+ grep { $show_over ? $_->per_agent : 1 }
+ grep { $show_over ? 1 : !$_->agentonly }
+ $conf->config_items;
+
+my @deleteable = qw( invoice_latexreturnaddress invoice_htmlreturnaddress );
+my %deleteable = map { $_ => 1 } @deleteable;
+
+my @sections = (qw(
+ important
+ billing payments payment_batching credit_cards e-checks taxation
+ packages suspension cancellation
+ printing print_services email_to_voice_services
+ invoicing invoice_email invoice_balances invoice_templates quotations
+ notification UI addresses customer_number customer_fields reporting
+ localization scalability backup
+ signup self-service self-service_skinning
+ API ticketing appointments network_monitoring
+ services
+ username password
+ telephony telephony_invoicing RADIUS wireless_broadband shell BIND hosting
+ ), '', qw( development deprecated )
+);
+
+my %section_items = ();
+foreach my $section (@sections) {
+ $section_items{$section} = [ grep $_->section eq $section, @config_items ];
+}
+
+@sections = grep scalar( @{ $section_items{$_} } ), @sections;
+
+my @all_agents = ();
+if ( $cgi->param('showagent') ) {
+ @all_agents = qsearch('agent', { 'disabled' => '' } );
+}
+
+sub section_title {
+ my $sec = ucfirst(shift || 'misc');
+ $sec =~ s/_/ /;
+ $sec;
+}
+
+</%init>