show labels for select(select_hash) config options, RT#3997
[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               <td bgcolor='#ffffff'>
73                 <% $conf->exists($i->key, $agentnum)
74                      ? '<img src="config-image.cgi?key='.      $i->key.
75                                                  ';agentnum='. $agentnum. '">'
76                      : 'empty'
77                 %>
78               </td>
79             </tr>
80             <tr>
81               <td>
82                 <% $conf->exists($i->key, $agentnum)
83                      ? qq!<a href="config-download.cgi?key=!. $i->key. ';agentnum='. $agentnum. qq!">download</a>!
84                      : ''
85                 %>
86               </td>
87             </tr>
88
89 %   } elsif ( $type eq 'binary' ) {
90
91             <tr>
92               <td>
93                 <% $conf->exists($i->key, $agentnum)
94                      ? qq!<a href="config-download.cgi?key=!. $i->key. ';agentnum='. $agentnum. qq!">download</a>!
95                      : 'empty'
96                 %>
97               </td>
98             </tr>
99
100 %   } elsif (    $type eq 'textarea'
101 %             || $type eq 'editlist'
102 %             || $type eq 'selectmultiple' ) { 
103
104             <tr>
105               <td id="<% $i->key.$n %>" bgcolor="#ffffff">
106 <font size="-2"><pre>
107 <% encode_entities(join("\n",
108      map { length($_) > 88 ? substr($_,0,88).'...' : $_ }
109          $conf->config($i->key, $agentnum)
110    ) )
111 %>
112 </pre></font>
113               </td>
114             </tr>
115
116 %   } elsif ( $type eq 'checkbox' ) {
117
118             <tr>
119               <td id="<% $i->key.$n %>" bgcolor="#<% $conf->exists($i->key, $agentnum) ? '00ff00">YES' : 'ff0000">NO' %></td>
120             </tr>
121
122 %   } elsif ( $type eq 'select' && $i->select_hash ) {
123 %
124 %     my %hash;
125 %     if ( ref($i->select_hash) eq 'ARRAY' ) {
126 %       tie %hash, 'Tie::IxHash', '' => '', @{ $i->select_hash };
127 %     } else {
128 %       tie %hash, 'Tie::IxHash', '' => '', %{ $i->select_hash };
129 %     }
130
131             <tr>
132               <td id="<% $i->key.$n %>" bgcolor="#ffffff">
133                 <% $conf->exists($i->key, $agentnum) ? $hash{ $conf->config($i->key, $agentnum) } : '' %>
134               </td>
135             </tr>
136
137 %   } elsif ( $type eq 'text' || $type eq 'select' ) {
138
139             <tr>
140               <td id="<% $i->key.$n %>" bgcolor="#ffffff">
141                 <% $conf->exists($i->key, $agentnum) ? $conf->config($i->key, $agentnum) : '' %>
142               </td>
143             </tr>
144
145 %   } elsif ( $type eq 'select-sub' ) { 
146
147             <tr>
148               <td id="<% $i->key.$n %>" bgcolor="#ffffff">
149                 <% $conf->config($i->key, $agentnum) %>: 
150                 <% &{ $i->option_sub }( $conf->config($i->key, $agentnum) ) %>
151               </td>
152             </tr>
153
154 %   } else { 
155
156             <tr><td>
157               <font color="#ff0000">unknown type <% $type %></font>
158             </td></tr>
159 %   } 
160 %   $n++;
161 % } 
162
163       </table></td>
164     </tr>
165 % } 
166
167   </table><br><br>
168 % } 
169
170
171 </body></html>
172 <%init>
173
174 die "access denied"
175   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
176
177 my $agentnum = '';
178 my $title;
179 my @menubar = ();
180 if ($cgi->param('agentnum') =~ /^(\d+)$/) {
181   $agentnum = $1;
182   my $agent = qsearchs('agent', { 'agentnum' => $agentnum } );
183   die "Agent $agentnum not found!" unless $agent;
184
185   push @menubar, 'View all agents' => $p.'browse/agent.cgi';
186   $title = 'Agent Configuration for '. $agent->agent;
187 } else {
188   $title = 'Global Configuration';
189 }
190
191 my $conf = new FS::Conf;
192  
193 my @config_items = grep { $agentnum ? $_->per_agent : 1 }
194                    grep { $_->key != ~/^invoice_(html|latex|template)/ }
195                         $conf->config_items; 
196
197 my @sections = qw(required billing username password UI session shell BIND );
198 push @sections, '', 'deprecated';
199
200 my %section_items = ();
201 foreach my $section (@sections) {
202   $section_items{$section} = [ grep $_->section eq $section, @config_items ];
203 }
204
205 @sections = grep scalar( @{ $section_items{$_} } ), @sections;
206
207 </%init>