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