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