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