1 <% include("/elements/header.html",'Edit Configuration', menubar( 'Main Menu' => $p ) ) %>
3 var gSafeOnload = new Array();
4 var gSafeOnsubmit = new Array();
5 window.onload = SafeOnload;
6 function SafeAddOnLoad(f) {
7 gSafeOnload[gSafeOnload.length] = f;
9 function SafeOnload() {
10 for (var i=0;i<gSafeOnload.length;i++)
13 function SafeAddOnSubmit(f) {
14 gSafeOnsubmit[gSafeOnsubmit.length] = f;
16 function SafeOnsubmit() {
17 for (var i=0;i<gSafeOnsubmit.length;i++)
21 % my $conf = new FS::Conf; my @config_items = $conf->config_items;
24 <form name="OneTrueForm" action="config-process.cgi" METHOD="POST" onSubmit="SafeOnsubmit()">
25 % foreach my $section ( qw(required billing username password UI session
30 <A NAME="<% $section || 'unclassified' %>"></A>
32 % foreach my $nav_section ( qw(required billing username password UI session
36 % if ( $section eq $nav_section ) {
38 [<A NAME="not<% $nav_section || 'unclassified' %>" style="background-color: #cccccc"><% ucfirst($nav_section || 'unclassified') %></A>]
41 [<A HREF="#<% $nav_section || 'unclassified' %>"><% ucfirst($nav_section || 'unclassified') %></A>]
46 <% table("#cccccc", 2) %>
48 <th colspan="2" bgcolor="#dcdcdc">
49 <% ucfirst($section || 'unclassified') %> configuration options
52 % foreach my $i (grep $_->section eq $section, @config_items) {
57 % foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) {
58 % #warn $i->key unless defined($type);
60 % if ( $type eq '' ) {
63 <font color="#ff0000">no type</font>
64 % } elsif ( $type eq 'textarea' ) {
67 <textarea name="<% $i->key. $n %>" rows=5><% "\n". join("\n", $conf->config($i->key) ) %></textarea>
68 % } elsif ( $type eq 'checkbox' ) {
71 <input name="<% $i->key. $n %>" type="checkbox" value="1"<% $conf->exists($i->key) ? ' CHECKED' : '' %>>
72 % } elsif ( $type eq 'text' ) {
75 <input name="<% $i->key. $n %>" type="<% $type %>" value="<% $conf->exists($i->key) ? $conf->config($i->key) : '' %>">
76 % } elsif ( $type eq 'select' || $type eq 'selectmultiple' ) {
79 <select name="<% $i->key. $n %>" <% $type eq 'selectmultiple' ? 'MULTIPLE' : '' %>>
82 % if ( $i->select_enum ) {
83 % tie %hash, 'Tie::IxHash',
84 % '' => '', map { $_ => $_ } @{ $i->select_enum };
85 % } elsif ( $i->select_hash ) {
86 % if ( ref($i->select_hash) eq 'ARRAY' ) {
87 % tie %hash, 'Tie::IxHash',
88 % '' => '', @{ $i->select_hash };
90 % tie %hash, 'Tie::IxHash',
91 % '' => '', %{ $i->select_hash };
94 % %hash = ( '' => 'WARNING: neither select_enum nor select_hash specified in Conf.pm for configuration option "'. $i->key. '"' );
98 % foreach my $value ( keys %hash ) {
99 % local($^W)=0; next if $saw{$value}++;
100 % my $label = $hash{$value};
104 <option value="<% $value %>"<% $value eq $conf->config($i->key) || ( $type eq 'selectmultiple' && grep { $_ eq $value } $conf->config($i->key) ) ? ' SELECTED' : '' %>><% $label %>
106 % my $curvalue = $conf->config($i->key);
107 % if ( $conf->exists($i->key) && $curvalue
108 % && ! $hash{$curvalue}
113 <option value="<% $conf->config($i->key) %>" SELECTED><% exists( $hash{ $conf->config($i->key) } ) ? $hash{ $conf->config($i->key) } : $conf->config($i->key) %>
118 % } elsif ( $type eq 'select-sub' ) {
121 <select name="<% $i->key. $n %>">
123 % my %options = &{$i->options_sub};
124 % my @options = sort { $a <=> $b } keys %options;
126 % foreach my $value ( @options ) {
127 % local($^W)=0; next if $saw{$value}++;
130 <option value="<% $value %>"<% $value eq $conf->config($i->key) ? ' SELECTED' : '' %>><% $value %>: <% $options{$value} %>
132 % if ( $conf->exists($i->key) && $conf->config($i->key) && ! exists $options{$conf->config($i->key)} ) {
134 <option value=<% $conf->config($i->key) %> SELECTED><% $conf->config($i->key) %>: <% &{ $i->option_sub }( $conf->config($i->key) ) %>
138 % } elsif ( $type eq 'editlist' ) {
142 function doremove<% $i->key. $n %>() {
143 fromObject = document.OneTrueForm.<% $i->key. $n %>;
144 for (var i=fromObject.options.length-1;i>-1;i--) {
145 if (fromObject.options[i].selected)
146 deleteOption<% $i->key. $n %>(fromObject,i);
149 function deleteOption<% $i->key. $n %>(object,index) {
150 object.options[index] = null;
152 function selectall<% $i->key. $n %>() {
153 fromObject = document.OneTrueForm.<% $i->key. $n %>;
154 for (var i=fromObject.options.length-1;i>-1;i--) {
155 fromObject.options[i].selected = true;
158 function doadd<% $i->key. $n %>(object) {
160 % if ( defined($i->editlist_parts) ) {
161 % foreach my $pnum ( 0 .. scalar(@{$i->editlist_parts})-1 ) {
164 if ( myvalue != "" ) { myvalue = myvalue + " "; }
165 % if ( $i->editlist_parts->[$pnum]{type} eq 'select' ) {
167 myvalue = myvalue + object.add<% $i->key. $n . "_$pnum" %>.options[object.add<% $i->key. $n . "_$pnum" %>.selectedIndex].value;
168 <!-- #RESET SELECT?? maybe not... -->
169 % } elsif ( $i->editlist_parts->[$pnum]{type} eq 'immutable' ) {
171 myvalue = myvalue + object.add<% $i->key. $n . "_$pnum" %>.value;
174 myvalue = myvalue + object.add<% $i->key. $n . "_$pnum" %>.value;
175 object.add<% $i->key. $n. "_$pnum" %>.value = "";
180 myvalue = object.add<% $i->key. $n. "_1" %>.value;
183 var optionName = new Option(myvalue, myvalue);
184 var length = object.<% $i->key. $n %>.length;
185 object.<% $i->key. $n %>.options[length] = optionName;
188 <select multiple size=5 name="<% $i->key. $n %>">
189 <option selected>----------------------------------------------------------------</option>
190 % foreach my $line ( $conf->config($i->key) ) {
192 <option value="<% $line %>"><% $line %></option>
196 <input type="button" value="remove selected" onClick="doremove<% $i->key. $n %>()">
197 <script>SafeAddOnLoad(doremove<% $i->key. $n %>);
198 SafeAddOnSubmit(selectall<% $i->key. $n %>);</script>
201 % if ( defined $i->editlist_parts ) {
202 % my $pnum=0; foreach my $part ( @{$i->editlist_parts} ) {
205 % if ( $part->{type} eq 'text' ) {
207 <input type="text" name="add<% $i->key. $n."_$pnum" %>">
208 % } elsif ( $part->{type} eq 'immutable' ) {
210 <% $part->{value} %><input type="hidden" name="add<% $i->key. $n. "_$pnum" %>" value="<% $part->{value} %>">
211 % } elsif ( $part->{type} eq 'select' ) {
213 <select name="add<% $i->key. $n. "_$pnum" %>">
214 % foreach my $key ( keys %{$part->{select_enum}} ) {
216 <option value="<% $key %>"><% $part->{select_enum}{$key} %></option>
222 <font color="#ff0000">unknown type <% $part->type %></font>
229 <td><input type="text" name="add<% $i->key. $n %>_0"></td>
232 <td><input type="button" value="add" onClick="doadd<% $i->key. $n %>(this.form)"></td>
237 <font color="#ff0000">unknown type <% $type %></font>
242 <td><a name="<% $i->key %>">
243 <b><% $i->key %></b> - <% $i->description %>
250 You may need to restart Apache and/or freeside-queued for configuration
251 changes to take effect.<br>
253 <input type="submit" value="Apply changes"><br><br>
262 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');