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