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