07042e5fdfd11692e9ff57b66f43dc7cda52efa1
[freeside.git] / FS / FS / Conf.pm
1 package FS::Conf;
2
3 use vars qw($base_dir @config_items @base_items @card_types $DEBUG);
4 use strict;
5 use vars qw( $base_dir @config_items @base_items @card_types @invoice_terms
6              $DEBUG
7            );
8 use Carp;
9 use IO::File;
10 use File::Basename;
11 use MIME::Base64;
12 use FS::ConfItem;
13 use FS::ConfDefaults;
14 use FS::Conf_compat17;
15 use FS::Locales;
16 use FS::payby;
17 use FS::conf;
18 use FS::Record qw(qsearch qsearchs);
19 use FS::UID qw(dbh datasrc use_confcompat);
20 use FS::Misc::Invoicing qw( spool_formats );
21
22 $base_dir = '%%%FREESIDE_CONF%%%';
23
24 $DEBUG = 0;
25
26 =head1 NAME
27
28 FS::Conf - Freeside configuration values
29
30 =head1 SYNOPSIS
31
32   use FS::Conf;
33
34   $conf = new FS::Conf;
35
36   $value = $conf->config('key');
37   @list  = $conf->config('key');
38   $bool  = $conf->exists('key');
39
40   $conf->touch('key');
41   $conf->set('key' => 'value');
42   $conf->delete('key');
43
44   @config_items = $conf->config_items;
45
46 =head1 DESCRIPTION
47
48 Read and write Freeside configuration values.  Keys currently map to filenames,
49 but this may change in the future.
50
51 =head1 METHODS
52
53 =over 4
54
55 =item new [ HASHREF ]
56
57 Create a new configuration object.
58
59 HASHREF may contain options to set the configuration context.  Currently 
60 accepts C<locale>, and C<localeonly> to disable fallback to the null locale.
61
62 =cut
63
64 sub new {
65   my($proto) = shift;
66   my $opts = shift || {};
67   my($class) = ref($proto) || $proto;
68   my $self = {
69     'base_dir'    => $base_dir,
70     'locale'      => $opts->{locale},
71     'localeonly'  => $opts->{localeonly}, # for config-view.cgi ONLY
72   };
73   warn "FS::Conf created with no locale fallback.\n" if $self->{localeonly};
74   bless ($self, $class);
75 }
76
77 =item base_dir
78
79 Returns the base directory.  By default this is /usr/local/etc/freeside.
80
81 =cut
82
83 sub base_dir {
84   my($self) = @_;
85   my $base_dir = $self->{base_dir};
86   -e $base_dir or die "FATAL: $base_dir doesn't exist!";
87   -d $base_dir or die "FATAL: $base_dir isn't a directory!";
88   -r $base_dir or die "FATAL: Can't read $base_dir!";
89   -x $base_dir or die "FATAL: $base_dir not searchable (executable)!";
90   $base_dir =~ /^(.*)$/;
91   $1;
92 }
93
94 =item conf KEY [ AGENTNUM [ NODEFAULT ] ]
95
96 Returns the L<FS::conf> record for the key and agent.
97
98 =cut
99
100 sub conf {
101   my $self = shift;
102   $self->_config(@_);
103 }
104
105 =item config KEY [ AGENTNUM [ NODEFAULT ] ]
106
107 Returns the configuration value or values (depending on context) for key.
108 The optional agent number selects an agent specific value instead of the
109 global default if one is present.  If NODEFAULT is true only the agent
110 specific value(s) is returned.
111
112 =cut
113
114 sub _usecompat {
115   my ($self, $method) = (shift, shift);
116   carp "NO CONFIGURATION RECORDS FOUND -- USING COMPATIBILITY MODE"
117     if use_confcompat;
118   my $compat = new FS::Conf_compat17 ("$base_dir/conf." . datasrc);
119   $compat->$method(@_);
120 }
121
122 sub _config {
123   my($self,$name,$agentnum,$agentonly)=@_;
124   my $hashref = { 'name' => $name };
125   local $FS::Record::conf = undef;  # XXX evil hack prevents recursion
126   my $cv;
127   my @a = (
128     ($agentnum || ()),
129     ($agentonly && $agentnum ? () : '')
130   );
131   my @l = (
132     ($self->{locale} || ()),
133     ($self->{localeonly} && $self->{locale} ? () : '')
134   );
135   # try with the agentnum first, then fall back to no agentnum if allowed
136   foreach my $a (@a) {
137     $hashref->{agentnum} = $a;
138     foreach my $l (@l) {
139       $hashref->{locale} = $l;
140       $cv = FS::Record::qsearchs('conf', $hashref);
141       return $cv if $cv;
142     }
143   }
144   return undef;
145 }
146
147 sub config {
148   my $self = shift;
149   return $self->_usecompat('config', @_) if use_confcompat;
150
151   carp "FS::Conf->config(". join(', ', @_). ") called"
152     if $DEBUG > 1;
153
154   my $cv = $self->_config(@_) or return;
155
156   if ( wantarray ) {
157     my $v = $cv->value;
158     chomp $v;
159     (split "\n", $v, -1);
160   } else {
161     (split("\n", $cv->value))[0];
162   }
163 }
164
165 =item config_binary KEY [ AGENTNUM [ NODEFAULT ] ]
166
167 Returns the exact scalar value for key.
168
169 =cut
170
171 sub config_binary {
172   my $self = shift;
173   return $self->_usecompat('config_binary', @_) if use_confcompat;
174
175   my $cv = $self->_config(@_) or return;
176   length($cv->value) ? decode_base64($cv->value) : '';
177 }
178
179 =item exists KEY [ AGENTNUM [ NODEFAULT ] ]
180
181 Returns true if the specified key exists, even if the corresponding value
182 is undefined.
183
184 =cut
185
186 sub exists {
187   my $self = shift;
188   return $self->_usecompat('exists', @_) if use_confcompat;
189
190   #my($name, $agentnum)=@_;
191
192   carp "FS::Conf->exists(". join(', ', @_). ") called"
193     if $DEBUG > 1;
194
195   defined($self->_config(@_));
196 }
197
198 #maybe this should just be the new exists instead of getting a method of its
199 #own, but i wanted to avoid possible fallout
200
201 sub config_bool {
202   my $self = shift;
203   return $self->_usecompat('exists', @_) if use_confcompat;
204
205   my($name,$agentnum,$agentonly) = @_;
206
207   carp "FS::Conf->config_bool(". join(', ', @_). ") called"
208     if $DEBUG > 1;
209
210   #defined($self->_config(@_));
211
212   #false laziness w/_config
213   my $hashref = { 'name' => $name };
214   local $FS::Record::conf = undef;  # XXX evil hack prevents recursion
215   my $cv;
216   my @a = (
217     ($agentnum || ()),
218     ($agentonly && $agentnum ? () : '')
219   );
220   my @l = (
221     ($self->{locale} || ()),
222     ($self->{localeonly} && $self->{locale} ? () : '')
223   );
224   # try with the agentnum first, then fall back to no agentnum if allowed
225   foreach my $a (@a) {
226     $hashref->{agentnum} = $a;
227     foreach my $l (@l) {
228       $hashref->{locale} = $l;
229       $cv = FS::Record::qsearchs('conf', $hashref);
230       if ( $cv ) {
231         if ( $cv->value eq '0'
232                && ($hashref->{agentnum} || $hashref->{locale} )
233            ) 
234         {
235           return 0; #an explicit false override, don't continue looking
236         } else {
237           return 1;
238         }
239       }
240     }
241   }
242   return 0;
243
244 }
245
246 =item config_orbase KEY SUFFIX
247
248 Returns the configuration value or values (depending on context) for 
249 KEY_SUFFIX, if it exists, otherwise for KEY
250
251 =cut
252
253 # outmoded as soon as we shift to agentnum based config values
254 # well, mostly.  still useful for e.g. late notices, etc. in that we want
255 # these to fall back to standard values
256 sub config_orbase {
257   my $self = shift;
258   return $self->_usecompat('config_orbase', @_) if use_confcompat;
259
260   my( $name, $suffix ) = @_;
261   if ( $self->exists("${name}_$suffix") ) {
262     $self->config("${name}_$suffix");
263   } else {
264     $self->config($name);
265   }
266 }
267
268 =item key_orbase KEY SUFFIX
269
270 If the config value KEY_SUFFIX exists, returns KEY_SUFFIX, otherwise returns
271 KEY.  Useful for determining which exact configuration option is returned by
272 config_orbase.
273
274 =cut
275
276 sub key_orbase {
277   my $self = shift;
278   #no compat for this...return $self->_usecompat('config_orbase', @_) if use_confcompat;
279
280   my( $name, $suffix ) = @_;
281   if ( $self->exists("${name}_$suffix") ) {
282     "${name}_$suffix";
283   } else {
284     $name;
285   }
286 }
287
288 =item invoice_templatenames
289
290 Returns all possible invoice template names.
291
292 =cut
293
294 sub invoice_templatenames {
295   my( $self ) = @_;
296
297   my %templatenames = ();
298   foreach my $item ( $self->config_items ) {
299     foreach my $base ( @base_items ) {
300       my( $main, $ext) = split(/\./, $base);
301       $ext = ".$ext" if $ext;
302       if ( $item->key =~ /^${main}_(.+)$ext$/ ) {
303       $templatenames{$1}++;
304       }
305     }
306   }
307   
308   map { $_ } #handle scalar context
309   sort keys %templatenames;
310
311 }
312
313 =item touch KEY [ AGENT ];
314
315 Creates the specified configuration key if it does not exist.
316
317 =cut
318
319 sub touch {
320   my $self = shift;
321   return $self->_usecompat('touch', @_) if use_confcompat;
322
323   my($name, $agentnum) = @_;
324   #unless ( $self->exists($name, $agentnum) ) {
325   unless ( $self->config_bool($name, $agentnum) ) {
326     if ( $agentnum && $self->exists($name) && $self->config($name,$agentnum) eq '0' ) {
327       $self->delete($name, $agentnum);
328     } else {
329       $self->set($name, '', $agentnum);
330     }
331   }
332 }
333
334 =item set KEY VALUE [ AGENTNUM ];
335
336 Sets the specified configuration key to the given value.
337
338 =cut
339
340 sub set {
341   my $self = shift;
342   return $self->_usecompat('set', @_) if use_confcompat;
343
344   my($name, $value, $agentnum) = @_;
345   $value =~ /^(.*)$/s;
346   $value = $1;
347
348   warn "[FS::Conf] SET $name\n" if $DEBUG;
349
350   my $hashref = {
351     name => $name,
352     agentnum => $agentnum,
353     locale => $self->{locale}
354   };
355
356   my $old = FS::Record::qsearchs('conf', $hashref);
357   my $new = new FS::conf { $old ? $old->hash : %$hashref };
358   $new->value($value);
359
360   my $error;
361   if ($old) {
362     $error = $new->replace($old);
363   } else {
364     $error = $new->insert;
365   }
366
367   die "error setting configuration value: $error \n"
368     if $error;
369
370 }
371
372 =item set_binary KEY VALUE [ AGENTNUM ]
373
374 Sets the specified configuration key to an exact scalar value which
375 can be retrieved with config_binary.
376
377 =cut
378
379 sub set_binary {
380   my $self  = shift;
381   return if use_confcompat;
382
383   my($name, $value, $agentnum)=@_;
384   $self->set($name, encode_base64($value), $agentnum);
385 }
386
387 =item delete KEY [ AGENTNUM ];
388
389 Deletes the specified configuration key.
390
391 =cut
392
393 sub delete {
394   my $self = shift;
395   return $self->_usecompat('delete', @_) if use_confcompat;
396
397   my($name, $agentnum) = @_;
398   if ( my $cv = FS::Record::qsearchs('conf', {name => $name, agentnum => $agentnum, locale => $self->{locale}}) ) {
399     warn "[FS::Conf] DELETE $name\n" if $DEBUG;
400
401     my $oldAutoCommit = $FS::UID::AutoCommit;
402     local $FS::UID::AutoCommit = 0;
403     my $dbh = dbh;
404
405     my $error = $cv->delete;
406
407     if ( $error ) {
408       $dbh->rollback if $oldAutoCommit;
409       die "error setting configuration value: $error \n"
410     }
411
412     $dbh->commit or die $dbh->errstr if $oldAutoCommit;
413
414   }
415 }
416
417 #maybe this should just be the new delete instead of getting a method of its
418 #own, but i wanted to avoid possible fallout
419
420 sub delete_bool {
421   my $self = shift;
422   return $self->_usecompat('delete', @_) if use_confcompat;
423
424   my($name, $agentnum) = @_;
425
426   warn "[FS::Conf] DELETE $name\n" if $DEBUG;
427
428   my $cv = FS::Record::qsearchs('conf', { name     => $name,
429                                           agentnum => $agentnum,
430                                           locale   => $self->{locale},
431                                         });
432
433   if ( $cv ) {
434     my $error = $cv->delete;
435     die $error if $error;
436   } elsif ( $agentnum ) {
437     $self->set($name, '0', $agentnum);
438   }
439
440 }
441
442 =item import_config_item CONFITEM DIR 
443
444   Imports the item specified by the CONFITEM (see L<FS::ConfItem>) into
445 the database as a conf record (see L<FS::conf>).  Imports from the file
446 in the directory DIR.
447
448 =cut
449
450 sub import_config_item { 
451   my ($self,$item,$dir) = @_;
452   my $key = $item->key;
453   if ( -e "$dir/$key" && ! use_confcompat ) {
454     warn "Inserting $key\n" if $DEBUG;
455     local $/;
456     my $value = readline(new IO::File "$dir/$key");
457     if ($item->type =~ /^(binary|image)$/ ) {
458       $self->set_binary($key, $value);
459     }else{
460       $self->set($key, $value);
461     }
462   }else {
463     warn "Not inserting $key\n" if $DEBUG;
464   }
465 }
466
467 =item verify_config_item CONFITEM DIR 
468
469   Compares the item specified by the CONFITEM (see L<FS::ConfItem>) in
470 the database to the legacy file value in DIR.
471
472 =cut
473
474 sub verify_config_item { 
475   return '' if use_confcompat;
476   my ($self,$item,$dir) = @_;
477   my $key = $item->key;
478   my $type = $item->type;
479
480   my $compat = new FS::Conf_compat17 $dir;
481   my $error = '';
482   
483   $error .= "$key fails existential comparison; "
484     if $self->exists($key) xor $compat->exists($key);
485
486   if ( $type !~ /^(binary|image)$/ ) {
487
488     {
489       no warnings;
490       $error .= "$key fails scalar comparison; "
491         unless scalar($self->config($key)) eq scalar($compat->config($key));
492     }
493
494     my (@new) = $self->config($key);
495     my (@old) = $compat->config($key);
496     unless ( scalar(@new) == scalar(@old)) { 
497       $error .= "$key fails list comparison; ";
498     }else{
499       my $r=1;
500       foreach (@old) { $r=0 if ($_ cmp shift(@new)); }
501       $error .= "$key fails list comparison; "
502         unless $r;
503     }
504
505   } else {
506
507     no warnings 'uninitialized';
508     $error .= "$key fails binary comparison; "
509       unless scalar($self->config_binary($key)) eq scalar($compat->config_binary($key));
510
511   }
512
513 #remove deprecated config on our own terms, not freeside-upgrade's
514 #  if ($error =~ /existential comparison/ && $item->section eq 'deprecated') {
515 #    my $proto;
516 #    for ( @config_items ) { $proto = $_; last if $proto->key eq $key;  }
517 #    unless ($proto->key eq $key) { 
518 #      warn "removed config item $error\n" if $DEBUG;
519 #      $error = '';
520 #    }
521 #  }
522
523   $error;
524 }
525
526 #item _orbase_items OPTIONS
527 #
528 #Returns all of the possible extensible config items as FS::ConfItem objects.
529 #See #L<FS::ConfItem>.  OPTIONS consists of name value pairs.  Possible
530 #options include
531 #
532 # dir - the directory to search for configuration option files instead
533 #       of using the conf records in the database
534 #
535 #cut
536
537 #quelle kludge
538 sub _orbase_items {
539   my ($self, %opt) = @_; 
540
541   my $listmaker = sub { my $v = shift;
542                         $v =~ s/_/!_/g;
543                         if ( $v =~ /\.(png|eps)$/ ) {
544                           $v =~ s/\./!_%./;
545                         }else{
546                           $v .= '!_%';
547                         }
548                         map { $_->name }
549                           FS::Record::qsearch( 'conf',
550                                                {},
551                                                '',
552                                                "WHERE name LIKE '$v' ESCAPE '!'"
553                                              );
554                       };
555
556   if (exists($opt{dir}) && $opt{dir}) {
557     $listmaker = sub { my $v = shift;
558                        if ( $v =~ /\.(png|eps)$/ ) {
559                          $v =~ s/\./_*./;
560                        }else{
561                          $v .= '_*';
562                        }
563                        map { basename $_ } glob($opt{dir}. "/$v" );
564                      };
565   }
566
567   ( map { 
568           my $proto;
569           my $base = $_;
570           for ( @config_items ) { $proto = $_; last if $proto->key eq $base;  }
571           die "don't know about $base items" unless $proto->key eq $base;
572
573           map { new FS::ConfItem { 
574                   'key'         => $_,
575                   'base_key'    => $proto->key,
576                   'section'     => $proto->section,
577                   'description' => 'Alternate ' . $proto->description . '  See the <a href="http://www.freeside.biz/mediawiki/index.php/Freeside:3:Documentation:Administration#Invoice_templates">billing documentation</a> for details.',
578                   'type'        => $proto->type,
579                 };
580               } &$listmaker($base);
581         } @base_items,
582   );
583 }
584
585 =item config_items
586
587 Returns all of the possible global/default configuration items as
588 FS::ConfItem objects.  See L<FS::ConfItem>.
589
590 =cut
591
592 sub config_items {
593   my $self = shift; 
594   return $self->_usecompat('config_items', @_) if use_confcompat;
595
596   ( @config_items, $self->_orbase_items(@_) );
597 }
598
599 =item invoice_from_full [ AGENTNUM ]
600
601 Returns values of invoice_from and invoice_from_name, appropriately combined
602 based on their current values.
603
604 =cut
605
606 sub invoice_from_full {
607   my ($self, $agentnum) = @_;
608   return $self->config('invoice_from_name', $agentnum ) ?
609          $self->config('invoice_from_name', $agentnum ) . ' <' .
610          $self->config('invoice_from', $agentnum ) . '>' :
611          $self->config('invoice_from', $agentnum );
612 }
613
614 =back
615
616 =head1 SUBROUTINES
617
618 =over 4
619
620 =item init-config DIR
621
622 Imports the configuration items from DIR (1.7 compatible)
623 to conf records in the database.
624
625 =cut
626
627 sub init_config {
628   my $dir = shift;
629
630   {
631     local $FS::UID::use_confcompat = 0;
632     my $conf = new FS::Conf;
633     foreach my $item ( $conf->config_items(dir => $dir) ) {
634       $conf->import_config_item($item, $dir);
635       my $error = $conf->verify_config_item($item, $dir);
636       return $error if $error;
637     }
638   
639     my $compat = new FS::Conf_compat17 $dir;
640     foreach my $item ( $compat->config_items ) {
641       my $error = $conf->verify_config_item($item, $dir);
642       return $error if $error;
643     }
644   }
645
646   $FS::UID::use_confcompat = 0;
647   '';  #success
648 }
649
650 =back
651
652 =head1 BUGS
653
654 If this was more than just crud that will never be useful outside Freeside I'd
655 worry that config_items is freeside-specific and icky.
656
657 =head1 SEE ALSO
658
659 "Configuration" in the web interface (config/config.cgi).
660
661 =cut
662
663 #Business::CreditCard
664 @card_types = (
665   "VISA card",
666   "MasterCard",
667   "Discover card",
668   "American Express card",
669   "Diner's Club/Carte Blanche",
670   "enRoute",
671   "JCB",
672   "BankCard",
673   "Switch",
674   "Solo",
675 );
676
677 @base_items = qw(
678 invoice_template
679 invoice_latex
680 invoice_latexreturnaddress
681 invoice_latexfooter
682 invoice_latexsmallfooter
683 invoice_latexnotes
684 invoice_latexcoupon
685 invoice_latexwatermark
686 invoice_html
687 invoice_htmlreturnaddress
688 invoice_htmlfooter
689 invoice_htmlnotes
690 invoice_htmlwatermark
691 logo.png
692 logo.eps
693 );
694
695 @invoice_terms = (
696   '',
697   'Payable upon receipt',
698   'Net 0', 'Net 3', 'Net 5', 'Net 7', 'Net 9', 'Net 10', 'Net 14', 
699   'Net 15', 'Net 18', 'Net 20', 'Net 21', 'Net 25', 'End of Month', 'Net 30',
700   'Net 45', 'Net 60', 'Net 90'
701 );
702
703 my %msg_template_options = (
704   'type'        => 'select-sub',
705   'options_sub' => sub { 
706     my @templates = qsearch({
707         'table' => 'msg_template', 
708         'hashref' => { 'disabled' => '' },
709         'extra_sql' => ' AND '. 
710           $FS::CurrentUser::CurrentUser->agentnums_sql(null => 1),
711         });
712     map { $_->msgnum, $_->msgname } @templates;
713   },
714   'option_sub'  => sub { 
715                          my $msg_template = FS::msg_template->by_key(shift);
716                          $msg_template ? $msg_template->msgname : ''
717                        },
718   'per_agent' => 1,
719 );
720
721 my %payment_gateway_options = (
722   'type'        => 'select-sub',
723   'options_sub' => sub {
724     my @gateways = qsearch({
725         'table' => 'payment_gateway',
726         'hashref' => { 'disabled' => '' },
727       });
728     map { $_->gatewaynum, $_->label } @gateways;
729   },
730   'option_sub'  => sub {
731     my $gateway = FS::payment_gateway->by_key(shift);
732     $gateway ? $gateway->label : ''
733   },
734 );
735
736 my %batch_gateway_options = (
737   %payment_gateway_options,
738   'options_sub' => sub {
739     my @gateways = qsearch('payment_gateway',
740       {
741         'disabled'          => '',
742         'gateway_namespace' => 'Business::BatchPayment',
743       }
744     );
745     map { $_->gatewaynum, $_->label } @gateways;
746   },
747   'per_agent' => 1,
748 );
749
750 my %invoice_mode_options = (
751   'type'        => 'select-sub',
752   'options_sub' => sub { 
753     my @modes = qsearch({
754         'table' => 'invoice_mode', 
755         'extra_sql' => ' WHERE '.
756           $FS::CurrentUser::CurrentUser->agentnums_sql(null => 1),
757         });
758     map { $_->modenum, $_->modename } @modes;
759   },
760   'option_sub'  => sub { 
761                          my $mode = FS::invoice_mode->by_key(shift);
762                          $mode ? $mode->modename : '',
763                        },
764   'per_agent' => 1,
765 );
766
767 my @cdr_formats = (
768   '' => '',
769   'default' => 'Default',
770   'source_default' => 'Default with source',
771   'accountcode_default' => 'Default plus accountcode',
772   'description_default' => 'Default with description field as destination',
773   'basic' => 'Basic',
774   'simple' => 'Simple',
775   'simple2' => 'Simple with source',
776   'accountcode_simple' => 'Simple with accountcode',
777 );
778
779 # takes the reason class (C, R, S) as an argument
780 sub reason_type_options {
781   my $reason_class = shift;
782
783   'type'        => 'select-sub',
784   'options_sub' => sub {
785     map { $_->typenum => $_->type } 
786       qsearch('reason_type', { class => $reason_class });
787   },
788   'option_sub'  => sub {
789     my $type = FS::reason_type->by_key(shift);
790     $type ? $type->type : '';
791   }
792 }
793
794 my $validate_email = sub { $_[0] =~
795                              /^[^@]+\@[[:alnum:]-]+(\.[[:alnum:]-]+)+$/
796                              ? '' : 'Invalid email address';
797                          };
798
799 #Billing (81 items)
800 #Invoicing (50 items)
801 #UI (69 items)
802 #Self-service (29 items)
803 #...
804 #Unclassified (77 items)
805
806 @config_items = map { new FS::ConfItem $_ } (
807
808   {
809     'key'         => 'address',
810     'section'     => 'deprecated',
811     'description' => 'This configuration option is no longer used.  See <a href="#invoice_template">invoice_template</a> instead.',
812     'type'        => 'text',
813   },
814
815   {
816     'key'         => 'event_log_level',
817     'section'     => 'notification',
818     'description' => 'Store events in the internal log if they are at least this severe.  "info" is the default, "debug" is very detailed and noisy.',
819     'type'        => 'select',
820     'select_enum' => [ '', 'debug', 'info', 'notice', 'warning', 'error', ],
821     # don't bother with higher levels
822   },
823
824   {
825     'key'         => 'log_sent_mail',
826     'section'     => 'notification',
827     'description' => 'Enable logging of template-generated email.',
828     'type'        => 'checkbox',
829   },
830
831   {
832     'key'         => 'alert_expiration',
833     'section'     => 'deprecated',
834     'description' => 'Enable alerts about credit card expiration.  This is obsolete and no longer works.',
835     'type'        => 'checkbox',
836     'per_agent'   => 1,
837   },
838
839   {
840     'key'         => 'alerter_template',
841     'section'     => 'deprecated',
842     'description' => 'Template file for billing method expiration alerts (i.e. expiring credit cards).',
843     'type'        => 'textarea',
844     'per_agent'   => 1,
845   },
846   
847   {
848     'key'         => 'alerter_msgnum',
849     'section'     => 'deprecated',
850     'description' => 'Template to use for credit card expiration alerts.',
851     %msg_template_options,
852   },
853
854   {
855     'key'         => 'part_pkg-lineage',
856     'section'     => '',
857     'description' => 'When editing a package definition, if setup or recur fees are changed, create a new package rather than changing the existing package.',
858     'type'        => 'checkbox',
859   },
860
861   {
862     'key'         => 'apacheip',
863     #not actually deprecated yet
864     #'section'     => 'deprecated',
865     #'description' => '<b>DEPRECATED</b>, add an <i>apache</i> <a href="../browse/part_export.cgi">export</a> instead.  Used to be the current IP address to assign to new virtual hosts',
866     'section'     => '',
867     'description' => 'IP address to assign to new virtual hosts',
868     'type'        => 'text',
869   },
870   
871   {
872     'key'         => 'credits-auto-apply-disable',
873     'section'     => 'billing',
874     'description' => 'Disable the "Auto-Apply to invoices" UI option for new credits',
875     'type'        => 'checkbox',
876   },
877   
878   {
879     'key'         => 'credit-card-surcharge-percentage',
880     'section'     => 'billing',
881     'description' => 'Add a credit card surcharge to invoices, as a % of the invoice total.  WARNING: Although recently permitted to US merchants in general, specific consumer protection laws may prohibit or restrict this practice in California, Colorado, Connecticut, Florda, Kansas, Maine, Massachusetts, New York, Oklahome, and Texas.  Surcharging is also generally prohibited in most countries outside the US, AU and UK.  When allowed, typically not permitted to be above 4%.',
882     'type'        => 'text',
883     'per_agent'   => 1,
884   },
885
886   {
887     'key'         => 'discount-show-always',
888     'section'     => 'billing',
889     'description' => 'Generate a line item on an invoice even when a package is discounted 100%',
890     'type'        => 'checkbox',
891   },
892
893   {
894     'key'         => 'discount-show_available',
895     'section'     => 'billing',
896     'description' => 'Show available prepayment discounts on invoices.',
897     'type'        => 'checkbox',
898   },
899
900   {
901     'key'         => 'invoice-barcode',
902     'section'     => 'billing',
903     'description' => 'Display a barcode on HTML and PDF invoices',
904     'type'        => 'checkbox',
905   },
906   
907   {
908     'key'         => 'cust_main-select-billday',
909     'section'     => 'billing',
910     'description' => 'When used with a specific billing event, allows the selection of the day of month on which to charge credit card / bank account automatically, on a per-customer basis',
911     'type'        => 'checkbox',
912   },
913
914   {
915     'key'         => 'cust_main-select-prorate_day',
916     'section'     => 'billing',
917     'description' => 'When used with prorate or anniversary packages, allows the selection of the prorate day of month, on a per-customer basis',
918     'type'        => 'checkbox',
919   },
920
921   {
922     'key'         => 'anniversary-rollback',
923     'section'     => 'billing',
924     'description' => 'When billing an anniversary package ordered after the 28th, roll the anniversary date back to the 28th instead of forward into the following month.',
925     'type'        => 'checkbox',
926   },
927
928   {
929     'key'         => 'encryption',
930     'section'     => 'billing',
931     'description' => 'Enable encryption of credit cards and echeck numbers',
932     'type'        => 'checkbox',
933   },
934
935   {
936     'key'         => 'encryptionmodule',
937     'section'     => 'billing',
938     'description' => 'Use which module for encryption?',
939     'type'        => 'select',
940     'select_enum' => [ '', 'Crypt::OpenSSL::RSA', ],
941   },
942
943   {
944     'key'         => 'encryptionpublickey',
945     'section'     => 'billing',
946     'description' => 'Encryption public key',
947     'type'        => 'textarea',
948   },
949
950   {
951     'key'         => 'encryptionprivatekey',
952     'section'     => 'billing',
953     'description' => 'Encryption private key',
954     'type'        => 'textarea',
955   },
956
957   {
958     'key'         => 'billco-url',
959     'section'     => 'billing',
960     'description' => 'The url to use for performing uploads to the invoice mailing service.',
961     'type'        => 'text',
962     'per_agent'   => 1,
963   },
964
965   {
966     'key'         => 'billco-username',
967     'section'     => 'billing',
968     'description' => 'The login name to use for uploads to the invoice mailing service.',
969     'type'        => 'text',
970     'per_agent'   => 1,
971     'agentonly'   => 1,
972   },
973
974   {
975     'key'         => 'billco-password',
976     'section'     => 'billing',
977     'description' => 'The password to use for uploads to the invoice mailing service.',
978     'type'        => 'text',
979     'per_agent'   => 1,
980     'agentonly'   => 1,
981   },
982
983   {
984     'key'         => 'billco-clicode',
985     'section'     => 'billing',
986     'description' => 'The clicode to use for uploads to the invoice mailing service.',
987     'type'        => 'text',
988     'per_agent'   => 1,
989   },
990
991   {
992     'key'         => 'billco-account_num',
993     'section'     => 'billing',
994     'description' => 'The data to place in the "Transaction Account No" / "TRACCTNUM" field.',
995     'type'        => 'select',
996     'select_hash' => [
997                        'invnum-date' => 'Invoice number - Date (default)',
998                        'display_custnum'  => 'Customer number',
999                      ],
1000     'per_agent'   => 1,
1001   },
1002
1003   {
1004     'key'         => 'next-bill-ignore-time',
1005     'section'     => 'billing',
1006     'description' => 'Ignore the time portion of next bill dates when billing, matching anything from 00:00:00 to 23:59:59 on the billing day.',
1007     'type'        => 'checkbox',
1008   },
1009   
1010   {
1011     'key'         => 'business-onlinepayment',
1012     'section'     => 'billing',
1013     'description' => '<a href="http://search.cpan.org/search?mode=module&query=Business%3A%3AOnlinePayment">Business::OnlinePayment</a> support, at least three lines: processor, login, and password.  An optional fourth line specifies the action or actions (multiple actions are separated with `,\': for example: `Authorization Only, Post Authorization\').    Optional additional lines are passed to Business::OnlinePayment as %processor_options.  For more detailed information and examples see the <a href="http://www.freeside.biz/mediawiki/index.php/Freeside:3:Documentation:Administration:Real-time_Processing">real-time credit card processing documentation</a>.',
1014     'type'        => 'textarea',
1015   },
1016
1017   {
1018     'key'         => 'business-onlinepayment-ach',
1019     'section'     => 'billing',
1020     'description' => 'Alternate <a href="http://search.cpan.org/search?mode=module&query=Business%3A%3AOnlinePayment">Business::OnlinePayment</a> support for ACH transactions (defaults to regular <b>business-onlinepayment</b>).  At least three lines: processor, login, and password.  An optional fourth line specifies the action or actions (multiple actions are separated with `,\': for example: `Authorization Only, Post Authorization\').    Optional additional lines are passed to Business::OnlinePayment as %processor_options.',
1021     'type'        => 'textarea',
1022   },
1023
1024   {
1025     'key'         => 'business-onlinepayment-namespace',
1026     'section'     => 'billing',
1027     'description' => 'Specifies which perl module namespace (which group of collection routines) is used by default.',
1028     'type'        => 'select',
1029     'select_hash' => [
1030                        'Business::OnlinePayment' => 'Direct API (Business::OnlinePayment)',
1031                        'Business::OnlineThirdPartyPayment' => 'Web API (Business::ThirdPartyPayment)',
1032                      ],
1033   },
1034
1035   {
1036     'key'         => 'business-onlinepayment-description',
1037     'section'     => 'billing',
1038     'description' => 'String passed as the description field to <a href="http://search.cpan.org/search?mode=module&query=Business%3A%3AOnlinePayment">Business::OnlinePayment</a>.  Evaluated as a double-quoted perl string, with the following variables available: <code>$agent</code> (the agent name), and <code>$pkgs</code> (a comma-separated list of packages for which these charges apply - not available in all situations)',
1039     'type'        => 'text',
1040   },
1041
1042   {
1043     'key'         => 'business-onlinepayment-email-override',
1044     'section'     => 'billing',
1045     'description' => 'Email address used instead of customer email address when submitting a BOP transaction.',
1046     'type'        => 'text',
1047   },
1048
1049   {
1050     'key'         => 'business-onlinepayment-email_customer',
1051     'section'     => 'billing',
1052     'description' => 'Controls the "email_customer" flag used by some Business::OnlinePayment processors to enable customer receipts.',
1053     'type'        => 'checkbox',
1054   },
1055
1056   {
1057     'key'         => 'business-onlinepayment-test_transaction',
1058     'section'     => 'billing',
1059     'description' => 'Turns on the Business::OnlinePayment test_transaction flag.  Note that not all gateway modules support this flag; if yours does not, transactions will still be sent live.',
1060     'type'        => 'checkbox',
1061   },
1062
1063   {
1064     'key'         => 'business-onlinepayment-currency',
1065     'section'     => 'billing',
1066     'description' => 'Currency parameter for Business::OnlinePayment transactions.',
1067     'type'        => 'select',
1068     'select_enum' => [ '', qw( USD AUD CAD DKK EUR GBP ILS JPY NZD ) ],
1069   },
1070
1071   {
1072     'key'         => 'business-onlinepayment-verification',
1073     'section'     => 'billing',
1074     'description' => 'Run a $1 authorization (followed by a void) to verify new credit card information.',
1075     'type'        => 'checkbox',
1076   },
1077
1078   {
1079     'key'         => 'currency',
1080     'section'     => 'billing',
1081     'description' => 'Currency',
1082     'type'        => 'select',
1083     'select_enum' => [ '', qw( USD AUD CAD DKK EUR GBP ILS JPY NZD XAF ) ],
1084   },
1085
1086   {
1087     'key'         => 'business-batchpayment-test_transaction',
1088     'section'     => 'billing',
1089     'description' => 'Turns on the Business::BatchPayment test_mode flag.  Note that not all gateway modules support this flag; if yours does not, using the batch gateway will fail.',
1090     'type'        => 'checkbox',
1091   },
1092
1093   {
1094     'key'         => 'countrydefault',
1095     'section'     => 'UI',
1096     'description' => 'Default two-letter country code (if not supplied, the default is `US\')',
1097     'type'        => 'text',
1098   },
1099
1100   {
1101     'key'         => 'date_format',
1102     'section'     => 'UI',
1103     'description' => 'Format for displaying dates',
1104     'type'        => 'select',
1105     'select_hash' => [
1106                        '%m/%d/%Y' => 'MM/DD/YYYY',
1107                        '%d/%m/%Y' => 'DD/MM/YYYY',
1108                        '%Y/%m/%d' => 'YYYY/MM/DD',
1109                        '%e %b %Y' => 'DD Mon YYYY',
1110                      ],
1111     'per_locale'  => 1,
1112   },
1113
1114   {
1115     'key'         => 'date_format_long',
1116     'section'     => 'UI',
1117     'description' => 'Verbose format for displaying dates',
1118     'type'        => 'select',
1119     'select_hash' => [
1120                        '%b %o, %Y' => 'Mon DDth, YYYY',
1121                        '%e %b %Y'  => 'DD Mon YYYY',
1122                        '%m/%d/%Y'  => 'MM/DD/YYYY',
1123                        '%d/%m/%Y'  => 'DD/MM/YYYY',
1124                        '%Y/%m/%d'  => 'YYYY/MM/DD',
1125                      ],
1126     'per_locale'  => 1,
1127   },
1128
1129   {
1130     'key'         => 'deletecustomers',
1131     'section'     => 'deprecated',
1132     'description' => 'Enable customer deletions.  Be very careful!  Deleting a customer will remove all traces that the customer ever existed!  It should probably only be used when auditing a legacy database.  Normally, you cancel all of a customers\' packages if they cancel service.',
1133     'type'        => 'checkbox',
1134   },
1135
1136   {
1137     'key'         => 'deleteinvoices',
1138     'section'     => 'UI',
1139     'description' => 'Enable invoices deletions.  Be very careful!  Deleting an invoice will remove all traces that the invoice ever existed!  Normally, you would void or apply a credit against the invoice instead.',
1140     'type'        => 'checkbox',
1141   },
1142
1143   {
1144     'key'         => 'deletepayments',
1145     'section'     => 'deprecated',
1146     'description' => 'Enable deletion of unclosed payments.  Really, with voids this is pretty much not recommended in any situation anymore.  Be very careful!  Only delete payments that were data-entry errors, not adjustments.  Optionally specify one or more comma-separated email addresses to be notified when a payment is deleted.',
1147     'type'        => [qw( checkbox text )],
1148   },
1149
1150   {
1151     'key'         => 'deletecredits',
1152     #not actually deprecated yet
1153     #'section'     => 'deprecated',
1154     #'description' => '<B>DEPRECATED</B>, now controlled by ACLs.  Used to enable deletion of unclosed credits.  Be very careful!  Only delete credits that were data-entry errors, not adjustments.  Optionally specify one or more comma-separated email addresses to be notified when a credit is deleted.',
1155     'section'     => '',
1156     'description' => 'One or more comma-separated email addresses to be notified when a credit is deleted.',
1157     'type'        => [qw( checkbox text )],
1158   },
1159
1160   {
1161     'key'         => 'deleterefunds',
1162     'section'     => 'billing',
1163     'description' => 'Enable deletion of unclosed refunds.  Be very careful!  Only delete refunds that were data-entry errors, not adjustments.',
1164     'type'        => 'checkbox',
1165   },
1166
1167   {
1168     'key'         => 'unapplypayments',
1169     'section'     => 'deprecated',
1170     'description' => '<B>DEPRECATED</B>, now controlled by ACLs.  Used to enable "unapplication" of unclosed payments.',
1171     'type'        => 'checkbox',
1172   },
1173
1174   {
1175     'key'         => 'unapplycredits',
1176     'section'     => 'deprecated',
1177     'description' => '<B>DEPRECATED</B>, now controlled by ACLs.  Used to enable "unapplication" of unclosed credits.',
1178     'type'        => 'checkbox',
1179   },
1180
1181   {
1182     'key'         => 'dirhash',
1183     'section'     => 'shell',
1184     'description' => 'Optional numeric value to control directory hashing.  If positive, hashes directories for the specified number of levels from the front of the username.  If negative, hashes directories for the specified number of levels from the end of the username.  Some examples: <ul><li>1: user -> <a href="#home">/home</a>/u/user<li>2: user -> <a href="#home">/home</a>/u/s/user<li>-1: user -> <a href="#home">/home</a>/r/user<li>-2: user -> <a href="#home">home</a>/r/e/user</ul>',
1185     'type'        => 'text',
1186   },
1187
1188   {
1189     'key'         => 'disable_cust_attachment',
1190     'section'     => '',
1191     'description' => 'Disable customer file attachments',
1192     'type'        => 'checkbox',
1193   },
1194
1195   {
1196     'key'         => 'max_attachment_size',
1197     'section'     => '',
1198     'description' => 'Maximum size for customer file attachments (leave blank for unlimited)',
1199     'type'        => 'text',
1200   },
1201
1202   {
1203     'key'         => 'disable_customer_referrals',
1204     'section'     => 'UI',
1205     'description' => 'Disable new customer-to-customer referrals in the web interface',
1206     'type'        => 'checkbox',
1207   },
1208
1209   {
1210     'key'         => 'editreferrals',
1211     'section'     => 'UI',
1212     'description' => 'Enable advertising source modification for existing customers',
1213     'type'        => 'checkbox',
1214   },
1215
1216   {
1217     'key'         => 'emailinvoiceonly',
1218     'section'     => 'invoicing',
1219     'description' => 'Disables postal mail invoices',
1220     'type'        => 'checkbox',
1221   },
1222
1223   {
1224     'key'         => 'disablepostalinvoicedefault',
1225     'section'     => 'invoicing',
1226     'description' => 'Disables postal mail invoices as the default option in the UI.  Be careful not to setup customers which are not sent invoices.  See <a href ="#emailinvoiceauto">emailinvoiceauto</a>.',
1227     'type'        => 'checkbox',
1228   },
1229
1230   {
1231     'key'         => 'emailinvoiceauto',
1232     'section'     => 'invoicing',
1233     'description' => 'Automatically adds new accounts to the email invoice list',
1234     'type'        => 'checkbox',
1235   },
1236
1237   {
1238     'key'         => 'emailinvoiceautoalways',
1239     'section'     => 'invoicing',
1240     'description' => 'Automatically adds new accounts to the email invoice list even when the list contains email addresses',
1241     'type'        => 'checkbox',
1242   },
1243
1244   {
1245     'key'         => 'emailinvoice-apostrophe',
1246     'section'     => 'invoicing',
1247     'description' => 'Allows the apostrophe (single quote) character in the email addresses in the email invoice list.',
1248     'type'        => 'checkbox',
1249   },
1250
1251   {
1252     'key'         => 'svc_acct-ip_addr',
1253     'section'     => '',
1254     'description' => 'Enable IP address management on login services like for broadband services.',
1255     'type'        => 'checkbox',
1256   },
1257
1258   {
1259     'key'         => 'exclude_ip_addr',
1260     'section'     => '',
1261     'description' => 'Exclude these from the list of available broadband service IP addresses. (One per line)',
1262     'type'        => 'textarea',
1263   },
1264   
1265   {
1266     'key'         => 'auto_router',
1267     'section'     => '',
1268     'description' => 'Automatically choose the correct router/block based on supplied ip address when possible while provisioning broadband services',
1269     'type'        => 'checkbox',
1270   },
1271   
1272   {
1273     'key'         => 'hidecancelledpackages',
1274     'section'     => 'UI',
1275     'description' => 'Prevent cancelled packages from showing up in listings (though they will still be in the database)',
1276     'type'        => 'checkbox',
1277   },
1278
1279   {
1280     'key'         => 'hidecancelledcustomers',
1281     'section'     => 'UI',
1282     'description' => 'Prevent customers with only cancelled packages from showing up in listings (though they will still be in the database)',
1283     'type'        => 'checkbox',
1284   },
1285
1286   {
1287     'key'         => 'home',
1288     'section'     => 'shell',
1289     'description' => 'For new users, prefixed to username to create a directory name.  Should have a leading but not a trailing slash.',
1290     'type'        => 'text',
1291   },
1292
1293   {
1294     'key'         => 'invoice_from',
1295     'section'     => 'required',
1296     'description' => 'Return address on email invoices (address only, see invoice_from_name)',
1297     'type'        => 'text',
1298     'per_agent'   => 1,
1299     'validate'    => $validate_email,
1300   },
1301
1302   {
1303     'key'         => 'invoice_from_name',
1304     'section'     => 'invoicing',
1305     'description' => 'Return name on email invoices (set address in invoice_from)',
1306     'type'        => 'text',
1307     'per_agent'   => 1,
1308     'validate'    => sub { (($_[0] =~ /[^[:alnum:][:space:]]/) && ($_[0] !~ /^\".*\"$/))
1309                            ? 'Invalid name.  Use quotation marks around names that contain punctuation.'
1310                            : '' }
1311   },
1312
1313   {
1314     'key'         => 'quotation_from',
1315     'section'     => '',
1316     'description' => 'Return address on email quotations',
1317     'type'        => 'text',
1318     'per_agent'   => 1,
1319   },
1320
1321
1322   {
1323     'key'         => 'invoice_subject',
1324     'section'     => 'invoicing',
1325     'description' => 'Subject: header on email invoices.  Defaults to "Invoice".  The following substitutions are available: $name, $name_short, $invoice_number, and $invoice_date.',
1326     'type'        => 'text',
1327     'per_agent'   => 1,
1328     'per_locale'  => 1,
1329   },
1330
1331   {
1332     'key'         => 'quotation_subject',
1333     'section'     => '',
1334     'description' => 'Subject: header on email quotations.  Defaults to "Quotation".', #  The following substitutions are available: $name, $name_short, $invoice_number, and $invoice_date.',
1335     'type'        => 'text',
1336     #'per_agent'   => 1,
1337     'per_locale'  => 1,
1338   },
1339
1340   {
1341     'key'         => 'invoice_usesummary',
1342     'section'     => 'invoicing',
1343     'description' => 'Indicates that html and latex invoices should be in summary style and make use of invoice_latexsummary.',
1344     'type'        => 'checkbox',
1345   },
1346
1347   {
1348     'key'         => 'invoice_template',
1349     'section'     => 'invoicing',
1350     'description' => 'Text template file for invoices.  Used if no invoice_html template is defined, and also seen by users using non-HTML capable mail clients.  See the <a href="http://www.freeside.biz/mediawiki/index.php/Freeside:3:Documentation:Administration#Plaintext_invoice_templates">billing documentation</a> for details.',
1351     'type'        => 'textarea',
1352   },
1353
1354   {
1355     'key'         => 'invoice_html',
1356     'section'     => 'invoicing',
1357     'description' => 'HTML template for invoices.  See the <a href="http://www.freeside.biz/mediawiki/index.php/Freeside:2.1:Documentation:Administration#HTML_invoice_templates">billing documentation</a> for details.',
1358
1359     'type'        => 'textarea',
1360   },
1361
1362   {
1363     'key'         => 'quotation_html',
1364     'section'     => '',
1365     'description' => 'HTML template for quotations.',
1366
1367     'type'        => 'textarea',
1368   },
1369
1370   {
1371     'key'         => 'invoice_htmlnotes',
1372     'section'     => 'invoicing',
1373     'description' => 'Notes section for HTML invoices.  Defaults to the same data in invoice_latexnotes if not specified.',
1374     'type'        => 'textarea',
1375     'per_agent'   => 1,
1376     'per_locale'  => 1,
1377   },
1378
1379   {
1380     'key'         => 'invoice_htmlfooter',
1381     'section'     => 'invoicing',
1382     'description' => 'Footer for HTML invoices.  Defaults to the same data in invoice_latexfooter if not specified.',
1383     'type'        => 'textarea',
1384     'per_agent'   => 1,
1385     'per_locale'  => 1,
1386   },
1387
1388   {
1389     'key'         => 'invoice_htmlsummary',
1390     'section'     => 'invoicing',
1391     'description' => 'Summary initial page for HTML invoices.',
1392     'type'        => 'textarea',
1393     'per_agent'   => 1,
1394     'per_locale'  => 1,
1395   },
1396
1397   {
1398     'key'         => 'invoice_htmlreturnaddress',
1399     'section'     => 'invoicing',
1400     'description' => 'Return address for HTML invoices.  Defaults to the same data in invoice_latexreturnaddress if not specified.',
1401     'type'        => 'textarea',
1402     'per_locale'  => 1,
1403   },
1404
1405   {
1406     'key'         => 'invoice_htmlwatermark',
1407     'section'     => 'invoicing',
1408     'description' => 'Watermark for HTML invoices. Appears in a semitransparent positioned DIV overlaid on the main invoice container.',
1409     'type'        => 'textarea',
1410     'per_agent'   => 1,
1411     'per_locale'  => 1,
1412   },
1413
1414   {
1415     'key'         => 'invoice_latex',
1416     'section'     => 'invoicing',
1417     'description' => 'Optional LaTeX template for typeset PostScript invoices.  See the <a href="http://www.freeside.biz/mediawiki/index.php/Freeside:2.1:Documentation:Administration#Typeset_.28LaTeX.29_invoice_templates">billing documentation</a> for details.',
1418     'type'        => 'textarea',
1419   },
1420
1421   {
1422     'key'         => 'quotation_latex',
1423     'section'     => '',
1424     'description' => 'LaTeX template for typeset PostScript quotations.',
1425     'type'        => 'textarea',
1426   },
1427
1428   {
1429     'key'         => 'invoice_latextopmargin',
1430     'section'     => 'invoicing',
1431     'description' => 'Optional LaTeX invoice topmargin setting. Include units.',
1432     'type'        => 'text',
1433     'per_agent'   => 1,
1434     'validate'    => sub { shift =~
1435                              /^-?\d*\.?\d+(in|mm|cm|pt|em|ex|pc|bp|dd|cc|sp)$/
1436                              ? '' : 'Invalid LaTex length';
1437                          },
1438   },
1439
1440   {
1441     'key'         => 'invoice_latexheadsep',
1442     'section'     => 'invoicing',
1443     'description' => 'Optional LaTeX invoice headsep setting. Include units.',
1444     'type'        => 'text',
1445     'per_agent'   => 1,
1446     'validate'    => sub { shift =~
1447                              /^-?\d*\.?\d+(in|mm|cm|pt|em|ex|pc|bp|dd|cc|sp)$/
1448                              ? '' : 'Invalid LaTex length';
1449                          },
1450   },
1451
1452   {
1453     'key'         => 'invoice_latexaddresssep',
1454     'section'     => 'invoicing',
1455     'description' => 'Optional LaTeX invoice separation between invoice header
1456 and customer address. Include units.',
1457     'type'        => 'text',
1458     'per_agent'   => 1,
1459     'validate'    => sub { shift =~
1460                              /^-?\d*\.?\d+(in|mm|cm|pt|em|ex|pc|bp|dd|cc|sp)$/
1461                              ? '' : 'Invalid LaTex length';
1462                          },
1463   },
1464
1465   {
1466     'key'         => 'invoice_latextextheight',
1467     'section'     => 'invoicing',
1468     'description' => 'Optional LaTeX invoice textheight setting. Include units.',
1469     'type'        => 'text',
1470     'per_agent'   => 1,
1471     'validate'    => sub { shift =~
1472                              /^-?\d*\.?\d+(in|mm|cm|pt|em|ex|pc|bp|dd|cc|sp)$/
1473                              ? '' : 'Invalid LaTex length';
1474                          },
1475   },
1476
1477   {
1478     'key'         => 'invoice_latexnotes',
1479     'section'     => 'invoicing',
1480     'description' => 'Notes section for LaTeX typeset PostScript invoices.',
1481     'type'        => 'textarea',
1482     'per_agent'   => 1,
1483     'per_locale'  => 1,
1484   },
1485
1486   {
1487     'key'         => 'quotation_latexnotes',
1488     'section'     => '',
1489     'description' => 'Notes section for LaTeX typeset PostScript quotations.',
1490     'type'        => 'textarea',
1491     'per_agent'   => 1,
1492     'per_locale'  => 1,
1493   },
1494
1495   {
1496     'key'         => 'invoice_latexfooter',
1497     'section'     => 'invoicing',
1498     'description' => 'Footer for LaTeX typeset PostScript invoices.',
1499     'type'        => 'textarea',
1500     'per_agent'   => 1,
1501     'per_locale'  => 1,
1502   },
1503
1504   {
1505     'key'         => 'invoice_latexsummary',
1506     'section'     => 'invoicing',
1507     'description' => 'Summary initial page for LaTeX typeset PostScript invoices.',
1508     'type'        => 'textarea',
1509     'per_agent'   => 1,
1510     'per_locale'  => 1,
1511   },
1512
1513   {
1514     'key'         => 'invoice_latexcoupon',
1515     'section'     => 'invoicing',
1516     'description' => 'Remittance coupon for LaTeX typeset PostScript invoices.',
1517     'type'        => 'textarea',
1518     'per_agent'   => 1,
1519     'per_locale'  => 1,
1520   },
1521
1522   {
1523     'key'         => 'invoice_latexextracouponspace',
1524     'section'     => 'invoicing',
1525     'description' => 'Optional LaTeX invoice textheight space to reserve for a tear off coupon.  Include units.  Default is 2.7 inches.',
1526     'type'        => 'text',
1527     'per_agent'   => 1,
1528     'validate'    => sub { shift =~
1529                              /^-?\d*\.?\d+(in|mm|cm|pt|em|ex|pc|bp|dd|cc|sp)$/
1530                              ? '' : 'Invalid LaTex length';
1531                          },
1532   },
1533
1534   {
1535     'key'         => 'invoice_latexcouponfootsep',
1536     'section'     => 'invoicing',
1537     'description' => 'Optional LaTeX invoice separation between bottom of coupon address and footer. Include units. Default is 0.2 inches.',
1538     'type'        => 'text',
1539     'per_agent'   => 1,
1540     'validate'    => sub { shift =~
1541                              /^-?\d*\.?\d+(in|mm|cm|pt|em|ex|pc|bp|dd|cc|sp)$/
1542                              ? '' : 'Invalid LaTex length';
1543                          },
1544   },
1545
1546   {
1547     'key'         => 'invoice_latexcouponamountenclosedsep',
1548     'section'     => 'invoicing',
1549     'description' => 'Optional LaTeX invoice separation between total due and amount enclosed line. Include units. Default is 2.25 em.',
1550     'type'        => 'text',
1551     'per_agent'   => 1,
1552     'validate'    => sub { shift =~
1553                              /^-?\d*\.?\d+(in|mm|cm|pt|em|ex|pc|bp|dd|cc|sp)$/
1554                              ? '' : 'Invalid LaTex length';
1555                          },
1556   },
1557   {
1558     'key'         => 'invoice_latexcoupontoaddresssep',
1559     'section'     => 'invoicing',
1560     'description' => 'Optional LaTeX invoice separation between invoice data and the address (usually invoice_latexreturnaddress).  Include units. Default is 1 inch.',
1561     'type'        => 'text',
1562     'per_agent'   => 1,
1563     'validate'    => sub { shift =~
1564                              /^-?\d*\.?\d+(in|mm|cm|pt|em|ex|pc|bp|dd|cc|sp)$/
1565                              ? '' : 'Invalid LaTex length';
1566                          },
1567   },
1568
1569   {
1570     'key'         => 'invoice_latexreturnaddress',
1571     'section'     => 'invoicing',
1572     'description' => 'Return address for LaTeX typeset PostScript invoices.',
1573     'type'        => 'textarea',
1574   },
1575
1576   {
1577     'key'         => 'invoice_latexverticalreturnaddress',
1578     'section'     => 'deprecated',
1579     'description' => 'Deprecated.  With old invoice_latex template, places the return address under the company logo rather than beside it.',
1580     'type'        => 'checkbox',
1581     'per_agent'   => 1,
1582   },
1583
1584   {
1585     'key'         => 'invoice_latexcouponaddcompanytoaddress',
1586     'section'     => 'invoicing',
1587     'description' => 'Add the company name to the To address on the remittance coupon because the return address does not contain it.',
1588     'type'        => 'checkbox',
1589     'per_agent'   => 1,
1590   },
1591
1592   {
1593     'key'         => 'invoice_latexsmallfooter',
1594     'section'     => 'invoicing',
1595     'description' => 'Optional small footer for multi-page LaTeX typeset PostScript invoices.',
1596     'type'        => 'textarea',
1597     'per_agent'   => 1,
1598     'per_locale'  => 1,
1599   },
1600
1601   {
1602     'key'         => 'invoice_latexwatermark',
1603     'section'     => 'invoicing',
1604     'description' => 'Watermark for LaTeX invoices. See "texdoc background" for information on what this can contain. The content itself should be enclosed in braces, optionally followed by a comma and any formatting options.',
1605     'type'        => 'textarea',
1606     'per_agent'   => 1,
1607     'per_locale'  => 1,
1608   },
1609
1610   {
1611     'key'         => 'invoice_email_pdf',
1612     'section'     => 'invoicing',
1613     'description' => 'Send PDF invoice as an attachment to emailed invoices.  By default, includes the HTML invoice as the email body, unless invoice_email_pdf_note is set.',
1614     'type'        => 'checkbox'
1615   },
1616
1617   {
1618     'key'         => 'quotation_email_pdf',
1619     'section'     => '',
1620     'description' => 'Send PDF quotations as an attachment to emailed quotations.  By default, includes the HTML quotation as the email body, unless quotation_email_pdf_note is set.',
1621     'type'        => 'checkbox'
1622   },
1623
1624   {
1625     'key'         => 'invoice_email_pdf_msgnum',
1626     'section'     => 'invoicing',
1627     'description' => 'Message template to send as the text and HTML part of PDF invoices. If not selected, a text and HTML version of the invoice will be sent.',
1628     %msg_template_options,
1629   },
1630
1631   {
1632     'key'         => 'invoice_email_pdf_note',
1633     'section'     => 'invoicing',
1634     'description' => 'If defined, this text will replace the default HTML invoice as the body of emailed PDF invoices.',
1635     'type'        => 'textarea'
1636   },
1637
1638   {
1639     'key'         => 'quotation_email_pdf_note',
1640     'section'     => '',
1641     'description' => 'If defined, this text will replace the default HTML quotation as the body of emailed PDF quotations.',
1642     'type'        => 'textarea'
1643   },
1644
1645   {
1646     'key'         => 'invoice_print_pdf',
1647     'section'     => 'invoicing',
1648     'description' => 'For all invoice print operations, store postal invoices for download in PDF format rather than printing them directly.',
1649     'type'        => 'checkbox',
1650   },
1651
1652   {
1653     'key'         => 'invoice_print_pdf-spoolagent',
1654     'section'     => 'invoicing',
1655     'description' => 'Store postal invoices PDF downloads in per-agent spools.',
1656     'type'        => 'checkbox',
1657   },
1658
1659   {
1660     'key'         => 'invoice_print_pdf-duplex',
1661     'section'     => 'invoicing',
1662     'description' => 'Insert blank pages so that spooled invoices are each an even number of pages.  Use this for double-sided printing.',
1663     'type'        => 'checkbox',
1664   },
1665
1666   { 
1667     'key'         => 'invoice_default_terms',
1668     'section'     => 'invoicing',
1669     'description' => 'Optional default invoice term, used to calculate a due date printed on invoices.',
1670     'type'        => 'select',
1671     'per_agent'   => 1,
1672     'select_enum' => \@invoice_terms,
1673   },
1674
1675   { 
1676     'key'         => 'invoice_show_prior_due_date',
1677     'section'     => 'invoicing',
1678     'description' => 'Show previous invoice due dates when showing prior balances.  Default is to show invoice date.',
1679     'type'        => 'checkbox',
1680   },
1681
1682   { 
1683     'key'         => 'invoice_omit_due_date',
1684     'section'     => 'invoicing',
1685     'description' => 'Omit the "Please pay by (date)" from invoices.',
1686     'type'        => 'checkbox',
1687     'per_agent'   => 1,
1688   },
1689
1690   { 
1691     'key'         => 'invoice_pay_by_msg',
1692     'section'     => 'invoicing',
1693     'description' => 'Test of the "Please pay by (date)" message.  Include [_1] to indicate the date, for example: "Please pay by [_1]"',
1694     'type'        => 'text',
1695     'per_agent'   => 1,
1696   },
1697
1698   { 
1699     'key'         => 'invoice_sections',
1700     'section'     => 'invoicing',
1701     'description' => 'Split invoice into sections and label according to package category when enabled.',
1702     'type'        => 'checkbox',
1703     'per_agent'   => 1,
1704   },
1705
1706   { 
1707     'key'         => 'invoice_include_aging',
1708     'section'     => 'invoicing',
1709     'description' => 'Show an aging line after the prior balance section.  Only valid when invoice_sections is enabled.',
1710     'type'        => 'checkbox',
1711   },
1712
1713   {
1714     'key'         => 'invoice_sections_method',
1715     'section'     => 'invoicing',
1716     'description' => 'How to group line items on multi-section invoices.',
1717     'type'        => 'select',
1718     'select_enum' => [ qw(category location) ],
1719   },
1720
1721   {
1722     'key'         => 'summary_subtotals_method',
1723     'section'     => 'invoicing',
1724     'description' => 'How to group line items when calculating summary subtotals.  By default, it will be the same method used for grouping invoice sections.',
1725     'type'        => 'select',
1726     'select_enum' => [ qw(category location) ],
1727   },
1728
1729   #quotations seem broken-ish with sections ATM?
1730   #{ 
1731   #  'key'         => 'quotation_sections',
1732   #  'section'     => 'invoicing',
1733   #  'description' => 'Split quotations into sections and label according to package category when enabled.',
1734   #  'type'        => 'checkbox',
1735   #  'per_agent'   => 1,
1736   #},
1737
1738   {
1739     'key'         => 'usage_class_summary',
1740     'section'     => 'invoicing',
1741     'description' => 'Summarize total usage by usage class in a separate section.',
1742     'type'        => 'checkbox',
1743   },
1744
1745   { 
1746     'key'         => 'usage_class_as_a_section',
1747     'section'     => 'invoicing',
1748     'description' => 'Split usage into sections and label according to usage class name when enabled.  Only valid when invoice_sections is enabled.',
1749     'type'        => 'checkbox',
1750   },
1751
1752   { 
1753     'key'         => 'phone_usage_class_summary',
1754     'section'     => 'invoicing',
1755     'description' => 'Summarize usage per DID by usage class and display all CDRs together regardless of usage class. Only valid when svc_phone_sections is enabled.',
1756     'type'        => 'checkbox',
1757   },
1758
1759   { 
1760     'key'         => 'svc_phone_sections',
1761     'section'     => 'invoicing',
1762     'description' => 'Create a section for each svc_phone when enabled.  Only valid when invoice_sections is enabled.',
1763     'type'        => 'checkbox',
1764   },
1765
1766   {
1767     'key'         => 'finance_pkgclass',
1768     'section'     => 'billing',
1769     'description' => 'The default package class for late fee charges, used if the fee event does not specify a package class itself.',
1770     'type'        => 'select-pkg_class',
1771   },
1772
1773   { 
1774     'key'         => 'separate_usage',
1775     'section'     => 'invoicing',
1776     'description' => 'Split the rated call usage into a separate line from the recurring charges.',
1777     'type'        => 'checkbox',
1778   },
1779
1780   {
1781     'key'         => 'invoice_send_receipts',
1782     'section'     => 'deprecated',
1783     'description' => '<b>DEPRECATED</b>, this used to send an invoice copy on payments and credits.  See the payment_receipt_email and XXXX instead.',
1784     'type'        => 'checkbox',
1785   },
1786
1787   {
1788     'key'         => 'payment_receipt',
1789     'section'     => 'notification',
1790     'description' => 'Send payment receipts.',
1791     'type'        => 'checkbox',
1792     'per_agent'   => 1,
1793     'agent_bool'  => 1,
1794   },
1795
1796   {
1797     'key'         => 'payment_receipt_statement_mode',
1798     'section'     => 'notification',
1799     'description' => 'Automatic payments will cause a post-payment statement to be sent to the customer. Select the invoice mode to use for this statement. If unspecified, it will use the "_statement" versions of invoice configuration settings, and have the notice name "Statement".',
1800     %invoice_mode_options,
1801   },
1802
1803   {
1804     'key'         => 'payment_receipt_msgnum',
1805     'section'     => 'notification',
1806     'description' => 'Template to use for manual payment receipts.',
1807     %msg_template_options,
1808   },
1809   
1810   {
1811     'key'         => 'payment_receipt_from',
1812     'section'     => 'notification',
1813     'description' => 'From: address for payment receipts, if not specified in the template.',
1814     'type'        => 'text',
1815     'per_agent'   => 1,
1816   },
1817
1818   {
1819     'key'         => 'payment_receipt_email',
1820     'section'     => 'deprecated',
1821     'description' => 'Template file for payment receipts.  Payment receipts are sent to the customer email invoice destination(s) when a payment is received.',
1822     'type'        => [qw( checkbox textarea )],
1823   },
1824
1825   {
1826     'key'         => 'payment_receipt-trigger',
1827     'section'     => 'notification',
1828     'description' => 'When payment receipts are triggered.  Defaults to when payment is made.',
1829     'type'        => 'select',
1830     'select_hash' => [
1831                        'cust_pay'          => 'When payment is made.',
1832                        'cust_bill_pay_pkg' => 'When payment is applied.',
1833                      ],
1834     'per_agent'   => 1,
1835   },
1836
1837   {
1838     'key'         => 'refund_receipt_msgnum',
1839     'section'     => 'notification',
1840     'description' => 'Template to use for manual refund receipts.',
1841     %msg_template_options,
1842   },
1843   
1844   {
1845     'key'         => 'trigger_export_insert_on_payment',
1846     'section'     => 'billing',
1847     'description' => 'Enable exports on payment application.',
1848     'type'        => 'checkbox',
1849   },
1850
1851   {
1852     'key'         => 'lpr',
1853     'section'     => 'required',
1854     'description' => 'Print command for paper invoices, for example `lpr -h\'',
1855     'type'        => 'text',
1856     'per_agent'   => 1,
1857   },
1858
1859   {
1860     'key'         => 'lpr-postscript_prefix',
1861     'section'     => 'billing',
1862     'description' => 'Raw printer commands prepended to the beginning of postscript print jobs (evaluated as a double-quoted perl string - backslash escapes are available)',
1863     'type'        => 'text',
1864   },
1865
1866   {
1867     'key'         => 'lpr-postscript_suffix',
1868     'section'     => 'billing',
1869     'description' => 'Raw printer commands added to the end of postscript print jobs (evaluated as a double-quoted perl string - backslash escapes are available)',
1870     'type'        => 'text',
1871   },
1872
1873   {
1874     'key'         => 'papersize',
1875     'section'     => 'billing',
1876     'description' => 'Invoice paper size.  Default is "letter" (U.S. standard).  The LaTeX template must be configured to match this size.',
1877     'type'        => 'select',
1878     'select_enum' => [ qw(letter a4) ],
1879   },
1880
1881   {
1882     'key'         => 'money_char',
1883     'section'     => '',
1884     'description' => 'Currency symbol - defaults to `$\'',
1885     'type'        => 'text',
1886   },
1887
1888   {
1889     'key'         => 'defaultrecords',
1890     'section'     => 'BIND',
1891     'description' => 'DNS entries to add automatically when creating a domain',
1892     'type'        => 'editlist',
1893     'editlist_parts' => [ { type=>'text' },
1894                           { type=>'immutable', value=>'IN' },
1895                           { type=>'select',
1896                             select_enum => {
1897                               map { $_=>$_ }
1898                                   #@{ FS::domain_record->rectypes }
1899                                   qw(A AAAA CNAME MX NS PTR SPF SRV TXT)
1900                             },
1901                           },
1902                           { type=> 'text' }, ],
1903   },
1904
1905   {
1906     'key'         => 'passwordmin',
1907     'section'     => 'password',
1908     'description' => 'Minimum password length (default 6)',
1909     'type'        => 'text',
1910   },
1911
1912   {
1913     'key'         => 'passwordmax',
1914     'section'     => 'password',
1915     'description' => 'Maximum password length (default 8) (don\'t set this over 12 if you need to import or export crypt() passwords)',
1916     'type'        => 'text',
1917   },
1918
1919   {
1920     'key'         => 'sip_passwordmin',
1921     'section'     => 'telephony',
1922     'description' => 'Minimum SIP password length (default 6)',
1923     'type'        => 'text',
1924   },
1925
1926   {
1927     'key'         => 'sip_passwordmax',
1928     'section'     => 'telephony',
1929     'description' => 'Maximum SIP password length (default 80)',
1930     'type'        => 'text',
1931   },
1932
1933
1934   {
1935     'key'         => 'password-noampersand',
1936     'section'     => 'password',
1937     'description' => 'Disallow ampersands in passwords',
1938     'type'        => 'checkbox',
1939   },
1940
1941   {
1942     'key'         => 'password-noexclamation',
1943     'section'     => 'password',
1944     'description' => 'Disallow exclamations in passwords (Not setting this could break old text Livingston or Cistron Radius servers)',
1945     'type'        => 'checkbox',
1946   },
1947
1948   {
1949     'key'         => 'default-password-encoding',
1950     'section'     => 'password',
1951     'description' => 'Default storage format for passwords',
1952     'type'        => 'select',
1953     'select_hash' => [
1954       'plain'       => 'Plain text',
1955       'crypt-des'   => 'Unix password (DES encrypted)',
1956       'crypt-md5'   => 'Unix password (MD5 digest)',
1957       'ldap-plain'  => 'LDAP (plain text)',
1958       'ldap-crypt'  => 'LDAP (DES encrypted)',
1959       'ldap-md5'    => 'LDAP (MD5 digest)',
1960       'ldap-sha1'   => 'LDAP (SHA1 digest)',
1961       'legacy'      => 'Legacy mode',
1962     ],
1963   },
1964
1965   {
1966     'key'         => 'referraldefault',
1967     'section'     => 'UI',
1968     'description' => 'Default referral, specified by refnum',
1969     'type'        => 'select-sub',
1970     'options_sub' => sub { require FS::Record;
1971                            require FS::part_referral;
1972                            map { $_->refnum => $_->referral }
1973                                FS::Record::qsearch( 'part_referral', 
1974                                                     { 'disabled' => '' }
1975                                                   );
1976                          },
1977     'option_sub'  => sub { require FS::Record;
1978                            require FS::part_referral;
1979                            my $part_referral = FS::Record::qsearchs(
1980                              'part_referral', { 'refnum'=>shift } );
1981                            $part_referral ? $part_referral->referral : '';
1982                          },
1983   },
1984
1985 #  {
1986 #    'key'         => 'registries',
1987 #    'section'     => 'required',
1988 #    'description' => 'Directory which contains domain registry information.  Each registry is a directory.',
1989 #  },
1990
1991   {
1992     'key'         => 'report_template',
1993     'section'     => 'deprecated',
1994     'description' => 'Deprecated template file for reports.',
1995     'type'        => 'textarea',
1996   },
1997
1998   {
1999     'key'         => 'maxsearchrecordsperpage',
2000     'section'     => 'UI',
2001     'description' => 'If set, number of search records to return per page.',
2002     'type'        => 'text',
2003   },
2004
2005   {
2006     'key'         => 'disable_maxselect',
2007     'section'     => 'UI',
2008     'description' => 'Prevent changing the number of records per page.',
2009     'type'        => 'checkbox',
2010   },
2011
2012   {
2013     'key'         => 'session-start',
2014     'section'     => 'session',
2015     'description' => 'If defined, the command which is executed on the Freeside machine when a session begins.  The contents of the file are treated as a double-quoted perl string, with the following variables available: <code>$ip</code>, <code>$nasip</code> and <code>$nasfqdn</code>, which are the IP address of the starting session, and the IP address and fully-qualified domain name of the NAS this session is on.',
2016     'type'        => 'text',
2017   },
2018
2019   {
2020     'key'         => 'session-stop',
2021     'section'     => 'session',
2022     'description' => 'If defined, the command which is executed on the Freeside machine when a session ends.  The contents of the file are treated as a double-quoted perl string, with the following variables available: <code>$ip</code>, <code>$nasip</code> and <code>$nasfqdn</code>, which are the IP address of the starting session, and the IP address and fully-qualified domain name of the NAS this session is on.',
2023     'type'        => 'text',
2024   },
2025
2026   {
2027     'key'         => 'shells',
2028     'section'     => 'shell',
2029     'description' => 'Legal shells (think /etc/shells).  You probably want to `cut -d: -f7 /etc/passwd | sort | uniq\' initially so that importing doesn\'t fail with `Illegal shell\' errors, then remove any special entries afterwords.  A blank line specifies that an empty shell is permitted.',
2030     'type'        => 'textarea',
2031   },
2032
2033   {
2034     'key'         => 'showpasswords',
2035     'section'     => 'UI',
2036     'description' => 'Display unencrypted user passwords in the backend (employee) web interface',
2037     'type'        => 'checkbox',
2038   },
2039
2040   {
2041     'key'         => 'report-showpasswords',
2042     'section'     => 'UI',
2043     'description' => 'This is a terrible idea.  Do not enable it.  STRONGLY NOT RECOMMENDED.  Enables display of passwords on services reports.',
2044     'type'        => 'checkbox',
2045   },
2046
2047   {
2048     'key'         => 'signupurl',
2049     'section'     => 'UI',
2050     'description' => 'if you are using customer-to-customer referrals, and you enter the URL of your <a href="http://www.freeside.biz/mediawiki/index.php/Freeside:2.1:Documentation:Self-Service_Installation">signup server CGI</a>, the customer view screen will display a customized link to the signup server with the appropriate customer as referral',
2051     'type'        => 'text',
2052   },
2053
2054   {
2055     'key'         => 'smtpmachine',
2056     'section'     => 'required',
2057     'description' => 'SMTP relay for Freeside\'s outgoing mail',
2058     'type'        => 'text',
2059   },
2060
2061   {
2062     'key'         => 'smtp-username',
2063     'section'     => '',
2064     'description' => 'Optional SMTP username for Freeside\'s outgoing mail',
2065     'type'        => 'text',
2066   },
2067
2068   {
2069     'key'         => 'smtp-password',
2070     'section'     => '',
2071     'description' => 'Optional SMTP password for Freeside\'s outgoing mail',
2072     'type'        => 'text',
2073   },
2074
2075   {
2076     'key'         => 'smtp-encryption',
2077     'section'     => '',
2078     'description' => 'Optional SMTP encryption method.  The STARTTLS methods require smtp-username and smtp-password to be set.',
2079     'type'        => 'select',
2080     'select_hash' => [ '25'           => 'None (port 25)',
2081                        '25-starttls'  => 'STARTTLS (port 25)',
2082                        '587-starttls' => 'STARTTLS / submission (port 587)',
2083                        '465-tls'      => 'SMTPS (SSL) (port 465)',
2084                      ],
2085   },
2086
2087   {
2088     'key'         => 'soadefaultttl',
2089     'section'     => 'BIND',
2090     'description' => 'SOA default TTL for new domains.',
2091     'type'        => 'text',
2092   },
2093
2094   {
2095     'key'         => 'soaemail',
2096     'section'     => 'BIND',
2097     'description' => 'SOA email for new domains, in BIND form (`.\' instead of `@\'), with trailing `.\'',
2098     'type'        => 'text',
2099   },
2100
2101   {
2102     'key'         => 'soaexpire',
2103     'section'     => 'BIND',
2104     'description' => 'SOA expire for new domains',
2105     'type'        => 'text',
2106   },
2107
2108   {
2109     'key'         => 'soamachine',
2110     'section'     => 'BIND',
2111     'description' => 'SOA machine for new domains, with trailing `.\'',
2112     'type'        => 'text',
2113   },
2114
2115   {
2116     'key'         => 'soarefresh',
2117     'section'     => 'BIND',
2118     'description' => 'SOA refresh for new domains',
2119     'type'        => 'text',
2120   },
2121
2122   {
2123     'key'         => 'soaretry',
2124     'section'     => 'BIND',
2125     'description' => 'SOA retry for new domains',
2126     'type'        => 'text',
2127   },
2128
2129   {
2130     'key'         => 'statedefault',
2131     'section'     => 'UI',
2132     'description' => 'Default state or province (if not supplied, the default is `CA\')',
2133     'type'        => 'text',
2134   },
2135
2136   {
2137     'key'         => 'unsuspend_balance',
2138     'section'     => 'billing',
2139     'description' => 'Enables the automatic unsuspension of suspended packages when a customer\'s balance due is at or below the specified amount after a payment or credit',
2140     'type'        => 'select',
2141     'select_enum' => [ 
2142       '', 'Zero', 'Latest invoice charges', 'Charges not past due'
2143     ],
2144   },
2145
2146   {
2147     'key'         => 'unsuspend-always_adjust_next_bill_date',
2148     'section'     => 'billing',
2149     'description' => 'Global override that causes unsuspensions to always adjust the next bill date under any circumstances.  This is now controlled on a per-package bases - probably best not to use this option unless you are a legacy installation that requires this behaviour.',
2150     'type'        => 'checkbox',
2151   },
2152
2153   {
2154     'key'         => 'usernamemin',
2155     'section'     => 'username',
2156     'description' => 'Minimum username length (default 2)',
2157     'type'        => 'text',
2158   },
2159
2160   {
2161     'key'         => 'usernamemax',
2162     'section'     => 'username',
2163     'description' => 'Maximum username length',
2164     'type'        => 'text',
2165   },
2166
2167   {
2168     'key'         => 'username-ampersand',
2169     'section'     => 'username',
2170     'description' => 'Allow the ampersand character (&amp;) in usernames.  Be careful when using this option in conjunction with <a href="../browse/part_export.cgi">exports</a> which execute shell commands, as the ampersand will be interpreted by the shell if not quoted.',
2171     'type'        => 'checkbox',
2172   },
2173
2174   {
2175     'key'         => 'username-letter',
2176     'section'     => 'username',
2177     'description' => 'Usernames must contain at least one letter',
2178     'type'        => 'checkbox',
2179     'per_agent'   => 1,
2180   },
2181
2182   {
2183     'key'         => 'username-letterfirst',
2184     'section'     => 'username',
2185     'description' => 'Usernames must start with a letter',
2186     'type'        => 'checkbox',
2187   },
2188
2189   {
2190     'key'         => 'username-noperiod',
2191     'section'     => 'username',
2192     'description' => 'Disallow periods in usernames',
2193     'type'        => 'checkbox',
2194   },
2195
2196   {
2197     'key'         => 'username-nounderscore',
2198     'section'     => 'username',
2199     'description' => 'Disallow underscores in usernames',
2200     'type'        => 'checkbox',
2201   },
2202
2203   {
2204     'key'         => 'username-nodash',
2205     'section'     => 'username',
2206     'description' => 'Disallow dashes in usernames',
2207     'type'        => 'checkbox',
2208   },
2209
2210   {
2211     'key'         => 'username-uppercase',
2212     'section'     => 'username',
2213     'description' => 'Allow uppercase characters in usernames.  Not recommended for use with FreeRADIUS with MySQL backend, which is case-insensitive by default.',
2214     'type'        => 'checkbox',
2215     'per_agent'   => 1,
2216   },
2217
2218   { 
2219     'key'         => 'username-percent',
2220     'section'     => 'username',
2221     'description' => 'Allow the percent character (%) in usernames.',
2222     'type'        => 'checkbox',
2223   },
2224
2225   { 
2226     'key'         => 'username-colon',
2227     'section'     => 'username',
2228     'description' => 'Allow the colon character (:) in usernames.',
2229     'type'        => 'checkbox',
2230   },
2231
2232   { 
2233     'key'         => 'username-slash',
2234     'section'     => 'username',
2235     'description' => 'Allow the slash character (/) in usernames.  When using, make sure to set "Home directory" to fixed and blank in all svc_acct service definitions.',
2236     'type'        => 'checkbox',
2237   },
2238
2239   { 
2240     'key'         => 'username-equals',
2241     'section'     => 'username',
2242     'description' => 'Allow the equal sign character (=) in usernames.',
2243     'type'        => 'checkbox',
2244   },
2245
2246   {
2247     'key'         => 'safe-part_bill_event',
2248     'section'     => 'UI',
2249     'description' => 'Validates invoice event expressions against a preset list.  Useful for webdemos, annoying to powerusers.',
2250     'type'        => 'checkbox',
2251   },
2252
2253   {
2254     'key'         => 'google_maps_api_key',
2255     'section'     => 'UI',
2256     'description' => 'API key for google maps.  This must be set for map and directions links to work.  See <a href="https://developers.google.com/maps/documentation/javascript/get-api-key" target="_top">Getting a Google Maps API Key</a>',
2257     'type'        => 'text',
2258   },
2259
2260   {
2261     'key'         => 'company_physical_address',
2262     'section'     => 'UI',
2263     'description' => 'Your physical company address, for use in supplying google map directions, defaults to company_address',
2264     'type'        => 'textarea',
2265     'per_agent'   => 1,
2266   },
2267
2268   {
2269     'key'         => 'show_ship_company',
2270     'section'     => 'UI',
2271     'description' => 'Turns on display/collection of a "service company name" field for customers.',
2272     'type'        => 'checkbox',
2273   },
2274
2275   {
2276     'key'         => 'show_ss',
2277     'section'     => 'UI',
2278     'description' => 'Turns on display/collection of social security numbers in the web interface.  Sometimes required by electronic check (ACH) processors.',
2279     'type'        => 'checkbox',
2280   },
2281
2282   {
2283     'key'         => 'unmask_ss',
2284     'section'     => 'UI',
2285     'description' => "Don't mask social security numbers in the web interface.",
2286     'type'        => 'checkbox',
2287   },
2288
2289   {
2290     'key'         => 'show_stateid',
2291     'section'     => 'UI',
2292     'description' => "Turns on display/collection of driver's license/state issued id numbers in the web interface.  Sometimes required by electronic check (ACH) processors.",
2293     'type'        => 'checkbox',
2294   },
2295
2296   {
2297     'key'         => 'national_id-country',
2298     'section'     => 'UI',
2299     'description' => 'Track a national identification number, for specific countries.',
2300     'type'        => 'select',
2301     'select_enum' => [ '', 'MY' ],
2302   },
2303
2304   {
2305     'key'         => 'show_bankstate',
2306     'section'     => 'UI',
2307     'description' => "Turns on display/collection of state for bank accounts in the web interface.  Sometimes required by electronic check (ACH) processors.",
2308     'type'        => 'checkbox',
2309   },
2310
2311   { 
2312     'key'         => 'agent_defaultpkg',
2313     'section'     => 'UI',
2314     'description' => 'Setting this option will cause new packages to be available to all agent types by default.',
2315     'type'        => 'checkbox',
2316   },
2317
2318   {
2319     'key'         => 'legacy_link',
2320     'section'     => 'UI',
2321     'description' => 'Display options in the web interface to link legacy pre-Freeside services.',
2322     'type'        => 'checkbox',
2323   },
2324
2325   {
2326     'key'         => 'legacy_link-steal',
2327     'section'     => 'UI',
2328     'description' => 'Allow "stealing" an already-audited service from one customer (or package) to another using the link function.',
2329     'type'        => 'checkbox',
2330   },
2331
2332   {
2333     'key'         => 'queue_dangerous_controls',
2334     'section'     => 'UI',
2335     'description' => 'Enable queue modification controls on account pages and for new jobs.  Unless you are a developer working on new export code, you should probably leave this off to avoid causing provisioning problems.',
2336     'type'        => 'checkbox',
2337   },
2338
2339   {
2340     'key'         => 'security_phrase',
2341     'section'     => 'password',
2342     'description' => 'Enable the tracking of a "security phrase" with each account.  Not recommended, as it is vulnerable to social engineering.',
2343     'type'        => 'checkbox',
2344   },
2345
2346   {
2347     'key'         => 'locale',
2348     'section'     => 'UI',
2349     'description' => 'Default locale',
2350     'type'        => 'select-sub',
2351     'options_sub' => sub {
2352       map { $_ => FS::Locales->description($_) } FS::Locales->locales;
2353     },
2354     'option_sub'  => sub {
2355       FS::Locales->description(shift)
2356     },
2357   },
2358
2359   {
2360     'key'         => 'signup_server-payby',
2361     'section'     => 'self-service',
2362     'description' => 'Acceptable payment types for the signup server',
2363     'type'        => 'selectmultiple',
2364     'select_enum' => [ qw(CARD DCRD CHEK DCHK LECB PREPAY PPAL BILL COMP) ],
2365   },
2366
2367   {
2368     'key'         => 'selfservice-payment_gateway',
2369     'section'     => 'self-service',
2370     'description' => 'Force the use of this payment gateway for self-service.',
2371     %payment_gateway_options,
2372   },
2373
2374   {
2375     'key'         => 'selfservice-save_unchecked',
2376     'section'     => 'self-service',
2377     'description' => 'In self-service, uncheck "Remember information" checkboxes by default (normally, they are checked by default).',
2378     'type'        => 'checkbox',
2379   },
2380
2381   {
2382     'key'         => 'default_agentnum',
2383     'section'     => 'UI',
2384     'description' => 'Default agent for the backoffice',
2385     'type'        => 'select-agent',
2386   },
2387
2388   {
2389     'key'         => 'signup_server-default_agentnum',
2390     'section'     => 'self-service',
2391     'description' => 'Default agent for the signup server',
2392     'type'        => 'select-agent',
2393   },
2394
2395   {
2396     'key'         => 'signup_server-default_refnum',
2397     'section'     => 'self-service',
2398     'description' => 'Default advertising source for the signup server',
2399     'type'        => 'select-sub',
2400     'options_sub' => sub { require FS::Record;
2401                            require FS::part_referral;
2402                            map { $_->refnum => $_->referral }
2403                                FS::Record::qsearch( 'part_referral', 
2404                                                     { 'disabled' => '' }
2405                                                   );
2406                          },
2407     'option_sub'  => sub { require FS::Record;
2408                            require FS::part_referral;
2409                            my $part_referral = FS::Record::qsearchs(
2410                              'part_referral', { 'refnum'=>shift } );
2411                            $part_referral ? $part_referral->referral : '';
2412                          },
2413   },
2414
2415   {
2416     'key'         => 'signup_server-default_pkgpart',
2417     'section'     => 'self-service',
2418     'description' => 'Default package for the signup server',
2419     'type'        => 'select-part_pkg',
2420   },
2421
2422   {
2423     'key'         => 'signup_server-default_svcpart',
2424     'section'     => 'self-service',
2425     'description' => 'Default service definition for the signup server - only necessary for services that trigger special provisioning widgets (such as DID provisioning or domain selection).',
2426     'type'        => 'select-part_svc',
2427   },
2428
2429   {
2430     'key'         => 'signup_server-default_domsvc',
2431     'section'     => 'self-service',
2432     'description' => 'If specified, the default domain svcpart for signup (useful when domain is set to selectable choice).',
2433     'type'        => 'text',
2434   },
2435
2436   {
2437     'key'         => 'signup_server-mac_addr_svcparts',
2438     'section'     => 'self-service',
2439     'description' => 'Service definitions which can receive mac addresses (current mapped to username for svc_acct).',
2440     'type'        => 'select-part_svc',
2441     'multiple'    => 1,
2442   },
2443
2444   {
2445     'key'         => 'signup_server-nomadix',
2446     'section'     => 'self-service',
2447     'description' => 'Signup page Nomadix integration',
2448     'type'        => 'checkbox',
2449   },
2450
2451   {
2452     'key'         => 'signup_server-service',
2453     'section'     => 'self-service',
2454     'description' => 'Service for the signup server - "Account (svc_acct)" is the default setting, or "Phone number (svc_phone)" for ITSP signup',
2455     'type'        => 'select',
2456     'select_hash' => [
2457                        'svc_acct'  => 'Account (svc_acct)',
2458                        'svc_phone' => 'Phone number (svc_phone)',
2459                        'svc_pbx'   => 'PBX (svc_pbx)',
2460                        'none'      => 'None - package only',
2461                      ],
2462   },
2463   
2464   {
2465     'key'         => 'signup_server-prepaid-template-custnum',
2466     'section'     => 'self-service',
2467     'description' => 'When the signup server is used with prepaid cards and customer info is not required for signup, the contact/address info will be copied from this customer, if specified',
2468     'type'        => 'text',
2469   },
2470
2471   {
2472     'key'         => 'signup_server-terms_of_service',
2473     'section'     => 'self-service',
2474     'description' => 'Terms of Service for the signup server.  May contain HTML.',
2475     'type'        => 'textarea',
2476     'per_agent'   => 1,
2477   },
2478
2479   {
2480     'key'         => 'selfservice_server-base_url',
2481     'section'     => 'self-service',
2482     'description' => 'Base URL for the self-service web interface - necessary for some widgets to find their way, including retrieval of non-US state information and phone number provisioning.',
2483     'type'        => 'text',
2484   },
2485
2486   {
2487     'key'         => 'show-msgcat-codes',
2488     'section'     => 'UI',
2489     'description' => 'Show msgcat codes in error messages.  Turn this option on before reporting errors to the mailing list.',
2490     'type'        => 'checkbox',
2491   },
2492
2493   {
2494     'key'         => 'signup_server-realtime',
2495     'section'     => 'self-service',
2496     'description' => 'Run billing for signup server signups immediately, and do not provision accounts which subsequently have a balance.',
2497     'type'        => 'checkbox',
2498   },
2499
2500   {
2501     'key'         => 'signup_server-classnum2',
2502     'section'     => 'self-service',
2503     'description' => 'Package Class for first optional purchase',
2504     'type'        => 'select-pkg_class',
2505   },
2506
2507   {
2508     'key'         => 'signup_server-classnum3',
2509     'section'     => 'self-service',
2510     'description' => 'Package Class for second optional purchase',
2511     'type'        => 'select-pkg_class',
2512   },
2513
2514   {
2515     'key'         => 'signup_server-third_party_as_card',
2516     'section'     => 'self-service',
2517     'description' => 'Allow customer payment type to be set to CARD even when using third-party credit card billing.',
2518     'type'        => 'checkbox',
2519   },
2520
2521   {
2522     'key'         => 'selfservice-xmlrpc',
2523     'section'     => 'self-service',
2524     'description' => 'Run a standalone self-service XML-RPC server on the backend (on port 8080).',
2525     'type'        => 'checkbox',
2526   },
2527
2528   {
2529     'key'         => 'selfservice-timeout',
2530     'section'     => 'self-service',
2531     'description' => 'Timeout for the self-service login cookie, in seconds.  Defaults to 1 hour.',
2532     'type'        => 'text',
2533   },
2534
2535   {
2536     'key'         => 'backend-realtime',
2537     'section'     => 'billing',
2538     'description' => 'Run billing for backend signups immediately.',
2539     'type'        => 'checkbox',
2540   },
2541
2542   {
2543     'key'         => 'decline_msgnum',
2544     'section'     => 'notification',
2545     'description' => 'Template to use for credit card and electronic check decline messages.',
2546     %msg_template_options,
2547   },
2548
2549   {
2550     'key'         => 'declinetemplate',
2551     'section'     => 'deprecated',
2552     'description' => 'Template file for credit card and electronic check decline emails.',
2553     'type'        => 'textarea',
2554   },
2555
2556   {
2557     'key'         => 'emaildecline',
2558     'section'     => 'notification',
2559     'description' => 'Enable emailing of credit card and electronic check decline notices.',
2560     'type'        => 'checkbox',
2561     'per_agent'   => 1,
2562   },
2563
2564   {
2565     'key'         => 'emaildecline-exclude',
2566     'section'     => 'notification',
2567     'description' => 'List of error messages that should not trigger email decline notices, one per line.',
2568     'type'        => 'textarea',
2569     'per_agent'   => 1,
2570   },
2571
2572   {
2573     'key'         => 'cancel_msgnum',
2574     'section'     => 'notification',
2575     'description' => 'Template to use for cancellation emails.',
2576     %msg_template_options,
2577   },
2578
2579   {
2580     'key'         => 'cancelmessage',
2581     'section'     => 'deprecated',
2582     'description' => 'Template file for cancellation emails.',
2583     'type'        => 'textarea',
2584   },
2585
2586   {
2587     'key'         => 'cancelsubject',
2588     'section'     => 'deprecated',
2589     'description' => 'Subject line for cancellation emails.',
2590     'type'        => 'text',
2591   },
2592
2593   {
2594     'key'         => 'emailcancel',
2595     'section'     => 'notification',
2596     'description' => 'Enable emailing of cancellation notices.  Make sure to select the template in the cancel_msgnum option.',
2597     'type'        => 'checkbox',
2598     'per_agent'   => 1,
2599   },
2600
2601   {
2602     'key'         => 'bill_usage_on_cancel',
2603     'section'     => 'billing',
2604     'description' => 'Enable automatic generation of an invoice for usage when a package is cancelled.  Not all packages can do this.  Usage data must already be available.',
2605     'type'        => 'checkbox',
2606   },
2607
2608   {
2609     'key'         => 'cancel_msgnum-referring_cust-pkg_class',
2610     'section'     => 'notification',
2611     'description' => 'Enable cancellation messages to the referring customer for these package classes.',
2612     'type'        => 'select-pkg_class',
2613     'multiple'    => 1,
2614   },
2615
2616   {
2617     'key'         => 'cancel_msgnum-referring_cust',
2618     'section'     => 'notification',
2619     'description' => 'Template to use for cancellation emails sent to the referring customer.',
2620     %msg_template_options,
2621   },
2622
2623   {
2624     'key'         => 'require_cardname',
2625     'section'     => 'billing',
2626     'description' => 'Require an "Exact name on card" to be entered explicitly; don\'t default to using the first and last name.',
2627     'type'        => 'checkbox',
2628   },
2629
2630   {
2631     'key'         => 'enable_taxclasses',
2632     'section'     => 'billing',
2633     'description' => 'Enable per-package tax classes',
2634     'type'        => 'checkbox',
2635   },
2636
2637   {
2638     'key'         => 'require_taxclasses',
2639     'section'     => 'billing',
2640     'description' => 'Require a taxclass to be entered for every package',
2641     'type'        => 'checkbox',
2642   },
2643
2644   {
2645     'key'         => 'enable_taxproducts',
2646     'section'     => 'billing',
2647     'description' => 'Enable per-package mapping to vendor tax data from CCH or elsewhere.',
2648     'type'        => 'checkbox',
2649   },
2650
2651   {
2652     'key'         => 'taxdatadirectdownload',
2653     'section'     => 'billing',  #well
2654     'description' => 'Enable downloading tax data directly from the vendor site. at least three lines: URL, username, and password.j',
2655     'type'        => 'textarea',
2656   },
2657
2658   {
2659     'key'         => 'ignore_incalculable_taxes',
2660     'section'     => 'billing',
2661     'description' => 'Prefer to invoice without tax over not billing at all',
2662     'type'        => 'checkbox',
2663   },
2664
2665   {
2666     'key'         => 'welcome_msgnum',
2667     'section'     => 'notification',
2668     'description' => 'Template to use for welcome messages when a svc_acct record is created.',
2669     %msg_template_options,
2670   },
2671   
2672   {
2673     'key'         => 'svc_acct_welcome_exclude',
2674     'section'     => 'notification',
2675     'description' => 'A list of svc_acct services for which no welcome email is to be sent.',
2676     'type'        => 'select-part_svc',
2677     'multiple'    => 1,
2678   },
2679
2680   {
2681     'key'         => 'welcome_email',
2682     'section'     => 'deprecated',
2683     'description' => 'Template file for welcome email.  Welcome emails are sent to the customer email invoice destination(s) each time a svc_acct record is created.',
2684     'type'        => 'textarea',
2685     'per_agent'   => 1,
2686   },
2687
2688   {
2689     'key'         => 'welcome_email-from',
2690     'section'     => 'deprecated',
2691     'description' => 'From: address header for welcome email',
2692     'type'        => 'text',
2693     'per_agent'   => 1,
2694   },
2695
2696   {
2697     'key'         => 'welcome_email-subject',
2698     'section'     => 'deprecated',
2699     'description' => 'Subject: header for welcome email',
2700     'type'        => 'text',
2701     'per_agent'   => 1,
2702   },
2703   
2704   {
2705     'key'         => 'welcome_email-mimetype',
2706     'section'     => 'deprecated',
2707     'description' => 'MIME type for welcome email',
2708     'type'        => 'select',
2709     'select_enum' => [ 'text/plain', 'text/html' ],
2710     'per_agent'   => 1,
2711   },
2712
2713   {
2714     'key'         => 'welcome_letter',
2715     'section'     => '',
2716     'description' => 'Optional LaTex template file for a printed welcome letter.  A welcome letter is printed the first time a cust_pkg record is created.  See the <a href="http://search.cpan.org/dist/Text-Template/lib/Text/Template.pm">Text::Template</a> documentation and the billing documentation for details on the template substitution language.  A variable exists for each fieldname in the customer record (<code>$first, $last, etc</code>).  The following additional variables are available<ul><li><code>$payby</code> - a friendler represenation of the field<li><code>$payinfo</code> - the masked payment information<li><code>$expdate</code> - the time at which the payment method expires (a UNIX timestamp)<li><code>$returnaddress</code> - the invoice return address for this customer\'s agent</ul>',
2717     'type'        => 'textarea',
2718   },
2719
2720 #  {
2721 #    'key'         => 'warning_msgnum',
2722 #    'section'     => 'notification',
2723 #    'description' => 'Template to use for warning messages, sent to the customer email invoice destination(s) when a svc_acct record has its usage drop below a threshold.',
2724 #    %msg_template_options,
2725 #  },
2726
2727   {
2728     'key'         => 'warning_email',
2729     'section'     => 'notification',
2730     'description' => 'Template file for warning email.  Warning emails are sent to the customer email invoice destination(s) each time a svc_acct record has its usage drop below a threshold or 0.  See the <a href="http://search.cpan.org/dist/Text-Template/lib/Text/Template.pm">Text::Template</a> documentation for details on the template substitution language.  The following variables are available<ul><li><code>$username</code> <li><code>$password</code> <li><code>$first</code> <li><code>$last</code> <li><code>$pkg</code> <li><code>$column</code> <li><code>$amount</code> <li><code>$threshold</code></ul>',
2731     'type'        => 'textarea',
2732   },
2733
2734   {
2735     'key'         => 'warning_email-from',
2736     'section'     => 'notification',
2737     'description' => 'From: address header for warning email',
2738     'type'        => 'text',
2739   },
2740
2741   {
2742     'key'         => 'warning_email-cc',
2743     'section'     => 'notification',
2744     'description' => 'Additional recipient(s) (comma separated) for warning email when remaining usage reaches zero.',
2745     'type'        => 'text',
2746   },
2747
2748   {
2749     'key'         => 'warning_email-subject',
2750     'section'     => 'notification',
2751     'description' => 'Subject: header for warning email',
2752     'type'        => 'text',
2753   },
2754   
2755   {
2756     'key'         => 'warning_email-mimetype',
2757     'section'     => 'notification',
2758     'description' => 'MIME type for warning email',
2759     'type'        => 'select',
2760     'select_enum' => [ 'text/plain', 'text/html' ],
2761   },
2762
2763   {
2764     'key'         => 'payby',
2765     'section'     => 'billing',
2766     'description' => 'Available payment types.',
2767     'type'        => 'selectmultiple',
2768     'select_enum' => [ qw(CARD DCRD CHEK DCHK LECB BILL CASH WEST MCRD MCHK PPAL COMP) ],
2769   },
2770
2771   {
2772     'key'         => 'payby-default',
2773     'section'     => 'UI',
2774     'description' => 'Default payment type.  HIDE disables display of billing information and sets customers to BILL.',
2775     'type'        => 'select',
2776     'select_enum' => [ '', qw(CARD DCRD CHEK DCHK LECB BILL CASH WEST MCRD PPAL COMP HIDE) ],
2777   },
2778
2779   {
2780     'key'         => 'require_cash_deposit_info',
2781     'section'     => 'billing',
2782     'description' => 'When recording cash payments, display bank deposit information fields.',
2783     'type'        => 'checkbox',
2784   },
2785
2786   {
2787     'key'         => 'paymentforcedtobatch',
2788     'section'     => 'deprecated',
2789     'description' => 'See batch-enable_payby and realtime-disable_payby.  Used to (for CHEK): Cause per customer payment entry to be forced to a batch processor rather than performed realtime.',
2790     'type'        => 'checkbox',
2791   },
2792
2793   {
2794     'key'         => 'svc_acct-notes',
2795     'section'     => 'deprecated',
2796     'description' => 'Extra HTML to be displayed on the Account View screen.',
2797     'type'        => 'textarea',
2798   },
2799
2800   {
2801     'key'         => 'radius-password',
2802     'section'     => '',
2803     'description' => 'RADIUS attribute for plain-text passwords.',
2804     'type'        => 'select',
2805     'select_enum' => [ 'Password', 'User-Password', 'Cleartext-Password' ],
2806   },
2807
2808   {
2809     'key'         => 'radius-ip',
2810     'section'     => '',
2811     'description' => 'RADIUS attribute for IP addresses.',
2812     'type'        => 'select',
2813     'select_enum' => [ 'Framed-IP-Address', 'Framed-Address' ],
2814   },
2815
2816   #http://dev.coova.org/svn/coova-chilli/doc/dictionary.chillispot
2817   {
2818     'key'         => 'radius-chillispot-max',
2819     'section'     => '',
2820     'description' => 'Enable ChilliSpot (and CoovaChilli) Max attributes, specifically ChilliSpot-Max-{Input,Output,Total}-{Octets,Gigawords}.',
2821     'type'        => 'checkbox',
2822   },
2823
2824   {
2825     'key'         => 'radius-canopy',
2826     'section'     => '',
2827     'description' => 'Enable RADIUS attributes for Cambium (formerly Motorola) Canopy (Motorola-Canopy-Gateway).',
2828     'type'        => 'checkbox',
2829   },
2830
2831   {
2832     'key'         => 'svc_broadband-radius',
2833     'section'     => '',
2834     'description' => 'Enable RADIUS groups for broadband services.',
2835     'type'        => 'checkbox',
2836   },
2837
2838   {
2839     'key'         => 'svc_acct-alldomains',
2840     'section'     => '',
2841     'description' => 'Allow accounts to select any domain in the database.  Normally accounts can only select from the domain set in the service definition and those purchased by the customer.',
2842     'type'        => 'checkbox',
2843   },
2844
2845   {
2846     'key'         => 'dump-localdest',
2847     'section'     => '',
2848     'description' => 'Destination for local database dumps (full path)',
2849     'type'        => 'text',
2850   },
2851
2852   {
2853     'key'         => 'dump-scpdest',
2854     'section'     => '',
2855     'description' => 'Destination for scp database dumps: user@host:/path',
2856     'type'        => 'text',
2857   },
2858
2859   {
2860     'key'         => 'dump-pgpid',
2861     'section'     => '',
2862     'description' => "Optional PGP public key user or key id for database dumps.  The public key should exist on the freeside user's public keyring, and the gpg binary and GnuPG perl module should be installed.",
2863     'type'        => 'text',
2864   },
2865
2866   {
2867     'key'         => 'dump-email_to',
2868     'section'     => '',
2869     'description' => "Optional email address to send success/failure message for database dumps.",
2870     'type'        => 'text',
2871     'validate'    => $validate_email,
2872   },
2873
2874   {
2875     'key'         => 'users-allow_comp',
2876     'section'     => 'deprecated',
2877     'description' => '<b>DEPRECATED</b>, enable the <i>Complimentary customer</i> access right instead.  Was: Usernames (Freeside users, created with <a href="../docs/man/bin/freeside-adduser.html">freeside-adduser</a>) which can create complimentary customers, one per line.  If no usernames are entered, all users can create complimentary accounts.',
2878     'type'        => 'textarea',
2879   },
2880
2881   {
2882     'key'         => 'credit_card-recurring_billing_flag',
2883     'section'     => 'billing',
2884     'description' => 'This controls when the system passes the "recurring_billing" flag on credit card transactions.  If supported by your processor (and the Business::OnlinePayment processor module), passing the flag indicates this is a recurring transaction and may turn off the CVV requirement. ',
2885     'type'        => 'select',
2886     'select_hash' => [
2887                        'actual_oncard' => 'Default/classic behavior: set the flag if a customer has actual previous charges on the card.',
2888                        'transaction_is_recur' => 'Set the flag if the transaction itself is recurring, irregardless of previous charges on the card.',
2889                      ],
2890   },
2891
2892   {
2893     'key'         => 'credit_card-recurring_billing_acct_code',
2894     'section'     => 'billing',
2895     'description' => 'When the "recurring billing" flag is set, also set the "acct_code" to "rebill".  Useful for reporting purposes with supported gateways (PlugNPay, others?)',
2896     'type'        => 'checkbox',
2897   },
2898
2899   {
2900     'key'         => 'cvv-save',
2901     'section'     => 'billing',
2902     'description' => 'NOT RECOMMENDED.  Saves CVV2 information after the initial transaction for the selected credit card types.  Enabling this option is almost certainly in violation of your merchant agreement(s), so please check them carefully before enabling this option for any credit card types.',
2903     'type'        => 'selectmultiple',
2904     'select_enum' => \@card_types,
2905   },
2906
2907   {
2908     'key'         => 'signup-require_cvv',
2909     'section'     => 'self-service',
2910     'description' => 'Require CVV for credit card signup.',
2911     'type'        => 'checkbox',
2912   },
2913
2914   {
2915     'key'         => 'backoffice-require_cvv',
2916     'section'     => 'billing',
2917     'description' => 'Require CVV for manual credit card entry.',
2918     'type'        => 'checkbox',
2919   },
2920
2921   {
2922     'key'         => 'selfservice-onfile_require_cvv',
2923     'section'     => 'self-service',
2924     'description' => 'Require CVV for on-file credit card during self-service payments.',
2925     'type'        => 'checkbox',
2926   },
2927
2928   {
2929     'key'         => 'selfservice-require_cvv',
2930     'section'     => 'self-service',
2931     'description' => 'Require CVV for credit card self-service payments, except for cards on-file.',
2932     'type'        => 'checkbox',
2933   },
2934
2935   {
2936     'key'         => 'manual_process-single_invoice_amount',
2937     'section'     => 'billing',
2938     'description' => 'When entering manual credit card and ACH payments, amount will not autofill if the customer has more than one open invoice',
2939     'type'        => 'checkbox',
2940   },
2941
2942   {
2943     'key'         => 'manual_process-pkgpart',
2944     'section'     => 'billing',
2945     'description' => 'Package to add to each manual credit card and ACH payment entered by employees from the backend.  Enabling this option may be in violation of your merchant agreement(s), so please check it(/them) carefully before enabling this option.',
2946     'type'        => 'select-part_pkg',
2947     'per_agent'   => 1,
2948   },
2949
2950   {
2951     'key'         => 'manual_process-display',
2952     'section'     => 'billing',
2953     'description' => 'When using manual_process-pkgpart, add the fee to the amount entered (default), or subtract the fee from the amount entered.',
2954     'type'        => 'select',
2955     'select_hash' => [
2956                        'add'      => 'Add fee to amount entered',
2957                        'subtract' => 'Subtract fee from amount entered',
2958                      ],
2959   },
2960
2961   {
2962     'key'         => 'manual_process-skip_first',
2963     'section'     => 'billing',
2964     'description' => "When using manual_process-pkgpart, omit the fee if it is the customer's first payment.",
2965     'type'        => 'checkbox',
2966   },
2967
2968   {
2969     'key'         => 'selfservice_immutable-package',
2970     'section'     => 'self-service',
2971     'description' => 'Disable package changes in self-service interface.',
2972     'type'        => 'checkbox',
2973     'per_agent'   => 1,
2974   },
2975
2976   {
2977     'key'         => 'selfservice_hide-usage',
2978     'section'     => 'self-service',
2979     'description' => 'Hide usage data in self-service interface.',
2980     'type'        => 'checkbox',
2981     'per_agent'   => 1,
2982   },
2983
2984   {
2985     'key'         => 'selfservice_process-pkgpart',
2986     'section'     => 'billing',
2987     'description' => 'Package to add to each manual credit card and ACH payment entered by the customer themselves in the self-service interface.  Enabling this option may be in violation of your merchant agreement(s), so please check it(/them) carefully before enabling this option.',
2988     'type'        => 'select-part_pkg',
2989     'per_agent'   => 1,
2990   },
2991
2992   {
2993     'key'         => 'selfservice_process-display',
2994     'section'     => 'billing',
2995     'description' => 'When using selfservice_process-pkgpart, add the fee to the amount entered (default), or subtract the fee from the amount entered.',
2996     'type'        => 'select',
2997     'select_hash' => [
2998                        'add'      => 'Add fee to amount entered',
2999                        'subtract' => 'Subtract fee from amount entered',
3000                      ],
3001   },
3002
3003   {
3004     'key'         => 'selfservice_process-skip_first',
3005     'section'     => 'billing',
3006     'description' => "When using selfservice_process-pkgpart, omit the fee if it is the customer's first payment.",
3007     'type'        => 'checkbox',
3008   },
3009
3010 #  {
3011 #    'key'         => 'auto_process-pkgpart',
3012 #    'section'     => 'billing',
3013 #    'description' => 'Package to add to each automatic credit card and ACH payment processed by billing events.  Enabling this option may be in violation of your merchant agreement(s), so please check them carefully before enabling this option.',
3014 #    'type'        => 'select-part_pkg',
3015 #  },
3016 #
3017 ##  {
3018 ##    'key'         => 'auto_process-display',
3019 ##    'section'     => 'billing',
3020 ##    'description' => 'When using auto_process-pkgpart, add the fee to the amount entered (default), or subtract the fee from the amount entered.',
3021 ##    'type'        => 'select',
3022 ##    'select_hash' => [
3023 ##                       'add'      => 'Add fee to amount entered',
3024 ##                       'subtract' => 'Subtract fee from amount entered',
3025 ##                     ],
3026 ##  },
3027 #
3028 #  {
3029 #    'key'         => 'auto_process-skip_first',
3030 #    'section'     => 'billing',
3031 #    'description' => "When using auto_process-pkgpart, omit the fee if it is the customer's first payment.",
3032 #    'type'        => 'checkbox',
3033 #  },
3034
3035   {
3036     'key'         => 'allow_negative_charges',
3037     'section'     => 'billing',
3038     'description' => 'Allow negative charges.  Normally not used unless importing data from a legacy system that requires this.',
3039     'type'        => 'checkbox',
3040   },
3041   {
3042       'key'         => 'auto_unset_catchall',
3043       'section'     => '',
3044       'description' => 'When canceling a svc_acct that is the email catchall for one or more svc_domains, automatically set their catchall fields to null.  If this option is not set, the attempt will simply fail.',
3045       'type'        => 'checkbox',
3046   },
3047
3048   {
3049     'key'         => 'system_usernames',
3050     'section'     => 'username',
3051     'description' => 'A list of system usernames that cannot be edited or removed, one per line.  Use a bare username to prohibit modification/deletion of the username in any domain, or username@domain to prohibit modification/deletetion of a specific username and domain.',
3052     'type'        => 'textarea',
3053   },
3054
3055   {
3056     'key'         => 'cust_pkg-change_svcpart',
3057     'section'     => '',
3058     'description' => "When changing packages, move services even if svcparts don't match between old and new pacakge definitions.",
3059     'type'        => 'checkbox',
3060   },
3061
3062   {
3063     'key'         => 'cust_pkg-change_pkgpart-bill_now',
3064     'section'     => '',
3065     'description' => "When changing packages, bill the new package immediately.  Useful for prepaid situations with RADIUS where an Expiration attribute based on the package must be present at all times.",
3066     'type'        => 'checkbox',
3067   },
3068
3069   {
3070     'key'         => 'disable_autoreverse',
3071     'section'     => 'BIND',
3072     'description' => 'Disable automatic synchronization of reverse-ARPA entries.',
3073     'type'        => 'checkbox',
3074   },
3075
3076   {
3077     'key'         => 'svc_www-enable_subdomains',
3078     'section'     => '',
3079     'description' => 'Enable selection of specific subdomains for virtual host creation.',
3080     'type'        => 'checkbox',
3081   },
3082
3083   {
3084     'key'         => 'svc_www-usersvc_svcpart',
3085     'section'     => '',
3086     'description' => 'Allowable service definition svcparts for virtual hosts, one per line.',
3087     'type'        => 'select-part_svc',
3088     'multiple'    => 1,
3089   },
3090
3091   {
3092     'key'         => 'selfservice_server-primary_only',
3093     'section'     => 'self-service',
3094     'description' => 'Only allow primary accounts to access self-service functionality.',
3095     'type'        => 'checkbox',
3096   },
3097
3098   {
3099     'key'         => 'selfservice_server-phone_login',
3100     'section'     => 'self-service',
3101     'description' => 'Allow login to self-service with phone number and PIN.',
3102     'type'        => 'checkbox',
3103   },
3104
3105   {
3106     'key'         => 'selfservice_server-single_domain',
3107     'section'     => 'self-service',
3108     'description' => 'If specified, only use this one domain for self-service access.',
3109     'type'        => 'text',
3110   },
3111
3112   {
3113     'key'         => 'selfservice_server-login_svcpart',
3114     'section'     => 'self-service',
3115     'description' => 'If specified, only allow the specified svcparts to login to self-service.',
3116     'type'        => 'select-part_svc',
3117     'multiple'    => 1,
3118   },
3119
3120   {
3121     'key'         => 'selfservice-svc_forward_svcpart',
3122     'section'     => 'self-service',
3123     'description' => 'Service for self-service forward editing.',
3124     'type'        => 'select-part_svc',
3125   },
3126
3127   {
3128     'key'         => 'selfservice-password_reset_verification',
3129     'section'     => 'self-service',
3130     'description' => 'If enabled, specifies the type of verification required for self-service password resets.',
3131     'type'        => 'select',
3132     'select_hash' => [ '' => 'Password reset disabled',
3133                        'email' => 'Click on a link in email',
3134                        'paymask,amount,zip' => 'Click on a link in email, and also verify with credit card (or bank account) last 4 digits, payment amount and zip code',
3135                      ],
3136   },
3137
3138   {
3139     'key'         => 'selfservice-password_reset_hours',
3140     'section'     => 'self-service',
3141     'description' => 'Numbers of hours an email password reset is valid.  Defaults to 24.',
3142     'type'        => 'text',
3143   },
3144
3145   {
3146     'key'         => 'selfservice-password_reset_msgnum',
3147     'section'     => 'self-service',
3148     'description' => 'Template to use for password reset emails.',
3149     %msg_template_options,
3150   },
3151
3152   {
3153     'key'         => 'selfservice-password_change_oldpass',
3154     'section'     => 'self-service',
3155     'description' => 'Require old password to be entered again for password changes (in addition to being logged in), at the API level.',
3156     'type'        => 'checkbox',
3157   },
3158
3159   {
3160     'key'         => 'selfservice-hide_invoices-taxclass',
3161     'section'     => 'self-service',
3162     'description' => 'Hide invoices with only this package tax class from self-service and supress sending (emailing, printing, faxing) them.  Typically set to something like "Previous balance" and used when importing legacy invoices into legacy_cust_bill.',
3163     'type'        => 'text',
3164   },
3165
3166   {
3167     'key'         => 'selfservice-recent-did-age',
3168     'section'     => 'self-service',
3169     'description' => 'If specified, defines "recent", in number of seconds, for "Download recently allocated DIDs" in self-service.',
3170     'type'        => 'text',
3171   },
3172
3173   {
3174     'key'         => 'selfservice_server-view-wholesale',
3175     'section'     => 'self-service',
3176     'description' => 'If enabled, use a wholesale package view in the self-service.',
3177     'type'        => 'checkbox',
3178   },
3179   
3180   {
3181     'key'         => 'selfservice-agent_signup',
3182     'section'     => 'self-service',
3183     'description' => 'Allow agent signup via self-service.',
3184     'type'        => 'checkbox',
3185   },
3186
3187   {
3188     'key'         => 'selfservice-agent_signup-agent_type',
3189     'section'     => 'self-service',
3190     'description' => 'Agent type when allowing agent signup via self-service.',
3191     'type'        => 'select-sub',
3192     'options_sub' => sub { require FS::Record;
3193                            require FS::agent_type;
3194                            map { $_->typenum => $_->atype }
3195                                FS::Record::qsearch('agent_type', {} ); # disabled=>'' } );
3196                          },
3197     'option_sub'  => sub { require FS::Record;
3198                            require FS::agent_type;
3199                            my $agent_type = FS::Record::qsearchs(
3200                              'agent_type', { 'typenum'=>shift }
3201                            );
3202                            $agent_type ? $agent_type->atype : '';
3203                          },
3204   },
3205
3206   {
3207     'key'         => 'selfservice-agent_login',
3208     'section'     => 'self-service',
3209     'description' => 'Allow agent login via self-service.',
3210     'type'        => 'checkbox',
3211   },
3212
3213   {
3214     'key'         => 'selfservice-self_suspend_reason',
3215     'section'     => 'self-service',
3216     'description' => 'Suspend reason when customers suspend their own packages. Set to nothing to disallow self-suspension.',
3217     'type'        => 'select-sub',
3218     #false laziness w/api_credit_reason
3219     'options_sub' => sub { require FS::Record;
3220                            require FS::reason;
3221                            my $type = qsearchs('reason_type', 
3222                              { class => 'S' }) 
3223                               or return ();
3224                            map { $_->reasonnum => $_->reason }
3225                                FS::Record::qsearch('reason', 
3226                                  { reason_type => $type->typenum } 
3227                                );
3228                          },
3229     'option_sub'  => sub { require FS::Record;
3230                            require FS::reason;
3231                            my $reason = FS::Record::qsearchs(
3232                              'reason', { 'reasonnum' => shift }
3233                            );
3234                            $reason ? $reason->reason : '';
3235                          },
3236
3237     'per_agent'   => 1,
3238   },
3239
3240   {
3241     'key'         => 'card_refund-days',
3242     'section'     => 'billing',
3243     'description' => 'After a payment, the number of days a refund link will be available for that payment.  Defaults to 120.',
3244     'type'        => 'text',
3245   },
3246
3247   {
3248     'key'         => 'agent-showpasswords',
3249     'section'     => '',
3250     'description' => 'Display unencrypted user passwords in the agent (reseller) interface',
3251     'type'        => 'checkbox',
3252   },
3253
3254   {
3255     'key'         => 'global_unique-username',
3256     'section'     => 'username',
3257     'description' => 'Global username uniqueness control: none (usual setting - check uniqueness per exports), username (all usernames are globally unique, regardless of domain or exports), or username@domain (all username@domain pairs are globally unique, regardless of exports).  disabled turns off duplicate checking completely and is STRONGLY NOT RECOMMENDED unless you REALLY need to turn this off.',
3258     'type'        => 'select',
3259     'select_enum' => [ 'none', 'username', 'username@domain', 'disabled' ],
3260   },
3261
3262   {
3263     'key'         => 'global_unique-phonenum',
3264     'section'     => '',
3265     'description' => 'Global phone number uniqueness control: none (usual setting - check countrycode+phonenumun uniqueness per exports), or countrycode+phonenum (all countrycode+phonenum pairs are globally unique, regardless of exports).  disabled turns off duplicate checking completely and is STRONGLY NOT RECOMMENDED unless you REALLY need to turn this off.',
3266     'type'        => 'select',
3267     'select_enum' => [ 'none', 'countrycode+phonenum', 'disabled' ],
3268   },
3269
3270   {
3271     'key'         => 'global_unique-pbx_title',
3272     'section'     => '',
3273     'description' => 'Global phone number uniqueness control: none (check uniqueness per exports), enabled (check across all services), or disabled (no duplicate checking).',
3274     'type'        => 'select',
3275     'select_enum' => [ 'enabled', 'disabled' ],
3276   },
3277
3278   {
3279     'key'         => 'global_unique-pbx_id',
3280     'section'     => '',
3281     'description' => 'Global PBX id uniqueness control: none (check uniqueness per exports), enabled (check across all services), or disabled (no duplicate checking).',
3282     'type'        => 'select',
3283     'select_enum' => [ 'enabled', 'disabled' ],
3284   },
3285
3286   {
3287     'key'         => 'svc_external-skip_manual',
3288     'section'     => 'UI',
3289     'description' => 'When provisioning svc_external services, skip manual entry of id and title fields in the UI.  Usually used in conjunction with an export that populates these fields (i.e. artera_turbo).',
3290     'type'        => 'checkbox',
3291   },
3292
3293   {
3294     'key'         => 'svc_external-display_type',
3295     'section'     => 'UI',
3296     'description' => 'Select a specific svc_external type to enable some UI changes specific to that type (i.e. artera_turbo).',
3297     'type'        => 'select',
3298     'select_enum' => [ 'generic', 'artera_turbo', ],
3299   },
3300
3301   {
3302     'key'         => 'ticket_system',
3303     'section'     => 'ticketing',
3304     'description' => 'Ticketing system integration.  <b>RT_Internal</b> uses the built-in RT ticketing system (see the <a href="http://www.freeside.biz/mediawiki/index.php/Freeside:3:Documentation:RT_Installation">integrated ticketing installation instructions</a>).   <b>RT_External</b> accesses an external RT installation in a separate database (local or remote).',
3305     'type'        => 'select',
3306     #'select_enum' => [ '', qw(RT_Internal RT_Libs RT_External) ],
3307     'select_enum' => [ '', qw(RT_Internal RT_External) ],
3308   },
3309
3310   {
3311     'key'         => 'network_monitoring_system',
3312     'section'     => 'network_monitoring',
3313     'description' => 'Networking monitoring system (NMS) integration.  <b>Torrus_Internal</b> uses the built-in Torrus ticketing system (see the <a href="http://www.freeside.biz/mediawiki/index.php/Freeside:3:Documentation:Torrus_Installation">integrated networking monitoring system installation instructions</a>).',
3314     'type'        => 'select',
3315     'select_enum' => [ '', qw(Torrus_Internal) ],
3316   },
3317
3318   {
3319     'key'         => 'nms-auto_add-svc_ips',
3320     'section'     => 'network_monitoring',
3321     'description' => 'Automatically add (and remove) IP addresses from these service tables to the network monitoring system.',
3322     'type'        => 'selectmultiple',
3323     'select_enum' => [ 'svc_acct', 'svc_broadband', 'svc_dsl' ],
3324   },
3325
3326   {
3327     'key'         => 'nms-auto_add-community',
3328     'section'     => 'network_monitoring',
3329     'description' => 'SNMP community string to use when automatically adding IP addresses from these services to the network monitoring system.',
3330     'type'        => 'text',
3331   },
3332
3333   {
3334     'key'         => 'ticket_system-default_queueid',
3335     'section'     => 'ticketing',
3336     'description' => 'Default queue used when creating new customer tickets.',
3337     'type'        => 'select-sub',
3338     'options_sub' => sub {
3339                            my $conf = new FS::Conf;
3340                            if ( $conf->config('ticket_system') ) {
3341                              eval "use FS::TicketSystem;";
3342                              die $@ if $@;
3343                              FS::TicketSystem->queues();
3344                            } else {
3345                              ();
3346                            }
3347                          },
3348     'option_sub'  => sub { 
3349                            my $conf = new FS::Conf;
3350                            if ( $conf->config('ticket_system') ) {
3351                              eval "use FS::TicketSystem;";
3352                              die $@ if $@;
3353                              FS::TicketSystem->queue(shift);
3354                            } else {
3355                              '';
3356                            }
3357                          },
3358   },
3359
3360   {
3361     'key'         => 'ticket_system-force_default_queueid',
3362     'section'     => 'ticketing',
3363     'description' => 'Disallow queue selection when creating new tickets from customer view.',
3364     'type'        => 'checkbox',
3365   },
3366
3367   {
3368     'key'         => 'ticket_system-selfservice_queueid',
3369     'section'     => 'ticketing',
3370     'description' => 'Queue used when creating new customer tickets from self-service.  Defautls to ticket_system-default_queueid if not specified.',
3371     #false laziness w/above
3372     'type'        => 'select-sub',
3373     'options_sub' => sub {
3374                            my $conf = new FS::Conf;
3375                            if ( $conf->config('ticket_system') ) {
3376                              eval "use FS::TicketSystem;";
3377                              die $@ if $@;
3378                              FS::TicketSystem->queues();
3379                            } else {
3380                              ();
3381                            }
3382                          },
3383     'option_sub'  => sub { 
3384                            my $conf = new FS::Conf;
3385                            if ( $conf->config('ticket_system') ) {
3386                              eval "use FS::TicketSystem;";
3387                              die $@ if $@;
3388                              FS::TicketSystem->queue(shift);
3389                            } else {
3390                              '';
3391                            }
3392                          },
3393   },
3394
3395   {
3396     'key'         => 'ticket_system-requestor',
3397     'section'     => 'ticketing',
3398     'description' => 'Email address to use as the requestor for new tickets.  If blank, the customer\'s invoicing address(es) will be used.',
3399     'type'        => 'text',
3400   },
3401
3402   {
3403     'key'         => 'ticket_system-priority_reverse',
3404     'section'     => 'ticketing',
3405     'description' => 'Enable this to consider lower numbered priorities more important.  A bad habit we picked up somewhere.  You probably want to avoid it and use the default.',
3406     'type'        => 'checkbox',
3407   },
3408
3409   {
3410     'key'         => 'ticket_system-custom_priority_field',
3411     'section'     => 'ticketing',
3412     'description' => 'Custom field from the ticketing system to use as a custom priority classification.',
3413     'type'        => 'text',
3414   },
3415
3416   {
3417     'key'         => 'ticket_system-custom_priority_field-values',
3418     'section'     => 'ticketing',
3419     'description' => 'Values for the custom field from the ticketing system to break down and sort customer ticket lists.',
3420     'type'        => 'textarea',
3421   },
3422
3423   {
3424     'key'         => 'ticket_system-custom_priority_field_queue',
3425     'section'     => 'ticketing',
3426     'description' => 'Ticketing system queue in which the custom field specified in ticket_system-custom_priority_field is located.',
3427     'type'        => 'text',
3428   },
3429
3430   {
3431     'key'         => 'ticket_system-selfservice_priority_field',
3432     'section'     => 'ticketing',
3433     'description' => 'Custom field from the ticket system to use as a customer-managed priority field.',
3434     'type'        => 'text',
3435   },
3436
3437   {
3438     'key'         => 'ticket_system-selfservice_edit_subject',
3439     'section'     => 'ticketing',
3440     'description' => 'Allow customers to edit ticket subjects through selfservice.',
3441     'type'        => 'checkbox',
3442   },
3443
3444   {
3445     'key'         => 'ticket_system-appointment-queueid',
3446     'section'     => 'ticketing',
3447     'description' => 'Ticketing queue to use for appointments.',
3448     #false laziness w/above
3449     'type'        => 'select-sub',
3450     'options_sub' => sub {
3451                            my $conf = new FS::Conf;
3452                            if ( $conf->config('ticket_system') ) {
3453                              eval "use FS::TicketSystem;";
3454                              die $@ if $@;
3455                              FS::TicketSystem->queues();
3456                            } else {
3457                              ();
3458                            }
3459                          },
3460     'option_sub'  => sub { 
3461                            my $conf = new FS::Conf;
3462                            if ( $conf->config('ticket_system') ) {
3463                              eval "use FS::TicketSystem;";
3464                              die $@ if $@;
3465                              FS::TicketSystem->queue(shift);
3466                            } else {
3467                              '';
3468                            }
3469                          },
3470   },
3471
3472   {
3473     'key'         => 'ticket_system-appointment-custom_field',
3474     'section'     => 'ticketing',
3475     'description' => 'Ticketing custom field to use as an appointment classification.',
3476     'type'        => 'text',
3477   },
3478
3479   {
3480     'key'         => 'ticket_system-escalation',
3481     'section'     => 'ticketing',
3482     'description' => 'Enable priority escalation of tickets as part of daily batch processing.',
3483     'type'        => 'checkbox',
3484   },
3485
3486   {
3487     'key'         => 'ticket_system-rt_external_datasrc',
3488     'section'     => 'ticketing',
3489     'description' => 'With external RT integration, the DBI data source for the external RT installation, for example, <code>DBI:Pg:user=rt_user;password=rt_word;host=rt.example.com;dbname=rt</code>',
3490     'type'        => 'text',
3491
3492   },
3493
3494   {
3495     'key'         => 'ticket_system-rt_external_url',
3496     'section'     => 'ticketing',
3497     'description' => 'With external RT integration, the URL for the external RT installation, for example, <code>https://rt.example.com/rt</code>',
3498     'type'        => 'text',
3499   },
3500
3501   {
3502     'key'         => 'company_name',
3503     'section'     => 'required',
3504     'description' => 'Your company name',
3505     'type'        => 'text',
3506     'per_agent'   => 1, #XXX just FS/FS/ClientAPI/Signup.pm
3507   },
3508
3509   {
3510     'key'         => 'company_url',
3511     'section'     => 'UI',
3512     'description' => 'Your company URL',
3513     'type'        => 'text',
3514     'per_agent'   => 1,
3515   },
3516
3517   {
3518     'key'         => 'company_address',
3519     'section'     => 'required',
3520     'description' => 'Your company address',
3521     'type'        => 'textarea',
3522     'per_agent'   => 1,
3523   },
3524
3525   {
3526     'key'         => 'company_phonenum',
3527     'section'     => 'notification',
3528     'description' => 'Your company phone number',
3529     'type'        => 'text',
3530     'per_agent'   => 1,
3531   },
3532
3533   {
3534     'key'         => 'echeck-void',
3535     'section'     => 'deprecated',
3536     'description' => '<B>DEPRECATED</B>, now controlled by ACLs.  Used to enable local-only voiding of echeck payments in addition to refunds against the payment gateway',
3537     'type'        => 'checkbox',
3538   },
3539
3540   {
3541     'key'         => 'cc-void',
3542     'section'     => 'deprecated',
3543     'description' => '<B>DEPRECATED</B>, now controlled by ACLs.  Used to enable local-only voiding of credit card payments in addition to refunds against the payment gateway',
3544     'type'        => 'checkbox',
3545   },
3546
3547   {
3548     'key'         => 'unvoid',
3549     'section'     => 'deprecated',
3550     'description' => '<B>DEPRECATED</B>, now controlled by ACLs.  Used to enable unvoiding of voided payments',
3551     'type'        => 'checkbox',
3552   },
3553
3554   {
3555     'key'         => 'address1-search',
3556     'section'     => 'UI',
3557     'description' => 'Enable the ability to search the address1 field from the quick customer search.  Not recommended in most cases as it tends to bring up too many search results - use explicit address searching from the advanced customer search instead.',
3558     'type'        => 'checkbox',
3559   },
3560
3561   {
3562     'key'         => 'address2-search',
3563     'section'     => 'UI',
3564     'description' => 'Enable a "Unit" search box which searches the second address field.  Useful for multi-tenant applications.  See also: cust_main-require_address2',
3565     'type'        => 'checkbox',
3566   },
3567
3568   {
3569     'key'         => 'cust_main-require_address2',
3570     'section'     => 'UI',
3571     'description' => 'Second address field is required.  Also enables "Unit" labeling of address2 on customer view and edit pages.  Useful for multi-tenant applications.  See also: address2-search', # service address only part not working in the modern world, see #41184  (on service address only, if billing and service addresses differ)
3572     'type'        => 'checkbox',
3573   },
3574
3575   {
3576     'key'         => 'agent-ship_address',
3577     'section'     => '',
3578     'description' => "Use the agent's master service address as the service address (only ship_address2 can be entered, if blank on the master address).  Useful for multi-tenant applications.",
3579     'type'        => 'checkbox',
3580     'per_agent'   => 1,
3581   },
3582
3583   { 'key'         => 'referral_credit',
3584     'section'     => 'deprecated',
3585     'description' => "Used to enable one-time referral credits in the amount of one month <i>referred</i> customer's recurring fee (irregardless of frequency).  Replace with a billing event on appropriate packages.",
3586     'type'        => 'checkbox',
3587   },
3588
3589   { 'key'         => 'selfservice_server-cache_module',
3590     'section'     => 'self-service',
3591     'description' => 'Module used to store self-service session information.  All modules handle any number of self-service servers.  Cache::SharedMemoryCache is appropriate for a single database / single Freeside server.  Cache::FileCache is useful for multiple databases on a single server, or when IPC::ShareLite is not available (i.e. FreeBSD).', #  _Database stores session information in the database and is appropriate for multiple Freeside servers, but may be slower.',
3592     'type'        => 'select',
3593     'select_enum' => [ 'Cache::SharedMemoryCache', 'Cache::FileCache', ], # '_Database' ],
3594   },
3595
3596   {
3597     'key'         => 'hylafax',
3598     'section'     => 'billing',
3599     'description' => 'Options for a HylaFAX server to enable the FAX invoice destination.  They should be in the form of a space separated list of arguments to the Fax::Hylafax::Client::sendfax subroutine.  You probably shouldn\'t override things like \'docfile\'.  *Note* Only supported when using typeset invoices (see the invoice_latex configuration option).',
3600     'type'        => [qw( checkbox textarea )],
3601   },
3602
3603   {
3604     'key'         => 'cust_bill-ftpformat',
3605     'section'     => 'invoicing',
3606     'description' => 'Enable FTP of raw invoice data - format.',
3607     'type'        => 'select',
3608     'options'     => [ spool_formats() ],
3609   },
3610
3611   {
3612     'key'         => 'cust_bill-ftpserver',
3613     'section'     => 'invoicing',
3614     'description' => 'Enable FTP of raw invoice data - server.',
3615     'type'        => 'text',
3616   },
3617
3618   {
3619     'key'         => 'cust_bill-ftpusername',
3620     'section'     => 'invoicing',
3621     'description' => 'Enable FTP of raw invoice data - server.',
3622     'type'        => 'text',
3623   },
3624
3625   {
3626     'key'         => 'cust_bill-ftppassword',
3627     'section'     => 'invoicing',
3628     'description' => 'Enable FTP of raw invoice data - server.',
3629     'type'        => 'text',
3630   },
3631
3632   {
3633     'key'         => 'cust_bill-ftpdir',
3634     'section'     => 'invoicing',
3635     'description' => 'Enable FTP of raw invoice data - server.',
3636     'type'        => 'text',
3637   },
3638
3639   {
3640     'key'         => 'cust_bill-spoolformat',
3641     'section'     => 'invoicing',
3642     'description' => 'Enable spooling of raw invoice data - format.',
3643     'type'        => 'select',
3644     'options'     => [ spool_formats() ],
3645   },
3646
3647   {
3648     'key'         => 'cust_bill-spoolagent',
3649     'section'     => 'invoicing',
3650     'description' => 'Enable per-agent spooling of raw invoice data.',
3651     'type'        => 'checkbox',
3652   },
3653
3654   {
3655     'key'         => 'bridgestone-batch_counter',
3656     'section'     => '',
3657     'description' => 'Batch counter for spool files.  Increments every time a spool file is uploaded.',
3658     'type'        => 'text',
3659     'per_agent'   => 1,
3660   },
3661
3662   {
3663     'key'         => 'bridgestone-prefix',
3664     'section'     => '',
3665     'description' => 'Agent identifier for uploading to BABT printing service.',
3666     'type'        => 'text',
3667     'per_agent'   => 1,
3668   },
3669
3670   {
3671     'key'         => 'bridgestone-confirm_template',
3672     'section'     => '',
3673     'description' => 'Confirmation email template for uploading to BABT service.  Text::Template format, with variables "$zipfile" (name of the zipped file), "$seq" (sequence number), "$prefix" (user ID string), and "$rows" (number of records in the file).  Should include Subject: and To: headers, separated from the rest of the message by a blank line.',
3674     # this could use a true message template, but it's hard to see how that
3675     # would make the world a better place
3676     'type'        => 'textarea',
3677     'per_agent'   => 1,
3678   },
3679
3680   {
3681     'key'         => 'ics-confirm_template',
3682     'section'     => '',
3683     'description' => 'Confirmation email template for uploading to ICS invoice printing.  Text::Template format, with variables "%count" and "%sum".',
3684     'type'        => 'textarea',
3685     'per_agent'   => 1,
3686   },
3687
3688   {
3689     'key'         => 'svc_acct-usage_suspend',
3690     'section'     => 'billing',
3691     'description' => 'Suspends the package an account belongs to when svc_acct.seconds or a bytecount is decremented to 0 or below (accounts with an empty seconds and up|down|totalbytes value are ignored).  Typically used in conjunction with prepaid packages and freeside-sqlradius-radacctd.',
3692     'type'        => 'checkbox',
3693   },
3694
3695   {
3696     'key'         => 'svc_acct-usage_unsuspend',
3697     'section'     => 'billing',
3698     'description' => 'Unuspends the package an account belongs to when svc_acct.seconds or a bytecount is incremented from 0 or below to a positive value (accounts with an empty seconds and up|down|totalbytes value are ignored).  Typically used in conjunction with prepaid packages and freeside-sqlradius-radacctd.',
3699     'type'        => 'checkbox',
3700   },
3701
3702   {
3703     'key'         => 'svc_acct-usage_threshold',
3704     'section'     => 'billing',
3705     'description' => 'The threshold (expressed as percentage) of acct.seconds or acct.up|down|totalbytes at which a warning message is sent to a service holder.  Typically used in conjunction with prepaid packages and freeside-sqlradius-radacctd.',
3706     'type'        => 'text',
3707   },
3708
3709   {
3710     'key'         => 'overlimit_groups',
3711     'section'     => '',
3712     'description' => 'RADIUS group(s) to assign to svc_acct which has exceeded its bandwidth or time limit.',
3713     'type'        => 'select-sub',
3714     'per_agent'   => 1,
3715     'multiple'    => 1,
3716     'options_sub' => sub { require FS::Record;
3717                            require FS::radius_group;
3718                            map { $_->groupnum => $_->long_description }
3719                                FS::Record::qsearch('radius_group', {} );
3720                          },
3721     'option_sub'  => sub { require FS::Record;
3722                            require FS::radius_group;
3723                            my $radius_group = FS::Record::qsearchs(
3724                              'radius_group', { 'groupnum' => shift }
3725                            );
3726                $radius_group ? $radius_group->long_description : '';
3727                          },
3728   },
3729
3730   {
3731     'key'         => 'cust-fields',
3732     'section'     => 'UI',
3733     'description' => 'Which customer fields to display on reports by default',
3734     'type'        => 'select',
3735     'select_hash' => [ FS::ConfDefaults->cust_fields_avail() ],
3736   },
3737
3738   {
3739     'key'         => 'cust_location-label_prefix',
3740     'section'     => 'UI',
3741     'description' => 'Optional "site ID" to show in the location label',
3742     'type'        => 'select',
3743     'select_hash' => [ '' => '',
3744                        'CoStAg'    => 'CoStAgXXXXX (country, state, agent name, locationnum)',
3745                        '_location' => 'Manually defined per location',
3746                       ],
3747   },
3748
3749   {
3750     'key'         => 'cust_pkg-display_times',
3751     'section'     => 'UI',
3752     'description' => 'Display full timestamps (not just dates) for customer packages.  Useful if you are doing real-time things like hourly prepaid.',
3753     'type'        => 'checkbox',
3754   },
3755
3756   {
3757     'key'         => 'cust_pkg-always_show_location',
3758     'section'     => 'UI',
3759     'description' => "Always display package locations, even when they're all the default service address.",
3760     'type'        => 'checkbox',
3761   },
3762
3763   {
3764     'key'         => 'cust_pkg-group_by_location',
3765     'section'     => 'UI',
3766     'description' => "Group packages by location.",
3767     'type'        => 'checkbox',
3768   },
3769
3770   {
3771     'key'         => 'cust_pkg-large_pkg_size',
3772     'section'     => 'UI',
3773     'description' => "In customer view, summarize packages with more than this many services.  Set to zero to never summarize packages.",
3774     'type'        => 'text',
3775   },
3776
3777   {
3778     'key'         => 'cust_pkg-hide_discontinued-part_svc',
3779     'section'     => 'UI',
3780     'description' => "In customer view, hide provisioned services which are no longer available in the package definition.  Not normally used except for very specific situations as it hides still-provisioned services.",
3781     'type'        => 'checkbox',
3782   },
3783
3784   {
3785     'key'         => 'part_pkg-show_fcc_options',
3786     'section'     => 'UI',
3787     'description' => "Show fields on package definitions for FCC Form 477 classification",
3788     'type'        => 'checkbox',
3789   },
3790
3791   {
3792     'key'         => 'svc_acct-edit_uid',
3793     'section'     => 'shell',
3794     'description' => 'Allow UID editing.',
3795     'type'        => 'checkbox',
3796   },
3797
3798   {
3799     'key'         => 'svc_acct-edit_gid',
3800     'section'     => 'shell',
3801     'description' => 'Allow GID editing.',
3802     'type'        => 'checkbox',
3803   },
3804
3805   {
3806     'key'         => 'svc_acct-no_edit_username',
3807     'section'     => 'shell',
3808     'description' => 'Disallow username editing.',
3809     'type'        => 'checkbox',
3810   },
3811
3812   {
3813     'key'         => 'zone-underscore',
3814     'section'     => 'BIND',
3815     'description' => 'Allow underscores in zone names.  As underscores are illegal characters in zone names, this option is not recommended.',
3816     'type'        => 'checkbox',
3817   },
3818
3819   {
3820     'key'         => 'echeck-nonus',
3821     'section'     => 'deprecated',
3822     'description' => 'Deprecated; see echeck-country instead.  Used to disable ABA-format account checking for Electronic Check payment info',
3823     'type'        => 'checkbox',
3824   },
3825
3826   {
3827     'key'         => 'echeck-country',
3828     'section'     => 'billing',
3829     'description' => 'Format electronic check information for the specified country.',
3830     'type'        => 'select',
3831     'select_hash' => [ 'US' => 'United States',
3832                        'CA' => 'Canada (enables branch)',
3833                        'XX' => 'Other',
3834                      ],
3835   },
3836
3837   {
3838     'key'         => 'voip-cust_accountcode_cdr',
3839     'section'     => 'telephony',
3840     'description' => 'Enable the per-customer option for CDR breakdown by accountcode.',
3841     'type'        => 'checkbox',
3842   },
3843
3844   {
3845     'key'         => 'voip-cust_cdr_spools',
3846     'section'     => 'telephony',
3847     'description' => 'Enable the per-customer option for individual CDR spools.',
3848     'type'        => 'checkbox',
3849   },
3850
3851   {
3852     'key'         => 'voip-cust_cdr_squelch',
3853     'section'     => 'telephony',
3854     'description' => 'Enable the per-customer option for not printing CDR on invoices.',
3855     'type'        => 'checkbox',
3856   },
3857
3858   {
3859     'key'         => 'voip-cdr_email',
3860     'section'     => 'telephony',
3861     'description' => 'Include the call details inline on emailed invoices (and HTML invoices viewed in the backend), even if the customer is configured for not printing them on the invoices.  Useful for including these details in electronic delivery but omitting them when printing.',
3862     'type'        => 'checkbox',
3863   },
3864
3865   {
3866     'key'         => 'voip-cust_email_csv_cdr',
3867     'section'     => 'deprecated',
3868     'description' => 'Deprecated, see voip-cdr_email_attach instead.  Used to enable the per-customer option for including CDR information as a CSV attachment on emailed invoices.',
3869     'type'        => 'checkbox',
3870   },
3871
3872   {
3873     'key'         => 'voip-cdr_email_attach',
3874     'section'     => 'telephony',
3875     'description' => 'Enable the per-customer option for including CDR information as an attachment on emailed invoices.',
3876     'type'        => 'select',
3877     'select_hash' => [ ''    => 'Disabled',
3878                        'csv' => 'Text (CSV) attachment',
3879                        'zip' => 'Zip attachment',
3880                      ],
3881   },
3882
3883   {
3884     'key'         => 'cgp_rule-domain_templates',
3885     'section'     => '',
3886     'description' => 'Communigate Pro rule templates for domains, one per line, "svcnum Name"',
3887     'type'        => 'textarea',
3888   },
3889
3890   {
3891     'key'         => 'svc_forward-no_srcsvc',
3892     'section'     => '',
3893     'description' => "Don't allow forwards from existing accounts, only arbitrary addresses.  Useful when exporting to systems such as Communigate Pro which treat forwards in this fashion.",
3894     'type'        => 'checkbox',
3895   },
3896
3897   {
3898     'key'         => 'svc_forward-arbitrary_dst',
3899     'section'     => '',
3900     'description' => "Allow forwards to point to arbitrary strings that don't necessarily look like email addresses.  Only used when using forwards for weird, non-email things.",
3901     'type'        => 'checkbox',
3902   },
3903
3904   {
3905     'key'         => 'tax-ship_address',
3906     'section'     => 'billing',
3907     'description' => 'By default, tax calculations are done based on the billing address.  Enable this switch to calculate tax based on the shipping address instead.',
3908     'type'        => 'checkbox',
3909   }
3910 ,
3911   {
3912     'key'         => 'tax-pkg_address',
3913     'section'     => 'billing',
3914     'description' => 'By default, tax calculations are done based on the billing address.  Enable this switch to calculate tax based on the package address instead (when present).',
3915     'type'        => 'checkbox',
3916   },
3917
3918   {
3919     'key'         => 'invoice-ship_address',
3920     'section'     => 'invoicing',
3921     'description' => 'Include the shipping address on invoices.',
3922     'type'        => 'checkbox',
3923   },
3924
3925   {
3926     'key'         => 'invoice-all_pkg_addresses',
3927     'section'     => 'invoicing',
3928     'description' => 'Show all package addresses on invoices, even the default.',
3929     'type'        => 'checkbox',
3930   },
3931
3932   {
3933     'key'         => 'invoice-unitprice',
3934     'section'     => 'invoicing',
3935     'description' => 'Enable unit pricing on invoices and quantities on packages.',
3936     'type'        => 'checkbox',
3937   },
3938
3939   {
3940     'key'         => 'invoice-smallernotes',
3941     'section'     => 'invoicing',
3942     'description' => 'Display the notes section in a smaller font on invoices.',
3943     'type'        => 'checkbox',
3944   },
3945
3946   {
3947     'key'         => 'invoice-smallerfooter',
3948     'section'     => 'invoicing',
3949     'description' => 'Display footers in a smaller font on invoices.',
3950     'type'        => 'checkbox',
3951   },
3952
3953   {
3954     'key'         => 'postal_invoice-fee_pkgpart',
3955     'section'     => 'billing',
3956     'description' => 'This allows selection of a package to insert on invoices for customers with postal invoices selected.',
3957     'type'        => 'select-part_pkg',
3958     'per_agent'   => 1,
3959   },
3960
3961   {
3962     'key'         => 'postal_invoice-recurring_only',
3963     'section'     => 'billing',
3964     'description' => 'The postal invoice fee is omitted on invoices without recurring charges when this is set.',
3965     'type'        => 'checkbox',
3966   },
3967
3968   {
3969     'key'         => 'batch-enable',
3970     'section'     => 'deprecated', #make sure batch-enable_payby is set for
3971                                    #everyone before removing
3972     'description' => 'Enable credit card and/or ACH batching - leave disabled for real-time installations.',
3973     'type'        => 'checkbox',
3974   },
3975
3976   {
3977     'key'         => 'batch-enable_payby',
3978     'section'     => 'billing',
3979     'description' => 'Enable batch processing for the specified payment types.',
3980     'type'        => 'selectmultiple',
3981     'select_enum' => [qw( CARD CHEK )],
3982   },
3983
3984   {
3985     'key'         => 'realtime-disable_payby',
3986     'section'     => 'billing',
3987     'description' => 'Disable realtime processing for the specified payment types.',
3988     'type'        => 'selectmultiple',
3989     'select_enum' => [qw( CARD CHEK )],
3990   },
3991
3992   {
3993     'key'         => 'batch-default_format',
3994     'section'     => 'billing',
3995     'description' => 'Default format for batches.',
3996     'type'        => 'select',
3997     'select_enum' => [ 'NACHA', 'csv-td_canada_trust-merchant_pc_batch',
3998                        'csv-chase_canada-E-xactBatch', 'BoM', 'PAP',
3999                        'paymentech', 'ach-spiritone', 'RBC', 'CIBC',
4000                     ]
4001   },
4002
4003   { 'key'         => 'batch-gateway-CARD',
4004     'section'     => 'billing',
4005     'description' => 'Business::BatchPayment gateway for credit card batches.',
4006     %batch_gateway_options,
4007   },
4008
4009   { 'key'         => 'batch-gateway-CHEK',
4010     'section'     => 'billing', 
4011     'description' => 'Business::BatchPayment gateway for check batches.',
4012     %batch_gateway_options,
4013   },
4014
4015   {
4016     'key'         => 'batch-reconsider',
4017     'section'     => 'billing',
4018     'description' => 'Allow imported batch results to change the status of payments from previous imports.  Enable this only if your gateway is known to send both positive and negative results for the same batch.',
4019     'type'        => 'checkbox',
4020   },
4021
4022   {
4023     'key'         => 'batch-auto_resolve_days',
4024     'section'     => 'billing',
4025     'description' => 'Automatically resolve payment batches this many days after they were first downloaded.',
4026     'type'        => 'text',
4027   },
4028
4029   {
4030     'key'         => 'batch-auto_resolve_status',
4031     'section'     => 'billing',
4032     'description' => 'When automatically resolving payment batches, take this action for payments of unknown status.',
4033     'type'        => 'select',
4034     'select_enum' => [ 'approve', 'decline' ],
4035   },
4036
4037   {
4038     'key'         => 'batch-errors_to',
4039     'section'     => 'billing',
4040     'description' => 'Email errors when processing batches to this address.  If unspecified, batch processing will stop immediately on error.',
4041     'type'        => 'text',
4042   },
4043
4044   #lists could be auto-generated from pay_batch info
4045   {
4046     'key'         => 'batch-fixed_format-CARD',
4047     'section'     => 'billing',
4048     'description' => 'Fixed (unchangeable) format for credit card batches.',
4049     'type'        => 'select',
4050     'select_enum' => [ 'csv-td_canada_trust-merchant_pc_batch', 'BoM', 'PAP' ,
4051                        'csv-chase_canada-E-xactBatch', 'paymentech' ]
4052   },
4053
4054   {
4055     'key'         => 'batch-fixed_format-CHEK',
4056     'section'     => 'billing',
4057     'description' => 'Fixed (unchangeable) format for electronic check batches.',
4058     'type'        => 'select',
4059     'select_enum' => [ 'NACHA', 'csv-td_canada_trust-merchant_pc_batch', 'BoM',
4060                        'PAP', 'paymentech', 'ach-spiritone', 'RBC',
4061                        'td_eft1464', 'eft_canada', 'CIBC'
4062                      ]
4063   },
4064
4065   {
4066     'key'         => 'batch-increment_expiration',
4067     'section'     => 'billing',
4068     'description' => 'Increment expiration date years in batches until cards are current.  Make sure this is acceptable to your batching provider before enabling.',
4069     'type'        => 'checkbox'
4070   },
4071
4072   {
4073     'key'         => 'batchconfig-BoM',
4074     'section'     => 'billing',
4075     'description' => 'Configuration for Bank of Montreal batching, seven lines: 1. Origin ID, 2. Datacenter, 3. Typecode, 4. Short name, 5. Long name, 6. Bank, 7. Bank account',
4076     'type'        => 'textarea',
4077   },
4078
4079 {
4080     'key'         => 'batchconfig-CIBC',
4081     'section'     => 'billing',
4082     'description' => 'Configuration for Canadian Imperial Bank of Commerce, six lines: 1. Origin ID, 2. Datacenter, 3. Typecode, 4. Short name, 5. Bank, 6. Bank account',
4083     'type'        => 'textarea',
4084   },
4085
4086   {
4087     'key'         => 'batchconfig-PAP',
4088     'section'     => 'billing',
4089     'description' => 'Configuration for PAP batching, seven lines: 1. Origin ID, 2. Datacenter, 3. Typecode, 4. Short name, 5. Long name, 6. Bank, 7. Bank account',
4090     'type'        => 'textarea',
4091   },
4092
4093   {
4094     'key'         => 'batchconfig-csv-chase_canada-E-xactBatch',
4095     'section'     => 'billing',
4096     'description' => 'Gateway ID for Chase Canada E-xact batching',
4097     'type'        => 'text',
4098   },
4099
4100   {
4101     'key'         => 'batchconfig-paymentech',
4102     'section'     => 'billing',
4103     'description' => 'Configuration for Chase Paymentech batching, six lines: 1. BIN, 2. Terminal ID, 3. Merchant ID, 4. Username, 5. Password (for batch uploads), 6. Flag to send recurring indicator.',
4104     'type'        => 'textarea',
4105   },
4106
4107   {
4108     'key'         => 'batchconfig-RBC',
4109     'section'     => 'billing',
4110     'description' => 'Configuration for Royal Bank of Canada PDS batching, five lines: 1. Client number, 2. Short name, 3. Long name, 4. Transaction code 5. (optional) set to TEST to turn on test mode.',
4111     'type'        => 'textarea',
4112   },
4113
4114   {
4115     'key'         => 'batchconfig-RBC-login',
4116     'section'     => 'billing',
4117     'description' => 'FTPS login for uploading Royal Bank of Canada batches. Two lines: 1. username, 2. password. If not supplied, batches can still be created but not automatically uploaded.',
4118     'type'        => 'textarea',
4119   },
4120
4121   {
4122     'key'         => 'batchconfig-td_eft1464',
4123     'section'     => 'billing',
4124     'description' => 'Configuration for TD Bank EFT1464 batching, seven lines: 1. Originator ID, 2. Datacenter Code, 3. Short name, 4. Long name, 5. Returned payment branch number, 6. Returned payment account, 7. Transaction code.',
4125     'type'        => 'textarea',
4126   },
4127
4128   {
4129     'key'         => 'batchconfig-eft_canada',
4130     'section'     => 'billing',
4131     'description' => 'Configuration for EFT Canada batching, five lines: 1. SFTP username, 2. SFTP password, 3. Business transaction code, 4. Personal transaction code, 5. Number of days to delay process date.  If you are using separate per-agent batches (batch-spoolagent), you must set this option separately for each agent, as the global setting will be ignored.',
4132     'type'        => 'textarea',
4133     'per_agent'   => 1,
4134   },
4135
4136   {
4137     'key'         => 'batchconfig-nacha-destination',
4138     'section'     => 'billing',
4139     'description' => 'Configuration for NACHA batching, Destination (9 digit transit routing number).',
4140     'type'        => 'text',
4141   },
4142
4143   {
4144     'key'         => 'batchconfig-nacha-destination_name',
4145     'section'     => 'billing',
4146     'description' => 'Configuration for NACHA batching, Destination (Bank Name, up to 23 characters).',
4147     'type'        => 'text',
4148   },
4149
4150   {
4151     'key'         => 'batchconfig-nacha-origin',
4152     'section'     => 'billing',
4153     'description' => 'Configuration for NACHA batching, Origin (your 10-digit company number, IRS tax ID recommended).',
4154     'type'        => 'text',
4155   },
4156
4157   {
4158     'key'         => 'batchconfig-nacha-origin_name',
4159     'section'     => 'billing',
4160     'description' => 'Configuration for NACHA batching, Origin name (defaults to company name, but sometimes bank name is needed instead.)',
4161     'type'        => 'text',
4162   },
4163
4164   {
4165     'key'         => 'batch-manual_approval',
4166     'section'     => 'billing',
4167     'description' => 'Allow manual batch closure, which will approve all payments that do not yet have a status.  This is not advised unless needed for specific payment processors that provide a report of rejected rather than approved payments.',
4168     'type'        => 'checkbox',
4169   },
4170
4171   {
4172     'key'         => 'batch-spoolagent',
4173     'section'     => 'billing',
4174     'description' => 'Store payment batches per-agent.',
4175     'type'        => 'checkbox',
4176   },
4177
4178   {
4179     'key'         => 'payment_history-years',
4180     'section'     => 'UI',
4181     'description' => 'Number of years of payment history to show by default.  Currently defaults to 2.',
4182     'type'        => 'text',
4183   },
4184
4185   {
4186     'key'         => 'change_history-years',
4187     'section'     => 'UI',
4188     'description' => 'Number of years of change history to show by default.  Currently defaults to 0.5.',
4189     'type'        => 'text',
4190   },
4191
4192   {
4193     'key'         => 'cust_main-packages-years',
4194     'section'     => 'UI',
4195     'description' => 'Number of years to show old (cancelled and one-time charge) packages by default.  Currently defaults to 2.',
4196     'type'        => 'text',
4197   },
4198
4199   {
4200     'key'         => 'cust_main-use_comments',
4201     'section'     => 'UI',
4202     'description' => 'Display free form comments on the customer edit screen.  Useful as a scratch pad.',
4203     'type'        => 'checkbox',
4204   },
4205
4206   {
4207     'key'         => 'cust_main-disable_notes',
4208     'section'     => 'UI',
4209     'description' => 'Disable new style customer notes - timestamped and user identified customer notes.  Useful in tracking who did what.',
4210     'type'        => 'checkbox',
4211   },
4212
4213   {
4214     'key'         => 'cust_main_note-display_times',
4215     'section'     => 'UI',
4216     'description' => 'Display full timestamps (not just dates) for customer notes.',
4217     'type'        => 'checkbox',
4218   },
4219
4220   {
4221     'key'         => 'cust_main_note-require_class',
4222     'section'     => 'UI',
4223     'description' => 'Require customer note classes for customer notes',
4224     'type'        => 'checkbox',
4225   },
4226
4227   {
4228     'key'         => 'cust_main-ticket_statuses',
4229     'section'     => 'UI',
4230     'description' => 'Show tickets with these statuses on the customer view page.',
4231     'type'        => 'selectmultiple',
4232     'select_enum' => [qw( new open stalled resolved rejected deleted )],
4233   },
4234
4235   {
4236     'key'         => 'cust_main-max_tickets',
4237     'section'     => 'UI',
4238     'description' => 'Maximum number of tickets to show on the customer view page.',
4239     'type'        => 'text',
4240   },
4241
4242   {
4243     'key'         => 'cust_main-enable_birthdate',
4244     'section'     => 'UI',
4245     'description' => 'Enable tracking of a birth date with each customer record',
4246     'type'        => 'checkbox',
4247   },
4248
4249   {
4250     'key'         => 'cust_main-enable_spouse',
4251     'section'     => 'UI',
4252     'description' => 'Enable tracking of a spouse\'s name and date of birth with each customer record',
4253     'type'        => 'checkbox',
4254   },
4255
4256   {
4257     'key'         => 'cust_main-enable_anniversary_date',
4258     'section'     => 'UI',
4259     'description' => 'Enable tracking of an anniversary date with each customer record',
4260     'type'        => 'checkbox',
4261   },
4262
4263   {
4264     'key'         => 'cust_main-enable_order_package',
4265     'section'     => 'UI',
4266     'description' => 'Display order new package on the basic tab',
4267     'type'        => 'checkbox',
4268   },
4269
4270   {
4271     'key'         => 'cust_main-edit_calling_list_exempt',
4272     'section'     => 'UI',
4273     'description' => 'Display the "calling_list_exempt" checkbox on customer edit.',
4274     'type'        => 'checkbox',
4275   },
4276
4277   {
4278     'key'         => 'support-key',
4279     'section'     => '',
4280     'description' => 'A support key enables access to commercial services delivered over the network, such as address normalization and invoice printing.',
4281     'type'        => 'text',
4282   },
4283
4284   {
4285     'key'         => 'freesideinc-webservice-svcpart',
4286     'section'     => '',
4287     'description' => 'Do not set this.',
4288     'type'        => 'text',
4289   },
4290
4291   {
4292     'key'         => 'card-types',
4293     'section'     => 'billing',
4294     'description' => 'Select one or more card types to enable only those card types.  If no card types are selected, all card types are available.',
4295     'type'        => 'selectmultiple',
4296     'select_enum' => \@card_types,
4297   },
4298
4299   {
4300     'key'         => 'disable-fuzzy',
4301     'section'     => 'UI',
4302     'description' => 'Disable fuzzy searching.  Speeds up searching for large sites, but only shows exact matches.',
4303     'type'        => 'checkbox',
4304   },
4305
4306   {
4307     'key'         => 'fuzzy-fuzziness',
4308     'section'     => 'UI',
4309     'description' => 'Set the "fuzziness" of fuzzy searching (see the String::Approx manpage for details).  Defaults to 10%',
4310     'type'        => 'text',
4311   },
4312
4313   {
4314     'key'         => 'enable_fuzzy_on_exact',
4315     'section'     => 'UI',
4316     'description' => 'Enable approximate customer searching even when an exact match is found.',
4317     'type'        => 'checkbox',
4318   },
4319
4320   { 'key'         => 'pkg_referral',
4321     'section'     => '',
4322     'description' => 'Enable package-specific advertising sources.',
4323     'type'        => 'checkbox',
4324   },
4325
4326   { 'key'         => 'pkg_referral-multiple',
4327     'section'     => '',
4328     'description' => 'In addition, allow multiple advertising sources to be associated with a single package.',
4329     'type'        => 'checkbox',
4330   },
4331
4332   {
4333     'key'         => 'dashboard-install_welcome',
4334     'section'     => 'UI',
4335     'description' => 'New install welcome screen.',
4336     'type'        => 'select',
4337     'select_enum' => [ '', 'ITSP_fsinc_hosted', ],
4338   },
4339
4340   {
4341     'key'         => 'dashboard-toplist',
4342     'section'     => 'UI',
4343     'description' => 'List of items to display on the top of the front page',
4344     'type'        => 'textarea',
4345   },
4346
4347   {
4348     'key'         => 'impending_recur_msgnum',
4349     'section'     => 'notification',
4350     'description' => 'Template to use for alerts about first-time recurring billing.',
4351     %msg_template_options,
4352   },
4353
4354   {
4355     'key'         => 'impending_recur_template',
4356     'section'     => 'deprecated',
4357     'description' => 'Template file for alerts about looming first time recurrant billing.  See the <a href="http://search.cpan.org/dist/Text-Template/lib/Text/Template.pm">Text::Template</a> documentation for details on the template substitition language.  Also see packages with a <a href="../browse/part_pkg.cgi">flat price plan</a>  The following variables are available<ul><li><code>$packages</code> allowing <code>$packages->[0]</code> thru <code>$packages->[n]</code> <li><code>$package</code> the first package, same as <code>$packages->[0]</code> <li><code>$recurdates</code> allowing <code>$recurdates->[0]</code> thru <code>$recurdates->[n]</code> <li><code>$recurdate</code> the first recurdate, same as <code>$recurdate->[0]</code> <li><code>$first</code> <li><code>$last</code></ul>',
4358 # <li><code>$payby</code> <li><code>$expdate</code> most likely only confuse
4359     'type'        => 'textarea',
4360   },
4361
4362   {
4363     'key'         => 'logo.png',
4364     'section'     => 'UI',  #'invoicing' ?
4365     'description' => 'Company logo for HTML invoices and the backoffice interface, in PNG format.  Suggested size somewhere near 92x62.',
4366     'type'        => 'image',
4367     'per_agent'   => 1, #XXX just view/logo.cgi, which is for the global
4368                         #old-style editor anyway...?
4369     'per_locale'  => 1,
4370   },
4371
4372   {
4373     'key'         => 'logo.eps',
4374     'section'     => 'invoicing',
4375     'description' => 'Company logo for printed and PDF invoices, in EPS format.',
4376     'type'        => 'image',
4377     'per_agent'   => 1, #XXX as above, kinda
4378     'per_locale'  => 1,
4379   },
4380
4381   {
4382     'key'         => 'selfservice-ignore_quantity',
4383     'section'     => 'self-service',
4384     'description' => 'Ignores service quantity restrictions in self-service context.  Strongly not recommended - just set your quantities correctly in the first place.',
4385     'type'        => 'checkbox',
4386   },
4387
4388   {
4389     'key'         => 'selfservice-session_timeout',
4390     'section'     => 'self-service',
4391     'description' => 'Self-service session timeout.  Defaults to 1 hour.',
4392     'type'        => 'select',
4393     'select_enum' => [ '1 hour', '2 hours', '4 hours', '8 hours', '1 day', '1 week', ],
4394   },
4395
4396   {
4397     'key'         => 'password-generated-characters',
4398     'section'     => 'password',
4399     'description' => 'Set of characters to use when generating random passwords. This must contain at least one lowercase letter, uppercase letter, digit, and punctuation mark.',
4400     'type'        => 'textarea',
4401   },
4402
4403   {
4404     'key'         => 'password-no_reuse',
4405     'section'     => 'password',
4406     'description' => 'Minimum number of password changes before a password can be reused. By default, passwords can be reused without restriction.',
4407     'type'        => 'text',
4408   },
4409
4410   {
4411     'key'         => 'password-insecure',
4412     'section'     => 'password',
4413     'description' => 'Disable all password security checks and allow entry of insecure passwords.  NOT RECOMMENDED.',
4414     'type'        => 'checkbox',
4415     'per_agent'   => 1,
4416   },
4417
4418   {
4419     'key'         => 'datavolume-forcemegabytes',
4420     'section'     => 'UI',
4421     'description' => 'All data volumes are expressed in megabytes',
4422     'type'        => 'checkbox',
4423   },
4424
4425   {
4426     'key'         => 'datavolume-significantdigits',
4427     'section'     => 'UI',
4428     'description' => 'number of significant digits to use to represent data volumes',
4429     'type'        => 'text',
4430   },
4431
4432   {
4433     'key'         => 'disable_void_after',
4434     'section'     => 'billing',
4435     'description' => 'Number of seconds after which freeside won\'t attempt to VOID a payment first when performing a refund.',
4436     'type'        => 'text',
4437   },
4438
4439   {
4440     'key'         => 'disable_line_item_date_ranges',
4441     'section'     => 'billing',
4442     'description' => 'Prevent freeside from automatically generating date ranges on invoice line items.',
4443     'type'        => 'checkbox',
4444   },
4445
4446   {
4447     'key'         => 'cust_bill-line_item-date_style',
4448     'section'     => 'billing',
4449     'description' => 'Display format for line item date ranges on invoice line items.',
4450     'type'        => 'select',
4451     'select_hash' => [ ''           => 'STARTDATE-ENDDATE',
4452                        'month_of'   => 'Month of MONTHNAME',
4453                        'X_month'    => 'DATE_DESC MONTHNAME',
4454                      ],
4455     'per_agent'   => 1,
4456   },
4457
4458   {
4459     'key'         => 'cust_bill-line_item-date_style-non_monthly',
4460     'section'     => 'billing',
4461     'description' => 'If set, override cust_bill-line_item-date_style for non-monthly charges.',
4462     'type'        => 'select',
4463     'select_hash' => [ ''           => 'Default',
4464                        'start_end'  => 'STARTDATE-ENDDATE',
4465                        'month_of'   => 'Month of MONTHNAME',
4466                        'X_month'    => 'DATE_DESC MONTHNAME',
4467                      ],
4468     'per_agent'   => 1,
4469   },
4470
4471   {
4472     'key'         => 'cust_bill-line_item-date_description',
4473     'section'     => 'billing',
4474     'description' => 'Text to display for "DATE_DESC" when using cust_bill-line_item-date_style DATE_DESC MONTHNAME.',
4475     'type'        => 'text',
4476     'per_agent'   => 1,
4477   },
4478
4479   {
4480     'key'         => 'support_packages',
4481     'section'     => '',
4482     'description' => 'A list of packages eligible for RT ticket time transfer, one pkgpart per line.', #this should really be a select multiple, or specified in the packages themselves...
4483     'type'        => 'select-part_pkg',
4484     'multiple'    => 1,
4485   },
4486
4487   {
4488     'key'         => 'cust_main-require_phone',
4489     'section'     => '',
4490     'description' => 'Require daytime or night phone for all customer records.',
4491     'type'        => 'checkbox',
4492     'per_agent'   => 1,
4493   },
4494
4495   {
4496     'key'         => 'cust_main-require_invoicing_list_email',
4497     'section'     => '',
4498     'description' => 'Email address field is required: require at least one invoicing email address for all customer records.',
4499     'type'        => 'checkbox',
4500     'per_agent'   => 1,
4501   },
4502
4503   {
4504     'key'         => 'cust_main-require_classnum',
4505     'section'     => '',
4506     'description' => 'Customer class is required: require customer class for all customer records.',
4507     'type'        => 'checkbox',
4508   },
4509
4510   {
4511     'key'         => 'cust_main-check_unique',
4512     'section'     => '',
4513     'description' => 'Warn before creating a customer record where these fields duplicate another customer.',
4514     'type'        => 'select',
4515     'multiple'    => 1,
4516     'select_hash' => [ 
4517       'address' => 'Billing or service address',
4518     ],
4519   },
4520
4521   {
4522     'key'         => 'svc_acct-display_paid_time_remaining',
4523     'section'     => '',
4524     'description' => 'Show paid time remaining in addition to time remaining.',
4525     'type'        => 'checkbox',
4526   },
4527
4528   {
4529     'key'         => 'cancel_credit_type',
4530     'section'     => 'billing',
4531     'description' => 'The group to use for new, automatically generated credit reasons resulting from cancellation.',
4532     reason_type_options('R'),
4533   },
4534
4535   {
4536     'key'         => 'suspend_credit_type',
4537     'section'     => 'billing',
4538     'description' => 'The group to use for new, automatically generated credit reasons resulting from package suspension.',
4539     reason_type_options('R'),
4540   },
4541
4542   {
4543     'key'         => 'referral_credit_type',
4544     'section'     => 'deprecated',
4545     'description' => 'Used to be the group to use for new, automatically generated credit reasons resulting from referrals.  Now set in a package billing event for the referral.',
4546     reason_type_options('R'),
4547   },
4548
4549   # was only used to negate invoices during signup when card was declined, now we just void
4550   {
4551     'key'         => 'signup_credit_type',
4552     'section'     => 'deprecated', #self-service?
4553     'description' => 'The group to use for new, automatically generated credit reasons resulting from signup and self-service declines.',
4554     reason_type_options('R'),
4555   },
4556
4557   {
4558     'key'         => 'prepayment_discounts-credit_type',
4559     'section'     => 'billing',
4560     'description' => 'Enables the offering of prepayment discounts and establishes the credit reason type.',
4561     reason_type_options('R'),
4562   },
4563
4564   {
4565     'key'         => 'cust_main-agent_custid-format',
4566     'section'     => '',
4567     'description' => 'Enables searching of various formatted values in cust_main.agent_custid',
4568     'type'        => 'select',
4569     'select_hash' => [
4570                        ''       => 'Numeric only',
4571                        '\d{7}'  => 'Numeric only, exactly 7 digits',
4572                        'ww?d+'  => 'Numeric with one or two letter prefix',
4573                      ],
4574   },
4575
4576   {
4577     'key'         => 'card_masking_method',
4578     'section'     => 'UI',
4579     'description' => 'Digits to display when masking credit cards.  Note that the first six digits are necessary to canonically identify the credit card type (Visa/MC, Amex, Discover, Maestro, etc.) in all cases.  The first four digits can identify the most common credit card types in most cases (Visa/MC, Amex, and Discover).  The first two digits can distinguish between Visa/MC and Amex.  Note: You should manually remove stored paymasks if you change this value on an existing database, to avoid problems using stored cards.',
4580     'type'        => 'select',
4581     'select_hash' => [
4582                        ''            => '123456xxxxxx1234',
4583                        'first6last2' => '123456xxxxxxxx12',
4584                        'first4last4' => '1234xxxxxxxx1234',
4585                        'first4last2' => '1234xxxxxxxxxx12',
4586                        'first2last4' => '12xxxxxxxxxx1234',
4587                        'first2last2' => '12xxxxxxxxxxxx12',
4588                        'first0last4' => 'xxxxxxxxxxxx1234',
4589                        'first0last2' => 'xxxxxxxxxxxxxx12',
4590                      ],
4591   },
4592
4593   {
4594     'key'         => 'disable_previous_balance',
4595     'section'     => 'invoicing',
4596     'description' => 'Show new charges only; do not list previous invoices, payments, or credits on the invoice.',
4597     'type'        => 'checkbox',
4598     'per_agent'   => 1,
4599   },
4600
4601   {
4602     'key'         => 'previous_balance-exclude_from_total',
4603     'section'     => 'invoicing',
4604     'description' => 'Show separate totals for previous invoice balance and new charges. Only meaningful when invoice_sections is false.',
4605     'type'        => 'checkbox',
4606   },
4607
4608   {
4609     'key'         => 'previous_balance-text',
4610     'section'     => 'invoicing',
4611     'description' => 'Text for the label of the total previous balance, when it is shown separately. Defaults to "Previous Balance".',
4612     'type'        => 'text',
4613     'per_locale'  => 1,
4614   },
4615
4616   {
4617     'key'         => 'previous_balance-text-total_new_charges',
4618     'section'     => 'invoicing',
4619     'description' => 'Text for the label of the total of new charges, when it is shown separately. If invoice_show_prior_due_date is enabled, the due date of current charges will be appended. Defaults to "Total New Charges".',
4620     'type'        => 'text',
4621     'per_locale'  => 1,
4622   },
4623
4624   {
4625     'key'         => 'previous_balance-section',
4626     'section'     => 'invoicing',
4627     'description' => 'Show previous invoice balances in a separate invoice section.  Does not require invoice_sections to be enabled.',
4628     'type'        => 'checkbox',
4629   },
4630
4631   {
4632     'key'         => 'previous_balance-summary_only',
4633     'section'     => 'invoicing',
4634     'description' => 'Only show a single line summarizing the total previous balance rather than one line per invoice.',
4635     'type'        => 'checkbox',
4636   },
4637
4638   {
4639     'key'         => 'previous_balance-show_credit',
4640     'section'     => 'invoicing',
4641     'description' => 'Show the customer\'s credit balance on invoices when applicable.',
4642     'type'        => 'checkbox',
4643   },
4644
4645   {
4646     'key'         => 'previous_balance-show_on_statements',
4647     'section'     => 'invoicing',
4648     'description' => 'Show previous invoices on statements, without itemized charges.',
4649     'type'        => 'checkbox',
4650   },
4651
4652   {
4653     'key'         => 'previous_balance-payments_since',
4654     'section'     => 'invoicing',
4655     'description' => 'Instead of showing payments (and credits) applied to the invoice, show those received since the previous invoice date.',
4656     'type'        => 'checkbox',
4657   },
4658
4659   {
4660     'key'         => 'previous_invoice_history',
4661     'section'     => 'invoicing',
4662     'description' => 'Show a month-by-month history of the customer\'s '.
4663                      'billing amounts.  This requires template '.
4664                      'modification and is currently not supported on the '.
4665                      'stock template.',
4666     'type'        => 'checkbox',
4667   },
4668
4669   {
4670     'key'         => 'balance_due_below_line',
4671     'section'     => 'invoicing',
4672     'description' => 'Place the balance due message below a line.  Only meaningful when when invoice_sections is false.',
4673     'type'        => 'checkbox',
4674   },
4675
4676   {
4677     'key'         => 'always_show_tax',
4678     'section'     => 'invoicing',
4679     'description' => 'Show a line for tax on the invoice even when the tax is zero.  Optionally provide text for the tax name to show.',
4680     'type'        => [ qw(checkbox text) ],
4681   },
4682
4683   {
4684     'key'         => 'address_standardize_method',
4685     'section'     => 'UI', #???
4686     'description' => 'Method for standardizing customer addresses.',
4687     'type'        => 'select',
4688     'select_hash' => [ '' => '', 
4689                        'usps'     => 'U.S. Postal Service',
4690                        'uscensus' => 'U.S. Census Bureau',
4691                        'ezlocate' => 'EZLocate',
4692                        'melissa'  => 'Melissa WebSmart',
4693                        'freeside' => 'Freeside web service (support contract required)',
4694                      ],
4695   },
4696
4697   {
4698     'key'         => 'usps_webtools-userid',
4699     'section'     => 'UI',
4700     'description' => 'Production UserID for USPS web tools.   Enables USPS address standardization.  See the <a href="http://www.usps.com/webtools/">USPS website</a>, register and agree not to use the tools for batch purposes.',
4701     'type'        => 'text',
4702   },
4703
4704   {
4705     'key'         => 'usps_webtools-password',
4706     'section'     => 'UI',
4707     'description' => 'Production password for USPS web tools.   Enables USPS address standardization.  See <a href="http://www.usps.com/webtools/">USPS website</a>, register and agree not to use the tools for batch purposes.',
4708     'type'        => 'text',
4709   },
4710
4711   {
4712     'key'         => 'ezlocate-userid',
4713     'section'     => 'UI',
4714     'description' => 'User ID for EZ-Locate service.  See <a href="http://www.geocode.com/">the TomTom website</a> for access and pricing information.',
4715     'type'        => 'text',
4716   },
4717
4718   {
4719     'key'         => 'ezlocate-password',
4720     'section'     => 'UI',
4721     'description' => 'Password for EZ-Locate service.',
4722     'type'        => 'text'
4723   },
4724
4725   {
4726     'key'         => 'melissa-userid',
4727     'section'     => 'UI', # it's really not...
4728     'description' => 'User ID for Melissa WebSmart service.  See <a href="http://www.melissadata.com/">the Melissa website</a> for access and pricing.',
4729     'type'        => 'text',
4730   },
4731
4732   {
4733     'key'         => 'melissa-enable_geocoding',
4734     'section'     => 'UI',
4735     'description' => 'Use the Melissa service for census tract and coordinate lookups.  Enable this only if your subscription includes geocoding access.',
4736     'type'        => 'checkbox',
4737   },
4738
4739   {
4740     'key'         => 'cust_main-auto_standardize_address',
4741     'section'     => 'UI',
4742     'description' => 'When using USPS web tools, automatically standardize the address without asking.',
4743     'type'        => 'checkbox',
4744   },
4745
4746   {
4747     'key'         => 'cust_main-require_censustract',
4748     'section'     => 'UI',
4749     'description' => 'Customer is required to have a census tract.  Useful for FCC form 477 reports. See also: cust_main-auto_standardize_address',
4750     'type'        => 'checkbox',
4751   },
4752
4753   {
4754     'key'         => 'cust_main-no_city_in_address',
4755     'section'     => 'UI',
4756     'description' => 'Turn off City for billing & shipping addresses',
4757     'type'        => 'checkbox',
4758   },
4759
4760   {
4761     'key'         => 'census_year',
4762     'section'     => 'UI',
4763     'description' => 'The year to use in census tract lookups.  NOTE: you need to select 2012 or 2013 for Year 2010 Census tract codes.  A selection of 2011 provides Year 2000 Census tract codes.  Use the freeside-censustract-update tool if exisitng customers need to be changed.',
4764     'type'        => 'select',
4765     'select_enum' => [ qw( 2013 2012 2011 ) ],
4766   },
4767
4768   {
4769     'key'         => 'tax_district_method',
4770     'section'     => 'billing', # 'UI', #???
4771     'description' => 'The method to use to look up tax district codes.',
4772     'type'        => 'select',
4773     #'select_hash' => [ FS::Misc::Geo::get_district_methods() ],
4774     #after RT#13763, using FS::Misc::Geo here now causes a dependancy loop :/
4775     'select_hash' => [
4776                        ''         => '',
4777                        'wa_sales' => 'Washington sales tax',
4778                      ],
4779   },
4780
4781   {
4782     'key'         => 'tax_district_taxname',
4783     'section'     => 'billing',
4784     'description' => 'The tax name to display on the invoice for district sales taxes. Defaults to "Tax".',
4785     'type'        => 'text',
4786   },
4787
4788   {
4789     'key'         => 'company_latitude',
4790     'section'     => 'UI',
4791     'description' => 'Your company latitude (-90 through 90)',
4792     'type'        => 'text',
4793   },
4794
4795   {
4796     'key'         => 'company_longitude',
4797     'section'     => 'UI',
4798     'description' => 'Your company longitude (-180 thru 180)',
4799     'type'        => 'text',
4800   },
4801
4802   {
4803     'key'         => 'geocode_module',
4804     'section'     => '',
4805     'description' => 'Module to geocode (retrieve a latitude and longitude for) addresses',
4806     'type'        => 'select',
4807     'select_enum' => [ 'Geo::Coder::Googlev3' ],
4808   },
4809
4810   {
4811     'key'         => 'geocode-require_nw_coordinates',
4812     'section'     => 'UI',
4813     'description' => 'Require latitude and longitude in the North Western quadrant, e.g. for North American co-ordinates, etc.',
4814     'type'        => 'checkbox',
4815   },
4816
4817   {
4818     'key'         => 'disable_acl_changes',
4819     'section'     => '',
4820     'description' => 'Disable all ACL changes, for demos.',
4821     'type'        => 'checkbox',
4822   },
4823
4824   {
4825     'key'         => 'disable_settings_changes',
4826     'section'     => '',
4827     'description' => 'Disable all settings changes, for demos, except for the usernames given in the comma-separated list.',
4828     'type'        => [qw( checkbox text )],
4829   },
4830
4831   {
4832     'key'         => 'cust_main-edit_agent_custid',
4833     'section'     => 'UI',
4834     'description' => 'Enable editing of the agent_custid field.',
4835     'type'        => 'checkbox',
4836   },
4837
4838   {
4839     'key'         => 'cust_main-default_agent_custid',
4840     'section'     => 'UI',
4841     'description' => 'Display the agent_custid field when available instead of the custnum field.  Restart Apache after changing.',
4842     'type'        => 'checkbox',
4843   },
4844
4845   {
4846     'key'         => 'cust_main-title-display_custnum',
4847     'section'     => 'UI',
4848     'description' => 'Add the display_custom (agent_custid or custnum) to the title on customer view pages.',
4849     'type'        => 'checkbox',
4850   },
4851
4852   {
4853     'key'         => 'cust_bill-default_agent_invid',
4854     'section'     => 'UI',
4855     'description' => 'Display the agent_invid field when available instead of the invnum field.',
4856     'type'        => 'checkbox',
4857   },
4858
4859   {
4860     'key'         => 'cust_main-auto_agent_custid',
4861     'section'     => 'UI',
4862     'description' => 'Automatically assign an agent_custid - select format',
4863     'type'        => 'select',
4864     'select_hash' => [ '' => 'No',
4865                        '1YMMXXXXXXXX' => '1YMMXXXXXXXX',
4866                      ],
4867   },
4868
4869   {
4870     'key'         => 'cust_main-custnum-display_prefix',
4871     'section'     => 'UI',
4872     'description' => 'Prefix the customer number with this string for display purposes.',
4873     'type'        => 'text',
4874     'per_agent'   => 1,
4875   },
4876
4877   {
4878     'key'         => 'cust_main-custnum-display_length',
4879     'section'     => 'UI',
4880     'description' => 'Zero fill the customer number to this many digits for display purposes.  Restart Apache after changing.',
4881     'type'        => 'text',
4882   },
4883
4884   {
4885     'key'         => 'cust_main-default_areacode',
4886     'section'     => 'UI',
4887     'description' => 'Default area code for customers.',
4888     'type'        => 'text',
4889   },
4890
4891   {
4892     'key'         => 'order_pkg-no_start_date',
4893     'section'     => 'UI',
4894     'description' => 'Don\'t set a default start date for new packages.',
4895     'type'        => 'checkbox',
4896   },
4897
4898   {
4899     'key'         => 'part_pkg-delay_start',
4900     'section'     => '',
4901     'description' => 'Enabled "delayed start" option for packages.',
4902     'type'        => 'checkbox',
4903   },
4904
4905   {
4906     'key'         => 'part_pkg-delay_cancel-days',
4907     'section'     => '',
4908     'description' => 'Number of days to suspend when using automatic suspension period before cancel (default is 1)',
4909     'type'        => 'text',
4910     'validate'    => sub { (($_[0] =~ /^\d*$/) && (($_[0] eq '') || $_[0]))
4911                            ? ''
4912                            : 'Must specify an integer number of days' }
4913   },
4914
4915   {
4916     'key'         => 'mcp_svcpart',
4917     'section'     => '',
4918     'description' => 'Master Control Program svcpart.  Leave this blank.',
4919     'type'        => 'text', #select-part_svc
4920   },
4921
4922   {
4923     'key'         => 'cust_bill-max_same_services',
4924     'section'     => 'invoicing',
4925     'description' => 'Maximum number of the same service to list individually on invoices before condensing to a single line listing the number of services.  Defaults to 5.',
4926     'type'        => 'text',
4927   },
4928
4929   {
4930     'key'         => 'cust_bill-consolidate_services',
4931     'section'     => 'invoicing',
4932     'description' => 'Consolidate service display into fewer lines on invoices rather than one per service.',
4933     'type'        => 'checkbox',
4934   },
4935
4936   {
4937     'key'         => 'suspend_email_admin',
4938     'section'     => '',
4939     'description' => 'Destination admin email address to enable suspension notices',
4940     'type'        => 'text',
4941   },
4942
4943   {
4944     'key'         => 'unsuspend_email_admin',
4945     'section'     => '',
4946     'description' => 'Destination admin email address to enable unsuspension notices',
4947     'type'        => 'text',
4948   },
4949   
4950   {
4951     'key'         => 'email_report-subject',
4952     'section'     => '',
4953     'description' => 'Subject for reports emailed by freeside-fetch.  Defaults to "Freeside report".',
4954     'type'        => 'text',
4955   },
4956
4957   {
4958     'key'         => 'selfservice-head',
4959     'section'     => 'self-service',
4960     'description' => 'HTML for the HEAD section of the self-service interface, typically used for LINK stylesheet tags',
4961     'type'        => 'textarea', #htmlarea?
4962     'per_agent'   => 1,
4963   },
4964
4965
4966   {
4967     'key'         => 'selfservice-body_header',
4968     'section'     => 'self-service',
4969     'description' => 'HTML header for the self-service interface',
4970     'type'        => 'textarea', #htmlarea?
4971     'per_agent'   => 1,
4972   },
4973
4974   {
4975     'key'         => 'selfservice-body_footer',
4976     'section'     => 'self-service',
4977     'description' => 'HTML footer for the self-service interface',
4978     'type'        => 'textarea', #htmlarea?
4979     'per_agent'   => 1,
4980   },
4981
4982
4983   {
4984     'key'         => 'selfservice-body_bgcolor',
4985     'section'     => 'self-service',
4986     'description' => 'HTML background color for the self-service interface, for example, #FFFFFF',
4987     'type'        => 'text',
4988     'per_agent'   => 1,
4989   },
4990
4991   {
4992     'key'         => 'selfservice-box_bgcolor',
4993     'section'     => 'self-service',
4994     'description' => 'HTML color for self-service interface input boxes, for example, #C0C0C0',
4995     'type'        => 'text',
4996     'per_agent'   => 1,
4997   },
4998
4999   {
5000     'key'         => 'selfservice-stripe1_bgcolor',
5001     'section'     => 'self-service',
5002     'description' => 'HTML color for self-service interface lists (primary stripe), for example, #FFFFFF',
5003     'type'        => 'text',
5004     'per_agent'   => 1,
5005   },
5006
5007   {
5008     'key'         => 'selfservice-stripe2_bgcolor',
5009     'section'     => 'self-service',
5010     'description' => 'HTML color for self-service interface lists (alternate stripe), for example, #DDDDDD',
5011     'type'        => 'text',
5012     'per_agent'   => 1,
5013   },
5014
5015   {
5016     'key'         => 'selfservice-text_color',
5017     'section'     => 'self-service',
5018     'description' => 'HTML text color for the self-service interface, for example, #000000',
5019     'type'        => 'text',
5020     'per_agent'   => 1,
5021   },
5022
5023   {
5024     'key'         => 'selfservice-link_color',
5025     'section'     => 'self-service',
5026     'description' => 'HTML link color for the self-service interface, for example, #0000FF',
5027     'type'        => 'text',
5028     'per_agent'   => 1,
5029   },
5030
5031   {
5032     'key'         => 'selfservice-vlink_color',
5033     'section'     => 'self-service',
5034     'description' => 'HTML visited link color for the self-service interface, for example, #FF00FF',
5035     'type'        => 'text',
5036     'per_agent'   => 1,
5037   },
5038
5039   {
5040     'key'         => 'selfservice-hlink_color',
5041     'section'     => 'self-service',
5042     'description' => 'HTML hover link color for the self-service interface, for example, #808080',
5043     'type'        => 'text',
5044     'per_agent'   => 1,
5045   },
5046
5047   {
5048     'key'         => 'selfservice-alink_color',
5049     'section'     => 'self-service',
5050     'description' => 'HTML active (clicked) link color for the self-service interface, for example, #808080',
5051     'type'        => 'text',
5052     'per_agent'   => 1,
5053   },
5054
5055   {
5056     'key'         => 'selfservice-font',
5057     'section'     => 'self-service',
5058     'description' => 'HTML font CSS for the self-service interface, for example, 0.9em/1.5em Arial, Helvetica, Geneva, sans-serif',
5059     'type'        => 'text',
5060     'per_agent'   => 1,
5061   },
5062
5063   {
5064     'key'         => 'selfservice-no_logo',
5065     'section'     => 'self-service',
5066     'description' => 'Disable the logo in self-service',
5067     'type'        => 'checkbox',
5068     'per_agent'   => 1,
5069   },
5070
5071   {
5072     'key'         => 'selfservice-title_color',
5073     'section'     => 'self-service',
5074     'description' => 'HTML color for the self-service title, for example, #000000',
5075     'type'        => 'text',
5076     'per_agent'   => 1,
5077   },
5078
5079   {
5080     'key'         => 'selfservice-title_align',
5081     'section'     => 'self-service',
5082     'description' => 'HTML alignment for the self-service title, for example, center',
5083     'type'        => 'text',
5084     'per_agent'   => 1,
5085   },
5086   {
5087     'key'         => 'selfservice-title_size',
5088     'section'     => 'self-service',
5089     'description' => 'HTML font size for the self-service title, for example, 3',
5090     'type'        => 'text',
5091     'per_agent'   => 1,
5092   },
5093
5094   {
5095     'key'         => 'selfservice-title_left_image',
5096     'section'     => 'self-service',
5097     'description' => 'Image used for the top of the menu in the self-service interface, in PNG format.',
5098     'type'        => 'image',
5099     'per_agent'   => 1,
5100   },
5101
5102   {
5103     'key'         => 'selfservice-title_right_image',
5104     'section'     => 'self-service',
5105     'description' => 'Image used for the top of the menu in the self-service interface, in PNG format.',
5106     'type'        => 'image',
5107     'per_agent'   => 1,
5108   },
5109
5110   {
5111     'key'         => 'selfservice-menu_disable',
5112     'section'     => 'self-service',
5113     'description' => 'Disable the selected menu entries in the self-service menu',
5114     'type'        => 'selectmultiple',
5115     'select_enum' => [ #false laziness w/myaccount_menu.html
5116                        'Overview',
5117                        'Purchase',
5118                        'Purchase additional package',
5119                        'Recharge my account with a credit card',
5120                        'Recharge my account with a check',
5121                        'Recharge my account with a prepaid card',
5122                        'View my usage',
5123                        'Create a ticket',
5124                        'Setup my services',
5125                        'Change my information',
5126                        'Change billing address',
5127                        'Change service address',
5128                        'Change payment information',
5129                        'Change password(s)',
5130                        'Logout',
5131                      ],
5132     'per_agent'   => 1,
5133   },
5134
5135   {
5136     'key'         => 'selfservice-menu_skipblanks',
5137     'section'     => 'self-service',
5138     'description' => 'Skip blank (spacer) entries in the self-service menu',
5139     'type'        => 'checkbox',
5140     'per_agent'   => 1,
5141   },
5142
5143   {
5144     'key'         => 'selfservice-menu_skipheadings',
5145     'section'     => 'self-service',
5146     'description' => 'Skip the unclickable heading entries in the self-service menu',
5147     'type'        => 'checkbox',
5148     'per_agent'   => 1,
5149   },
5150
5151   {
5152     'key'         => 'selfservice-menu_bgcolor',
5153     'section'     => 'self-service',
5154     'description' => 'HTML color for the self-service menu, for example, #C0C0C0',
5155     'type'        => 'text',
5156     'per_agent'   => 1,
5157   },
5158
5159   {
5160     'key'         => 'selfservice-menu_fontsize',
5161     'section'     => 'self-service',
5162     'description' => 'HTML font size for the self-service menu, for example, -1',
5163     'type'        => 'text',
5164     'per_agent'   => 1,
5165   },
5166   {
5167     'key'         => 'selfservice-menu_nounderline',
5168     'section'     => 'self-service',
5169     'description' => 'Styles menu links in the self-service without underlining.',
5170     'type'        => 'checkbox',
5171     'per_agent'   => 1,
5172   },
5173
5174
5175   {
5176     'key'         => 'selfservice-menu_top_image',
5177     'section'     => 'self-service',
5178     'description' => 'Image used for the top of the menu in the self-service interface, in PNG format.',
5179     'type'        => 'image',
5180     'per_agent'   => 1,
5181   },
5182
5183   {
5184     'key'         => 'selfservice-menu_body_image',
5185     'section'     => 'self-service',
5186     'description' => 'Repeating image used for the body of the menu in the self-service interface, in PNG format.',
5187     'type'        => 'image',
5188     'per_agent'   => 1,
5189   },
5190
5191   {
5192     'key'         => 'selfservice-menu_bottom_image',
5193     'section'     => 'self-service',
5194     'description' => 'Image used for the bottom of the menu in the self-service interface, in PNG format.',
5195     'type'        => 'image',
5196     'per_agent'   => 1,
5197   },
5198   
5199   {
5200     'key'         => 'selfservice-view_usage_nodomain',
5201     'section'     => 'self-service',
5202     'description' => 'Show usernames without their domains in "View my usage" in the self-service interface.',
5203     'type'        => 'checkbox',
5204   },
5205
5206   {
5207     'key'         => 'selfservice-login_banner_image',
5208     'section'     => 'self-service',
5209     'description' => 'Banner image shown on the login page, in PNG format.',
5210     'type'        => 'image',
5211   },
5212
5213   {
5214     'key'         => 'selfservice-login_banner_url',
5215     'section'     => 'self-service',
5216     'description' => 'Link for the login banner.',
5217     'type'        => 'text',
5218   },
5219
5220   {
5221     'key'         => 'ng_selfservice-menu',
5222     'section'     => 'self-service',
5223     'description' => 'Custom menu for the next-generation self-service interface.  Each line is in the format "link Label", for example "main.php Home".  Sub-menu items are listed on subsequent lines.  Blank lines terminate the submenu.', #more docs/examples would be helpful
5224     'type'        => 'textarea',
5225   },
5226
5227   {
5228     'key'         => 'signup-no_company',
5229     'section'     => 'self-service',
5230     'description' => "Don't display a field for company name on signup.",
5231     'type'        => 'checkbox',
5232   },
5233
5234   {
5235     'key'         => 'signup-recommend_email',
5236     'section'     => 'self-service',
5237     'description' => 'Encourage the entry of an invoicing email address on signup.',
5238     'type'        => 'checkbox',
5239   },
5240
5241   {
5242     'key'         => 'signup-recommend_daytime',
5243     'section'     => 'self-service',
5244     'description' => 'Encourage the entry of a daytime phone number on signup.',
5245     'type'        => 'checkbox',
5246   },
5247
5248   {
5249     'key'         => 'signup-duplicate_cc-warn_hours',
5250     'section'     => 'self-service',
5251     'description' => 'Issue a warning if the same credit card is used for multiple signups within this many hours.',
5252     'type'        => 'text',
5253   },
5254
5255   {
5256     'key'         => 'svc_phone-radius-password',
5257     'section'     => 'telephony',
5258     'description' => 'Password when exporting svc_phone records to RADIUS',
5259     'type'        => 'select',
5260     'select_hash' => [
5261       '' => 'Use default from svc_phone-radius-default_password config',
5262       'countrycode_phonenum' => 'Phone number (with country code)',
5263     ],
5264   },
5265
5266   {
5267     'key'         => 'svc_phone-radius-default_password',
5268     'section'     => 'telephony',
5269     'description' => 'Default password when exporting svc_phone records to RADIUS',
5270     'type'        => 'text',
5271   },
5272
5273   {
5274     'key'         => 'svc_phone-allow_alpha_phonenum',
5275     'section'     => 'telephony',
5276     'description' => 'Allow letters in phone numbers.',
5277     'type'        => 'checkbox',
5278   },
5279
5280   {
5281     'key'         => 'svc_phone-domain',
5282     'section'     => 'telephony',
5283     'description' => 'Track an optional domain association with each phone service.',
5284     'type'        => 'checkbox',
5285   },
5286
5287   {
5288     'key'         => 'svc_phone-phone_name-max_length',
5289     'section'     => 'telephony',
5290     'description' => 'Maximum length of the phone service "Name" field (svc_phone.phone_name).  Sometimes useful to limit this (to 15?) when exporting as Caller ID data.',
5291     'type'        => 'text',
5292   },
5293
5294   {
5295     'key'         => 'svc_phone-random_pin',
5296     'section'     => 'telephony',
5297     'description' => 'Number of random digits to generate in the "PIN" field, if empty.',
5298     'type'        => 'text',
5299   },
5300
5301   {
5302     'key'         => 'svc_phone-lnp',
5303     'section'     => 'telephony',
5304     'description' => 'Enables Number Portability features for svc_phone',
5305     'type'        => 'checkbox',
5306   },
5307
5308   {
5309     'key'         => 'svc_phone-bulk_provision_simple',
5310     'section'     => 'telephony',
5311     'description' => 'Bulk provision phone numbers with a simple number range instead of from DID vendor orders',
5312     'type'        => 'checkbox',
5313   },
5314
5315   {
5316     'key'         => 'default_phone_countrycode',
5317     'section'     => 'telephony',
5318     'description' => 'Default countrycode',
5319     'type'        => 'text',
5320   },
5321
5322   {
5323     'key'         => 'cdr-charged_party-field',
5324     'section'     => 'telephony',
5325     'description' => 'Set the charged_party field of CDRs to this field.',
5326     'type'        => 'select-sub',
5327     'options_sub' => sub { my $fields = FS::cdr->table_info->{'fields'};
5328                            map { $_ => $fields->{$_}||$_ }
5329                            grep { $_ !~ /^(acctid|charged_party)$/ }
5330                            FS::Schema::dbdef->table('cdr')->columns;
5331                          },
5332     'option_sub'  => sub { my $f = shift;
5333                            FS::cdr->table_info->{'fields'}{$f} || $f;
5334                          },
5335   },
5336
5337   #probably deprecate in favor of cdr-charged_party-field above
5338   {
5339     'key'         => 'cdr-charged_party-accountcode',
5340     'section'     => 'telephony',
5341     'description' => 'Set the charged_party field of CDRs to the accountcode.',
5342     'type'        => 'checkbox',
5343   },
5344
5345   {
5346     'key'         => 'cdr-charged_party-accountcode-trim_leading_0s',
5347     'section'     => 'telephony',
5348     'description' => 'When setting the charged_party field of CDRs to the accountcode, trim any leading zeros.',
5349     'type'        => 'checkbox',
5350   },
5351
5352 #  {
5353 #    'key'         => 'cdr-charged_party-truncate_prefix',
5354 #    'section'     => '',
5355 #    'description' => 'If the charged_party field has this prefix, truncate it to the length in cdr-charged_party-truncate_length.',
5356 #    'type'        => 'text',
5357 #  },
5358 #
5359 #  {
5360 #    'key'         => 'cdr-charged_party-truncate_length',
5361 #    'section'     => '',
5362 #    'description' => 'If the charged_party field has the prefix in cdr-charged_party-truncate_prefix, truncate it to this length.',
5363 #    'type'        => 'text',
5364 #  },
5365
5366   {
5367     'key'         => 'cdr-skip_duplicate_rewrite',
5368     'section'     => 'telephony',
5369     'description' => 'Use the freeside-cdrrewrited daemon to prevent billing CDRs with a src, dst and calldate identical to an existing CDR',
5370     'type'        => 'checkbox',
5371   },
5372
5373   {
5374     'key'         => 'cdr-charged_party_rewrite',
5375     'section'     => 'telephony',
5376     'description' => 'Do charged party rewriting in the freeside-cdrrewrited daemon; useful if CDRs are being dropped off directly in the database and require special charged_party processing such as cdr-charged_party-accountcode or cdr-charged_party-truncate*.',
5377     'type'        => 'checkbox',
5378   },
5379
5380   {
5381     'key'         => 'cdr-taqua-da_rewrite',
5382     'section'     => 'telephony',
5383     'description' => 'For the Taqua CDR format, a comma-separated list of directory assistance 800 numbers.  Any CDRs with these numbers as "BilledNumber" will be rewritten to the "CallingPartyNumber" (and CallType "12") on import.',
5384     'type'        => 'text',
5385   },
5386
5387   {
5388     'key'         => 'cdr-taqua-accountcode_rewrite',
5389     'section'     => 'telephony',
5390     'description' => 'For the Taqua CDR format, pull accountcodes from secondary CDRs with matching sessionNumber.',
5391     'type'        => 'checkbox',
5392   },
5393
5394   {
5395     'key'         => 'cdr-taqua-callerid_rewrite',
5396     'section'     => 'telephony',
5397     'description' => 'For the Taqua CDR format, pull Caller ID blocking information from secondary CDRs.',
5398     'type'        => 'checkbox',
5399   },
5400
5401   {
5402     'key'         => 'cdr-asterisk_australia_rewrite',
5403     'section'     => 'telephony',
5404     'description' => 'For Asterisk CDRs, assign CDR type numbers based on Australian conventions.',
5405     'type'        => 'checkbox',
5406   },
5407
5408   {
5409     'key'         => 'cdr-userfield_dnis_rewrite',
5410     'section'     => 'telephony',
5411     'description' => 'If the CDR userfield contains "DNIS=" followed by a sequence of digits, use that as the destination number for the call.',
5412     'type'        => 'checkbox',
5413   },
5414
5415   {
5416     'key'         => 'cdr-intl_to_domestic_rewrite',
5417     'section'     => 'telephony',
5418     'description' => 'Strip the "011" international prefix from CDR destination numbers if the rest of the number is 7 digits or shorter, and so probably does not contain a country code.',
5419     'type'        => 'checkbox',
5420   },
5421
5422   {
5423     'key'         => 'cdr-gsm_tap3-sender',
5424     'section'     => 'telephony',
5425     'description' => 'GSM TAP3 Sender network (5 letter code)',
5426     'type'        => 'text',
5427   },
5428
5429   {
5430     'key'         => 'cust_pkg-show_autosuspend',
5431     'section'     => 'UI',
5432     'description' => 'Show package auto-suspend dates.  Use with caution for now; can slow down customer view for large insallations.',
5433     'type'        => 'checkbox',
5434   },
5435
5436   {
5437     'key'         => 'cdr-asterisk_forward_rewrite',
5438     'section'     => 'telephony',
5439     'description' => 'Enable special processing for CDRs representing forwarded calls: For CDRs that have a dcontext that starts with "Local/" but does not match dst, set charged_party to dst, parse a new dst from dstchannel, and set amaflags to "2" ("BILL"/"BILLING").',
5440     'type'        => 'checkbox',
5441   },
5442
5443   {
5444     'key'         => 'mc-outbound_packages',
5445     'section'     => '',
5446     'description' => "Don't use this.",
5447     'type'        => 'select-part_pkg',
5448     'multiple'    => 1,
5449   },
5450
5451   {
5452     'key'         => 'disable-cust-pkg_class',
5453     'section'     => 'UI',
5454     'description' => 'Disable the two-step dropdown for selecting package class and package, and return to the classic single dropdown.',
5455     'type'        => 'checkbox',
5456   },
5457
5458   {
5459     'key'         => 'queued-max_kids',
5460     'section'     => '',
5461     'description' => 'Maximum number of queued processes.  Defaults to 10.',
5462     'type'        => 'text',
5463   },
5464
5465   {
5466     'key'         => 'queued-sleep_time',
5467     'section'     => '',
5468     'description' => 'Time to sleep between attempts to find new jobs to process in the queue.  Defaults to 10.  Installations doing real-time CDR processing for prepaid may want to set it lower.',
5469     'type'        => 'text',
5470   },
5471
5472   {
5473     'key'         => 'queue-no_history',
5474     'section'     => '',
5475     'description' => "Don't recreate the h_queue and h_queue_arg tables on upgrades.  This can save disk space for large installs, especially when using prepaid or multi-process billing.  After turning this option on, drop the h_queue and h_queue_arg tables, run freeside-dbdef-create and restart Apache and Freeside.",
5476     'type'        => 'checkbox',
5477   },
5478
5479   {
5480     'key'         => 'cancelled_cust-noevents',
5481     'section'     => 'billing',
5482     'description' => "Don't run events for cancelled customers",
5483     'type'        => 'checkbox',
5484   },
5485
5486   {
5487     'key'         => 'agent-invoice_template',
5488     'section'     => 'invoicing',
5489     'description' => 'Enable display/edit of old-style per-agent invoice template selection',
5490     'type'        => 'checkbox',
5491   },
5492
5493   {
5494     'key'         => 'svc_broadband-manage_link',
5495     'section'     => 'UI',
5496     'description' => 'URL for svc_broadband "Manage Device" link.  The following substitutions are available: $ip_addr and $mac_addr.',
5497     'type'        => 'text',
5498   },
5499
5500   {
5501     'key'         => 'svc_broadband-manage_link_text',
5502     'section'     => 'UI',
5503     'description' => 'Label for "Manage Device" link',
5504     'type'        => 'text',
5505   },
5506
5507   {
5508     'key'         => 'svc_broadband-manage_link_loc',
5509     'section'     => 'UI',
5510     'description' => 'Location for "Manage Device" link',
5511     'type'        => 'select',
5512     'select_hash' => [
5513       'bottom' => 'Near Unprovision link',
5514       'right'  => 'With export-related links',
5515     ],
5516   },
5517
5518   {
5519     'key'         => 'svc_broadband-manage_link-new_window',
5520     'section'     => 'UI',
5521     'description' => 'Open the "Manage Device" link in a new window',
5522     'type'        => 'checkbox',
5523   },
5524
5525   #more fine-grained, service def-level control could be useful eventually?
5526   {
5527     'key'         => 'svc_broadband-allow_null_ip_addr',
5528     'section'     => '',
5529     'description' => '',
5530     'type'        => 'checkbox',
5531   },
5532
5533   {
5534     'key'         => 'svc_hardware-check_mac_addr',
5535     'section'     => '', #?
5536     'description' => 'Require the "hardware address" field in hardware services to be a valid MAC address.',
5537     'type'        => 'checkbox',
5538   },
5539
5540   {
5541     'key'         => 'tax-report_groups',
5542     'section'     => '',
5543     'description' => 'List of grouping possibilities for tax names on reports, one per line, "label op value" (op can be = or !=).',
5544     'type'        => 'textarea',
5545   },
5546
5547   {
5548     'key'         => 'tax-cust_exempt-groups',
5549     'section'     => 'billing',
5550     'description' => 'List of grouping possibilities for tax names, for per-customer exemption purposes, one tax name per line.  For example, "GST" would indicate the ability to exempt customers individually from taxes named "GST" (but not other taxes).',
5551     'type'        => 'textarea',
5552   },
5553
5554   {
5555     'key'         => 'tax-cust_exempt-groups-require_individual_nums',
5556     'section'     => 'deprecated',
5557     'description' => 'Deprecated: see tax-cust_exempt-groups-num_req',
5558     'type'        => 'checkbox',
5559   },
5560
5561   {
5562     'key'         => 'tax-cust_exempt-groups-num_req',
5563     'section'     => 'billing',
5564     'description' => 'When using tax-cust_exempt-groups, control whether individual tax exemption numbers are required for exemption from different taxes.',
5565     'type'        => 'select',
5566     'select_hash' => [ ''            => 'Not required',
5567                        'residential' => 'Required for residential customers only',
5568                        'all'         => 'Required for all customers',
5569                      ],
5570   },
5571
5572   {
5573     'key'         => 'tax-round_per_line_item',
5574     'section'     => 'billing',
5575     'description' => 'Calculate tax and round to the nearest cent for each line item, rather than for the whole invoice.',
5576     'type'        => 'checkbox',
5577   },
5578
5579   {
5580     'key'         => 'cust_main-default_view',
5581     'section'     => 'UI',
5582     'description' => 'Default customer view, for users who have not selected a default view in their preferences.',
5583     'type'        => 'select',
5584     'select_hash' => [
5585       #false laziness w/view/cust_main.cgi and pref/pref.html
5586       'basics'          => 'Basics',
5587       'notes'           => 'Notes',
5588       'tickets'         => 'Tickets',
5589       'packages'        => 'Packages',
5590       'payment_history' => 'Payment History',
5591       'change_history'  => 'Change History',
5592       'jumbo'           => 'Jumbo',
5593     ],
5594   },
5595
5596   {
5597     'key'         => 'enable_tax_adjustments',
5598     'section'     => 'billing',
5599     'description' => 'Enable the ability to add manual tax adjustments.',
5600     'type'        => 'checkbox',
5601   },
5602
5603   {
5604     'key'         => 'rt-crontool',
5605     'section'     => '',
5606     'description' => 'Enable the RT CronTool extension.',
5607     'type'        => 'checkbox',
5608   },
5609
5610   {
5611     'key'         => 'pkg-balances',
5612     'section'     => 'billing',
5613     'description' => 'Enable per-package balances.',
5614     'type'        => 'checkbox',
5615   },
5616
5617   {
5618     'key'         => 'pkg-addon_classnum',
5619     'section'     => 'billing',
5620     'description' => 'Enable the ability to restrict additional package orders based on package class.',
5621     'type'        => 'checkbox',
5622   },
5623
5624   {
5625     'key'         => 'cust_main-edit_signupdate',
5626     'section'     => 'UI',
5627     'description' => 'Enable manual editing of the signup date.',
5628     'type'        => 'checkbox',
5629   },
5630
5631   {
5632     'key'         => 'svc_acct-disable_access_number',
5633     'section'     => 'UI',
5634     'description' => 'Disable access number selection.',
5635     'type'        => 'checkbox',
5636   },
5637
5638   {
5639     'key'         => 'cust_bill_pay_pkg-manual',
5640     'section'     => 'UI',
5641     'description' => 'Allow manual application of payments to line items.',
5642     'type'        => 'checkbox',
5643   },
5644
5645   {
5646     'key'         => 'cust_credit_bill_pkg-manual',
5647     'section'     => 'UI',
5648     'description' => 'Allow manual application of credits to line items.',
5649     'type'        => 'checkbox',
5650   },
5651
5652   {
5653     'key'         => 'breakage-days',
5654     'section'     => 'billing',
5655     'description' => 'If set to a number of days, after an account goes that long without activity, recognizes any outstanding payments and credits as "breakage" by creating a breakage charge and invoice.',
5656     'type'        => 'text',
5657     'per_agent'   => 1,
5658   },
5659
5660   {
5661     'key'         => 'breakage-pkg_class',
5662     'section'     => 'billing',
5663     'description' => 'Package class to use for breakage reconciliation.',
5664     'type'        => 'select-pkg_class',
5665   },
5666
5667   {
5668     'key'         => 'disable_cron_billing',
5669     'section'     => 'billing',
5670     'description' => 'Disable billing and collection from being run by freeside-daily and freeside-monthly, while still allowing other actions to run, such as notifications and backup.',
5671     'type'        => 'checkbox',
5672   },
5673
5674   {
5675     'key'         => 'svc_domain-edit_domain',
5676     'section'     => '',
5677     'description' => 'Enable domain renaming',
5678     'type'        => 'checkbox',
5679   },
5680
5681   {
5682     'key'         => 'enable_legacy_prepaid_income',
5683     'section'     => '',
5684     'description' => "Enable legacy prepaid income reporting.  Only useful when you have imported pre-Freeside packages with longer-than-monthly duration, and need to do prepaid income reporting on them before they've been invoiced the first time.",
5685     'type'        => 'checkbox',
5686   },
5687
5688   {
5689     'key'         => 'cust_main-exports',
5690     'section'     => '',
5691     'description' => 'Export(s) to call on cust_main insert, modification and deletion.',
5692     'type'        => 'select-sub',
5693     'multiple'    => 1,
5694     'options_sub' => sub {
5695       require FS::Record;
5696       require FS::part_export;
5697       my @part_export =
5698         map { qsearch( 'part_export', {exporttype => $_ } ) }
5699           keys %{FS::part_export::export_info('cust_main')};
5700       map { $_->exportnum => $_->exportname } @part_export;
5701     },
5702     'option_sub'  => sub {
5703       require FS::Record;
5704       require FS::part_export;
5705       my $part_export = FS::Record::qsearchs(
5706         'part_export', { 'exportnum' => shift }
5707       );
5708       $part_export
5709         ? $part_export->exportname
5710         : '';
5711     },
5712   },
5713
5714   #false laziness w/above options_sub and option_sub
5715   {
5716     'key'         => 'cust_location-exports',
5717     'section'     => '',
5718     'description' => 'Export(s) to call on cust_location insert or modification',
5719     'type'        => 'select-sub',
5720     'multiple'    => 1,
5721     'options_sub' => sub {
5722       require FS::Record;
5723       require FS::part_export;
5724       my @part_export =
5725         map { qsearch( 'part_export', {exporttype => $_ } ) }
5726           keys %{FS::part_export::export_info('cust_location')};
5727       map { $_->exportnum => $_->exportname } @part_export;
5728     },
5729     'option_sub'  => sub {
5730       require FS::Record;
5731       require FS::part_export;
5732       my $part_export = FS::Record::qsearchs(
5733         'part_export', { 'exportnum' => shift }
5734       );
5735       $part_export
5736         ? $part_export->exportname
5737         : '';
5738     },
5739   },
5740
5741   {
5742     'key'         => 'cust_tag-location',
5743     'section'     => 'UI',
5744     'description' => 'Location where customer tags are displayed.',
5745     'type'        => 'select',
5746     'select_enum' => [ 'misc_info', 'top' ],
5747   },
5748
5749   {
5750     'key'         => 'cust_main-custom_link',
5751     'section'     => 'UI',
5752     'description' => 'URL to use as source for the "Custom" tab in the View Customer page.  The customer number will be appended, or you can insert "$custnum" to have it inserted elsewhere.  "$agentnum" will be replaced with the agent number, "$agent_custid" with be replaced with the agent customer ID (if any), and "$usernum" will be replaced with the employee number.',
5753     'type'        => 'textarea',
5754   },
5755
5756   {
5757     'key'         => 'cust_main-custom_content',
5758     'section'     => 'UI',
5759     'description' => 'As an alternative to cust_main-custom_link (leave it blank), the contant to display on this customer page, one item per line.  Available iems are: small_custview, birthdate, spouse_birthdate, svc_acct, svc_phone and svc_external.',
5760     'type'        => 'textarea',
5761   },
5762
5763   {
5764     'key'         => 'cust_main-custom_title',
5765     'section'     => 'UI',
5766     'description' => 'Title for the "Custom" tab in the View Customer page.',
5767     'type'        => 'text',
5768   },
5769
5770   {
5771     'key'         => 'part_pkg-default_suspend_bill',
5772     'section'     => 'billing',
5773     'description' => 'Default the "Continue recurring billing while suspended" flag to on for new package definitions.',
5774     'type'        => 'checkbox',
5775   },
5776   
5777   {
5778     'key'         => 'qual-alt_address_format',
5779     'section'     => 'UI',
5780     'description' => 'Enable the alternate address format (location type, number, and kind) for qualifications.',
5781     'type'        => 'checkbox',
5782   },
5783
5784   {
5785     'key'         => 'prospect_main-alt_address_format',
5786     'section'     => 'UI',
5787     'description' => 'Enable the alternate address format (location type, number, and kind) for prospects.  Recommended if qual-alt_address_format is set and the main use of propects is for qualifications.',
5788     'type'        => 'checkbox',
5789   },
5790
5791   {
5792     'key'         => 'prospect_main-location_required',
5793     'section'     => 'UI',
5794     'description' => 'Require an address for prospects.  Recommended if the main use of propects is for qualifications.',
5795     'type'        => 'checkbox',
5796   },
5797
5798   {
5799     'key'         => 'note-classes',
5800     'section'     => 'deprecated',
5801     'description' => 'Use customer note classes (now automatically used if classes are defined)',
5802     'type'        => 'select',
5803     'select_hash' => [
5804                        0 => 'Disabled',
5805                        1 => 'Enabled',
5806                        2 => 'Enabled, with tabs',
5807                      ],
5808   },
5809
5810   {
5811     'key'         => 'svc_acct-cf_privatekey-message',
5812     'section'     => '',
5813     'description' => 'For internal use: HTML displayed when cf_privatekey field is set.',
5814     'type'        => 'textarea',
5815   },
5816
5817   {
5818     'key'         => 'menu-prepend_links',
5819     'section'     => 'UI',
5820     'description' => 'Links to prepend to the main menu, one per line, with format "URL Link Label (optional ALT popup)".',
5821     'type'        => 'textarea',
5822   },
5823
5824   {
5825     'key'         => 'cust_main-external_links',
5826     'section'     => 'UI',
5827     'description' => 'External links available in customer view, one per line, with format "URL Link Label (optional ALT popup)".  The URL will have custnum appended.',
5828     'type'        => 'textarea',
5829   },
5830   
5831   {
5832     'key'         => 'svc_phone-did-summary',
5833     'section'     => 'invoicing',
5834     'description' => 'Experimental feature to enable DID activity summary on invoices, showing # DIDs activated/deactivated/ported-in/ported-out and total minutes usage, covering period since last invoice.',
5835     'type'        => 'checkbox',
5836   },
5837
5838   {
5839     'key'         => 'svc_acct-usage_seconds',
5840     'section'     => 'invoicing',
5841     'description' => 'Enable calculation of RADIUS usage time for invoices.  You must modify your template to display this information.',
5842     'type'        => 'checkbox',
5843   },
5844   
5845   {
5846     'key'         => 'opensips_gwlist',
5847     'section'     => 'telephony',
5848     'description' => 'For svc_phone OpenSIPS dr_rules export, gwlist column value, per-agent',
5849     'type'        => 'text',
5850     'per_agent'   => 1,
5851     'agentonly'   => 1,
5852   },
5853
5854   {
5855     'key'         => 'opensips_description',
5856     'section'     => 'telephony',
5857     'description' => 'For svc_phone OpenSIPS dr_rules export, description column value, per-agent',
5858     'type'        => 'text',
5859     'per_agent'   => 1,
5860     'agentonly'   => 1,
5861   },
5862   
5863   {
5864     'key'         => 'opensips_route',
5865     'section'     => 'telephony',
5866     'description' => 'For svc_phone OpenSIPS dr_rules export, routeid column value, per-agent',
5867     'type'        => 'text',
5868     'per_agent'   => 1,
5869     'agentonly'   => 1,
5870   },
5871
5872   {
5873     'key'         => 'cust_bill-no_recipients-error',
5874     'section'     => 'invoicing',
5875     'description' => 'For customers with no invoice recipients, throw a job queue error rather than the default behavior of emailing the invoice to the invoice_from address.',
5876     'type'        => 'checkbox',
5877   },
5878
5879   {
5880     'key'         => 'cust_bill-latex_lineitem_maxlength',
5881     'section'     => 'deprecated',
5882     'description' => 'With old invoice_latex template, truncate long line items to this number of characters on typeset invoices, to avoid losing things off the right margin.  Defaults to 50.  (With current invoice_latex template, this is handled internally in the template itself instead.)',
5883     'type'        => 'text',
5884   },
5885
5886   {
5887     'key'         => 'invoice_payment_details',
5888     'section'     => 'invoicing',
5889     'description' => 'When displaying payments on an invoice, show the payment method used, including the check or credit card number.  Credit card numbers will be masked.',
5890     'type'        => 'checkbox',
5891   },
5892
5893   {
5894     'key'         => 'cust_main-status_module',
5895     'section'     => 'UI',
5896     'description' => 'Which module to use for customer status display.  The "Classic" module (the default) considers accounts with cancelled recurring packages but un-cancelled one-time charges Inactive.  The "Recurring" module considers those customers Cancelled.  Similarly for customers with suspended recurring packages but one-time charges.  Restart Apache after changing.', #other differences?
5897     'type'        => 'select',
5898     'select_enum' => [ 'Classic', 'Recurring' ],
5899   },
5900
5901   { 
5902     'key'         => 'username-pound',
5903     'section'     => 'username',
5904     'description' => 'Allow the pound character (#) in usernames.',
5905     'type'        => 'checkbox',
5906   },
5907
5908   { 
5909     'key'         => 'username-exclamation',
5910     'section'     => 'username',
5911     'description' => 'Allow the exclamation character (!) in usernames.',
5912     'type'        => 'checkbox',
5913   },
5914
5915   {
5916     'key'         => 'ie-compatibility_mode',
5917     'section'     => 'UI',
5918     'description' => "Compatibility mode META tag for Internet Explorer, used on the customer view page.  Not necessary in normal operation unless custom content (notes, cust_main-custom_link) is included on customer view that is incompatibile with newer IE verisons.",
5919     'type'        => 'select',
5920     'select_enum' => [ '', '7', 'EmulateIE7', '8', 'EmulateIE8' ],
5921   },
5922
5923   {
5924     'key'         => 'disable_payauto_default',
5925     'section'     => 'UI',
5926     'description' => 'Disable the "Charge future payments to this (card|check) automatically" checkbox from defaulting to checked.',
5927     'type'        => 'checkbox',
5928   },
5929   
5930   {
5931     'key'         => 'payment-history-report',
5932     'section'     => 'UI',
5933     'description' => 'Show a link to the raw database payment history report in the Reports menu.  DO NOT ENABLE THIS for modern installations.',
5934     'type'        => 'checkbox',
5935   },
5936   
5937   {
5938     'key'         => 'svc_broadband-require-nw-coordinates',
5939     'section'     => 'deprecated',
5940     'description' => 'Deprecated; see geocode-require_nw_coordinates instead',
5941     'type'        => 'checkbox',
5942   },
5943   
5944   {
5945     'key'         => 'cust-email-high-visibility',
5946     'section'     => 'UI',
5947     'description' => 'Move the invoicing e-mail address field to the top of the billing address section and highlight it.',
5948     'type'        => 'checkbox',
5949   },
5950   
5951   {
5952     'key'         => 'cust-edit-alt-field-order',
5953     'section'     => 'UI',
5954     'description' => 'An alternate ordering of fields for the New Customer and Edit Customer screens.',
5955     'type'        => 'checkbox',
5956   },
5957
5958   {
5959     'key'         => 'cust_bill-enable_promised_date',
5960     'section'     => 'UI',
5961     'description' => 'Enable display/editing of the "promised payment date" field on invoices.',
5962     'type'        => 'checkbox',
5963   },
5964   
5965   {
5966     'key'         => 'available-locales',
5967     'section'     => '',
5968     'description' => 'Limit available locales (employee preferences, per-customer locale selection, etc.) to a particular set.',
5969     'type'        => 'select-sub',
5970     'multiple'    => 1,
5971     'options_sub' => sub { 
5972       map { $_ => FS::Locales->description($_) }
5973       FS::Locales->locales;
5974     },
5975     'option_sub'  => sub { FS::Locales->description(shift) },
5976   },
5977
5978   {
5979     'key'         => 'cust_main-require_locale',
5980     'section'     => 'UI',
5981     'description' => 'Require an explicit locale to be chosen for new customers.',
5982     'type'        => 'checkbox',
5983   },
5984   
5985   {
5986     'key'         => 'translate-auto-insert',
5987     'section'     => '',
5988     'description' => 'Auto-insert untranslated strings for selected non-en_US locales with their default/en_US values.  Do not turn this on unless translating the interface into a new language.  Restart Apache after changing.',
5989     'type'        => 'select',
5990     'multiple'    => 1,
5991     'select_enum' => [ grep { $_ ne 'en_US' } FS::Locales::locales ],
5992   },
5993
5994   {
5995     'key'         => 'svc_acct-tower_sector',
5996     'section'     => '',
5997     'description' => 'Track tower and sector for svc_acct (account) services.',
5998     'type'        => 'checkbox',
5999   },
6000
6001   {
6002     'key'         => 'cdr-prerate',
6003     'section'     => 'telephony',
6004     'description' => 'Experimental feature to rate CDRs immediately, rather than waiting until invoice generation time.  Can reduce invoice generation time when processing lots of CDRs.  Currently works with "VoIP/telco CDR rating (standard)" price plans using "Phone numbers (svc_phone.phonenum)" CDR service matching, without any included minutes.',
6005     'type'        => 'checkbox',
6006   },
6007
6008   {
6009     'key'         => 'cdr-prerate-cdrtypenums',
6010     'section'     => 'telephony',
6011     'description' => 'When using cdr-prerate to rate CDRs immediately, limit processing to these CDR types.',
6012     'type'        => 'select-sub',
6013     'multiple'    => 1,
6014     'options_sub' => sub { require FS::Record;
6015                            require FS::cdr_type;
6016                            map { $_->cdrtypenum => $_->cdrtypename }
6017                                FS::Record::qsearch( 'cdr_type', 
6018                                                     {} #{ 'disabled' => '' }
6019                                                   );
6020                          },
6021     'option_sub'  => sub { require FS::Record;
6022                            require FS::cdr_type;
6023                            my $cdr_type = FS::Record::qsearchs(
6024                              'cdr_type', { 'cdrtypenum'=>shift } );
6025                            $cdr_type ? $cdr_type->cdrtypename : '';
6026                          },
6027   },
6028
6029   {
6030     'key'         => 'cdr-minutes_priority',
6031     'section'     => 'telephony',
6032     'description' => 'Priority rule for assigning included minutes to CDRs.',
6033     'type'        => 'select',
6034     'select_hash' => [
6035       ''          => 'No specific order',
6036       'time'      => 'Chronological',
6037       'rate_high' => 'Highest rate first',
6038       'rate_low'  => 'Lowest rate first',
6039     ],
6040   },
6041
6042   {
6043     'key'         => 'cdr-lrn_lookup',
6044     'section'     => 'telephony',
6045     'description' => 'Look up LRNs of destination numbers for exact matching to the terminating carrier.  This feature requires a Freeside support contract for paid access to the central NPAC database; see <a href ="#support-key">support-key</a>.',
6046     'type'        => 'checkbox',
6047   },
6048   
6049   {
6050     'key'         => 'brand-agent',
6051     'section'     => 'UI',
6052     'description' => 'Brand the backoffice interface (currently Help->About) using the company_name, company_url and logo.png configuration settings of the selected agent.  Typically used when selling or bundling hosted access to the backoffice interface.  NOTE: The AGPL software license has specific requirements for source code availability in this situation.',
6053     'type'        => 'select-agent',
6054   },
6055
6056   {
6057     'key'         => 'cust_class-tax_exempt',
6058     'section'     => 'billing',
6059     'description' => 'Control the tax exemption flag per customer class rather than per indivual customer.',
6060     'type'        => 'checkbox',
6061   },
6062
6063   {
6064     'key'         => 'selfservice-billing_history-line_items',
6065     'section'     => 'self-service',
6066     'description' => 'Return line item billing detail for the self-service billing_history API call.',
6067     'type'        => 'checkbox',
6068   },
6069
6070   {
6071     'key'         => 'selfservice-default_cdr_format',
6072     'section'     => 'self-service',
6073     'description' => 'Format for showing outbound CDRs in self-service.  The per-package option overrides this.',
6074     'type'        => 'select',
6075     'select_hash' => \@cdr_formats,
6076   },
6077
6078   {
6079     'key'         => 'selfservice-default_inbound_cdr_format',
6080     'section'     => 'self-service',
6081     'description' => 'Format for showing inbound CDRs in self-service.  The per-package option overrides this.  Leave blank to avoid showing these CDRs.',
6082     'type'        => 'select',
6083     'select_hash' => \@cdr_formats,
6084   },
6085
6086   {
6087     'key'         => 'selfservice-hide_cdr_price',
6088     'section'     => 'self-service',
6089     'description' => 'Don\'t show the "Price" column on CDRs in self-service.',
6090     'type'        => 'checkbox',
6091   },
6092
6093   {
6094     'key'         => 'selfservice-enable_payment_without_balance',
6095     'section'     => 'self-service',
6096     'description' => 'Allow selfservice customers to make payments even if balance is zero or below (resulting in an unapplied payment and negative balance.)',
6097     'type'        => 'checkbox',
6098   },
6099
6100   {
6101     'key'         => 'selfservice-announcement',
6102     'section'     => 'self-service',
6103     'description' => 'HTML announcement to display to all authenticated users on account overview page',
6104     'type'        => 'textarea',
6105   },
6106
6107   {
6108     'key'         => 'logout-timeout',
6109     'section'     => 'UI',
6110     'description' => 'If set, automatically log users out of the backoffice after this many minutes.',
6111     'type'       => 'text',
6112   },
6113   
6114   {
6115     'key'         => 'spreadsheet_format',
6116     'section'     => 'UI',
6117     'description' => 'Default format for spreadsheet download.',
6118     'type'        => 'select',
6119     'select_hash' => [
6120       'XLS' => 'XLS (Excel 97/2000/XP)',
6121       'XLSX' => 'XLSX (Excel 2007+)',
6122     ],
6123   },
6124
6125   {
6126     'key'         => 'agent-email_day',
6127     'section'     => '',
6128     'description' => 'On this day of each month, agents with master customer records containing email addresses will be emailed a list of their customers and balances.',
6129     'type'        => 'text',
6130   },
6131
6132   {
6133     'key'         => 'report-cust_pay-select_time',
6134     'section'     => 'UI',
6135     'description' => 'Enable time selection on payment and refund reports.',
6136     'type'        => 'checkbox',
6137   },
6138
6139   {
6140     'key'         => 'default_credit_limit',
6141     'section'     => 'billing',
6142     'description' => 'Default customer credit limit',
6143     'type'        => 'text',
6144   },
6145
6146   {
6147     'key'         => 'api_shared_secret',
6148     'section'     => 'API',
6149     'description' => 'Shared secret for back-office API authentication',
6150     'type'        => 'text',
6151   },
6152
6153   {
6154     'key'         => 'xmlrpc_api',
6155     'section'     => 'API',
6156     'description' => 'Enable the back-office API XML-RPC server (on port 8008).',
6157     'type'        => 'checkbox',
6158   },
6159
6160 #  {
6161 #    'key'         => 'jsonrpc_api',
6162 #    'section'     => 'API',
6163 #    'description' => 'Enable the back-office API JSON-RPC server (on port 8081).',
6164 #    'type'        => 'checkbox',
6165 #  },
6166
6167   {
6168     'key'         => 'api_credit_reason',
6169     'section'     => 'API',
6170     'description' => 'Default reason for back-office API credits',
6171     'type'        => 'select-sub',
6172     #false laziness w/api_credit_reason
6173     'options_sub' => sub { require FS::Record;
6174                            require FS::reason;
6175                            my $type = qsearchs('reason_type', 
6176                              { class => 'R' }) 
6177                               or return ();
6178                            map { $_->reasonnum => $_->reason }
6179                                FS::Record::qsearch('reason', 
6180                                  { reason_type => $type->typenum } 
6181                                );
6182                          },
6183     'option_sub'  => sub { require FS::Record;
6184                            require FS::reason;
6185                            my $reason = FS::Record::qsearchs(
6186                              'reason', { 'reasonnum' => shift }
6187                            );
6188                            $reason ? $reason->reason : '';
6189                          },
6190   },
6191
6192   {
6193     'key'         => 'part_pkg-term_discounts',
6194     'section'     => 'billing',
6195     'description' => 'Enable the term discounts feature.  Recommended to keep turned off unless actually using - not well optimized for large installations.',
6196     'type'        => 'checkbox',
6197   },
6198
6199   {
6200     'key'         => 'prepaid-never_renew',
6201     'section'     => 'billing',
6202     'description' => 'Prepaid packages never renew.',
6203     'type'        => 'checkbox',
6204   },
6205
6206   {
6207     'key'         => 'agent-disable_counts',
6208     'section'     => 'UI',
6209     'description' => 'On the agent browse page, disable the customer and package counts.  Typically used for very large databases when this page takes too long to render.',
6210     'type'        => 'checkbox',
6211   },
6212
6213   {
6214     'key'         => 'tollfree-country',
6215     'section'     => 'telephony',
6216     'description' => 'Country / region for toll-free recognition',
6217     'type'        => 'select',
6218     'select_hash' => [ ''   => 'NANPA (US/Canada)',
6219                        'AU' => 'Australia',
6220                        'NZ' => 'New Zealand',
6221                      ],
6222   },
6223
6224   {
6225     'key'         => 'old_fcc_report',
6226     'section'     => '',
6227     'description' => 'Use the old (pre-2014) FCC Form 477 report format.',
6228     'type'        => 'checkbox',
6229   },
6230
6231   {
6232     'key'         => 'cust_main-default_commercial',
6233     'section'     => 'UI',
6234     'description' => 'Default for new customers is commercial rather than residential.',
6235     'type'        => 'checkbox',
6236   },
6237
6238   {
6239     'key'         => 'default_appointment_length',
6240     'section'     => 'UI',
6241     'description' => 'Default appointment length, in minutes (30 minute granularity).',
6242     'type'        => 'text',
6243   },
6244
6245   { key => "apacheroot", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6246   { key => "apachemachine", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6247   { key => "apachemachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6248   { key => "bindprimary", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6249   { key => "bindsecondaries", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6250   { key => "bsdshellmachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6251   { key => "cyrus", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6252   { key => "cp_app", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6253   { key => "erpcdmachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6254   { key => "icradiusmachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6255   { key => "icradius_mysqldest", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6256   { key => "icradius_mysqlsource", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6257   { key => "icradius_secrets", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6258   { key => "maildisablecatchall", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6259   { key => "mxmachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6260   { key => "nsmachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6261   { key => "arecords", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6262   { key => "cnamerecords", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6263   { key => "nismachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6264   { key => "qmailmachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6265   { key => "radiusmachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6266   { key => "sendmailconfigpath", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6267   { key => "sendmailmachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6268   { key => "sendmailrestart", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6269   { key => "shellmachine", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6270   { key => "shellmachine-useradd", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6271   { key => "shellmachine-userdel", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6272   { key => "shellmachine-usermod", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6273   { key => "shellmachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6274   { key => "radiusprepend", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6275   { key => "textradiusprepend", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6276   { key => "username_policy", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6277   { key => "vpopmailmachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6278   { key => "vpopmailrestart", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6279   { key => "safe-part_pkg", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6280   { key => "selfservice_server-quiet", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6281   { key => "signup_server-quiet", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6282   { key => "signup_server-email", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6283   { key => "vonage-username", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6284   { key => "vonage-password", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6285   { key => "vonage-fromnumber", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
6286
6287   {
6288     'key'         => 'selfservice-db_profile',
6289     'section'     => 'development',
6290     'description' => 'Enable collection and logging of database profiling information for self-service servers.  This has significant overhead, do not leave enabled in production beyond that necessary to collect profiling data.',
6291     'type'        => 'checkbox',
6292   },
6293
6294
6295   # for internal use only; test databases should declare this option and
6296   # everyone else should pretend it doesn't exist
6297   #{
6298   #  'key'         => 'no_random_ids',
6299   #  'section'     => '',
6300   #  'description' => 'Replace random identifiers in UI code with a static string, for repeatable testing. Don\'t use in production.',
6301   #  'type'        => 'checkbox',
6302   #},
6303
6304 );
6305
6306 1;
6307