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++)
22 % my $conf = new FS::Conf; my @config_items = $conf->config_items;
25 <form name="OneTrueForm" action="config-process.cgi" METHOD="POST" onSubmit="SafeOnsubmit()">
26 % foreach my $section ( qw(required billing username password UI session
31 <A NAME="<% $section || 'unclassified' %>"></A>
33 % foreach my $nav_section ( qw(required billing username password UI session
37 % if ( $section eq $nav_section ) {
39 [<A NAME="not<% $nav_section || 'unclassified' %>" style="background-color: #cccccc"><% ucfirst($nav_section || 'unclassified') %></A>]
42 [<A HREF="#<% $nav_section || 'unclassified' %>"><% ucfirst($nav_section || 'unclassified') %></A>]
47 <% table("#cccccc", 2) %>
49 <th colspan="2" bgcolor="#dcdcdc">
50 <% ucfirst($section || 'unclassified') %> configuration options
53 % foreach my $i (grep $_->section eq $section, @config_items) {
58 % foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) {
59 % #warn $i->key unless defined($type);
61 % if ( $type eq '' ) {
64 <font color="#ff0000">no type</font>
65 % } elsif ( $type eq 'textarea' ) {
68 <textarea name="<% $i->key. $n %>" rows=5><% "\n". join("\n", $conf->config($i->key) ) %></textarea>
69 % } elsif ( $type eq 'checkbox' ) {
72 <input name="<% $i->key. $n %>" type="checkbox" value="1"<% $conf->exists($i->key) ? ' CHECKED' : '' %>>
73 % } elsif ( $type eq 'text' ) {
76 <input name="<% $i->key. $n %>" type="<% $type %>" value="<% $conf->exists($i->key) ? $conf->config($i->key) : '' %>">
77 % } elsif ( $type eq 'select' || $type eq 'selectmultiple' ) {
80 <select name="<% $i->key. $n %>" <% $type eq 'selectmultiple' ? 'MULTIPLE' : '' %>>
83 % if ( $i->select_enum ) {
84 % tie %hash, 'Tie::IxHash',
85 % '' => '', map { $_ => $_ } @{ $i->select_enum };
86 % } elsif ( $i->select_hash ) {
87 % if ( ref($i->select_hash) eq 'ARRAY' ) {
88 % tie %hash, 'Tie::IxHash',
89 % '' => '', @{ $i->select_hash };
91 % tie %hash, 'Tie::IxHash',
92 % '' => '', %{ $i->select_hash };
95 % %hash = ( '' => 'WARNING: neither select_enum nor select_hash specified in Conf.pm for configuration option "'. $i->key. '"' );
99 % foreach my $value ( keys %hash ) {
100 % local($^W)=0; next if $saw{$value}++;
101 % my $label = $hash{$value};
105 <option value="<% $value %>"<% $value eq $conf->config($i->key) || ( $type eq 'selectmultiple' && grep { $_ eq $value } $conf->config($i->key) ) ? ' SELECTED' : '' %>><% $label %>
107 % my $curvalue = $conf->config($i->key);
108 % if ( $conf->exists($i->key) && $curvalue
109 % && ! $hash{$curvalue}
114 <option value="<% $conf->config($i->key) %>" SELECTED><% exists( $hash{ $conf->config($i->key) } ) ? $hash{ $conf->config($i->key) } : $conf->config($i->key) %>
119 % } elsif ( $type eq 'select-sub' ) {
122 <select name="<% $i->key. $n %>">
124 % my %options = &{$i->options_sub};
125 % my @options = sort { $a <=> $b } keys %options;
127 % foreach my $value ( @options ) {
128 % local($^W)=0; next if $saw{$value}++;
131 <option value="<% $value %>"<% $value eq $conf->config($i->key) ? ' SELECTED' : '' %>><% $value %>: <% $options{$value} %>
133 % if ( $conf->exists($i->key) && $conf->config($i->key) && ! exists $options{$conf->config($i->key)} ) {
135 <option value=<% $conf->config($i->key) %> SELECTED><% $conf->config($i->key) %>: <% &{ $i->option_sub }( $conf->config($i->key) ) %>
139 % } elsif ( $type eq 'editlist' ) {
143 function doremove<% $i->key. $n %>() {
144 fromObject = document.OneTrueForm.<% $i->key. $n %>;
145 for (var i=fromObject.options.length-1;i>-1;i--) {
146 if (fromObject.options[i].selected)
147 deleteOption<% $i->key. $n %>(fromObject,i);
150 function deleteOption<% $i->key. $n %>(object,index) {
151 object.options[index] = null;
153 function selectall<% $i->key. $n %>() {
154 fromObject = document.OneTrueForm.<% $i->key. $n %>;
155 for (var i=fromObject.options.length-1;i>-1;i--) {
156 fromObject.options[i].selected = true;
159 function doadd<% $i->key. $n %>(object) {
161 % if ( defined($i->editlist_parts) ) {
162 % foreach my $pnum ( 0 .. scalar(@{$i->editlist_parts})-1 ) {
165 if ( myvalue != "" ) { myvalue = myvalue + " "; }
166 % if ( $i->editlist_parts->[$pnum]{type} eq 'select' ) {
168 myvalue = myvalue + object.add<% $i->key. $n . "_$pnum" %>.options[object.add<% $i->key. $n . "_$pnum" %>.selectedIndex].value;
169 <!-- #RESET SELECT?? maybe not... -->
170 % } elsif ( $i->editlist_parts->[$pnum]{type} eq 'immutable' ) {
172 myvalue = myvalue + object.add<% $i->key. $n . "_$pnum" %>.value;
175 myvalue = myvalue + object.add<% $i->key. $n . "_$pnum" %>.value;
176 object.add<% $i->key. $n. "_$pnum" %>.value = "";
181 myvalue = object.add<% $i->key. $n. "_1" %>.value;
184 var optionName = new Option(myvalue, myvalue);
185 var length = object.<% $i->key. $n %>.length;
186 object.<% $i->key. $n %>.options[length] = optionName;
189 <select multiple size=5 name="<% $i->key. $n %>">
190 <option selected>----------------------------------------------------------------</option>
191 % foreach my $line ( $conf->config($i->key) ) {
193 <option value="<% $line %>"><% $line %></option>
197 <input type="button" value="remove selected" onClick="doremove<% $i->key. $n %>()">
198 <script>SafeAddOnLoad(doremove<% $i->key. $n %>);
199 SafeAddOnSubmit(selectall<% $i->key. $n %>);</script>
202 % if ( defined $i->editlist_parts ) {
203 % my $pnum=0; foreach my $part ( @{$i->editlist_parts} ) {
206 % if ( $part->{type} eq 'text' ) {
208 <input type="text" name="add<% $i->key. $n."_$pnum" %>">
209 % } elsif ( $part->{type} eq 'immutable' ) {
211 <% $part->{value} %><input type="hidden" name="add<% $i->key. $n. "_$pnum" %>" value="<% $part->{value} %>">
212 % } elsif ( $part->{type} eq 'select' ) {
214 <select name="add<% $i->key. $n. "_$pnum" %>">
215 % foreach my $key ( keys %{$part->{select_enum}} ) {
217 <option value="<% $key %>"><% $part->{select_enum}{$key} %></option>
223 <font color="#ff0000">unknown type <% $part->type %></font>
230 <td><input type="text" name="add<% $i->key. $n %>_0"></td>
233 <td><input type="button" value="add" onClick="doadd<% $i->key. $n %>(this.form)"></td>
238 <font color="#ff0000">unknown type <% $type %></font>
243 <td><a name="<% $i->key %>">
244 <b><% $i->key %></b> - <% $i->description %>
251 You may need to restart Apache and/or freeside-queued for configuration
252 changes to take effect.<br>
254 <input type="submit" value="Apply changes"><br><br>