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