add eps preview to config, for RT#5025
[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 %   } elsif ( $type eq 'checkbox' ) {
116
117             <tr>
118               <td id="<% $i->key.$n %>" bgcolor="#<% $conf->exists($i->key, $agentnum) ? '00ff00">YES' : 'ff0000">NO' %></td>
119             </tr>
120 %   } elsif ( $type eq 'text' || $type eq 'select' ) {
121
122             <tr>
123               <td id="<% $i->key.$n %>" bgcolor="#ffffff">
124                 <% $conf->exists($i->key, $agentnum) ? $conf->config($i->key, $agentnum) : '' %>
125               </td></tr>
126 %   } elsif ( $type eq 'select-sub' ) { 
127
128             <tr>
129               <td id="<% $i->key.$n %>" bgcolor="#ffffff">
130                 <% $conf->config($i->key, $agentnum) %>: 
131                 <% &{ $i->option_sub }( $conf->config($i->key, $agentnum) ) %>
132               </td>
133             </tr>
134 %   } else { 
135
136             <tr><td>
137               <font color="#ff0000">unknown type <% $type %></font>
138             </td></tr>
139 %   } 
140 %   $n++;
141 % } 
142
143       </table></td>
144     </tr>
145 % } 
146
147   </table><br><br>
148 % } 
149
150
151 </body></html>
152 <%init>
153
154 die "access denied"
155   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
156
157 my $agentnum = '';
158 my $title;
159 my @menubar = ();
160 if ($cgi->param('agentnum') =~ /^(\d+)$/) {
161   $agentnum = $1;
162   my $agent = qsearchs('agent', { 'agentnum' => $agentnum } );
163   die "Agent $agentnum not found!" unless $agent;
164
165   push @menubar, 'View all agents' => $p.'browse/agent.cgi';
166   $title = 'Agent Configuration for '. $agent->agent;
167 } else {
168   $title = 'Global Configuration';
169 }
170
171 my $conf = new FS::Conf;
172  
173 my @config_items = grep { $agentnum ? $_->per_agent : 1 }
174                    grep { $_->key != ~/^invoice_(html|latex|template)/ }
175                         $conf->config_items; 
176
177 my @sections = qw(required billing username password UI session shell BIND );
178 push @sections, '', 'deprecated';
179
180 my %section_items = ();
181 foreach my $section (@sections) {
182   $section_items{$section} = [ grep $_->section eq $section, @config_items ];
183 }
184
185 @sections = grep scalar( @{ $section_items{$_} } ), @sections;
186
187 </%init>