2 <%= include("/elements/header.html",'Edit Configuration', menubar( 'Main Menu' => $p ) ) %>
4 var gSafeOnload = new Array();
5 var gSafeOnsubmit = new Array();
6 window.onload = SafeOnload;
7 function SafeAddOnLoad(f) {
8 gSafeOnload[gSafeOnload.length] = f;
10 function SafeOnload() {
11 for (var i=0;i<gSafeOnload.length;i++)
14 function SafeAddOnSubmit(f) {
15 gSafeOnsubmit[gSafeOnsubmit.length] = f;
17 function SafeOnsubmit() {
18 for (var i=0;i<gSafeOnsubmit.length;i++)
23 <% my $conf = new FS::Conf; my @config_items = $conf->config_items; %>
25 <form name="OneTrueForm" action="config-process.cgi" METHOD="POST" onSubmit="SafeOnsubmit()">
27 <% foreach my $section ( qw(required billing username password UI session
30 '', 'deprecated') { %>
31 <A NAME="<%= $section || 'unclassified' %>"></A>
33 <% foreach my $nav_section ( qw(required billing username password UI session
36 '', 'deprecated') { %>
37 <% if ( $section eq $nav_section ) { %>
38 [<A NAME="not<%= $nav_section || 'unclassified' %>" style="background-color: #cccccc"><%= ucfirst($nav_section || 'unclassified') %></A>]
40 [<A HREF="#<%= $nav_section || 'unclassified' %>"><%= ucfirst($nav_section || 'unclassified') %></A>]
44 <%= table("#cccccc", 2) %>
46 <th colspan="2" bgcolor="#dcdcdc">
47 <%= ucfirst($section || 'unclassified') %> configuration options
50 <% foreach my $i (grep $_->section eq $section, @config_items) { %>
54 foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) {
55 #warn $i->key unless defined($type);
57 <% if ( $type eq '' ) { %>
59 <font color="#ff0000">no type</font>
61 <% } elsif ( $type eq 'textarea' ) { %>
63 <textarea name="<%= $i->key. $n %>" rows=5><%= "\n". join("\n", $conf->config($i->key) ) %></textarea>
65 <% } elsif ( $type eq 'checkbox' ) { %>
67 <input name="<%= $i->key. $n %>" type="checkbox" value="1"<%= $conf->exists($i->key) ? ' CHECKED' : '' %>>
69 <% } elsif ( $type eq 'text' ) { %>
71 <input name="<%= $i->key. $n %>" type="<%= $type %>" value="<%= $conf->exists($i->key) ? $conf->config($i->key) : '' %>">
73 <% } elsif ( $type eq 'select' || $type eq 'selectmultiple' ) { %>
75 <select name="<%= $i->key. $n %>" <%= $type eq 'selectmultiple' ? 'MULTIPLE' : '' %>>
78 if ( $i->select_enum ) {
79 tie %hash, 'Tie::IxHash',
80 '' => '', map { $_ => $_ } @{ $i->select_enum };
81 } elsif ( $i->select_hash ) {
82 if ( ref($i->select_hash) eq 'ARRAY' ) {
83 tie %hash, 'Tie::IxHash',
84 '' => '', @{ $i->select_hash };
86 tie %hash, 'Tie::IxHash',
87 '' => '', %{ $i->select_hash };
90 %hash = ( '' => 'WARNING: neither select_enum nor select_hash specified in Conf.pm for configuration option "'. $i->key. '"' );
94 foreach my $value ( keys %hash ) {
95 local($^W)=0; next if $saw{$value}++;
96 my $label = $hash{$value};
99 <option value="<%= $value %>"<%= $value eq $conf->config($i->key) || ( $type eq 'selectmultiple' && grep { $_ eq $value } $conf->config($i->key) ) ? ' SELECTED' : '' %>><%= $label %>
103 <% my $curvalue = $conf->config($i->key);
104 if ( $conf->exists($i->key) && $curvalue
105 && ! $hash{$curvalue}
109 <option value="<%= $conf->config($i->key) %>" SELECTED><%= exists( $hash{ $conf->config($i->key) } ) ? $hash{ $conf->config($i->key) } : $conf->config($i->key) %>
115 <% } elsif ( $type eq 'select-sub' ) { %>
117 <select name="<%= $i->key. $n %>">
119 <% my %options = &{$i->options_sub};
120 my @options = sort { $a <=> $b } keys %options;
122 foreach my $value ( @options ) {
123 local($^W)=0; next if $saw{$value}++;
125 <option value="<%= $value %>"<%= $value eq $conf->config($i->key) ? ' SELECTED' : '' %>><%= $value %>: <%= $options{$value} %>
127 <% if ( $conf->exists($i->key) && $conf->config($i->key) && ! exists $options{$conf->config($i->key)} ) { %>
128 <option value=<%= $conf->config($i->key) %> SELECTED><%= $conf->config($i->key) %>: <%= &{ $i->option_sub }( $conf->config($i->key) ) %>
132 <% } elsif ( $type eq 'editlist' ) { %>
135 function doremove<%= $i->key. $n %>() {
136 fromObject = document.OneTrueForm.<%= $i->key. $n %>;
137 for (var i=fromObject.options.length-1;i>-1;i--) {
138 if (fromObject.options[i].selected)
139 deleteOption<%= $i->key. $n %>(fromObject,i);
142 function deleteOption<%= $i->key. $n %>(object,index) {
143 object.options[index] = null;
145 function selectall<%= $i->key. $n %>() {
146 fromObject = document.OneTrueForm.<%= $i->key. $n %>;
147 for (var i=fromObject.options.length-1;i>-1;i--) {
148 fromObject.options[i].selected = true;
151 function doadd<%= $i->key. $n %>(object) {
153 <% if ( defined($i->editlist_parts) ) { %>
155 <% foreach my $pnum ( 0 .. scalar(@{$i->editlist_parts})-1 ) { %>
157 if ( myvalue != "" ) { myvalue = myvalue + " "; }
158 <% if ( $i->editlist_parts->[$pnum]{type} eq 'select' ) { %>
159 myvalue = myvalue + object.add<%= $i->key. $n . "_$pnum" %>.options[object.add<%= $i->key. $n . "_$pnum" %>.selectedIndex].value;
160 <!-- #RESET SELECT?? maybe not... -->
161 <% } elsif ( $i->editlist_parts->[$pnum]{type} eq 'immutable' ) { %>
162 myvalue = myvalue + object.add<%= $i->key. $n . "_$pnum" %>.value;
164 myvalue = myvalue + object.add<%= $i->key. $n . "_$pnum" %>.value;
165 object.add<%= $i->key. $n. "_$pnum" %>.value = "";
171 myvalue = object.add<%= $i->key. $n. "_1" %>.value;
173 var optionName = new Option(myvalue, myvalue);
174 var length = object.<%= $i->key. $n %>.length;
175 object.<%= $i->key. $n %>.options[length] = optionName;
178 <select multiple size=5 name="<%= $i->key. $n %>">
179 <option selected>----------------------------------------------------------------</option>
180 <% foreach my $line ( $conf->config($i->key) ) { %>
181 <option value="<%= $line %>"><%= $line %></option>
184 <input type="button" value="remove selected" onClick="doremove<%= $i->key. $n %>()">
185 <script>SafeAddOnLoad(doremove<%= $i->key. $n %>);
186 SafeAddOnSubmit(selectall<%= $i->key. $n %>);</script>
189 <% if ( defined $i->editlist_parts ) { %>
190 <% my $pnum=0; foreach my $part ( @{$i->editlist_parts} ) { %>
192 <% if ( $part->{type} eq 'text' ) { %>
193 <input type="text" name="add<%= $i->key. $n."_$pnum" %>">
194 <% } elsif ( $part->{type} eq 'immutable' ) { %>
195 <%= $part->{value} %><input type="hidden" name="add<%= $i->key. $n. "_$pnum" %>" value="<%= $part->{value} %>">
196 <% } elsif ( $part->{type} eq 'select' ) { %>
197 <select name="add<%= $i->key. $n. "_$pnum" %>">
198 <% foreach my $key ( keys %{$part->{select_enum}} ) { %>
199 <option value="<%= $key %>"><%= $part->{select_enum}{$key} %></option>
203 <font color="#ff0000">unknown type <%= $part->type %></font>
208 <td><input type="text" name="add<%= $i->key. $n %>_0"></td>
210 <td><input type="button" value="add" onClick="doadd<%= $i->key. $n %>(this.form)"></td>
215 <font color="#ff0000">unknown type <%= $type %></font>
221 <td><a name="<%= $i->key %>">
222 <b><%= $i->key %></b> - <%= $i->description %>
228 You may need to restart Apache and/or freeside-queued for configuration
229 changes to take effect.<br>
231 <input type="submit" value="Apply changes"><br><br>