enable CardFortress in test database, #71513
[freeside.git] / httemplate / config / config.cgi
index d58c2f8..50b3eba 100644 (file)
@@ -24,6 +24,7 @@ function SafeOnsubmit() {
 
 <FORM NAME="OneTrueForm" ACTION="config-process.cgi" METHOD="POST" enctype="multipart/form-data" onSubmit="SafeOnsubmit()">
 <INPUT TYPE="hidden" NAME="agentnum" VALUE="<% $agentnum %>">
+<INPUT TYPE="hidden" NAME="locale" VALUE="<% $locale %>">
 <INPUT TYPE="hidden" NAME="key" VALUE="<% $key %>">
 
 Setting <b><% $key %></b>
@@ -39,30 +40,58 @@ Setting <b><% $key %></b>
 <table><tr><td>
 
 % my $n = 0;
+% my $submit = 0;
 % foreach my $type (@types) {
 %   if ( $type eq '' ) {
 
   <font color="#ff0000">no type</font>
 
+%   } elsif ( $type eq 'image' ) { 
+%     $submit++;
+
+  <% $conf->exists($key, $agentnum)
+       ? 'Current image<br>'.
+         '<img src="config-image.cgi?key='.      $key.
+                                   ';agentnum='. $agentnum.
+                                   ';locale='.   $locale .'"><br>'
+       : ''
+  %>
+
+  <BR>
+  New image filename <input type="file" name="<% "$key$n" %>">
+
 %   } elsif ( $type eq 'binary' ) { 
+%     $submit++;
 
   Filename <input type="file" name="<% "$key$n" %>">
 
 %   } elsif ( $type eq 'textarea' ) { 
+%     $submit++;
 
-  <textarea name="<% "$key$n" %>" rows=18 cols=88 wrap="off"><% join("\n", $conf->config($key, $agentnum)) %></textarea>
+  <textarea name="<% "$key$n" %>" rows=12 cols=78 wrap="off"><% join("\n", $conf->config($key, $agentnum)) |h %></textarea>
 
 %   } elsif ( $type eq 'checkbox' ) { 
+%
+%     if ( $agentnum && $conf->exists($key) && ! $agent_bool ) {
 
-  <input name="<% "$key$n" %>" type="checkbox" value="1"
-    <% $conf->exists($key, $agentnum) ? 'CHECKED' : '' %> >
+        <input name="<% "$key$n" %>" type="checkbox" value="1" CHECKED DISABLED>
+        <FONT SIZE="-1"><I>(global setting cannot yet be overridden)</I></FONT>
 
-%   } elsif ( $type eq 'text' )  { 
+%     } else {
+%       $submit++;
+
+        <input name="<% "$key$n" %>" type="checkbox" value="1"
+          <% $conf->config_bool($key, $agentnum) ? 'CHECKED' : '' %> >
+%     }
 
-  <input name="<% "$key$n" %>" type="text" value="<% $conf->exists($key, $agentnum) ? $conf->config($key, $agentnum) : '' %>">
+%   } elsif ( $type eq 'text' )  {
+%     $submit++;
 
-%   } elsif ( $type eq 'select' || $type eq 'selectmultiple' )  { 
+  <input name="<% "$key$n" %>" type="text" value="<% $conf->exists($key, $agentnum) ? $conf->config($key, $agentnum) : '' |h %>">
 
+%   } elsif ( $type eq 'select' || $type eq 'selectmultiple' )  {
+%     $submit++;
   <select name="<% "$key$n" %>" <% $type eq 'selectmultiple' ? 'MULTIPLE' : '' %>>
 
 %
@@ -72,11 +101,9 @@ Setting <b><% $key %></b>
 %         '' => '', map { $_ => $_ } @{ $config_item->select_enum };
 %     } elsif ( $config_item->select_hash ) {
 %       if ( ref($config_item->select_hash) eq 'ARRAY' ) {
-%         tie %hash, 'Tie::IxHash',
-%           '' => '', @{ $config_item->select_hash };
+%         tie %hash, 'Tie::IxHash', '' => '', @{ $config_item->select_hash };
 %       } else {
-%         tie %hash, 'Tie::IxHash',
-%           '' => '', %{ $config_item->select_hash };
+%         tie %hash, 'Tie::IxHash', '' => '', %{ $config_item->select_hash };
 %       }
 %     } else {
 %       %hash = ( '' => 'WARNING: neither select_enum nor select_hash specified in Conf.pm for configuration option "'. $key. '"' );
@@ -119,17 +146,34 @@ Setting <b><% $key %></b>
 
   </select>
 
-%   } elsif ( $type eq 'select-sub' ) { 
+%   } elsif ( $type eq 'select-sub' ) {
+%     $submit++;
 
-  <select name="<% "$key$n" %>"><option value="">
+  <select name="<% "$key$n" %>" <% $config_item->multiple ? 'MULTIPLE' : '' %>>
+
+%     unless ( $config_item->multiple ) {
+        <option value="">
+%     }
 
 %     my %options = &{$config_item->options_sub};
-%     my @options = sort { $a <=> $b } keys %options;
+%     my @options = keys %options;
+%     my $sortsub = $config_item->sort_sub || sub { $a <=> $b };
+%     @options = sort $sortsub @options;
 %     my %saw;
 %     foreach my $value ( @options ) {
 %       local($^W)=0; next if $saw{$value}++;
 
-    <option value="<% $value %>" <% $value eq $conf->config($key, $agentnum) ? 'SELECTED' : '' %>><% $value %>: <% $options{$value} %>
+        <option value="<% $value %>"
+
+%         if ( $value eq $conf->config($key, $agentnum)
+%              || ( $config_item->multiple
+%                   && grep { $_ eq $value } $conf->config($key, $agentnum) ) ){
+
+            SELECTED
+
+%         }
+
+        ><% $value %>: <% $options{$value} %>
 
 %     } 
 %     my $curvalue = $conf->config($key, $agentnum);
@@ -141,8 +185,8 @@ Setting <b><% $key %></b>
 
   </select>
 
-%   } elsif ( $type eq 'editlist' ) { 
-%
+%   } elsif ( $type eq 'editlist' ) {
+%     $submit++;
   <script>
     function doremove<% "$key$n" %>() {
       fromObject = document.OneTrueForm.<% "$key$n" %>;
@@ -257,9 +301,25 @@ Setting <b><% $key %></b>
     <td><input type="button" value="add" onClick="doadd<% "$key$n" %>(this.form)"></td>
   </tr></table>
 
+%   } elsif ( $element_types{$type} ) {
+%     $submit++;
+%
+%     my %opt = ( 'element_name' => "$key$n",
+%                 'empty_label'  => ' ',
+%               );
+%     if ( $config_item->multiple ) {
+%       $opt{'multiple'} = 1 if $config_item->multiple;
+%       $opt{'curr_value'} = [ $conf->config($key, $agentnum) ];
+%     } else {
+%       $opt{'curr_value'} = 
+%         $conf->exists($key, $agentnum) ? $conf->config($key, $agentnum) : '';
+%     }
+
+      <% include("/elements/$type.html", %opt ) %>
+
 %   } else {
 
-  <font color="#ff0000">unknown type $type</font>
+      <font color="#ff0000">unknown type <% $type %></font>
 
 %   }
 % $n++;
@@ -271,17 +331,19 @@ Setting <b><% $key %></b>
 % }
 </tr>
 </table>
-<INPUT TYPE="submit" VALUE="<% $title %>">
+
+% if ( $submit ) {
+  <INPUT TYPE="submit" VALUE="<% $title %>">
+% }
 </FORM>
 
 </BODY>
 </HTML>
 <%once>
 
-my $conf = new FS::Conf;
-my @config_items = grep { $_->key != ~/^invoice_(html|latex|template)/ }
-                        $conf->config_items; 
-my %confitems = map { $_->key => $_ } @config_items;
+my %element_types = map { $_ => 1 } qw(
+  select-part_svc select-part_pkg select-pkg_class select-agent
+);
 
 </%once>
 <%init>
@@ -296,6 +358,15 @@ if ($cgi->param('agentnum') =~ /(\d+)$/) {
   $agentnum=$1;
 }
 
+my $locale = '';
+if ( $cgi->param('locale') =~ /^(\w+_\w+)$/) {
+  $locale = $1;
+}
+
+my $conf = new FS::Conf { 'locale' => $locale, 'localeonly' => 1 };
+my @config_items = $conf->config_items; 
+my %confitems = map { $_->key => $_ } @config_items;
+
 my $agent = '';
 my $title;
 if ($agentnum) {
@@ -315,5 +386,6 @@ my $config_item = $confitems{$key};
 my $description = $config_item->description;
 my $config_type = $config_item->type;
 my @types = ref($config_type) ? @$config_type : ($config_type);
+my $agent_bool = $config_item->agent_bool;
 
 </%init>