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