(start of) reconcile breakage from stale accounts, RT#6407
[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::payby;
12 use FS::conf;
13 use FS::Record qw(qsearch qsearchs);
14 use FS::UID qw(dbh datasrc use_confcompat);
15
16 $base_dir = '%%%FREESIDE_CONF%%%';
17
18 $DEBUG = 0;
19
20 =head1 NAME
21
22 FS::Conf - Freeside configuration values
23
24 =head1 SYNOPSIS
25
26   use FS::Conf;
27
28   $conf = new FS::Conf;
29
30   $value = $conf->config('key');
31   @list  = $conf->config('key');
32   $bool  = $conf->exists('key');
33
34   $conf->touch('key');
35   $conf->set('key' => 'value');
36   $conf->delete('key');
37
38   @config_items = $conf->config_items;
39
40 =head1 DESCRIPTION
41
42 Read and write Freeside configuration values.  Keys currently map to filenames,
43 but this may change in the future.
44
45 =head1 METHODS
46
47 =over 4
48
49 =item new
50
51 Create a new configuration object.
52
53 =cut
54
55 sub new {
56   my($proto) = @_;
57   my($class) = ref($proto) || $proto;
58   my($self) = { 'base_dir' => $base_dir };
59   bless ($self, $class);
60 }
61
62 =item base_dir
63
64 Returns the base directory.  By default this is /usr/local/etc/freeside.
65
66 =cut
67
68 sub base_dir {
69   my($self) = @_;
70   my $base_dir = $self->{base_dir};
71   -e $base_dir or die "FATAL: $base_dir doesn't exist!";
72   -d $base_dir or die "FATAL: $base_dir isn't a directory!";
73   -r $base_dir or die "FATAL: Can't read $base_dir!";
74   -x $base_dir or die "FATAL: $base_dir not searchable (executable)!";
75   $base_dir =~ /^(.*)$/;
76   $1;
77 }
78
79 =item conf KEY [ AGENTNUM [ NODEFAULT ] ]
80
81 Returns the L<FS::conf> record for the key and agent.
82
83 =cut
84
85 sub conf {
86   my $self = shift;
87   $self->_config(@_);
88 }
89
90 =item config KEY [ AGENTNUM [ NODEFAULT ] ]
91
92 Returns the configuration value or values (depending on context) for key.
93 The optional agent number selects an agent specific value instead of the
94 global default if one is present.  If NODEFAULT is true only the agent
95 specific value(s) is returned.
96
97 =cut
98
99 sub _usecompat {
100   my ($self, $method) = (shift, shift);
101   carp "NO CONFIGURATION RECORDS FOUND -- USING COMPATIBILITY MODE"
102     if use_confcompat;
103   my $compat = new FS::Conf_compat17 ("$base_dir/conf." . datasrc);
104   $compat->$method(@_);
105 }
106
107 sub _config {
108   my($self,$name,$agentnum,$agentonly)=@_;
109   my $hashref = { 'name' => $name };
110   $hashref->{agentnum} = $agentnum;
111   local $FS::Record::conf = undef;  # XXX evil hack prevents recursion
112   my $cv = FS::Record::qsearchs('conf', $hashref);
113   if (!$agentonly && !$cv && defined($agentnum) && $agentnum) {
114     $hashref->{agentnum} = '';
115     $cv = FS::Record::qsearchs('conf', $hashref);
116   }
117   return $cv;
118 }
119
120 sub config {
121   my $self = shift;
122   return $self->_usecompat('config', @_) if use_confcompat;
123
124   carp "FS::Conf->config(". join(', ', @_). ") called"
125     if $DEBUG > 1;
126
127   my $cv = $self->_config(@_) or return;
128
129   if ( wantarray ) {
130     my $v = $cv->value;
131     chomp $v;
132     (split "\n", $v, -1);
133   } else {
134     (split("\n", $cv->value))[0];
135   }
136 }
137
138 =item config_binary KEY [ AGENTNUM [ NODEFAULT ] ]
139
140 Returns the exact scalar value for key.
141
142 =cut
143
144 sub config_binary {
145   my $self = shift;
146   return $self->_usecompat('config_binary', @_) if use_confcompat;
147
148   my $cv = $self->_config(@_) or return;
149   length($cv->value) ? decode_base64($cv->value) : '';
150 }
151
152 =item exists KEY [ AGENTNUM [ NODEFAULT ] ]
153
154 Returns true if the specified key exists, even if the corresponding value
155 is undefined.
156
157 =cut
158
159 sub exists {
160   my $self = shift;
161   return $self->_usecompat('exists', @_) if use_confcompat;
162
163   my($name, $agentnum)=@_;
164
165   carp "FS::Conf->exists(". join(', ', @_). ") called"
166     if $DEBUG > 1;
167
168   defined($self->_config(@_));
169 }
170
171 =item config_orbase KEY SUFFIX
172
173 Returns the configuration value or values (depending on context) for 
174 KEY_SUFFIX, if it exists, otherwise for KEY
175
176 =cut
177
178 # outmoded as soon as we shift to agentnum based config values
179 # well, mostly.  still useful for e.g. late notices, etc. in that we want
180 # these to fall back to standard values
181 sub config_orbase {
182   my $self = shift;
183   return $self->_usecompat('config_orbase', @_) if use_confcompat;
184
185   my( $name, $suffix ) = @_;
186   if ( $self->exists("${name}_$suffix") ) {
187     $self->config("${name}_$suffix");
188   } else {
189     $self->config($name);
190   }
191 }
192
193 =item key_orbase KEY SUFFIX
194
195 If the config value KEY_SUFFIX exists, returns KEY_SUFFIX, otherwise returns
196 KEY.  Useful for determining which exact configuration option is returned by
197 config_orbase.
198
199 =cut
200
201 sub key_orbase {
202   my $self = shift;
203   #no compat for this...return $self->_usecompat('config_orbase', @_) if use_confcompat;
204
205   my( $name, $suffix ) = @_;
206   if ( $self->exists("${name}_$suffix") ) {
207     "${name}_$suffix";
208   } else {
209     $name;
210   }
211 }
212
213 =item invoice_templatenames
214
215 Returns all possible invoice template names.
216
217 =cut
218
219 sub invoice_templatenames {
220   my( $self ) = @_;
221
222   my %templatenames = ();
223   foreach my $item ( $self->config_items ) {
224     foreach my $base ( @base_items ) {
225       my( $main, $ext) = split(/\./, $base);
226       $ext = ".$ext" if $ext;
227       if ( $item->key =~ /^${main}_(.+)$ext$/ ) {
228       $templatenames{$1}++;
229       }
230     }
231   }
232   
233   map { $_ } #handle scalar context
234   sort keys %templatenames;
235
236 }
237
238 =item touch KEY [ AGENT ];
239
240 Creates the specified configuration key if it does not exist.
241
242 =cut
243
244 sub touch {
245   my $self = shift;
246   return $self->_usecompat('touch', @_) if use_confcompat;
247
248   my($name, $agentnum) = @_;
249   unless ( $self->exists($name, $agentnum) ) {
250     $self->set($name, '', $agentnum);
251   }
252 }
253
254 =item set KEY VALUE [ AGENTNUM ];
255
256 Sets the specified configuration key to the given value.
257
258 =cut
259
260 sub set {
261   my $self = shift;
262   return $self->_usecompat('set', @_) if use_confcompat;
263
264   my($name, $value, $agentnum) = @_;
265   $value =~ /^(.*)$/s;
266   $value = $1;
267
268   warn "[FS::Conf] SET $name\n" if $DEBUG;
269
270   my $old = FS::Record::qsearchs('conf', {name => $name, agentnum => $agentnum});
271   my $new = new FS::conf { $old ? $old->hash 
272                                 : ('name' => $name, 'agentnum' => $agentnum)
273                          };
274   $new->value($value);
275
276   my $error;
277   if ($old) {
278     $error = $new->replace($old);
279   } else {
280     $error = $new->insert;
281   }
282
283   die "error setting configuration value: $error \n"
284     if $error;
285
286 }
287
288 =item set_binary KEY VALUE [ AGENTNUM ]
289
290 Sets the specified configuration key to an exact scalar value which
291 can be retrieved with config_binary.
292
293 =cut
294
295 sub set_binary {
296   my $self  = shift;
297   return if use_confcompat;
298
299   my($name, $value, $agentnum)=@_;
300   $self->set($name, encode_base64($value), $agentnum);
301 }
302
303 =item delete KEY [ AGENTNUM ];
304
305 Deletes the specified configuration key.
306
307 =cut
308
309 sub delete {
310   my $self = shift;
311   return $self->_usecompat('delete', @_) if use_confcompat;
312
313   my($name, $agentnum) = @_;
314   if ( my $cv = FS::Record::qsearchs('conf', {name => $name, agentnum => $agentnum}) ) {
315     warn "[FS::Conf] DELETE $name\n";
316
317     my $oldAutoCommit = $FS::UID::AutoCommit;
318     local $FS::UID::AutoCommit = 0;
319     my $dbh = dbh;
320
321     my $error = $cv->delete;
322
323     if ( $error ) {
324       $dbh->rollback if $oldAutoCommit;
325       die "error setting configuration value: $error \n"
326     }
327
328     $dbh->commit or die $dbh->errstr if $oldAutoCommit;
329
330   }
331 }
332
333 =item import_config_item CONFITEM DIR 
334
335   Imports the item specified by the CONFITEM (see L<FS::ConfItem>) into
336 the database as a conf record (see L<FS::conf>).  Imports from the file
337 in the directory DIR.
338
339 =cut
340
341 sub import_config_item { 
342   my ($self,$item,$dir) = @_;
343   my $key = $item->key;
344   if ( -e "$dir/$key" && ! use_confcompat ) {
345     warn "Inserting $key\n" if $DEBUG;
346     local $/;
347     my $value = readline(new IO::File "$dir/$key");
348     if ($item->type =~ /^(binary|image)$/ ) {
349       $self->set_binary($key, $value);
350     }else{
351       $self->set($key, $value);
352     }
353   }else {
354     warn "Not inserting $key\n" if $DEBUG;
355   }
356 }
357
358 =item verify_config_item CONFITEM DIR 
359
360   Compares the item specified by the CONFITEM (see L<FS::ConfItem>) in
361 the database to the legacy file value in DIR.
362
363 =cut
364
365 sub verify_config_item { 
366   return '' if use_confcompat;
367   my ($self,$item,$dir) = @_;
368   my $key = $item->key;
369   my $type = $item->type;
370
371   my $compat = new FS::Conf_compat17 $dir;
372   my $error = '';
373   
374   $error .= "$key fails existential comparison; "
375     if $self->exists($key) xor $compat->exists($key);
376
377   if ( $type !~ /^(binary|image)$/ ) {
378
379     {
380       no warnings;
381       $error .= "$key fails scalar comparison; "
382         unless scalar($self->config($key)) eq scalar($compat->config($key));
383     }
384
385     my (@new) = $self->config($key);
386     my (@old) = $compat->config($key);
387     unless ( scalar(@new) == scalar(@old)) { 
388       $error .= "$key fails list comparison; ";
389     }else{
390       my $r=1;
391       foreach (@old) { $r=0 if ($_ cmp shift(@new)); }
392       $error .= "$key fails list comparison; "
393         unless $r;
394     }
395
396   } else {
397
398     $error .= "$key fails binary comparison; "
399       unless scalar($self->config_binary($key)) eq scalar($compat->config_binary($key));
400
401   }
402
403 #remove deprecated config on our own terms, not freeside-upgrade's
404 #  if ($error =~ /existential comparison/ && $item->section eq 'deprecated') {
405 #    my $proto;
406 #    for ( @config_items ) { $proto = $_; last if $proto->key eq $key;  }
407 #    unless ($proto->key eq $key) { 
408 #      warn "removed config item $error\n" if $DEBUG;
409 #      $error = '';
410 #    }
411 #  }
412
413   $error;
414 }
415
416 #item _orbase_items OPTIONS
417 #
418 #Returns all of the possible extensible config items as FS::ConfItem objects.
419 #See #L<FS::ConfItem>.  OPTIONS consists of name value pairs.  Possible
420 #options include
421 #
422 # dir - the directory to search for configuration option files instead
423 #       of using the conf records in the database
424 #
425 #cut
426
427 #quelle kludge
428 sub _orbase_items {
429   my ($self, %opt) = @_; 
430
431   my $listmaker = sub { my $v = shift;
432                         $v =~ s/_/!_/g;
433                         if ( $v =~ /\.(png|eps)$/ ) {
434                           $v =~ s/\./!_%./;
435                         }else{
436                           $v .= '!_%';
437                         }
438                         map { $_->name }
439                           FS::Record::qsearch( 'conf',
440                                                {},
441                                                '',
442                                                "WHERE name LIKE '$v' ESCAPE '!'"
443                                              );
444                       };
445
446   if (exists($opt{dir}) && $opt{dir}) {
447     $listmaker = sub { my $v = shift;
448                        if ( $v =~ /\.(png|eps)$/ ) {
449                          $v =~ s/\./_*./;
450                        }else{
451                          $v .= '_*';
452                        }
453                        map { basename $_ } glob($opt{dir}. "/$v" );
454                      };
455   }
456
457   ( map { 
458           my $proto;
459           my $base = $_;
460           for ( @config_items ) { $proto = $_; last if $proto->key eq $base;  }
461           die "don't know about $base items" unless $proto->key eq $base;
462
463           map { new FS::ConfItem { 
464                   'key'         => $_,
465                   'base_key'    => $proto->key,
466                   'section'     => $proto->section,
467                   'description' => 'Alternate ' . $proto->description . '  See the <a href="http://www.freeside.biz/mediawiki/index.php/Freeside:1.7:Documentation:Administration#Invoice_templates">billing documentation</a> for details.',
468                   'type'        => $proto->type,
469                 };
470               } &$listmaker($base);
471         } @base_items,
472   );
473 }
474
475 =item config_items
476
477 Returns all of the possible global/default configuration items as
478 FS::ConfItem objects.  See L<FS::ConfItem>.
479
480 =cut
481
482 sub config_items {
483   my $self = shift; 
484   return $self->_usecompat('config_items', @_) if use_confcompat;
485
486   ( @config_items, $self->_orbase_items(@_) );
487 }
488
489 =back
490
491 =head1 SUBROUTINES
492
493 =over 4
494
495 =item init-config DIR
496
497 Imports the configuration items from DIR (1.7 compatible)
498 to conf records in the database.
499
500 =cut
501
502 sub init_config {
503   my $dir = shift;
504
505   {
506     local $FS::UID::use_confcompat = 0;
507     my $conf = new FS::Conf;
508     foreach my $item ( $conf->config_items(dir => $dir) ) {
509       $conf->import_config_item($item, $dir);
510       my $error = $conf->verify_config_item($item, $dir);
511       return $error if $error;
512     }
513   
514     my $compat = new FS::Conf_compat17 $dir;
515     foreach my $item ( $compat->config_items ) {
516       my $error = $conf->verify_config_item($item, $dir);
517       return $error if $error;
518     }
519   }
520
521   $FS::UID::use_confcompat = 0;
522   '';  #success
523 }
524
525 =back
526
527 =head1 BUGS
528
529 If this was more than just crud that will never be useful outside Freeside I'd
530 worry that config_items is freeside-specific and icky.
531
532 =head1 SEE ALSO
533
534 "Configuration" in the web interface (config/config.cgi).
535
536 =cut
537
538 #Business::CreditCard
539 @card_types = (
540   "VISA card",
541   "MasterCard",
542   "Discover card",
543   "American Express card",
544   "Diner's Club/Carte Blanche",
545   "enRoute",
546   "JCB",
547   "BankCard",
548   "Switch",
549   "Solo",
550 );
551
552 @base_items = qw (
553                    invoice_template
554                    invoice_latex
555                    invoice_latexreturnaddress
556                    invoice_latexfooter
557                    invoice_latexsmallfooter
558                    invoice_latexnotes
559                    invoice_latexcoupon
560                    invoice_html
561                    invoice_htmlreturnaddress
562                    invoice_htmlfooter
563                    invoice_htmlnotes
564                    logo.png
565                    logo.eps
566                  );
567
568 @config_items = map { new FS::ConfItem $_ } (
569
570   {
571     'key'         => 'address',
572     'section'     => 'deprecated',
573     'description' => 'This configuration option is no longer used.  See <a href="#invoice_template">invoice_template</a> instead.',
574     'type'        => 'text',
575   },
576
577   {
578     'key'         => 'alert_expiration',
579     'section'     => 'billing',
580     'description' => 'Enable alerts about billing method expiration (i.e. expiring credit cards).',
581     'type'        => 'checkbox',
582     'per_agent'   => 1,
583   },
584
585   {
586     'key'         => 'alerter_template',
587     'section'     => 'billing',
588     'description' => 'Template file for billing method expiration alerts (i.e. expiring credit cards).  See the <a href="http://www.freeside.biz/mediawiki/index.php/Freeside:1.7:Documentation:Administration#Credit_cards_and_Electronic_checks">billing documentation</a> for details.',
589     'type'        => 'textarea',
590     'per_agent'   => 1,
591   },
592
593   {
594     'key'         => 'apacheip',
595     #not actually deprecated yet
596     #'section'     => 'deprecated',
597     #'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',
598     'section'     => '',
599     'description' => 'IP address to assign to new virtual hosts',
600     'type'        => 'text',
601   },
602
603   {
604     'key'         => 'encryption',
605     'section'     => 'billing',
606     'description' => 'Enable encryption of credit cards.',
607     'type'        => 'checkbox',
608   },
609
610   {
611     'key'         => 'encryptionmodule',
612     'section'     => 'billing',
613     'description' => 'Use which module for encryption?',
614     'type'        => 'text',
615   },
616
617   {
618     'key'         => 'encryptionpublickey',
619     'section'     => 'billing',
620     'description' => 'Your RSA Public Key - Required if Encryption is turned on.',
621     'type'        => 'textarea',
622   },
623
624   {
625     'key'         => 'encryptionprivatekey',
626     'section'     => 'billing',
627     'description' => 'Your RSA Private Key - Including this will enable the "Bill Now" feature.  However if the system is compromised, a hacker can use this key to decode the stored credit card information.  This is generally not a good idea.',
628     'type'        => 'textarea',
629   },
630
631   {
632     'key'         => 'billco-url',
633     'section'     => 'billing',
634     'description' => 'The url to use for performing uploads to the invoice mailing service.',
635     'type'        => 'text',
636     'per_agent'   => 1,
637   },
638
639   {
640     'key'         => 'billco-username',
641     'section'     => 'billing',
642     'description' => 'The login name to use for uploads to the invoice mailing service.',
643     'type'        => 'text',
644     'per_agent'   => 1,
645     'agentonly'   => 1,
646   },
647
648   {
649     'key'         => 'billco-password',
650     'section'     => 'billing',
651     'description' => 'The password to use for uploads to the invoice mailing service.',
652     'type'        => 'text',
653     'per_agent'   => 1,
654     'agentonly'   => 1,
655   },
656
657   {
658     'key'         => 'billco-clicode',
659     'section'     => 'billing',
660     'description' => 'The clicode to use for uploads to the invoice mailing service.',
661     'type'        => 'text',
662     'per_agent'   => 1,
663   },
664
665   {
666     'key'         => 'business-onlinepayment',
667     'section'     => 'billing',
668     '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.',
669     'type'        => 'textarea',
670   },
671
672   {
673     'key'         => 'business-onlinepayment-ach',
674     'section'     => 'billing',
675     '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.',
676     'type'        => 'textarea',
677   },
678
679   {
680     'key'         => 'business-onlinepayment-namespace',
681     'section'     => 'billing',
682     'description' => 'Specifies which perl module namespace (which group of collection routines) is used by default.',
683     'type'        => 'select',
684     'select_hash' => [
685                        'Business::OnlinePayment' => 'Direct API (Business::OnlinePayment)',
686                        'Business::OnlineThirdPartyPayment' => 'Web API (Business::ThirdPartyPayment)',
687                      ],
688   },
689
690   {
691     'key'         => 'business-onlinepayment-description',
692     'section'     => 'billing',
693     '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)',
694     'type'        => 'text',
695   },
696
697   {
698     'key'         => 'business-onlinepayment-email-override',
699     'section'     => 'billing',
700     'description' => 'Email address used instead of customer email address when submitting a BOP transaction.',
701     'type'        => 'text',
702   },
703
704   {
705     'key'         => 'business-onlinepayment-email_customer',
706     'section'     => 'billing',
707     'description' => 'Controls the "email_customer" flag used by some Business::OnlinePayment processors to enable customer receipts.',
708     'type'        => 'checkbox',
709   },
710
711   {
712     'key'         => 'countrydefault',
713     'section'     => 'UI',
714     'description' => 'Default two-letter country code (if not supplied, the default is `US\')',
715     'type'        => 'text',
716   },
717
718   {
719     'key'         => 'date_format',
720     'section'     => 'UI',
721     'description' => 'Format for displaying dates',
722     'type'        => 'select',
723     'select_hash' => [
724                        '%m/%d/%Y' => 'MM/DD/YYYY',
725                        '%Y/%m/%d' => 'YYYY/MM/DD',
726                      ],
727   },
728
729   {
730     'key'         => 'deletecustomers',
731     'section'     => 'UI',
732     '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.',
733     'type'        => 'checkbox',
734   },
735
736   {
737     'key'         => 'deleteinvoices',
738     'section'     => 'UI',
739     '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?
740     'type'        => 'checkbox',
741   },
742
743   {
744     'key'         => 'deletepayments',
745     'section'     => 'billing',
746     '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.',
747     'type'        => [qw( checkbox text )],
748   },
749
750   {
751     'key'         => 'deletecredits',
752     #not actually deprecated yet
753     #'section'     => 'deprecated',
754     #'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.',
755     'section'     => '',
756     'description' => 'One or more comma-separated email addresses to be notified when a credit is deleted.',
757     'type'        => [qw( checkbox text )],
758   },
759
760   {
761     'key'         => 'deleterefunds',
762     'section'     => 'billing',
763     'description' => 'Enable deletion of unclosed refunds.  Be very careful!  Only delete refunds that were data-entry errors, not adjustments.',
764     'type'        => 'checkbox',
765   },
766
767   {
768     'key'         => 'unapplypayments',
769     'section'     => 'deprecated',
770     'description' => '<B>DEPRECATED</B>, now controlled by ACLs.  Used to enable "unapplication" of unclosed payments.',
771     'type'        => 'checkbox',
772   },
773
774   {
775     'key'         => 'unapplycredits',
776     'section'     => 'deprecated',
777     'description' => '<B>DEPRECATED</B>, now controlled by ACLs.  Used to nable "unapplication" of unclosed credits.',
778     'type'        => 'checkbox',
779   },
780
781   {
782     'key'         => 'dirhash',
783     'section'     => 'shell',
784     '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>',
785     'type'        => 'text',
786   },
787
788   {
789     'key'         => 'disable_cust_attachment',
790     'section'     => '',
791     'description' => 'Disable customer file attachments',
792     'type'        => 'checkbox',
793   },
794
795   {
796     'key'         => 'max_attachment_size',
797     'section'     => '',
798     'description' => 'Maximum size for customer file attachments (leave blank for unlimited)',
799     'type'        => 'text',
800   },
801
802   {
803     'key'         => 'disable_customer_referrals',
804     'section'     => 'UI',
805     'description' => 'Disable new customer-to-customer referrals in the web interface',
806     'type'        => 'checkbox',
807   },
808
809   {
810     'key'         => 'editreferrals',
811     'section'     => 'UI',
812     'description' => 'Enable advertising source modification for existing customers',
813     'type'       => 'checkbox',
814   },
815
816   {
817     'key'         => 'emailinvoiceonly',
818     'section'     => 'billing',
819     'description' => 'Disables postal mail invoices',
820     'type'       => 'checkbox',
821   },
822
823   {
824     'key'         => 'disablepostalinvoicedefault',
825     'section'     => 'billing',
826     '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>.',
827     'type'       => 'checkbox',
828   },
829
830   {
831     'key'         => 'emailinvoiceauto',
832     'section'     => 'billing',
833     'description' => 'Automatically adds new accounts to the email invoice list',
834     'type'       => 'checkbox',
835   },
836
837   {
838     'key'         => 'emailinvoiceautoalways',
839     'section'     => 'billing',
840     'description' => 'Automatically adds new accounts to the email invoice list even when the list contains email addresses',
841     'type'       => 'checkbox',
842   },
843
844   {
845     'key'         => 'exclude_ip_addr',
846     'section'     => '',
847     'description' => 'Exclude these from the list of available broadband service IP addresses. (One per line)',
848     'type'        => 'textarea',
849   },
850   
851   {
852     'key'         => 'auto_router',
853     'section'     => '',
854     'description' => 'Automatically choose the correct router/block based on supplied ip address when possible while provisioning broadband services',
855     'type'        => 'checkbox',
856   },
857   
858   {
859     'key'         => 'hidecancelledpackages',
860     'section'     => 'UI',
861     'description' => 'Prevent cancelled packages from showing up in listings (though they will still be in the database)',
862     'type'        => 'checkbox',
863   },
864
865   {
866     'key'         => 'hidecancelledcustomers',
867     'section'     => 'UI',
868     'description' => 'Prevent customers with only cancelled packages from showing up in listings (though they will still be in the database)',
869     'type'        => 'checkbox',
870   },
871
872   {
873     'key'         => 'home',
874     'section'     => 'shell',
875     'description' => 'For new users, prefixed to username to create a directory name.  Should have a leading but not a trailing slash.',
876     'type'        => 'text',
877   },
878
879   {
880     'key'         => 'invoice_from',
881     'section'     => 'required',
882     'description' => 'Return address on email invoices',
883     'type'        => 'text',
884     'per_agent'   => 1,
885   },
886
887   {
888     'key'         => 'invoice_subject',
889     'section'     => 'billing',
890     'description' => 'Subject: header on email invoices.  Defaults to "Invoice".  The following substitutions are available: $name, $name_short, $invoice_number, and $invoice_date.',
891     'type'        => 'text',
892     'per_agent'   => 1,
893   },
894
895   {
896     'key'         => 'invoice_usesummary',
897     'section'     => 'billing',
898     'description' => 'Indicates that html and latex invoices should be in summary style and make use of invoice_latexsummary.',
899     'type'        => 'checkbox',
900   },
901
902   {
903     'key'         => 'invoice_template',
904     'section'     => 'billing',
905     '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:1.7:Documentation:Administration#Plaintext_invoice_templates">billing documentation</a> for details.',
906     'type'        => 'textarea',
907   },
908
909   {
910     'key'         => 'invoice_html',
911     'section'     => 'billing',
912     'description' => 'Optional HTML template for invoices.  See the <a href="http://www.freeside.biz/mediawiki/index.php/Freeside:1.7:Documentation:Administration#HTML_invoice_templates">billing documentation</a> for details.',
913
914     'type'        => 'textarea',
915   },
916
917   {
918     'key'         => 'invoice_htmlnotes',
919     'section'     => 'billing',
920     'description' => 'Notes section for HTML invoices.  Defaults to the same data in invoice_latexnotes if not specified.',
921     'type'        => 'textarea',
922     'per_agent'   => 1,
923   },
924
925   {
926     'key'         => 'invoice_htmlfooter',
927     'section'     => 'billing',
928     'description' => 'Footer for HTML invoices.  Defaults to the same data in invoice_latexfooter if not specified.',
929     'type'        => 'textarea',
930     'per_agent'   => 1,
931   },
932
933   {
934     'key'         => 'invoice_htmlsummary',
935     'section'     => 'billing',
936     'description' => 'Summary initial page for HTML invoices.',
937     'type'        => 'textarea',
938     'per_agent'   => 1,
939   },
940
941   {
942     'key'         => 'invoice_htmlreturnaddress',
943     'section'     => 'billing',
944     'description' => 'Return address for HTML invoices.  Defaults to the same data in invoice_latexreturnaddress if not specified.',
945     'type'        => 'textarea',
946   },
947
948   {
949     'key'         => 'invoice_latex',
950     'section'     => 'billing',
951     'description' => 'Optional LaTeX template for typeset PostScript invoices.  See the <a href="http://www.freeside.biz/mediawiki/index.php/Freeside:1.7:Documentation:Administration#Typeset_.28LaTeX.29_invoice_templates">billing documentation</a> for details.',
952     'type'        => 'textarea',
953   },
954
955   {
956     'key'         => 'invoice_latexnotes',
957     'section'     => 'billing',
958     'description' => 'Notes section for LaTeX typeset PostScript invoices.',
959     'type'        => 'textarea',
960     'per_agent'   => 1,
961   },
962
963   {
964     'key'         => 'invoice_latexfooter',
965     'section'     => 'billing',
966     'description' => 'Footer for LaTeX typeset PostScript invoices.',
967     'type'        => 'textarea',
968     'per_agent'   => 1,
969   },
970
971   {
972     'key'         => 'invoice_latexsummary',
973     'section'     => 'billing',
974     'description' => 'Summary initial page for LaTeX typeset PostScript invoices.',
975     'type'        => 'textarea',
976     'per_agent'   => 1,
977   },
978
979   {
980     'key'         => 'invoice_latexcoupon',
981     'section'     => 'billing',
982     'description' => 'Remittance coupon for LaTeX typeset PostScript invoices.',
983     'type'        => 'textarea',
984     'per_agent'   => 1,
985   },
986
987   {
988     'key'         => 'invoice_latexreturnaddress',
989     'section'     => 'billing',
990     'description' => 'Return address for LaTeX typeset PostScript invoices.',
991     'type'        => 'textarea',
992   },
993
994   {
995     'key'         => 'invoice_latexsmallfooter',
996     'section'     => 'billing',
997     'description' => 'Optional small footer for multi-page LaTeX typeset PostScript invoices.',
998     'type'        => 'textarea',
999     'per_agent'   => 1,
1000   },
1001
1002   {
1003     'key'         => 'invoice_email_pdf',
1004     'section'     => 'billing',
1005     '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.',
1006     'type'        => 'checkbox'
1007   },
1008
1009   {
1010     'key'         => 'invoice_email_pdf_note',
1011     'section'     => 'billing',
1012     'description' => 'If defined, this text will replace the default plain text invoice as the body of emailed PDF invoices.',
1013     'type'        => 'textarea'
1014   },
1015
1016
1017   { 
1018     'key'         => 'invoice_default_terms',
1019     'section'     => 'billing',
1020     'description' => 'Optional default invoice term, used to calculate a due date printed on invoices.',
1021     'type'        => 'select',
1022     'select_enum' => [ '', 'Payable upon receipt', 'Net 0', 'Net 10', 'Net 15', 'Net 20', 'Net 30', 'Net 45', 'Net 60' ],
1023   },
1024
1025   { 
1026     'key'         => 'invoice_sections',
1027     'section'     => 'billing',
1028     'description' => 'Split invoice into sections and label according to package category when enabled.',
1029     'type'        => 'checkbox',
1030   },
1031
1032   {
1033     'key'         => 'finance_pkgclass',
1034     'section'     => 'billing',
1035     'description' => 'The package class for finance charges',
1036     'type'        => 'select-pkg_class',
1037   },
1038
1039   { 
1040     'key'         => 'separate_usage',
1041     'section'     => 'billing',
1042     'description' => 'Split the rated call usage into a separate line from the recurring charges.',
1043     'type'        => 'checkbox',
1044   },
1045
1046   {
1047     'key'         => 'invoice_send_receipts',
1048     'section'     => 'deprecated',
1049     'description' => '<b>DEPRECATED</b>, this used to send an invoice copy on payments and credits.  See the payment_receipt_email and XXXX instead.',
1050     'type'        => 'checkbox',
1051   },
1052
1053   {
1054     'key'         => 'payment_receipt_email',
1055     'section'     => 'billing',
1056     'description' => 'Template file for payment receipts.  Payment receipts are sent to the customer email invoice destination(s) when a payment is received.  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>$date</code> <li><code>$name</code> <li><code>$paynum</code> - Freeside payment number <li><code>$paid</code> - Amount of payment <li><code>$payby</code> - Payment type (Card, Check, Electronic check, etc.) <li><code>$payinfo</code> - Masked credit card number or check number <li><code>$balance</code> - New balance<li><code>$pkg</code> - Package (requires payment_receipt-trigger set to "when payment is applied".)</ul>',
1057     'type'        => [qw( checkbox textarea )],
1058   },
1059
1060   {
1061     'key'         => 'payment_receipt-trigger',
1062     'section'     => 'billing',
1063     'description' => 'When payment receipts are triggered.  Defaults to when payment is made.',
1064     'type'        => 'select',
1065     'select_hash' => [
1066                        'cust_pay'          => 'When payment is made.',
1067                        'cust_bill_pay_pkg' => 'When payment is applied.',
1068                      ],
1069   },
1070
1071   {
1072     'key'         => 'lpr',
1073     'section'     => 'required',
1074     'description' => 'Print command for paper invoices, for example `lpr -h\'',
1075     'type'        => 'text',
1076   },
1077
1078   {
1079     'key'         => 'lpr-postscript_prefix',
1080     'section'     => 'billing',
1081     'description' => 'Raw printer commands prepended to the beginning of postscript print jobs (evaluated as a double-quoted perl string - backslash escapes are available)',
1082     'type'        => 'text',
1083   },
1084
1085   {
1086     'key'         => 'lpr-postscript_suffix',
1087     'section'     => 'billing',
1088     'description' => 'Raw printer commands added to the end of postscript print jobs (evaluated as a double-quoted perl string - backslash escapes are available)',
1089     'type'        => 'text',
1090   },
1091
1092   {
1093     'key'         => 'money_char',
1094     'section'     => '',
1095     'description' => 'Currency symbol - defaults to `$\'',
1096     'type'        => 'text',
1097   },
1098
1099   {
1100     'key'         => 'defaultrecords',
1101     'section'     => 'BIND',
1102     'description' => 'DNS entries to add automatically when creating a domain',
1103     'type'        => 'editlist',
1104     'editlist_parts' => [ { type=>'text' },
1105                           { type=>'immutable', value=>'IN' },
1106                           { type=>'select',
1107                             select_enum=>{ map { $_=>$_ } qw(A CNAME MX NS TXT)} },
1108                           { type=> 'text' }, ],
1109   },
1110
1111   {
1112     'key'         => 'passwordmin',
1113     'section'     => 'password',
1114     'description' => 'Minimum password length (default 6)',
1115     'type'        => 'text',
1116   },
1117
1118   {
1119     'key'         => 'passwordmax',
1120     'section'     => 'password',
1121     'description' => 'Maximum password length (default 8) (don\'t set this over 12 if you need to import or export crypt() passwords)',
1122     'type'        => 'text',
1123   },
1124
1125   {
1126     'key' => 'password-noampersand',
1127     'section' => 'password',
1128     'description' => 'Disallow ampersands in passwords',
1129     'type' => 'checkbox',
1130   },
1131
1132   {
1133     'key' => 'password-noexclamation',
1134     'section' => 'password',
1135     'description' => 'Disallow exclamations in passwords (Not setting this could break old text Livingston or Cistron Radius servers)',
1136     'type' => 'checkbox',
1137   },
1138
1139   {
1140     'key'         => 'referraldefault',
1141     'section'     => 'UI',
1142     'description' => 'Default referral, specified by refnum',
1143     'type'        => 'text',
1144   },
1145
1146 #  {
1147 #    'key'         => 'registries',
1148 #    'section'     => 'required',
1149 #    'description' => 'Directory which contains domain registry information.  Each registry is a directory.',
1150 #  },
1151
1152   {
1153     'key'         => 'report_template',
1154     'section'     => 'deprecated',
1155     'description' => 'Deprecated template file for reports.',
1156     'type'        => 'textarea',
1157   },
1158
1159   {
1160     'key'         => 'maxsearchrecordsperpage',
1161     'section'     => 'UI',
1162     'description' => 'If set, number of search records to return per page.',
1163     'type'        => 'text',
1164   },
1165
1166   {
1167     'key'         => 'session-start',
1168     'section'     => 'session',
1169     '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.',
1170     'type'        => 'text',
1171   },
1172
1173   {
1174     'key'         => 'session-stop',
1175     'section'     => 'session',
1176     '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.',
1177     'type'        => 'text',
1178   },
1179
1180   {
1181     'key'         => 'shells',
1182     'section'     => 'shell',
1183     '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.',
1184     'type'        => 'textarea',
1185   },
1186
1187   {
1188     'key'         => 'showpasswords',
1189     'section'     => 'UI',
1190     'description' => 'Display unencrypted user passwords in the backend (employee) web interface',
1191     'type'        => 'checkbox',
1192   },
1193
1194   {
1195     'key'         => 'signupurl',
1196     'section'     => 'UI',
1197     '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:1.7: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',
1198     'type'        => 'text',
1199   },
1200
1201   {
1202     'key'         => 'smtpmachine',
1203     'section'     => 'required',
1204     'description' => 'SMTP relay for Freeside\'s outgoing mail',
1205     'type'        => 'text',
1206   },
1207
1208   {
1209     'key'         => 'soadefaultttl',
1210     'section'     => 'BIND',
1211     'description' => 'SOA default TTL for new domains.',
1212     'type'        => 'text',
1213   },
1214
1215   {
1216     'key'         => 'soaemail',
1217     'section'     => 'BIND',
1218     'description' => 'SOA email for new domains, in BIND form (`.\' instead of `@\'), with trailing `.\'',
1219     'type'        => 'text',
1220   },
1221
1222   {
1223     'key'         => 'soaexpire',
1224     'section'     => 'BIND',
1225     'description' => 'SOA expire for new domains',
1226     'type'        => 'text',
1227   },
1228
1229   {
1230     'key'         => 'soamachine',
1231     'section'     => 'BIND',
1232     'description' => 'SOA machine for new domains, with trailing `.\'',
1233     'type'        => 'text',
1234   },
1235
1236   {
1237     'key'         => 'soarefresh',
1238     'section'     => 'BIND',
1239     'description' => 'SOA refresh for new domains',
1240     'type'        => 'text',
1241   },
1242
1243   {
1244     'key'         => 'soaretry',
1245     'section'     => 'BIND',
1246     'description' => 'SOA retry for new domains',
1247     'type'        => 'text',
1248   },
1249
1250   {
1251     'key'         => 'statedefault',
1252     'section'     => 'UI',
1253     'description' => 'Default state or province (if not supplied, the default is `CA\')',
1254     'type'        => 'text',
1255   },
1256
1257   {
1258     'key'         => 'unsuspendauto',
1259     'section'     => 'billing',
1260     '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',
1261     'type'        => 'checkbox',
1262   },
1263
1264   {
1265     'key'         => 'unsuspend-always_adjust_next_bill_date',
1266     'section'     => 'billing',
1267     '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.',
1268     'type'        => 'checkbox',
1269   },
1270
1271   {
1272     'key'         => 'usernamemin',
1273     'section'     => 'username',
1274     'description' => 'Minimum username length (default 2)',
1275     'type'        => 'text',
1276   },
1277
1278   {
1279     'key'         => 'usernamemax',
1280     'section'     => 'username',
1281     'description' => 'Maximum username length',
1282     'type'        => 'text',
1283   },
1284
1285   {
1286     'key'         => 'username-ampersand',
1287     'section'     => 'username',
1288     '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.',
1289     'type'        => 'checkbox',
1290   },
1291
1292   {
1293     'key'         => 'username-letter',
1294     'section'     => 'username',
1295     'description' => 'Usernames must contain at least one letter',
1296     'type'        => 'checkbox',
1297     'per_agent'   => 1,
1298   },
1299
1300   {
1301     'key'         => 'username-letterfirst',
1302     'section'     => 'username',
1303     'description' => 'Usernames must start with a letter',
1304     'type'        => 'checkbox',
1305   },
1306
1307   {
1308     'key'         => 'username-noperiod',
1309     'section'     => 'username',
1310     'description' => 'Disallow periods in usernames',
1311     'type'        => 'checkbox',
1312   },
1313
1314   {
1315     'key'         => 'username-nounderscore',
1316     'section'     => 'username',
1317     'description' => 'Disallow underscores in usernames',
1318     'type'        => 'checkbox',
1319   },
1320
1321   {
1322     'key'         => 'username-nodash',
1323     'section'     => 'username',
1324     'description' => 'Disallow dashes in usernames',
1325     'type'        => 'checkbox',
1326   },
1327
1328   {
1329     'key'         => 'username-uppercase',
1330     'section'     => 'username',
1331     'description' => 'Allow uppercase characters in usernames.  Not recommended for use with FreeRADIUS with MySQL backend, which is case-insensitive by default.',
1332     'type'        => 'checkbox',
1333   },
1334
1335   { 
1336     'key'         => 'username-percent',
1337     'section'     => 'username',
1338     'description' => 'Allow the percent character (%) in usernames.',
1339     'type'        => 'checkbox',
1340   },
1341
1342   { 
1343     'key'         => 'username-colon',
1344     'section'     => 'username',
1345     'description' => 'Allow the colon character (:) in usernames.',
1346     'type'        => 'checkbox',
1347   },
1348
1349   {
1350     'key'         => 'safe-part_bill_event',
1351     'section'     => 'UI',
1352     'description' => 'Validates invoice event expressions against a preset list.  Useful for webdemos, annoying to powerusers.',
1353     'type'        => 'checkbox',
1354   },
1355
1356   {
1357     'key'         => 'show_ss',
1358     'section'     => 'UI',
1359     'description' => 'Turns on display/collection of social security numbers in the web interface.  Sometimes required by electronic check (ACH) processors.',
1360     'type'        => 'checkbox',
1361   },
1362
1363   {
1364     'key'         => 'show_stateid',
1365     'section'     => 'UI',
1366     'description' => "Turns on display/collection of driver's license/state issued id numbers in the web interface.  Sometimes required by electronic check (ACH) processors.",
1367     'type'        => 'checkbox',
1368   },
1369
1370   {
1371     'key'         => 'show_bankstate',
1372     'section'     => 'UI',
1373     'description' => "Turns on display/collection of state for bank accounts in the web interface.  Sometimes required by electronic check (ACH) processors.",
1374     'type'        => 'checkbox',
1375   },
1376
1377   { 
1378     'key'         => 'agent_defaultpkg',
1379     'section'     => 'UI',
1380     'description' => 'Setting this option will cause new packages to be available to all agent types by default.',
1381     'type'        => 'checkbox',
1382   },
1383
1384   {
1385     'key'         => 'legacy_link',
1386     'section'     => 'UI',
1387     'description' => 'Display options in the web interface to link legacy pre-Freeside services.',
1388     'type'        => 'checkbox',
1389   },
1390
1391   {
1392     'key'         => 'legacy_link-steal',
1393     'section'     => 'UI',
1394     'description' => 'Allow "stealing" an already-audited service from one customer (or package) to another using the link function.',
1395     'type'        => 'checkbox',
1396   },
1397
1398   {
1399     'key'         => 'queue_dangerous_controls',
1400     'section'     => 'UI',
1401     '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.',
1402     'type'        => 'checkbox',
1403   },
1404
1405   {
1406     'key'         => 'security_phrase',
1407     'section'     => 'password',
1408     'description' => 'Enable the tracking of a "security phrase" with each account.  Not recommended, as it is vulnerable to social engineering.',
1409     'type'        => 'checkbox',
1410   },
1411
1412   {
1413     'key'         => 'locale',
1414     'section'     => 'UI',
1415     'description' => 'Message locale',
1416     'type'        => 'select',
1417     'select_enum' => [ qw(en_US) ],
1418   },
1419
1420   {
1421     'key'         => 'signup_server-payby',
1422     'section'     => '',
1423     'description' => 'Acceptable payment types for the signup server',
1424     'type'        => 'selectmultiple',
1425     'select_enum' => [ qw(CARD DCRD CHEK DCHK LECB PREPAY BILL COMP) ],
1426   },
1427
1428   {
1429     'key'         => 'signup_server-default_agentnum',
1430     'section'     => '',
1431     'description' => 'Default agent for the signup server',
1432     'type'        => 'select-sub',
1433     'options_sub' => sub { require FS::Record;
1434                            require FS::agent;
1435                            map { $_->agentnum => $_->agent }
1436                                FS::Record::qsearch('agent', { disabled=>'' } );
1437                          },
1438     'option_sub'  => sub { require FS::Record;
1439                            require FS::agent;
1440                            my $agent = FS::Record::qsearchs(
1441                              'agent', { 'agentnum'=>shift }
1442                            );
1443                            $agent ? $agent->agent : '';
1444                          },
1445   },
1446
1447   {
1448     'key'         => 'signup_server-default_refnum',
1449     'section'     => '',
1450     'description' => 'Default advertising source for the signup server',
1451     'type'        => 'select-sub',
1452     'options_sub' => sub { require FS::Record;
1453                            require FS::part_referral;
1454                            map { $_->refnum => $_->referral }
1455                                FS::Record::qsearch( 'part_referral', 
1456                                                     { 'disabled' => '' }
1457                                                   );
1458                          },
1459     'option_sub'  => sub { require FS::Record;
1460                            require FS::part_referral;
1461                            my $part_referral = FS::Record::qsearchs(
1462                              'part_referral', { 'refnum'=>shift } );
1463                            $part_referral ? $part_referral->referral : '';
1464                          },
1465   },
1466
1467   {
1468     'key'         => 'signup_server-default_pkgpart',
1469     'section'     => '',
1470     'description' => 'Default package for the signup server',
1471     'type'        => 'select-part_pkg',
1472   },
1473
1474   {
1475     'key'         => 'signup_server-default_svcpart',
1476     'section'     => '',
1477     'description' => 'Default service definition for the signup server - only necessary for services that trigger special provisioning widgets (such as DID provisioning).',
1478     'type'        => 'select-part_svc',
1479   },
1480
1481   {
1482     'key'         => 'signup_server-mac_addr_svcparts',
1483     'section'     => '',
1484     'description' => 'Service definitions which can receive mac addresses (current mapped to username for svc_acct).',
1485     'type'        => 'select-part_svc',
1486     'multiple'    => 1,
1487   },
1488
1489   {
1490     'key'         => 'signup_server-nomadix',
1491     'section'     => '',
1492     'description' => 'Signup page Nomadix integration',
1493     'type'        => 'checkbox',
1494   },
1495
1496   {
1497     'key'         => 'signup_server-service',
1498     'section'     => '',
1499     'description' => 'Service for the signup server - "Account (svc_acct)" is the default setting, or "Phone number (svc_phone)" for ITSP signup',
1500     'type'        => 'select',
1501     'select_hash' => [
1502                        'svc_acct'  => 'Account (svc_acct)',
1503                        'svc_phone' => 'Phone number (svc_phone)',
1504                      ],
1505   },
1506
1507   {
1508     'key'         => 'selfservice_server-base_url',
1509     'section'     => '',
1510     '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.',
1511     'type'        => 'text',
1512   },
1513
1514   {
1515     'key'         => 'show-msgcat-codes',
1516     'section'     => 'UI',
1517     'description' => 'Show msgcat codes in error messages.  Turn this option on before reporting errors to the mailing list.',
1518     'type'        => 'checkbox',
1519   },
1520
1521   {
1522     'key'         => 'signup_server-realtime',
1523     'section'     => '',
1524     'description' => 'Run billing for signup server signups immediately, and do not provision accounts which subsequently have a balance.',
1525     'type'        => 'checkbox',
1526   },
1527   {
1528     'key'         => 'signup_server-classnum2',
1529     'section'     => '',
1530     'description' => 'Package Class for first optional purchase',
1531     'type'        => 'select-pkg_class',
1532   },
1533
1534   {
1535     'key'         => 'signup_server-classnum3',
1536     'section'     => '',
1537     'description' => 'Package Class for second optional purchase',
1538     'type'        => 'select-pkg_class',
1539   },
1540
1541   {
1542     'key'         => 'backend-realtime',
1543     'section'     => '',
1544     'description' => 'Run billing for backend signups immediately.',
1545     'type'        => 'checkbox',
1546   },
1547
1548   {
1549     'key'         => 'declinetemplate',
1550     'section'     => 'billing',
1551     'description' => 'Template file for credit card and electronic check decline emails.',
1552     'type'        => 'textarea',
1553   },
1554
1555   {
1556     'key'         => 'emaildecline',
1557     'section'     => 'billing',
1558     'description' => 'Enable emailing of credit card and electronic check decline notices.',
1559     'type'        => 'checkbox',
1560   },
1561
1562   {
1563     'key'         => 'emaildecline-exclude',
1564     'section'     => 'billing',
1565     'description' => 'List of error messages that should not trigger email decline notices, one per line.',
1566     'type'        => 'textarea',
1567   },
1568
1569   {
1570     'key'         => 'cancelmessage',
1571     'section'     => 'billing',
1572     'description' => 'Template file for cancellation emails.',
1573     'type'        => 'textarea',
1574   },
1575
1576   {
1577     'key'         => 'cancelsubject',
1578     'section'     => 'billing',
1579     'description' => 'Subject line for cancellation emails.',
1580     'type'        => 'text',
1581   },
1582
1583   {
1584     'key'         => 'emailcancel',
1585     'section'     => 'billing',
1586     'description' => 'Enable emailing of cancellation notices.  Make sure to fill in the cancelmessage and cancelsubject configuration values as well.',
1587     'type'        => 'checkbox',
1588   },
1589
1590   {
1591     'key'         => 'bill_usage_on_cancel',
1592     'section'     => 'billing',
1593     '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.',
1594     'type'        => 'checkbox',
1595   },
1596
1597   {
1598     'key'         => 'require_cardname',
1599     'section'     => 'billing',
1600     'description' => 'Require an "Exact name on card" to be entered explicitly; don\'t default to using the first and last name.',
1601     'type'        => 'checkbox',
1602   },
1603
1604   {
1605     'key'         => 'enable_taxclasses',
1606     'section'     => 'billing',
1607     'description' => 'Enable per-package tax classes',
1608     'type'        => 'checkbox',
1609   },
1610
1611   {
1612     'key'         => 'require_taxclasses',
1613     'section'     => 'billing',
1614     'description' => 'Require a taxclass to be entered for every package',
1615     'type'        => 'checkbox',
1616   },
1617
1618   {
1619     'key'         => 'enable_taxproducts',
1620     'section'     => 'billing',
1621     'description' => 'Enable per-package mapping to vendor tax data from CCH or elsewhere.',
1622     'type'        => 'checkbox',
1623   },
1624
1625   {
1626     'key'         => 'taxdatadirectdownload',
1627     'section'     => 'billing',  #well
1628     'description' => 'Enable downloading tax data directly from the vendor site',
1629     'type'        => 'checkbox',
1630   },
1631
1632   {
1633     'key'         => 'ignore_incalculable_taxes',
1634     'section'     => 'billing',
1635     'description' => 'Prefer to invoice without tax over not billing at all',
1636     'type'        => 'checkbox',
1637   },
1638
1639   {
1640     'key'         => 'welcome_email',
1641     'section'     => '',
1642     '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.  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></ul>',
1643     'type'        => 'textarea',
1644     'per_agent'   => 1,
1645   },
1646
1647   {
1648     'key'         => 'welcome_email-from',
1649     'section'     => '',
1650     'description' => 'From: address header for welcome email',
1651     'type'        => 'text',
1652     'per_agent'   => 1,
1653   },
1654
1655   {
1656     'key'         => 'welcome_email-subject',
1657     'section'     => '',
1658     'description' => 'Subject: header for welcome email',
1659     'type'        => 'text',
1660     'per_agent'   => 1,
1661   },
1662   
1663   {
1664     'key'         => 'welcome_email-mimetype',
1665     'section'     => '',
1666     'description' => 'MIME type for welcome email',
1667     'type'        => 'select',
1668     'select_enum' => [ 'text/plain', 'text/html' ],
1669     'per_agent'   => 1,
1670   },
1671
1672   {
1673     'key'         => 'welcome_letter',
1674     'section'     => '',
1675     '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>',
1676     'type'        => 'textarea',
1677   },
1678
1679   {
1680     'key'         => 'warning_email',
1681     'section'     => '',
1682     '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>',
1683     'type'        => 'textarea',
1684   },
1685
1686   {
1687     'key'         => 'warning_email-from',
1688     'section'     => '',
1689     'description' => 'From: address header for warning email',
1690     'type'        => 'text',
1691   },
1692
1693   {
1694     'key'         => 'warning_email-cc',
1695     'section'     => '',
1696     'description' => 'Additional recipient(s) (comma separated) for warning email when remaining usage reaches zero.',
1697     'type'        => 'text',
1698   },
1699
1700   {
1701     'key'         => 'warning_email-subject',
1702     'section'     => '',
1703     'description' => 'Subject: header for warning email',
1704     'type'        => 'text',
1705   },
1706   
1707   {
1708     'key'         => 'warning_email-mimetype',
1709     'section'     => '',
1710     'description' => 'MIME type for warning email',
1711     'type'        => 'select',
1712     'select_enum' => [ 'text/plain', 'text/html' ],
1713   },
1714
1715   {
1716     'key'         => 'payby',
1717     'section'     => 'billing',
1718     'description' => 'Available payment types.',
1719     'type'        => 'selectmultiple',
1720     'select_enum' => [ qw(CARD DCRD CHEK DCHK LECB BILL CASH WEST MCRD COMP) ],
1721   },
1722
1723   {
1724     'key'         => 'payby-default',
1725     'section'     => 'UI',
1726     'description' => 'Default payment type.  HIDE disables display of billing information and sets customers to BILL.',
1727     'type'        => 'select',
1728     'select_enum' => [ '', qw(CARD DCRD CHEK DCHK LECB BILL CASH WEST MCRD COMP HIDE) ],
1729   },
1730
1731   {
1732     'key'         => 'paymentforcedtobatch',
1733     'section'     => 'deprecated',
1734     '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.',
1735     'type'        => 'checkbox',
1736   },
1737
1738   {
1739     'key'         => 'svc_acct-notes',
1740     'section'     => 'UI',
1741     'description' => 'Extra HTML to be displayed on the Account View screen.',
1742     'type'        => 'textarea',
1743   },
1744
1745   {
1746     'key'         => 'radius-password',
1747     'section'     => '',
1748     'description' => 'RADIUS attribute for plain-text passwords.',
1749     'type'        => 'select',
1750     'select_enum' => [ 'Password', 'User-Password' ],
1751   },
1752
1753   {
1754     'key'         => 'radius-ip',
1755     'section'     => '',
1756     'description' => 'RADIUS attribute for IP addresses.',
1757     'type'        => 'select',
1758     'select_enum' => [ 'Framed-IP-Address', 'Framed-Address' ],
1759   },
1760
1761   #http://dev.coova.org/svn/coova-chilli/doc/dictionary.chillispot
1762   {
1763     'key'         => 'radius-chillispot-max',
1764     'section'     => '',
1765     'description' => 'Enable ChilliSpot (and CoovaChilli) Max attributes, specifically ChilliSpot-Max-{Input,Output,Total}-{Octets,Gigawords}.',
1766     'type'        => 'checkbox',
1767   },
1768
1769   {
1770     'key'         => 'svc_acct-alldomains',
1771     'section'     => '',
1772     '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.',
1773     'type'        => 'checkbox',
1774   },
1775
1776   {
1777     'key'         => 'dump-scpdest',
1778     'section'     => '',
1779     'description' => 'destination for scp database dumps: user@host:/path',
1780     'type'        => 'text',
1781   },
1782
1783   {
1784     'key'         => 'dump-pgpid',
1785     'section'     => '',
1786     '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.",
1787     'type'        => 'text',
1788   },
1789
1790   {
1791     'key'         => 'users-allow_comp',
1792     'section'     => 'deprecated',
1793     '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.',
1794     'type'        => 'textarea',
1795   },
1796
1797   {
1798     'key'         => 'credit_card-recurring_billing_flag',
1799     'section'     => 'billing',
1800     '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. ',
1801     'type'        => 'select',
1802     'select_hash' => [
1803                        'actual_oncard' => 'Default/classic behavior: set the flag if a customer has actual previous charges on the card.',
1804                        'transaction_is_recur' => 'Set the flag if the transaction itself is recurring, irregardless of previous charges on the card.',
1805                      ],
1806   },
1807
1808   {
1809     'key'         => 'credit_card-recurring_billing_acct_code',
1810     'section'     => 'billing',
1811     'description' => 'When the "recurring billing" flag is set, also set the "acct_code" to "rebill".  Useful for reporting purposes with supported gateways (PlugNPay, others?)',
1812     'type'        => 'checkbox',
1813   },
1814
1815   {
1816     'key'         => 'cvv-save',
1817     'section'     => 'billing',
1818     '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.',
1819     'type'        => 'selectmultiple',
1820     'select_enum' => \@card_types,
1821   },
1822
1823   {
1824     'key'         => 'manual_process-pkgpart',
1825     'section'     => 'billing',
1826     'description' => 'Package to add to each manual credit card and ACH payments entered from the backend.  Enabling this option may be in violation of your merchant agreement(s), so please check them carefully before enabling this option.',
1827     'type'        => 'select-part_pkg',
1828   },
1829
1830   {
1831     'key'         => 'manual_process-display',
1832     'section'     => 'billing',
1833     'description' => 'When using manual_process-pkgpart, add the fee to the amount entered (default), or subtract the fee from the amount entered.',
1834     'type'        => 'select',
1835     'select_hash' => [
1836                        'add'      => 'Add fee to amount entered',
1837                        'subtract' => 'Subtract fee from amount entered',
1838                      ],
1839   },
1840
1841   {
1842     'key'         => 'manual_process-skip_first',
1843     'section'     => 'billing',
1844     'description' => "When using manual_process-pkgpart, omit the fee if it is the customer's first payment.",
1845     'type'        => 'checkbox',
1846   },
1847
1848   {
1849     'key'         => 'allow_negative_charges',
1850     'section'     => 'billing',
1851     'description' => 'Allow negative charges.  Normally not used unless importing data from a legacy system that requires this.',
1852     'type'        => 'checkbox',
1853   },
1854   {
1855       'key'         => 'auto_unset_catchall',
1856       'section'     => '',
1857       '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.',
1858       'type'        => 'checkbox',
1859   },
1860
1861   {
1862     'key'         => 'system_usernames',
1863     'section'     => 'username',
1864     '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.',
1865     'type'        => 'textarea',
1866   },
1867
1868   {
1869     'key'         => 'cust_pkg-change_svcpart',
1870     'section'     => '',
1871     'description' => "When changing packages, move services even if svcparts don't match between old and new pacakge definitions.",
1872     'type'        => 'checkbox',
1873   },
1874
1875   {
1876     'key'         => 'disable_autoreverse',
1877     'section'     => 'BIND',
1878     'description' => 'Disable automatic synchronization of reverse-ARPA entries.',
1879     'type'        => 'checkbox',
1880   },
1881
1882   {
1883     'key'         => 'svc_www-enable_subdomains',
1884     'section'     => '',
1885     'description' => 'Enable selection of specific subdomains for virtual host creation.',
1886     'type'        => 'checkbox',
1887   },
1888
1889   {
1890     'key'         => 'svc_www-usersvc_svcpart',
1891     'section'     => '',
1892     'description' => 'Allowable service definition svcparts for virtual hosts, one per line.',
1893     'type'        => 'select-part_svc',
1894     'multiple'    => 1,
1895   },
1896
1897   {
1898     'key'         => 'selfservice_server-primary_only',
1899     'section'     => '',
1900     'description' => 'Only allow primary accounts to access self-service functionality.',
1901     'type'        => 'checkbox',
1902   },
1903
1904   {
1905     'key'         => 'selfservice_server-phone_login',
1906     'section'     => '',
1907     'description' => 'Allow login to self-service with phone number and PIN.',
1908     'type'        => 'checkbox',
1909   },
1910
1911   {
1912     'key'         => 'selfservice_server-single_domain',
1913     'section'     => '',
1914     'description' => 'If specified, only use this one domain for self-service access.',
1915     'type'        => 'text',
1916   },
1917
1918   {
1919     'key'         => 'card_refund-days',
1920     'section'     => 'billing',
1921     'description' => 'After a payment, the number of days a refund link will be available for that payment.  Defaults to 120.',
1922     'type'        => 'text',
1923   },
1924
1925   {
1926     'key'         => 'agent-showpasswords',
1927     'section'     => '',
1928     'description' => 'Display unencrypted user passwords in the agent (reseller) interface',
1929     'type'        => 'checkbox',
1930   },
1931
1932   {
1933     'key'         => 'global_unique-username',
1934     'section'     => 'username',
1935     '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.',
1936     'type'        => 'select',
1937     'select_enum' => [ 'none', 'username', 'username@domain', 'disabled' ],
1938   },
1939
1940   {
1941     'key'         => 'global_unique-phonenum',
1942     'section'     => '',
1943     '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.',
1944     'type'        => 'select',
1945     'select_enum' => [ 'none', 'countrycode+phonenum', 'disabled' ],
1946   },
1947
1948   {
1949     'key'         => 'svc_external-skip_manual',
1950     'section'     => 'UI',
1951     '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).',
1952     'type'        => 'checkbox',
1953   },
1954
1955   {
1956     'key'         => 'svc_external-display_type',
1957     'section'     => 'UI',
1958     'description' => 'Select a specific svc_external type to enable some UI changes specific to that type (i.e. artera_turbo).',
1959     'type'        => 'select',
1960     'select_enum' => [ 'generic', 'artera_turbo', ],
1961   },
1962
1963   {
1964     'key'         => 'ticket_system',
1965     'section'     => '',
1966     '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:1.7:Documentation:RT_Installation">integrated ticketing installation instructions</a>).   <b>RT_External</b> accesses an external RT installation in a separate database (local or remote).',
1967     'type'        => 'select',
1968     #'select_enum' => [ '', qw(RT_Internal RT_Libs RT_External) ],
1969     'select_enum' => [ '', qw(RT_Internal RT_External) ],
1970   },
1971
1972   {
1973     'key'         => 'ticket_system-default_queueid',
1974     'section'     => '',
1975     'description' => 'Default queue used when creating new customer tickets.',
1976     'type'        => 'select-sub',
1977     'options_sub' => sub {
1978                            my $conf = new FS::Conf;
1979                            if ( $conf->config('ticket_system') ) {
1980                              eval "use FS::TicketSystem;";
1981                              die $@ if $@;
1982                              FS::TicketSystem->queues();
1983                            } else {
1984                              ();
1985                            }
1986                          },
1987     'option_sub'  => sub { 
1988                            my $conf = new FS::Conf;
1989                            if ( $conf->config('ticket_system') ) {
1990                              eval "use FS::TicketSystem;";
1991                              die $@ if $@;
1992                              FS::TicketSystem->queue(shift);
1993                            } else {
1994                              '';
1995                            }
1996                          },
1997   },
1998
1999   {
2000     'key'         => 'ticket_system-priority_reverse',
2001     'section'     => '',
2002     '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.',
2003     'type'        => 'checkbox',
2004   },
2005
2006   {
2007     'key'         => 'ticket_system-custom_priority_field',
2008     'section'     => '',
2009     'description' => 'Custom field from the ticketing system to use as a custom priority classification.',
2010     'type'        => 'text',
2011   },
2012
2013   {
2014     'key'         => 'ticket_system-custom_priority_field-values',
2015     'section'     => '',
2016     'description' => 'Values for the custom field from the ticketing system to break down and sort customer ticket lists.',
2017     'type'        => 'textarea',
2018   },
2019
2020   {
2021     'key'         => 'ticket_system-custom_priority_field_queue',
2022     'section'     => '',
2023     'description' => 'Ticketing system queue in which the custom field specified in ticket_system-custom_priority_field is located.',
2024     'type'        => 'text',
2025   },
2026
2027   {
2028     'key'         => 'ticket_system-rt_external_datasrc',
2029     'section'     => '',
2030     '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>',
2031     'type'        => 'text',
2032
2033   },
2034
2035   {
2036     'key'         => 'ticket_system-rt_external_url',
2037     'section'     => '',
2038     'description' => 'With external RT integration, the URL for the external RT installation, for example, <code>https://rt.example.com/rt</code>',
2039     'type'        => 'text',
2040   },
2041
2042   {
2043     'key'         => 'company_name',
2044     'section'     => 'required',
2045     'description' => 'Your company name',
2046     'type'        => 'text',
2047     'per_agent'   => 1, #XXX just FS/FS/ClientAPI/Signup.pm
2048   },
2049
2050   {
2051     'key'         => 'company_address',
2052     'section'     => 'required',
2053     'description' => 'Your company address',
2054     'type'        => 'textarea',
2055     'per_agent'   => 1,
2056   },
2057
2058   {
2059     'key'         => 'echeck-void',
2060     'section'     => 'deprecated',
2061     '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',
2062     'type'        => 'checkbox',
2063   },
2064
2065   {
2066     'key'         => 'cc-void',
2067     'section'     => 'deprecated',
2068     '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',
2069     'type'        => 'checkbox',
2070   },
2071
2072   {
2073     'key'         => 'unvoid',
2074     'section'     => 'deprecated',
2075     'description' => '<B>DEPRECATED</B>, now controlled by ACLs.  Used to enable unvoiding of voided payments',
2076     'type'        => 'checkbox',
2077   },
2078
2079   {
2080     'key'         => 'address1-search',
2081     'section'     => 'UI',
2082     'description' => 'Enable the ability to search the address1 field from customer search.',
2083     'type'        => 'checkbox',
2084   },
2085
2086   {
2087     'key'         => 'address2-search',
2088     'section'     => 'UI',
2089     'description' => 'Enable a "Unit" search box which searches the second address field.  Useful for multi-tenant applications.  See also: cust_main-require_address2',
2090     'type'        => 'checkbox',
2091   },
2092
2093   {
2094     'key'         => 'cust_main-require_address2',
2095     'section'     => 'UI',
2096     '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',
2097     'type'        => 'checkbox',
2098   },
2099
2100   {
2101     'key'         => 'agent-ship_address',
2102     'section'     => '',
2103     '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.",
2104     'type'        => 'checkbox',
2105   },
2106
2107   { 'key'         => 'referral_credit',
2108     'section'     => 'deprecated',
2109     '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.",
2110     'type'        => 'checkbox',
2111   },
2112
2113   { 'key'         => 'selfservice_server-cache_module',
2114     'section'     => '',
2115     '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.',
2116     'type'        => 'select',
2117     'select_enum' => [ 'Cache::SharedMemoryCache', 'Cache::FileCache', ], # '_Database' ],
2118   },
2119
2120   {
2121     'key'         => 'hylafax',
2122     'section'     => 'billing',
2123     '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).',
2124     'type'        => [qw( checkbox textarea )],
2125   },
2126
2127   {
2128     'key'         => 'cust_bill-ftpformat',
2129     'section'     => 'billing',
2130     'description' => 'Enable FTP of raw invoice data - format.',
2131     'type'        => 'select',
2132     'select_enum' => [ '', 'default', 'billco', ],
2133   },
2134
2135   {
2136     'key'         => 'cust_bill-ftpserver',
2137     'section'     => 'billing',
2138     'description' => 'Enable FTP of raw invoice data - server.',
2139     'type'        => 'text',
2140   },
2141
2142   {
2143     'key'         => 'cust_bill-ftpusername',
2144     'section'     => 'billing',
2145     'description' => 'Enable FTP of raw invoice data - server.',
2146     'type'        => 'text',
2147   },
2148
2149   {
2150     'key'         => 'cust_bill-ftppassword',
2151     'section'     => 'billing',
2152     'description' => 'Enable FTP of raw invoice data - server.',
2153     'type'        => 'text',
2154   },
2155
2156   {
2157     'key'         => 'cust_bill-ftpdir',
2158     'section'     => 'billing',
2159     'description' => 'Enable FTP of raw invoice data - server.',
2160     'type'        => 'text',
2161   },
2162
2163   {
2164     'key'         => 'cust_bill-spoolformat',
2165     'section'     => 'billing',
2166     'description' => 'Enable spooling of raw invoice data - format.',
2167     'type'        => 'select',
2168     'select_enum' => [ '', 'default', 'billco', ],
2169   },
2170
2171   {
2172     'key'         => 'cust_bill-spoolagent',
2173     'section'     => 'billing',
2174     'description' => 'Enable per-agent spooling of raw invoice data.',
2175     'type'        => 'checkbox',
2176   },
2177
2178   {
2179     'key'         => 'svc_acct-usage_suspend',
2180     'section'     => 'billing',
2181     '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.',
2182     'type'        => 'checkbox',
2183   },
2184
2185   {
2186     'key'         => 'svc_acct-usage_unsuspend',
2187     'section'     => 'billing',
2188     '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.',
2189     'type'        => 'checkbox',
2190   },
2191
2192   {
2193     'key'         => 'svc_acct-usage_threshold',
2194     'section'     => 'billing',
2195     '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.',
2196     'type'        => 'text',
2197   },
2198
2199   {
2200     'key'         => 'cust-fields',
2201     'section'     => 'UI',
2202     'description' => 'Which customer fields to display on reports by default',
2203     'type'        => 'select',
2204     'select_hash' => [ FS::ConfDefaults->cust_fields_avail() ],
2205   },
2206
2207   {
2208     'key'         => 'cust_pkg-display_times',
2209     'section'     => 'UI',
2210     'description' => 'Display full timestamps (not just dates) for customer packages.  Useful if you are doing real-time things like hourly prepaid.',
2211     'type'        => 'checkbox',
2212   },
2213
2214   {
2215     'key'         => 'cust_pkg-always_show_location',
2216     'section'     => 'UI',
2217     'description' => "Always display package locations, even when they're all the default service address.",
2218     'type'        => 'checkbox',
2219   },
2220
2221   {
2222     'key'         => 'svc_acct-edit_uid',
2223     'section'     => 'shell',
2224     'description' => 'Allow UID editing.',
2225     'type'        => 'checkbox',
2226   },
2227
2228   {
2229     'key'         => 'svc_acct-edit_gid',
2230     'section'     => 'shell',
2231     'description' => 'Allow GID editing.',
2232     'type'        => 'checkbox',
2233   },
2234
2235   {
2236     'key'         => 'zone-underscore',
2237     'section'     => 'BIND',
2238     'description' => 'Allow underscores in zone names.  As underscores are illegal characters in zone names, this option is not recommended.',
2239     'type'        => 'checkbox',
2240   },
2241
2242   {
2243     'key'         => 'echeck-nonus',
2244     'section'     => 'billing',
2245     'description' => 'Disable ABA-format account checking for Electronic Check payment info',
2246     'type'        => 'checkbox',
2247   },
2248
2249   {
2250     'key'         => 'voip-cust_cdr_spools',
2251     'section'     => '',
2252     'description' => 'Enable the per-customer option for individual CDR spools.',
2253     'type'        => 'checkbox',
2254   },
2255
2256   {
2257     'key'         => 'voip-cust_cdr_squelch',
2258     'section'     => '',
2259     'description' => 'Enable the per-customer option for not printing CDR on invoices.',
2260     'type'        => 'checkbox',
2261   },
2262
2263   {
2264     'key'         => 'voip-cdr_email',
2265     'section'     => '',
2266     'description' => 'Include the call details on emailed invoices even if the customer is configured for not printing them on the invoices.',
2267     'type'        => 'checkbox',
2268   },
2269
2270   {
2271     'key'         => 'voip-cust_email_csv_cdr',
2272     'section'     => '',
2273     'description' => 'Enable the per-customer option for including CDR information as a CSV attachment on emailed invoices.',
2274     'type'        => 'checkbox',
2275   },
2276
2277   {
2278     'key'         => 'svc_forward-arbitrary_dst',
2279     'section'     => '',
2280     '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.",
2281     'type'        => 'checkbox',
2282   },
2283
2284   {
2285     'key'         => 'tax-ship_address',
2286     'section'     => 'billing',
2287     'description' => 'By default, tax calculations are done based on the billing address.  Enable this switch to calculate tax based on the shipping address instead.',
2288     'type'        => 'checkbox',
2289   }
2290 ,
2291   {
2292     'key'         => 'tax-pkg_address',
2293     'section'     => 'billing',
2294     '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).  Note that this option is currently incompatible with vendor data taxation enabled by enable_taxproducts.',
2295     'type'        => 'checkbox',
2296   },
2297
2298   {
2299     'key'         => 'invoice-ship_address',
2300     'section'     => 'billing',
2301     'description' => 'Include the shipping address on invoices.',
2302     'type'        => 'checkbox',
2303   },
2304
2305   {
2306     'key'         => 'invoice-unitprice',
2307     'section'     => 'billing',
2308     'description' => 'Enable unit pricing on invoices.',
2309     'type'        => 'checkbox',
2310   },
2311
2312   {
2313     'key'         => 'invoice-smallernotes',
2314     'section'     => 'billing',
2315     'description' => 'Display the notes section in a smaller font on invoices.',
2316     'type'        => 'checkbox',
2317   },
2318
2319   {
2320     'key'         => 'invoice-smallerfooter',
2321     'section'     => 'billing',
2322     'description' => 'Display footers in a smaller font on invoices.',
2323     'type'        => 'checkbox',
2324   },
2325
2326   {
2327     'key'         => 'postal_invoice-fee_pkgpart',
2328     'section'     => 'billing',
2329     'description' => 'This allows selection of a package to insert on invoices for customers with postal invoices selected.',
2330     'type'        => 'select-part_pkg',
2331   },
2332
2333   {
2334     'key'         => 'postal_invoice-recurring_only',
2335     'section'     => 'billing',
2336     'description' => 'The postal invoice fee is omitted on invoices without reucrring charges when this is set.',
2337     'type'        => 'checkbox',
2338   },
2339
2340   {
2341     'key'         => 'batch-enable',
2342     'section'     => 'deprecated', #make sure batch-enable_payby is set for
2343                                    #everyone before removing
2344     'description' => 'Enable credit card and/or ACH batching - leave disabled for real-time installations.',
2345     'type'        => 'checkbox',
2346   },
2347
2348   {
2349     'key'         => 'batch-enable_payby',
2350     'section'     => 'billing',
2351     'description' => 'Enable batch processing for the specified payment types.',
2352     'type'        => 'selectmultiple',
2353     'select_enum' => [qw( CARD CHEK )],
2354   },
2355
2356   {
2357     'key'         => 'realtime-disable_payby',
2358     'section'     => 'billing',
2359     'description' => 'Disable realtime processing for the specified payment types.',
2360     'type'        => 'selectmultiple',
2361     'select_enum' => [qw( CARD CHEK )],
2362   },
2363
2364   {
2365     'key'         => 'batch-default_format',
2366     'section'     => 'billing',
2367     'description' => 'Default format for batches.',
2368     'type'        => 'select',
2369     'select_enum' => [ 'csv-td_canada_trust-merchant_pc_batch',
2370                        'csv-chase_canada-E-xactBatch', 'BoM', 'PAP',
2371                        'paymentech', 'ach-spiritone',
2372                     ]
2373   },
2374
2375   #lists could be auto-generated from pay_batch info
2376   {
2377     'key'         => 'batch-fixed_format-CARD',
2378     'section'     => 'billing',
2379     'description' => 'Fixed (unchangeable) format for credit card batches.',
2380     'type'        => 'select',
2381     'select_enum' => [ 'csv-td_canada_trust-merchant_pc_batch', 'BoM', 'PAP' ,
2382                        'csv-chase_canada-E-xactBatch', 'paymentech' ]
2383   },
2384
2385   {
2386     'key'         => 'batch-fixed_format-CHEK',
2387     'section'     => 'billing',
2388     'description' => 'Fixed (unchangeable) format for electronic check batches.',
2389     'type'        => 'select',
2390     'select_enum' => [ 'csv-td_canada_trust-merchant_pc_batch', 'BoM', 'PAP',
2391                        'paymentech', 'ach-spiritone',
2392                      ]
2393   },
2394
2395   {
2396     'key'         => 'batch-increment_expiration',
2397     'section'     => 'billing',
2398     'description' => 'Increment expiration date years in batches until cards are current.  Make sure this is acceptable to your batching provider before enabling.',
2399     'type'        => 'checkbox'
2400   },
2401
2402   {
2403     'key'         => 'batchconfig-BoM',
2404     'section'     => 'billing',
2405     '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',
2406     'type'        => 'textarea',
2407   },
2408
2409   {
2410     'key'         => 'batchconfig-PAP',
2411     'section'     => 'billing',
2412     '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',
2413     'type'        => 'textarea',
2414   },
2415
2416   {
2417     'key'         => 'batchconfig-csv-chase_canada-E-xactBatch',
2418     'section'     => 'billing',
2419     'description' => 'Gateway ID for Chase Canada E-xact batching',
2420     'type'        => 'text',
2421   },
2422
2423   {
2424     'key'         => 'batchconfig-paymentech',
2425     'section'     => 'billing',
2426     'description' => 'Configuration for Chase Paymentech batching, five lines: 1. BIN, 2. Terminal ID, 3. Merchant ID, 4. Username, 5. Password (for batch uploads)',
2427     'type'        => 'textarea',
2428   },
2429
2430   {
2431     'key'         => 'payment_history-years',
2432     'section'     => 'UI',
2433     'description' => 'Number of years of payment history to show by default.  Currently defaults to 2.',
2434     'type'        => 'text',
2435   },
2436
2437   {
2438     'key'         => 'change_history-years',
2439     'section'     => 'UI',
2440     'description' => 'Number of years of change history to show by default.  Currently defaults to 0.5.',
2441     'type'        => 'text',
2442   },
2443
2444   {
2445     'key'         => 'cust_main-packages-years',
2446     'section'     => 'UI',
2447     'description' => 'Number of years to show old (cancelled and one-time charge) packages by default.  Currently defaults to 2.',
2448     'type'        => 'text',
2449   },
2450
2451   {
2452     'key'         => 'cust_main-use_comments',
2453     'section'     => 'UI',
2454     'description' => 'Display free form comments on the customer edit screen.  Useful as a scratch pad.',
2455     'type'        => 'checkbox',
2456   },
2457
2458   {
2459     'key'         => 'cust_main-disable_notes',
2460     'section'     => 'UI',
2461     'description' => 'Disable new style customer notes - timestamped and user identified customer notes.  Useful in tracking who did what.',
2462     'type'        => 'checkbox',
2463   },
2464
2465   {
2466     'key'         => 'cust_main_note-display_times',
2467     'section'     => 'UI',
2468     'description' => 'Display full timestamps (not just dates) for customer notes.',
2469     'type'        => 'checkbox',
2470   },
2471
2472   {
2473     'key'         => 'cust_main-ticket_statuses',
2474     'section'     => 'UI',
2475     'description' => 'Show tickets with these statuses on the customer view page.',
2476     'type'        => 'selectmultiple',
2477     'select_enum' => [qw( new open stalled resolved rejected deleted )],
2478   },
2479
2480   {
2481     'key'         => 'cust_main-max_tickets',
2482     'section'     => 'UI',
2483     'description' => 'Maximum number of tickets to show on the customer view page.',
2484     'type'        => 'text',
2485   },
2486
2487   {
2488     'key'         => 'cust_main-skeleton_tables',
2489     'section'     => '',
2490     '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.',
2491     'type'        => 'textarea',
2492   },
2493
2494   {
2495     'key'         => 'cust_main-skeleton_custnum',
2496     'section'     => '',
2497     'description' => 'Customer number specifying the source data to copy into skeleton tables for new customers.',
2498     'type'        => 'text',
2499   },
2500
2501   {
2502     'key'         => 'cust_main-enable_birthdate',
2503     'section'     => 'UI',
2504     'descritpion' => 'Enable tracking of a birth date with each customer record',
2505     'type'        => 'checkbox',
2506   },
2507
2508   {
2509     'key'         => 'support-key',
2510     'section'     => '',
2511     '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.',
2512     'type'        => 'text',
2513   },
2514
2515   {
2516     'key'         => 'card-types',
2517     'section'     => 'billing',
2518     'description' => 'Select one or more card types to enable only those card types.  If no card types are selected, all card types are available.',
2519     'type'        => 'selectmultiple',
2520     'select_enum' => \@card_types,
2521   },
2522
2523   {
2524     'key'         => 'disable-fuzzy',
2525     'section'     => 'UI',
2526     'description' => 'Disable fuzzy searching.  Speeds up searching for large sites, but only shows exact matches.',
2527     'type'        => 'checkbox',
2528   },
2529
2530   { 'key'         => 'pkg_referral',
2531     'section'     => '',
2532     'description' => 'Enable package-specific advertising sources.',
2533     'type'        => 'checkbox',
2534   },
2535
2536   { 'key'         => 'pkg_referral-multiple',
2537     'section'     => '',
2538     'description' => 'In addition, allow multiple advertising sources to be associated with a single package.',
2539     'type'        => 'checkbox',
2540   },
2541
2542   {
2543     'key'         => 'dashboard-install_welcome',
2544     'section'     => 'UI',
2545     'description' => 'New install welcome screen.',
2546     'type'        => 'select',
2547     'select_enum' => [ '', 'ITSP_fsinc_hosted', ],
2548   },
2549
2550   {
2551     'key'         => 'dashboard-toplist',
2552     'section'     => 'UI',
2553     'description' => 'List of items to display on the top of the front page',
2554     'type'        => 'textarea',
2555   },
2556
2557   {
2558     'key'         => 'impending_recur_template',
2559     'section'     => 'billing',
2560     '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>',
2561 # <li><code>$payby</code> <li><code>$expdate</code> most likely only confuse
2562     'type'        => 'textarea',
2563   },
2564
2565   {
2566     'key'         => 'logo.png',
2567     'section'     => 'billing',  #? 
2568     'description' => 'Company logo for HTML invoices and the backoffice interface, in PNG format.  Suggested size somewhere near 92x62.',
2569     'type'        => 'image',
2570     'per_agent'   => 1, #XXX just view/logo.cgi, which is for the global
2571                         #old-style editor anyway...?
2572   },
2573
2574   {
2575     'key'         => 'logo.eps',
2576     'section'     => 'billing',  #? 
2577     'description' => 'Company logo for printed and PDF invoices, in EPS format.',
2578     'type'        => 'image',
2579     'per_agent'   => 1, #XXX as above, kinda
2580   },
2581
2582   {
2583     'key'         => 'selfservice-ignore_quantity',
2584     'section'     => '',
2585     'description' => 'Ignores service quantity restrictions in self-service context.  Strongly not recommended - just set your quantities correctly in the first place.',
2586     'type'        => 'checkbox',
2587   },
2588
2589   {
2590     'key'         => 'selfservice-session_timeout',
2591     'section'     => '',
2592     'description' => 'Self-service session timeout.  Defaults to 1 hour.',
2593     'type'        => 'select',
2594     'select_enum' => [ '1 hour', '2 hours', '4 hours', '8 hours', '1 day', '1 week', ],
2595   },
2596
2597   {
2598     'key'         => 'disable_setup_suspended_pkgs',
2599     'section'     => 'billing',
2600     'description' => 'Disables charging of setup fees for suspended packages.',
2601     'type'       => 'checkbox',
2602   },
2603
2604   {
2605     'key' => 'password-generated-allcaps',
2606     'section' => 'password',
2607     'description' => 'Causes passwords automatically generated to consist entirely of capital letters',
2608     'type' => 'checkbox',
2609   },
2610
2611   {
2612     'key'         => 'datavolume-forcemegabytes',
2613     'section'     => 'UI',
2614     'description' => 'All data volumes are expressed in megabytes',
2615     'type'        => 'checkbox',
2616   },
2617
2618   {
2619     'key'         => 'datavolume-significantdigits',
2620     'section'     => 'UI',
2621     'description' => 'number of significant digits to use to represent data volumes',
2622     'type'        => 'text',
2623   },
2624
2625   {
2626     'key'         => 'disable_void_after',
2627     'section'     => 'billing',
2628     'description' => 'Number of seconds after which freeside won\'t attempt to VOID a payment first when performing a refund.',
2629     'type'        => 'text',
2630   },
2631
2632   {
2633     'key'         => 'disable_line_item_date_ranges',
2634     'section'     => 'billing',
2635     'description' => 'Prevent freeside from automatically generating date ranges on invoice line items.',
2636     'type'        => 'checkbox',
2637   },
2638
2639   {
2640     'key'         => 'support_packages',
2641     'section'     => '',
2642     '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...
2643     'type'        => 'select-part_pkg',
2644     'multiple'    => 1,
2645   },
2646
2647   {
2648     'key'         => 'cust_main-require_phone',
2649     'section'     => '',
2650     'description' => 'Require daytime or night phone for all customer records.',
2651     'type'        => 'checkbox',
2652   },
2653
2654   {
2655     'key'         => 'cust_main-require_invoicing_list_email',
2656     'section'     => '',
2657     'description' => 'Email address field is required: require at least one invoicing email address for all customer records.',
2658     'type'        => 'checkbox',
2659   },
2660
2661   {
2662     'key'         => 'svc_acct-display_paid_time_remaining',
2663     'section'     => '',
2664     'description' => 'Show paid time remaining in addition to time remaining.',
2665     'type'        => 'checkbox',
2666   },
2667
2668   {
2669     'key'         => 'cancel_credit_type',
2670     'section'     => 'billing',
2671     'description' => 'The group to use for new, automatically generated credit reasons resulting from cancellation.',
2672     'type'        => 'select-sub',
2673     'options_sub' => sub { require FS::Record;
2674                            require FS::reason_type;
2675                            map { $_->typenum => $_->type }
2676                                FS::Record::qsearch('reason_type', { class=>'R' } );
2677                          },
2678     'option_sub'  => sub { require FS::Record;
2679                            require FS::reason_type;
2680                            my $reason_type = FS::Record::qsearchs(
2681                              'reason_type', { 'typenum' => shift }
2682                            );
2683                            $reason_type ? $reason_type->type : '';
2684                          },
2685   },
2686
2687   {
2688     'key'         => 'referral_credit_type',
2689     'section'     => 'deprecated',
2690     '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.',
2691     'type'        => 'select-sub',
2692     'options_sub' => sub { require FS::Record;
2693                            require FS::reason_type;
2694                            map { $_->typenum => $_->type }
2695                                FS::Record::qsearch('reason_type', { class=>'R' } );
2696                          },
2697     'option_sub'  => sub { require FS::Record;
2698                            require FS::reason_type;
2699                            my $reason_type = FS::Record::qsearchs(
2700                              'reason_type', { 'typenum' => shift }
2701                            );
2702                            $reason_type ? $reason_type->type : '';
2703                          },
2704   },
2705
2706   {
2707     'key'         => 'signup_credit_type',
2708     'section'     => 'billing',
2709     'description' => 'The group to use for new, automatically generated credit reasons resulting from signup and self-service declines.',
2710     'type'        => 'select-sub',
2711     'options_sub' => sub { require FS::Record;
2712                            require FS::reason_type;
2713                            map { $_->typenum => $_->type }
2714                                FS::Record::qsearch('reason_type', { class=>'R' } );
2715                          },
2716     'option_sub'  => sub { require FS::Record;
2717                            require FS::reason_type;
2718                            my $reason_type = FS::Record::qsearchs(
2719                              'reason_type', { 'typenum' => shift }
2720                            );
2721                            $reason_type ? $reason_type->type : '';
2722                          },
2723   },
2724
2725   {
2726     'key'         => 'cust_main-agent_custid-format',
2727     'section'     => '',
2728     'description' => 'Enables searching of various formatted values in cust_main.agent_custid',
2729     'type'        => 'select',
2730     'select_hash' => [
2731                        ''      => 'Numeric only',
2732                        'ww?d+' => 'Numeric with one or two letter prefix',
2733                      ],
2734   },
2735
2736   {
2737     'key'         => 'card_masking_method',
2738     'section'     => 'UI',
2739     '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.',
2740     'type'        => 'select',
2741     'select_hash' => [
2742                        ''            => '123456xxxxxx1234',
2743                        'first6last2' => '123456xxxxxxxx12',
2744                        'first4last4' => '1234xxxxxxxx1234',
2745                        'first4last2' => '1234xxxxxxxxxx12',
2746                        'first2last4' => '12xxxxxxxxxx1234',
2747                        'first2last2' => '12xxxxxxxxxxxx12',
2748                        'first0last4' => 'xxxxxxxxxxxx1234',
2749                        'first0last2' => 'xxxxxxxxxxxxxx12',
2750                      ],
2751   },
2752
2753   {
2754     'key'         => 'disable_previous_balance',
2755     'section'     => 'billing',
2756     'description' => 'Disable inclusion of previous balancem payment, and credit lines on invoices',
2757     'type'        => 'checkbox',
2758   },
2759
2760   {
2761     'key'         => 'previous_balance-summary_only',
2762     'section'     => 'billing',
2763     'description' => 'Only show a single line summarizing the total previous balance rather than one line per invoice.',
2764     'type'        => 'checkbox',
2765   },
2766
2767   {
2768     'key'         => 'usps_webtools-userid',
2769     'section'     => 'UI',
2770     '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.',
2771     'type'        => 'text',
2772   },
2773
2774   {
2775     'key'         => 'usps_webtools-password',
2776     'section'     => 'UI',
2777     '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.',
2778     'type'        => 'text',
2779   },
2780
2781   {
2782     'key'         => 'cust_main-auto_standardize_address',
2783     'section'     => 'UI',
2784     'description' => 'When using USPS web tools, automatically standardize the address without asking.',
2785     'type'        => 'checkbox',
2786   },
2787
2788   {
2789     'key'         => 'cust_main-require_censustract',
2790     'section'     => 'UI',
2791     'description' => 'Customer is required to have a census tract.  Useful for FCC form 477 reports. See also: cust_main-auto_standardize_address',
2792     'type'        => 'checkbox',
2793   },
2794
2795   {
2796     'key'         => 'census_year',
2797     'section'     => 'UI',
2798     'description' => 'The year to use in census tract lookups',
2799     'type'        => 'select',
2800     'select_enum' => [ qw( 2009 2008 2007 2006 ) ],
2801   },
2802
2803   {
2804     'key'         => 'company_latitude',
2805     'section'     => 'UI',
2806     'description' => 'Your company latitude (-90 through 90)',
2807     'type'        => 'text',
2808   },
2809
2810   {
2811     'key'         => 'company_longitude',
2812     'section'     => 'UI',
2813     'description' => 'Your company longitude (-180 thru 180)',
2814     'type'        => 'text',
2815   },
2816
2817   {
2818     'key'         => 'disable_acl_changes',
2819     'section'     => '',
2820     'description' => 'Disable all ACL changes, for demos.',
2821     'type'        => 'checkbox',
2822   },
2823
2824   {
2825     'key'         => 'cust_main-edit_agent_custid',
2826     'section'     => 'UI',
2827     'description' => 'Enable editing of the agent_custid field.',
2828     'type'        => 'checkbox',
2829   },
2830
2831   {
2832     'key'         => 'cust_main-default_agent_custid',
2833     'section'     => 'UI',
2834     'description' => 'Display the agent_custid field when available instead of the custnum field.',
2835     'type'        => 'checkbox',
2836   },
2837
2838   {
2839     'key'         => 'cust_bill-default_agent_invid',
2840     'section'     => 'UI',
2841     'description' => 'Display the agent_invid field when available instead of the invnum field.',
2842     'type'        => 'checkbox',
2843   },
2844
2845   {
2846     'key'         => 'cust_main-auto_agent_custid',
2847     'section'     => 'UI',
2848     'description' => 'Automatically assign an agent_custid - select format',
2849     'type'        => 'select',
2850     'select_hash' => [ '' => 'No',
2851                        '1YMMXXXXXXXX' => '1YMMXXXXXXXX',
2852                      ],
2853   },
2854
2855   {
2856     'key'         => 'cust_main-default_areacode',
2857     'section'     => 'UI',
2858     'description' => 'Default area code for customers.',
2859     'type'        => 'text',
2860   },
2861
2862   {
2863     'key'         => 'mcp_svcpart',
2864     'section'     => '',
2865     'description' => 'Master Control Program svcpart.  Leave this blank.',
2866     'type'        => 'text', #select-part_svc
2867   },
2868
2869   {
2870     'key'         => 'cust_bill-max_same_services',
2871     'section'     => 'billing',
2872     '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.',
2873     'type'        => 'text',
2874   },
2875
2876   {
2877     'key'         => 'cust_bill-consolidate_services',
2878     'section'     => 'billing',
2879     'description' => 'Consolidate service display into fewer lines on invoices rather than one per service.',
2880     'type'        => 'checkbox',
2881   },
2882
2883   {
2884     'key'         => 'suspend_email_admin',
2885     'section'     => '',
2886     'description' => 'Destination admin email address to enable suspension notices',
2887     'type'        => 'text',
2888   },
2889
2890   {
2891     'key'         => 'email_report-subject',
2892     'section'     => '',
2893     'description' => 'Subject for reports emailed by freeside-fetch.  Defaults to "Freeside report".',
2894     'type'        => 'text',
2895   },
2896
2897   {
2898     'key'         => 'selfservice-head',
2899     'section'     => '',
2900     'description' => 'HTML for the HEAD section of the self-service interface, typically used for LINK stylesheet tags',
2901     'type'        => 'textarea', #htmlarea?
2902     'per_agent'   => 1,
2903   },
2904
2905
2906   {
2907     'key'         => 'selfservice-body_header',
2908     'section'     => '',
2909     'description' => 'HTML header for the self-service interface',
2910     'type'        => 'textarea', #htmlarea?
2911     'per_agent'   => 1,
2912   },
2913
2914   {
2915     'key'         => 'selfservice-body_footer',
2916     'section'     => '',
2917     'description' => 'HTML header for the self-service interface',
2918     'type'        => 'textarea', #htmlarea?
2919     'per_agent'   => 1,
2920   },
2921
2922
2923   {
2924     'key'         => 'selfservice-body_bgcolor',
2925     'section'     => '',
2926     'description' => 'HTML background color for the self-service interface, for example, #FFFFFF',
2927     'type'        => 'text',
2928     'per_agent'   => 1,
2929   },
2930
2931   {
2932     'key'         => 'selfservice-box_bgcolor',
2933     'section'     => '',
2934     'description' => 'HTML color for self-service interface input boxes, for example, #C0C0C0"',
2935     'type'        => 'text',
2936     'per_agent'   => 1,
2937   },
2938
2939   {
2940     'key'         => 'selfservice-bulk_format',
2941     'section'     => '',
2942     'description' => 'Parameter arrangement for selfservice bulk features',
2943     'type'        => 'select',
2944     'select_enum' => [ '', 'izoom-soap', 'izoom-ftp' ],
2945     'per_agent'   => 1,
2946   },
2947
2948   {
2949     'key'         => 'selfservice-bulk_ftp_dir',
2950     'section'     => '',
2951     'description' => 'Enable bulk ftp provisioning in this folder',
2952     'type'        => 'text',
2953     'per_agent'   => 1,
2954   },
2955
2956   {
2957     'key'         => 'signup-no_company',
2958     'section'     => '',
2959     'description' => "Don't display a field for company name on signup.",
2960     'type'        => 'checkbox',
2961   },
2962
2963   {
2964     'key'         => 'signup-recommend_email',
2965     'section'     => '',
2966     'description' => 'Encourage the entry of an invoicing email address on signup.',
2967     'type'        => 'checkbox',
2968   },
2969
2970   {
2971     'key'         => 'signup-recommend_daytime',
2972     'section'     => '',
2973     'description' => 'Encourage the entry of a daytime phone number  invoicing email address on signup.',
2974     'type'        => 'checkbox',
2975   },
2976
2977   {
2978     'key'         => 'svc_phone-radius-default_password',
2979     'section'     => '',
2980     'description' => 'Default password when exporting svc_phone records to RADIUS',
2981     'type'        => 'text',
2982   },
2983
2984   {
2985     'key'         => 'svc_phone-allow_alpha_phonenum',
2986     'section'     => '',
2987     'description' => 'Allow letters in phone numbers.',
2988     'type'        => 'checkbox',
2989   },
2990
2991   {
2992     'key'         => 'default_phone_countrycode',
2993     'section'     => '',
2994     'description' => 'Default countrcode',
2995     'type'        => 'text',
2996   },
2997
2998   {
2999     'key'         => 'cdr-charged_party-accountcode',
3000     'section'     => '',
3001     'description' => 'Set the charged_party field of CDRs to the accountcode.',
3002     'type'        => 'checkbox',
3003   },
3004
3005   {
3006     'key'         => 'cdr-charged_party-accountcode-trim_leading_0s',
3007     'section'     => '',
3008     'description' => 'When setting the charged_party field of CDRs to the accountcode, trim any leading zeros.',
3009     'type'        => 'checkbox',
3010   },
3011
3012 #  {
3013 #    'key'         => 'cdr-charged_party-truncate_prefix',
3014 #    'section'     => '',
3015 #    'description' => 'If the charged_party field has this prefix, truncate it to the length in cdr-charged_party-truncate_length.',
3016 #    'type'        => 'text',
3017 #  },
3018 #
3019 #  {
3020 #    'key'         => 'cdr-charged_party-truncate_length',
3021 #    'section'     => '',
3022 #    'description' => 'If the charged_party field has the prefix in cdr-charged_party-truncate_prefix, truncate it to this length.',
3023 #    'type'        => 'text',
3024 #  },
3025
3026   {
3027     'key'         => 'cdr-charged_party_rewrite',
3028     'section'     => '',
3029     '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*.',
3030     'type'        => 'checkbox',
3031   },
3032
3033   {
3034     'key'         => 'cdr-taqua-da_rewrite',
3035     'section'     => '',
3036     '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.',
3037     'type'        => 'text',
3038   },
3039
3040   {
3041     'key'         => 'cust_pkg-show_autosuspend',
3042     'section'     => 'UI',
3043     'description' => 'Show package auto-suspend dates.  Use with caution for now; can slow down customer view for large insallations.',
3044     'type'       => 'checkbox',
3045   },
3046
3047   {
3048     'key'         => 'cdr-asterisk_forward_rewrite',
3049     'section'     => '',
3050     '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").',
3051     'type'        => 'checkbox',
3052   },
3053
3054   {
3055     'key'         => 'sg-multicustomer_hack',
3056     'section'     => '',
3057     'description' => "Don't use this.",
3058     'type'        => 'checkbox',
3059   },
3060
3061   {
3062     'key'         => 'sg-ping_username',
3063     'section'     => '',
3064     'description' => "Don't use this.",
3065     'type'        => 'text',
3066   },
3067
3068   {
3069     'key'         => 'sg-ping_password',
3070     'section'     => '',
3071     'description' => "Don't use this.",
3072     'type'        => 'text',
3073   },
3074
3075   {
3076     'key'         => 'sg-login_username',
3077     'section'     => '',
3078     'description' => "Don't use this.",
3079     'type'        => 'text',
3080   },
3081
3082   {
3083     'key'         => 'disable-cust-pkg_class',
3084     'section'     => 'UI',
3085     'description' => 'Disable the two-step dropdown for selecting package class and package, and return to the classic single dropdown.',
3086     'type'        => 'checkbox',
3087   },
3088
3089   {
3090     'key'         => 'queued-max_kids',
3091     'section'     => '',
3092     'description' => 'Maximum number of queued processes.  Defaults to 10.',
3093     'type'        => 'text',
3094   },
3095
3096   {
3097     'key'         => 'cancelled_cust-noevents',
3098     'section'     => 'billing',
3099     'description' => "Don't run events for cancelled customers",
3100     'type'        => 'checkbox',
3101   },
3102
3103   {
3104     'key'         => 'agent-invoice_template',
3105     'section'     => 'billing',
3106     'description' => 'Enable display/edit of old-style per-agent invoice template selection',
3107     'type'        => 'checkbox',
3108   },
3109
3110   {
3111     'key'         => 'svc_broadband-manage_link',
3112     'section'     => 'UI',
3113     'description' => 'URL for svc_broadband "Manage Device" link.  The following substitutions are available: $ip_addr.',
3114     'type'        => 'text',
3115   },
3116
3117   #more fine-grained, service def-level control could be useful eventually?
3118   {
3119     'key'         => 'svc_broadband-allow_null_ip_addr',
3120     'section'     => '',
3121     'description' => '',
3122     'type'        => 'checkbox',
3123   },
3124
3125   {
3126     'key'         => 'tax-report_groups',
3127     'section'     => '',
3128     'description' => 'List of grouping possibilities for tax names on reports, one per line, "label op value" (op can be = or !=).',
3129     'type'        => 'textarea',
3130   },
3131
3132   {
3133     'key'         => 'tax-cust_exempt-groups',
3134     'section'     => '',
3135     '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).',
3136     'type'        => 'textarea',
3137   },
3138
3139   {
3140     'key'         => 'cust_main-default_view',
3141     'section'     => 'UI',
3142     'description' => 'Default customer view, for users who have not selected a default view in their preferences.',
3143     'type'        => 'select',
3144     'select_hash' => [
3145       #false laziness w/view/cust_main.cgi and pref/pref.html
3146       'basics'          => 'Basics',
3147       'notes'           => 'Notes',
3148       'tickets'         => 'Tickets',
3149       'packages'        => 'Packages',
3150       'payment_history' => 'Payment History',
3151       'change_history'  => 'Change History',
3152       'jumbo'           => 'Jumbo',
3153     ],
3154   },
3155
3156   {
3157     'key'         => 'enable_tax_adjustments',
3158     'section'     => 'billing',
3159     'description' => 'Enable the ability to add manual tax adjustments.',
3160     'type'        => 'checkbox',
3161   },
3162
3163   {
3164     'key'         => 'rt-crontool',
3165     'section'     => '',
3166     'description' => 'Enable the RT CronTool extension.',
3167     'type'        => 'checkbox',
3168   },
3169
3170   {
3171     'key'         => 'pkg-balances',
3172     'section'     => 'billing',
3173     'description' => 'Enable experimental package balances.  Not recommended for general use.',
3174     'type'        => 'checkbox',
3175   },
3176
3177   {
3178     'key'         => 'pkg-addon_classnum',
3179     'section'     => 'billing',
3180     'description' => 'Enable the ability to restrict additional package orders based on package class.',
3181     'type'        => 'checkbox',
3182   },
3183
3184   {
3185     'key'         => 'cust_main-edit_signupdate',
3186     'section'     => 'UI',
3187     'descritpion' => 'Enable manual editing of the signup date.',
3188     'type'        => 'checkbox',
3189   },
3190
3191   {
3192     'key'         => 'svc_acct-disable_access_number',
3193     'section'     => 'UI',
3194     'descritpion' => 'Disable access number selection.',
3195     'type'        => 'checkbox',
3196   },
3197
3198   {
3199     'key'         => 'cust_bill_pay_pkg-manual',
3200     'section'     => 'UI',
3201     'description' => 'Allow manual application of payments to line items.',
3202     'type'        => 'checkbox',
3203   },
3204
3205   {
3206     'key'         => 'cust_credit_bill_pkg-manual',
3207     'section'     => 'UI',
3208     'description' => 'Allow manual application of credits to line items.',
3209     'type'        => 'checkbox',
3210   },
3211
3212   {
3213     'key'         => 'breakage-days',
3214     'section'     => 'billing',
3215     '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.',
3216     'type'        => 'text',
3217     'per_agent'   => 1,
3218   },
3219
3220   {
3221     'key'         => 'breakage-pkg_class',
3222     'section'     => 'billing',
3223     'description' => 'Package class to use for breakage reconciliation.',
3224     'type'        => 'select-pkg_class',
3225   },
3226
3227
3228   { key => "apacheroot", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3229   { key => "apachemachine", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3230   { key => "apachemachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3231   { key => "bindprimary", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3232   { key => "bindsecondaries", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3233   { key => "bsdshellmachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3234   { key => "cyrus", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3235   { key => "cp_app", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3236   { key => "erpcdmachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3237   { key => "icradiusmachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3238   { key => "icradius_mysqldest", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3239   { key => "icradius_mysqlsource", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3240   { key => "icradius_secrets", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3241   { key => "maildisablecatchall", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3242   { key => "mxmachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3243   { key => "nsmachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3244   { key => "arecords", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3245   { key => "cnamerecords", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3246   { key => "nismachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3247   { key => "qmailmachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3248   { key => "radiusmachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3249   { key => "sendmailconfigpath", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3250   { key => "sendmailmachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3251   { key => "sendmailrestart", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3252   { key => "shellmachine", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3253   { key => "shellmachine-useradd", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3254   { key => "shellmachine-userdel", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3255   { key => "shellmachine-usermod", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3256   { key => "shellmachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3257   { key => "radiusprepend", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3258   { key => "textradiusprepend", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3259   { key => "username_policy", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3260   { key => "vpopmailmachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3261   { key => "vpopmailrestart", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3262   { key => "safe-part_pkg", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3263   { key => "selfservice_server-quiet", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3264   { key => "signup_server-quiet", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3265   { key => "signup_server-email", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3266   { key => "vonage-username", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3267   { key => "vonage-password", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3268   { key => "vonage-fromnumber", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3269
3270 );
3271
3272 1;
3273