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