2 <%= header('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 '' ) { %>
58 <font color="#ff0000">no type</font>
59 <% } elsif ( $type eq 'textarea' ) { %>
60 <textarea name="<%= $i->key. $n %>" rows=5><%= "\n". join("\n", $conf->config($i->key) ) %></textarea>
61 <% } elsif ( $type eq 'checkbox' ) { %>
62 <input name="<%= $i->key. $n %>" type="checkbox" value="1"<%= $conf->exists($i->key) ? ' CHECKED' : '' %>>
63 <% } elsif ( $type eq 'text' ) { %>
64 <input name="<%= $i->key. $n %>" type="<%= $type %>" value="<%= $conf->exists($i->key) ? $conf->config($i->key) : '' %>">
65 <% } elsif ( $type eq 'select' || $type eq 'selectmultiple' ) { %>
66 <select name="<%= $i->key. $n %>" <%= $type eq 'selectmultiple' ? 'MULTIPLE' : '' %>>
68 foreach my $value ( "", @{$i->select_enum} ) {
69 local($^W)=0; next if $saw{$value}++; %>
70 <option value="<%= $value %>"<%= $value eq $conf->config($i->key) || ( $type eq 'selectmultiple' && grep { $_ eq $value } $conf->config($i->key) ) ? ' SELECTED' : '' %>><%= $value %>
72 <% if ( $conf->exists($i->key) && $conf->config($i->key) && ! grep { $conf->config($i->key) eq $_ } @{$i->select_enum}) { %>
73 <option value=<%= $conf->config($i->key) %> SELECTED><%= $conf->config($i->key) %>
76 <% } elsif ( $type eq 'select-sub' ) { %>
77 <select name="<%= $i->key. $n %>">
79 <% my %options = &{$i->options_sub};
80 my @options = sort { $a <=> $b } keys %options;
82 foreach my $value ( @options ) {
83 local($^W)=0; next if $saw{$value}++;
85 <option value="<%= $value %>"<%= $value eq $conf->config($i->key) ? ' SELECTED' : '' %>><%= $value %>: <%= $options{$value} %>
87 <% if ( $conf->exists($i->key) && $conf->config($i->key) && ! exists $options{$conf->config($i->key)} ) { %>
88 <option value=<%= $conf->config($i->key) %> SELECTED><%= $conf->config($i->key) %>: <%= &{ $i->option_sub }( $conf->config($i->key) ) %>
91 <% } elsif ( $type eq 'editlist' ) { %>
93 function doremove<%= $i->key. $n %>() {
94 fromObject = document.OneTrueForm.<%= $i->key. $n %>;
95 for (var i=fromObject.options.length-1;i>-1;i--) {
96 if (fromObject.options[i].selected)
97 deleteOption<%= $i->key. $n %>(fromObject,i);
100 function deleteOption<%= $i->key. $n %>(object,index) {
101 object.options[index] = null;
103 function selectall<%= $i->key. $n %>() {
104 fromObject = document.OneTrueForm.<%= $i->key. $n %>;
105 for (var i=fromObject.options.length-1;i>-1;i--) {
106 fromObject.options[i].selected = true;
109 function doadd<%= $i->key. $n %>(object) {
111 <% if ( defined($i->editlist_parts) ) { %>
113 <% foreach my $pnum ( 0 .. scalar(@{$i->editlist_parts})-1 ) { %>
115 if ( myvalue != "" ) { myvalue = myvalue + " "; }
116 <% if ( $i->editlist_parts->[$pnum]{type} eq 'select' ) { %>
117 myvalue = myvalue + object.add<%= $i->key. $n . "_$pnum" %>.options[object.add<%= $i->key. $n . "_$pnum" %>.selectedIndex].value;
118 <!-- #RESET SELECT?? maybe not... -->
119 <% } elsif ( $i->editlist_parts->[$pnum]{type} eq 'immutable' ) { %>
120 myvalue = myvalue + object.add<%= $i->key. $n . "_$pnum" %>.value;
122 myvalue = myvalue + object.add<%= $i->key. $n . "_$pnum" %>.value;
123 object.add<%= $i->key. $n. "_$pnum" %>.value = "";
129 myvalue = object.add<%= $i->key. $n. "_1" %>.value;
131 var optionName = new Option(myvalue, myvalue);
132 var length = object.<%= $i->key. $n %>.length;
133 object.<%= $i->key. $n %>.options[length] = optionName;
136 <select multiple size=5 name="<%= $i->key. $n %>">
137 <option selected>----------------------------------------------------------------</option>
138 <% foreach my $line ( $conf->config($i->key) ) { %>
139 <option value="<%= $line %>"><%= $line %></option>
142 <input type="button" value="remove selected" onClick="doremove<%= $i->key. $n %>()">
143 <script>SafeAddOnLoad(doremove<%= $i->key. $n %>);
144 SafeAddOnSubmit(selectall<%= $i->key. $n %>);</script>
147 <% if ( defined $i->editlist_parts ) { %>
148 <% my $pnum=0; foreach my $part ( @{$i->editlist_parts} ) { %>
150 <% if ( $part->{type} eq 'text' ) { %>
151 <input type="text" name="add<%= $i->key. $n."_$pnum" %>">
152 <% } elsif ( $part->{type} eq 'immutable' ) { %>
153 <%= $part->{value} %><input type="hidden" name="add<%= $i->key. $n. "_$pnum" %>" value="<%= $part->{value} %>">
154 <% } elsif ( $part->{type} eq 'select' ) { %>
155 <select name="add<%= $i->key. $n. "_$pnum" %>">
156 <% foreach my $key ( keys %{$part->{select_enum}} ) { %>
157 <option value="<%= $key %>"><%= $part->{select_enum}{$key} %></option>
161 <font color="#ff0000">unknown type <%= $part->type %></font>
166 <td><input type="text" name="add<%= $i->key. $n %>_0"></td>
168 <td><input type="button" value="add" onClick="doadd<%= $i->key. $n %>(this.form)"></td>
171 <font color="#ff0000">unknown type <%= $type %></font>
175 <td><a name="<%= $i->key %>">
176 <b><%= $i->key %></b> - <%= $i->description %>
182 You may need to restart Apache and/or freeside-queued for configuration
183 changes to take effect.<br>
185 <input type="submit" value="Apply changes"><br><br>