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