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