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