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" enctype="multipart/form-data" 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 'binary' ) {
67 Filename <input type="file" name="<% $i->key. $n %>">
68 % } elsif ( $type eq 'textarea' ) {
71 <textarea name="<% $i->key. $n %>" rows=5><% "\n". join("\n", $conf->config($i->key) ) %></textarea>
72 % } elsif ( $type eq 'checkbox' ) {
75 <input name="<% $i->key. $n %>" type="checkbox" value="1"<% $conf->exists($i->key) ? ' CHECKED' : '' %>>
76 % } elsif ( $type eq 'text' ) {
79 <input name="<% $i->key. $n %>" type="<% $type %>" value="<% $conf->exists($i->key) ? $conf->config($i->key) : '' %>">
80 % } elsif ( $type eq 'select' || $type eq 'selectmultiple' ) {
83 <select name="<% $i->key. $n %>" <% $type eq 'selectmultiple' ? 'MULTIPLE' : '' %>>
86 % if ( $i->select_enum ) {
87 % tie %hash, 'Tie::IxHash',
88 % '' => '', map { $_ => $_ } @{ $i->select_enum };
89 % } elsif ( $i->select_hash ) {
90 % if ( ref($i->select_hash) eq 'ARRAY' ) {
91 % tie %hash, 'Tie::IxHash',
92 % '' => '', @{ $i->select_hash };
94 % tie %hash, 'Tie::IxHash',
95 % '' => '', %{ $i->select_hash };
98 % %hash = ( '' => 'WARNING: neither select_enum nor select_hash specified in Conf.pm for configuration option "'. $i->key. '"' );
102 % foreach my $value ( keys %hash ) {
103 % local($^W)=0; next if $saw{$value}++;
104 % my $label = $hash{$value};
108 <option value="<% $value %>"<% $value eq $conf->config($i->key) || ( $type eq 'selectmultiple' && grep { $_ eq $value } $conf->config($i->key) ) ? ' SELECTED' : '' %>><% $label %>
110 % my $curvalue = $conf->config($i->key);
111 % if ( $conf->exists($i->key) && $curvalue
112 % && ! $hash{$curvalue}
117 <option value="<% $conf->config($i->key) %>" SELECTED><% exists( $hash{ $conf->config($i->key) } ) ? $hash{ $conf->config($i->key) } : $conf->config($i->key) %>
122 % } elsif ( $type eq 'select-sub' ) {
125 <select name="<% $i->key. $n %>">
127 % my %options = &{$i->options_sub};
128 % my @options = sort { $a <=> $b } keys %options;
130 % foreach my $value ( @options ) {
131 % local($^W)=0; next if $saw{$value}++;
134 <option value="<% $value %>"<% $value eq $conf->config($i->key) ? ' SELECTED' : '' %>><% $value %>: <% $options{$value} %>
136 % if ( $conf->exists($i->key) && $conf->config($i->key) && ! exists $options{$conf->config($i->key)} ) {
138 <option value=<% $conf->config($i->key) %> SELECTED><% $conf->config($i->key) %>: <% &{ $i->option_sub }( $conf->config($i->key) ) %>
142 % } elsif ( $type eq 'editlist' ) {
146 function doremove<% $i->key. $n %>() {
147 fromObject = document.OneTrueForm.<% $i->key. $n %>;
148 for (var i=fromObject.options.length-1;i>-1;i--) {
149 if (fromObject.options[i].selected)
150 deleteOption<% $i->key. $n %>(fromObject,i);
153 function deleteOption<% $i->key. $n %>(object,index) {
154 object.options[index] = null;
156 function selectall<% $i->key. $n %>() {
157 fromObject = document.OneTrueForm.<% $i->key. $n %>;
158 for (var i=fromObject.options.length-1;i>-1;i--) {
159 fromObject.options[i].selected = true;
162 function doadd<% $i->key. $n %>(object) {
164 % if ( defined($i->editlist_parts) ) {
165 % foreach my $pnum ( 0 .. scalar(@{$i->editlist_parts})-1 ) {
168 if ( myvalue != "" ) { myvalue = myvalue + " "; }
169 % if ( $i->editlist_parts->[$pnum]{type} eq 'select' ) {
171 myvalue = myvalue + object.add<% $i->key. $n . "_$pnum" %>.options[object.add<% $i->key. $n . "_$pnum" %>.selectedIndex].value;
172 <!-- #RESET SELECT?? maybe not... -->
173 % } elsif ( $i->editlist_parts->[$pnum]{type} eq 'immutable' ) {
175 myvalue = myvalue + object.add<% $i->key. $n . "_$pnum" %>.value;
178 myvalue = myvalue + object.add<% $i->key. $n . "_$pnum" %>.value;
179 object.add<% $i->key. $n. "_$pnum" %>.value = "";
184 myvalue = object.add<% $i->key. $n. "_1" %>.value;
187 var optionName = new Option(myvalue, myvalue);
188 var length = object.<% $i->key. $n %>.length;
189 object.<% $i->key. $n %>.options[length] = optionName;
192 <select multiple size=5 name="<% $i->key. $n %>">
193 <option selected>----------------------------------------------------------------</option>
194 % foreach my $line ( $conf->config($i->key) ) {
196 <option value="<% $line %>"><% $line %></option>
200 <input type="button" value="remove selected" onClick="doremove<% $i->key. $n %>()">
201 <script>SafeAddOnLoad(doremove<% $i->key. $n %>);
202 SafeAddOnSubmit(selectall<% $i->key. $n %>);</script>
205 % if ( defined $i->editlist_parts ) {
206 % my $pnum=0; foreach my $part ( @{$i->editlist_parts} ) {
209 % if ( $part->{type} eq 'text' ) {
211 <input type="text" name="add<% $i->key. $n."_$pnum" %>">
212 % } elsif ( $part->{type} eq 'immutable' ) {
214 <% $part->{value} %><input type="hidden" name="add<% $i->key. $n. "_$pnum" %>" value="<% $part->{value} %>">
215 % } elsif ( $part->{type} eq 'select' ) {
217 <select name="add<% $i->key. $n. "_$pnum" %>">
218 % foreach my $key ( keys %{$part->{select_enum}} ) {
220 <option value="<% $key %>"><% $part->{select_enum}{$key} %></option>
226 <font color="#ff0000">unknown type <% $part->type %></font>
233 <td><input type="text" name="add<% $i->key. $n %>_0"></td>
236 <td><input type="button" value="add" onClick="doadd<% $i->key. $n %>(this.form)"></td>
241 <font color="#ff0000">unknown type <% $type %></font>
246 <td><a name="<% $i->key %>">
247 <b><% $i->key %></b> - <% $i->description %>
254 You may need to restart Apache and/or freeside-queued for configuration
255 changes to take effect.<br>
257 <input type="submit" value="Apply changes"><br><br>
266 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');