move config edit popup to elements/popup_link.html
[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 <SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/overlibmws.js"></SCRIPT>
13 <SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/overlibmws_iframe.js"></SCRIPT>
14 <SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/overlibmws_draggable.js"></SCRIPT>
15 <SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/iframecontentmws.js"></SCRIPT>
16
17 % if ($FS::UID::use_confcompat) {
18
19   <FONT SIZE="+1" COLOR="#ff0000">CONFIGURATION NOT STORED IN DATABASE -- USING COMPATIBILITY MODE</FONT><BR><BR>
20 %}
21 %
22 % foreach my $section ( qw(required billing username password UI session
23 %                            shell BIND
24 %                           ),
25 %                         '', 'deprecated') { 
26
27   <A NAME="<% $section || 'unclassified' %>"></A>
28   <FONT SIZE="-2">
29 % foreach my $nav_section ( qw(required billing username password UI session
30 %                                  shell BIND
31 %                                 ),
32 %                               '', 'deprecated') { 
33 % if ( $section eq $nav_section ) { 
34
35       [<A NAME="not<% $nav_section || 'unclassified' %>" style="background-color: #cccccc"><% ucfirst($nav_section || 'unclassified') %></A>]
36 % } else { 
37
38       [<A HREF="#<% $nav_section || 'unclassified' %>"><% ucfirst($nav_section || 'unclassified') %></A>]
39 % } 
40 % } 
41
42   </FONT><BR>
43   <TABLE BGCOLOR="#cccccc" BORDER=1 CELLSPACING=0 CELLPADDING=0 BORDERCOLOR="#999999">
44   <tr>
45     <th colspan="2" bgcolor="#dcdcdc">
46       <% ucfirst($section || 'unclassified') %> configuration options
47     </th>
48   </tr>
49 % foreach my $i (grep $_->section eq $section, @config_items) { 
50 %   my @types = ref($i->type) ? @{$i->type} : ($i->type);
51 %   my( $width, $height ) = ( 522, 336 );
52 %   if ( grep $_ eq 'textarea', @types ) {
53 %     #800x600
54 %     $width = 763;
55 %     $height = 408;
56 %     #1024x768
57 %     #$width =
58 %     #$height = 
59 %   }
60
61     <tr>
62       <td><% include('/elements/popup_link.html',
63                        'action'      => 'config.cgi?key='.      $i->key.
64                                                   ';agentnum='. $agentnum,
65                        'width'       => $width,
66                        'height'      => $height,
67                        'actionlabel' => 'Enter configuration value',
68                        'label'       => '<b>'. $i->key. '</b>',
69                        'aname'       => $i->key,
70                     )
71           %>: <% $i->description %>
72       </td>
73       <td><table border=0>
74 % foreach my $type (@types) {
75 %             my $n = 0; 
76 % if ( $type eq '' ) { 
77
78             <tr>
79               <td><font color="#ff0000">no type</font></td>
80             </tr>
81 % } elsif (   $type eq 'binary' ) {
82
83             <tr>
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 % } elsif (   $type eq 'textarea'
90 %                      || $type eq 'editlist'
91 %                      || $type eq 'selectmultiple' ) { 
92
93             <tr>
94               <td bgcolor="#ffffff">
95 <font size="-2"><pre>
96 <% encode_entities(join("\n",
97      map { length($_) > 88 ? substr($_,0,88).'...' : $_ }
98          $conf->config($i->key, $agentnum)
99    ) )
100 %>
101 </pre></font>
102               </td>
103             </tr>
104 % } elsif ( $type eq 'checkbox' ) { 
105
106             <tr>
107               <td bgcolor="#<% $conf->exists($i->key, $agentnum) ? '00ff00">YES' : 'ff0000">NO' %></td>
108             </tr>
109 % } elsif ( $type eq 'text' || $type eq 'select' )  { 
110
111             <tr>
112               <td bgcolor="#ffffff">
113                 <% $conf->exists($i->key, $agentnum) ? $conf->config($i->key, $agentnum) : '' %>
114               </td></tr>
115 % } elsif ( $type eq 'select-sub' ) { 
116
117             <tr>
118               <td bgcolor="#ffffff">
119                 <% $conf->config($i->key, $agentnum) %>: 
120                 <% &{ $i->option_sub }( $conf->config($i->key, $agentnum) ) %>
121               </td>
122             </tr>
123 % } else { 
124
125             <tr><td>
126               <font color="#ff0000">unknown type <% $type %></font>
127             </td></tr>
128 % } 
129 % $n++; } 
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>