rest of per-agent config for company_name, company_address, logo, etc.. RT#3989
[freeside.git] / httemplate / config / config-view.cgi
1 <% include("/elements/header.html", $title, menubar(@menubar)) %>
2
3 Click on a configuration value to change it.
4 <BR><BR>
5
6 <% include('/elements/init_overlib.html') %>
7
8 % if ($FS::UID::use_confcompat) {
9   <FONT SIZE="+1" COLOR="#ff0000">CONFIGURATION NOT STORED IN DATABASE -- USING COMPATIBILITY MODE</FONT><BR><BR>
10 %}
11
12 % foreach my $section (@sections) {
13
14     <A NAME="<% $section || 'unclassified' %>"></A>
15     <FONT SIZE="-2">
16
17 %   foreach my $nav_section (@sections) {
18 %
19 %     if ( $section eq $nav_section ) { 
20         [<A NAME="not<% $nav_section || 'unclassified' %>" style="background-color: #cccccc"><% ucfirst($nav_section || 'unclassified') %></A>]
21 %     } else { 
22         [<A HREF="#<% $nav_section || 'unclassified' %>"><% ucfirst($nav_section || 'unclassified') %></A>]
23 %     } 
24 %
25 %   } 
26
27   </FONT><BR>
28   <TABLE BGCOLOR="#cccccc" BORDER=1 CELLSPACING=0 CELLPADDING=0 BORDERCOLOR="#999999">
29   <tr>
30     <th colspan="2" bgcolor="#dcdcdc">
31       <% ucfirst($section || 'unclassified') %> configuration options
32     </th>
33   </tr>
34 % foreach my $i (@{ $section_items{$section} }) { 
35 %   my @types = ref($i->type) ? @{$i->type} : ($i->type);
36 %   my( $width, $height ) = ( 522, 336 );
37 %   if ( grep $_ eq 'textarea', @types ) {
38 %     #800x600
39 %     $width = 763;
40 %     $height = 408;
41 %     #1024x768
42 %     #$width =
43 %     #$height = 
44 %   }
45
46     <tr>
47       <td><% include('/elements/popup_link.html',
48                        'action'      => 'config.cgi?key='.      $i->key.
49                                                   ';agentnum='. $agentnum,
50                        'width'       => $width,
51                        'height'      => $height,
52                        'actionlabel' => 'Enter configuration value',
53                        'label'       => '<b>'. $i->key. '</b>',
54                        'aname'       => $i->key,
55                     )
56           %>: <% $i->description %>
57       </td>
58       <td><table border=0>
59
60 % my $n = 0;
61 % foreach my $type (@types) {
62
63 %   if ( $type eq '' ) { 
64
65             <tr>
66               <td><font color="#ff0000">no type</font></td>
67             </tr>
68
69 %   } elsif (   $type eq 'image' ) {
70
71             <tr>
72
73               <% $conf->exists($i->key, $agentnum)
74                    ? '<img src="config-image.cgi?key='.      $i->key.
75                                                ';agentnum='. $agentnum. '">'
76                    : 'empty'
77               %>
78             </tr>
79
80 %   } elsif (   $type eq 'binary' ) {
81
82             <tr>
83
84               <% $conf->exists($i->key, $agentnum)
85                    ? qq!<a href="config-download.cgi?key=!. $i->key. ';agentnum='. $agentnum. qq!">download</a>!
86                    : 'empty'
87               %>
88             </tr>
89
90 %   } elsif (    $type eq 'textarea'
91 %             || $type eq 'editlist'
92 %             || $type eq 'selectmultiple' ) { 
93
94             <tr>
95               <td id="<% $i->key.$n %>" bgcolor="#ffffff">
96 <font size="-2"><pre>
97 <% encode_entities(join("\n",
98      map { length($_) > 88 ? substr($_,0,88).'...' : $_ }
99          $conf->config($i->key, $agentnum)
100    ) )
101 %>
102 </pre></font>
103               </td>
104             </tr>
105 %   } elsif ( $type eq 'checkbox' ) {
106
107             <tr>
108               <td id="<% $i->key.$n %>" bgcolor="#<% $conf->exists($i->key, $agentnum) ? '00ff00">YES' : 'ff0000">NO' %></td>
109             </tr>
110 %   } elsif ( $type eq 'text' || $type eq 'select' ) {
111
112             <tr>
113               <td id="<% $i->key.$n %>" bgcolor="#ffffff">
114                 <% $conf->exists($i->key, $agentnum) ? $conf->config($i->key, $agentnum) : '' %>
115               </td></tr>
116 %   } elsif ( $type eq 'select-sub' ) { 
117
118             <tr>
119               <td id="<% $i->key.$n %>" bgcolor="#ffffff">
120                 <% $conf->config($i->key, $agentnum) %>: 
121                 <% &{ $i->option_sub }( $conf->config($i->key, $agentnum) ) %>
122               </td>
123             </tr>
124 %   } else { 
125
126             <tr><td>
127               <font color="#ff0000">unknown type <% $type %></font>
128             </td></tr>
129 %   } 
130 %   $n++;
131 % } 
132
133       </table></td>
134     </tr>
135 % } 
136
137   </table><br><br>
138 % } 
139
140
141 </body></html>
142 <%init>
143
144 die "access denied"
145   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
146
147 my $agentnum = '';
148 my $title;
149 my @menubar = ();
150 if ($cgi->param('agentnum') =~ /^(\d+)$/) {
151   $agentnum = $1;
152   my $agent = qsearchs('agent', { 'agentnum' => $agentnum } );
153   die "Agent $agentnum not found!" unless $agent;
154
155   push @menubar, 'View all agents' => $p.'browse/agent.cgi';
156   $title = 'Agent Configuration for '. $agent->agent;
157 } else {
158   $title = 'Global Configuration';
159 }
160
161 my $conf = new FS::Conf;
162  
163 my @config_items = grep { $agentnum ? $_->per_agent : 1 }
164                    grep { $_->key != ~/^invoice_(html|latex|template)/ }
165                         $conf->config_items; 
166
167 my @sections = qw(required billing username password UI session shell BIND );
168 push @sections, '', 'deprecated';
169
170 my %section_items = ();
171 foreach my $section (@sections) {
172   $section_items{$section} = [ grep $_->section eq $section, @config_items ];
173 }
174
175 @sections = grep scalar( @{ $section_items{$_} } ), @sections;
176
177 </%init>