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