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