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