+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
+my $agentnum = '';
+my $title;
+my @menubar = ();
+if ($cgi->param('agentnum') =~ /^(\d+)$/) {
+ $agentnum = $1;
+ my $agent = qsearchs('agent', { 'agentnum' => $agentnum } );
+ die "Agent $agentnum not found!" unless $agent;
+
+ push @menubar, 'View all agents' => $p.'browse/agent.cgi';
+ $title = 'Agent Configuration for '. $agent->agent;
+} else {
+ $title = 'Global Configuration';
+}
+
+my $conf = new FS::Conf;
+
+my @config_items = grep { $agentnum ? $_->per_agent : 1 }
+ grep { $_->key != ~/^invoice_(html|latex|template)/ }
+ $conf->config_items;
+
+my @sections = qw(required billing username password UI session shell BIND );
+push @sections, '', 'deprecated';
+
+my %section_items = ();
+foreach my $section (@sections) {
+ $section_items{$section} = [ grep $_->section eq $section, @config_items ];
+}
+
+@sections = grep scalar( @{ $section_items{$_} } ), @sections;
+
+</%init>