event refactor, landing on HEAD!
[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 IO::File;
5 use File::Basename;
6 use MIME::Base64;
7 use FS::ConfItem;
8 use FS::ConfDefaults;
9 use FS::Conf_compat17;
10 use FS::conf;
11 use FS::Record qw(qsearch qsearchs);
12 use FS::UID qw(dbh datasrc use_confcompat);
13
14 $base_dir = '%%%FREESIDE_CONF%%%';
15
16 $DEBUG = 0;
17
18 =head1 NAME
19
20 FS::Conf - Freeside configuration values
21
22 =head1 SYNOPSIS
23
24   use FS::Conf;
25
26   $conf = new FS::Conf;
27
28   $value = $conf->config('key');
29   @list  = $conf->config('key');
30   $bool  = $conf->exists('key');
31
32   $conf->touch('key');
33   $conf->set('key' => 'value');
34   $conf->delete('key');
35
36   @config_items = $conf->config_items;
37
38 =head1 DESCRIPTION
39
40 Read and write Freeside configuration values.  Keys currently map to filenames,
41 but this may change in the future.
42
43 =head1 METHODS
44
45 =over 4
46
47 =item new
48
49 Create a new configuration object.
50
51 =cut
52
53 sub new {
54   my($proto) = @_;
55   my($class) = ref($proto) || $proto;
56   my($self) = { 'base_dir' => $base_dir };
57   bless ($self, $class);
58 }
59
60 =item base_dir
61
62 Returns the base directory.  By default this is /usr/local/etc/freeside.
63
64 =cut
65
66 sub base_dir {
67   my($self) = @_;
68   my $base_dir = $self->{base_dir};
69   -e $base_dir or die "FATAL: $base_dir doesn't exist!";
70   -d $base_dir or die "FATAL: $base_dir isn't a directory!";
71   -r $base_dir or die "FATAL: Can't read $base_dir!";
72   -x $base_dir or die "FATAL: $base_dir not searchable (executable)!";
73   $base_dir =~ /^(.*)$/;
74   $1;
75 }
76
77 =item config KEY [ AGENTNUM ]
78
79 Returns the configuration value or values (depending on context) for key.
80 The optional agent number selects an agent specific value instead of the
81 global default if one is present.
82
83 =cut
84
85 sub _usecompat {
86   my ($self, $method) = (shift, shift);
87   warn "NO CONFIGURATION RECORDS FOUND -- USING COMPATIBILITY MODE"
88     if use_confcompat;
89   my $compat = new FS::Conf_compat17 ("$base_dir/conf." . datasrc);
90   $compat->$method(@_);
91 }
92
93 sub _config {
94   my($self,$name,$agentnum)=@_;
95   my $hashref = { 'name' => $name };
96   $hashref->{agentnum} = $agentnum;
97   local $FS::Record::conf = undef;  # XXX evil hack prevents recursion
98   my $cv = FS::Record::qsearchs('conf', $hashref);
99   if (!$cv && defined($agentnum)) {
100     $hashref->{agentnum} = '';
101     $cv = FS::Record::qsearchs('conf', $hashref);
102   }
103   return $cv;
104 }
105
106 sub config {
107   my $self = shift;
108   return $self->_usecompat('config', @_) if use_confcompat;
109
110   my($name,$agentnum)=@_;
111   my $cv = $self->_config($name, $agentnum) or return;
112
113   if ( wantarray ) {
114     my $v = $cv->value;
115     chomp $v;
116     (split "\n", $v, -1);
117   } else {
118     (split("\n", $cv->value))[0];
119   }
120 }
121
122 =item config_binary KEY [ AGENTNUM ]
123
124 Returns the exact scalar value for key.
125
126 =cut
127
128 sub config_binary {
129   my $self = shift;
130   return $self->_usecompat('config_binary', @_) if use_confcompat;
131
132   my($name,$agentnum)=@_;
133   my $cv = $self->_config($name, $agentnum) or return;
134   decode_base64($cv->value);
135 }
136
137 =item exists KEY [ AGENTNUM ]
138
139 Returns true if the specified key exists, even if the corresponding value
140 is undefined.
141
142 =cut
143
144 sub exists {
145   my $self = shift;
146   return $self->_usecompat('exists', @_) if use_confcompat;
147
148   my($name,$agentnum)=@_;
149   defined($self->_config($name, $agentnum));
150 }
151
152 #=item config_orbase KEY SUFFIX
153 #
154 #Returns the configuration value or values (depending on context) for 
155 #KEY_SUFFIX, if it exists, otherwise for KEY
156 #
157 #=cut
158
159 # outmoded as soon as we shift to agentnum based config values
160 # well, mostly.  still useful for e.g. late notices, etc. in that we want
161 # these to fall back to standard values
162 sub config_orbase {
163   my $self = shift;
164   return $self->_usecompat('config_orbase', @_) if use_confcompat;
165
166   my( $name, $suffix ) = @_;
167   if ( $self->exists("${name}_$suffix") ) {
168     $self->config("${name}_$suffix");
169   } else {
170     $self->config($name);
171   }
172 }
173
174 =item invoice_templatenames
175
176 Returns all possible invoice template names.
177
178 =cut
179
180 sub invoice_templatenames {
181   my( $self ) = @_;
182
183   my %templatenames = ();
184   foreach my $item ( $self->config_items ) {
185     foreach my $base ( @base_items ) {
186       my( $main, $ext) = split(/\./, $base);
187       $ext = ".$ext" if $ext;
188       if ( $item->key =~ /^${main}_(.+)$ext$/ ) {
189       $templatenames{$1}++;
190       }
191     }
192   }
193   
194   sort keys %templatenames;
195
196 }
197
198 =item touch KEY [ AGENT ];
199
200 Creates the specified configuration key if it does not exist.
201
202 =cut
203
204 sub touch {
205   my $self = shift;
206   return $self->_usecompat('touch', @_) if use_confcompat;
207
208   my($name, $agentnum) = @_;
209   unless ( $self->exists($name, $agentnum) ) {
210     $self->set($name, '', $agentnum);
211   }
212 }
213
214 =item set KEY VALUE [ AGENTNUM ];
215
216 Sets the specified configuration key to the given value.
217
218 =cut
219
220 sub set {
221   my $self = shift;
222   return $self->_usecompat('set', @_) if use_confcompat;
223
224   my($name, $value, $agentnum) = @_;
225   $value =~ /^(.*)$/s;
226   $value = $1;
227
228   warn "[FS::Conf] SET $name\n" if $DEBUG;
229
230   my $old = FS::Record::qsearchs('conf', {name => $name, agentnum => $agentnum});
231   my $new = new FS::conf { $old ? $old->hash 
232                                 : ('name' => $name, 'agentnum' => $agentnum)
233                          };
234   $new->value($value);
235
236   my $error;
237   if ($old) {
238     $error = $new->replace($old);
239   } else {
240     $error = $new->insert;
241   }
242
243   die "error setting configuration value: $error \n"
244     if $error;
245
246 }
247
248 =item set_binary KEY VALUE [ AGENTNUM ]
249
250 Sets the specified configuration key to an exact scalar value which
251 can be retrieved with config_binary.
252
253 =cut
254
255 sub set_binary {
256   my $self  = shift;
257   return if use_confcompat;
258
259   my($name, $value, $agentnum)=@_;
260   $self->set($name, encode_base64($value), $agentnum);
261 }
262
263 =item delete KEY [ AGENTNUM ];
264
265 Deletes the specified configuration key.
266
267 =cut
268
269 sub delete {
270   my $self = shift;
271   return $self->_usecompat('delete', @_) if use_confcompat;
272
273   my($name, $agentnum) = @_;
274   if ( my $cv = FS::Record::qsearchs('conf', {name => $name, agentnum => $agentnum}) ) {
275     warn "[FS::Conf] DELETE $name\n";
276
277     my $oldAutoCommit = $FS::UID::AutoCommit;
278     local $FS::UID::AutoCommit = 0;
279     my $dbh = dbh;
280
281     my $error = $cv->delete;
282
283     if ( $error ) {
284       $dbh->rollback if $oldAutoCommit;
285       die "error setting configuration value: $error \n"
286     }
287
288     $dbh->commit or die $dbh->errstr if $oldAutoCommit;
289
290   }
291 }
292
293 =item import_config_item CONFITEM DIR 
294
295   Imports the item specified by the CONFITEM (see L<FS::ConfItem>) into
296 the database as a conf record (see L<FS::conf>).  Imports from the file
297 in the directory DIR.
298
299 =cut
300
301 sub import_config_item { 
302   my ($self,$item,$dir) = @_;
303   my $key = $item->key;
304   if ( -e "$dir/$key" && ! use_confcompat ) {
305     warn "Inserting $key\n" if $DEBUG;
306     local $/;
307     my $value = readline(new IO::File "$dir/$key");
308     if ($item->type eq 'binary') {
309       $self->set_binary($key, $value);
310     }else{
311       $self->set($key, $value);
312     }
313   }else {
314     warn "Not inserting $key\n" if $DEBUG;
315   }
316 }
317
318 =item verify_config_item CONFITEM DIR 
319
320   Compares the item specified by the CONFITEM (see L<FS::ConfItem>) in
321 the database to the legacy file value in DIR.
322
323 =cut
324
325 sub verify_config_item { 
326   return '' if use_confcompat;
327   my ($self,$item,$dir) = @_;
328   my $key = $item->key;
329   my $type = $item->type;
330
331   my $compat = new FS::Conf_compat17 $dir;
332   my $error = '';
333   
334   $error .= "$key fails existential comparison; "
335     if $self->exists($key) xor $compat->exists($key);
336
337   unless ($type eq 'binary') {
338     {
339       no warnings;
340       $error .= "$key fails scalar comparison; "
341         unless scalar($self->config($key)) eq scalar($compat->config($key));
342     }
343
344     my (@new) = $self->config($key);
345     my (@old) = $compat->config($key);
346     unless ( scalar(@new) == scalar(@old)) { 
347       $error .= "$key fails list comparison; ";
348     }else{
349       my $r=1;
350       foreach (@old) { $r=0 if ($_ cmp shift(@new)); }
351       $error .= "$key fails list comparison; "
352         unless $r;
353     }
354   }
355
356   if ($type eq 'binary') {
357     $error .= "$key fails binary comparison; "
358       unless scalar($self->config_binary($key)) eq scalar($compat->config_binary($key));
359   }
360
361   if ($error =~ /existential comparison/ && $item->section eq 'deprecated') {
362     my $proto;
363     for ( @config_items ) { $proto = $_; last if $proto->key eq $key;  }
364     unless ($proto->key eq $key) { 
365       warn "removed config item $error\n" if $DEBUG;
366       $error = '';
367     }
368   }
369
370   $error;
371 }
372
373 #item _orbase_items OPTIONS
374 #
375 #Returns all of the possible extensible config items as FS::ConfItem objects.
376 #See #L<FS::ConfItem>.  OPTIONS consists of name value pairs.  Possible
377 #options include
378 #
379 # dir - the directory to search for configuration option files instead
380 #       of using the conf records in the database
381 #
382 #cut
383
384 #quelle kludge
385 sub _orbase_items {
386   my ($self, %opt) = @_; 
387
388   my $listmaker = sub { my $v = shift;
389                         $v =~ s/_/!_/g;
390                         if ( $v =~ /\.(png|eps)$/ ) {
391                           $v =~ s/\./!_%./;
392                         }else{
393                           $v .= '!_%';
394                         }
395                         map { $_->name }
396                           FS::Record::qsearch( 'conf',
397                                                {},
398                                                '',
399                                                "WHERE name LIKE '$v' ESCAPE '!'"
400                                              );
401                       };
402
403   if (exists($opt{dir}) && $opt{dir}) {
404     $listmaker = sub { my $v = shift;
405                        if ( $v =~ /\.(png|eps)$/ ) {
406                          $v =~ s/\./_*./;
407                        }else{
408                          $v .= '_*';
409                        }
410                        map { basename $_ } glob($opt{dir}. "/$v" );
411                      };
412   }
413
414   ( map { 
415           my $proto;
416           my $base = $_;
417           for ( @config_items ) { $proto = $_; last if $proto->key eq $base;  }
418           die "don't know about $base items" unless $proto->key eq $base;
419
420           map { new FS::ConfItem { 
421                                    'key' => $_,
422                                    'section' => $proto->section,
423                                    'description' => 'Alternate ' . $proto->description . '  See the <a href="../docs/billing.html">billing documentation</a> for details.',
424                                    'type' => $proto->type,
425                                  };
426               } &$listmaker($base);
427         } @base_items,
428   );
429 }
430
431 =item config_items
432
433 Returns all of the possible global/default configuration items as
434 FS::ConfItem objects.  See L<FS::ConfItem>.
435
436 =cut
437
438 sub config_items {
439   my $self = shift; 
440   return $self->_usecompat('config_items', @_) if use_confcompat;
441
442   ( @config_items, $self->_orbase_items(@_) );
443 }
444
445 =back
446
447 =head1 SUBROUTINES
448
449 =over 4
450
451 =item init-config DIR
452
453 Imports the non-deprecated configuration items from DIR (1.7 compatible)
454 to conf records in the database.
455
456 =cut
457
458 sub init_config {
459   my $dir = shift;
460
461   {
462     local $FS::UID::use_confcompat = 0;
463     my $conf = new FS::Conf;
464     foreach my $item ( $conf->config_items(dir => $dir) ) {
465       $conf->import_config_item($item, $dir);
466       my $error = $conf->verify_config_item($item, $dir);
467       return $error if $error;
468     }
469   
470     my $compat = new FS::Conf_compat17 $dir;
471     foreach my $item ( $compat->config_items ) {
472       my $error = $conf->verify_config_item($item, $dir);
473       return $error if $error;
474     }
475   }
476
477   $FS::UID::use_confcompat = 0;
478   '';  #success
479 }
480
481 =back
482
483 =head1 BUGS
484
485 If this was more than just crud that will never be useful outside Freeside I'd
486 worry that config_items is freeside-specific and icky.
487
488 =head1 SEE ALSO
489
490 "Configuration" in the web interface (config/config.cgi).
491
492 httemplate/docs/config.html
493
494 =cut
495
496 #Business::CreditCard
497 @card_types = (
498   "VISA card",
499   "MasterCard",
500   "Discover card",
501   "American Express card",
502   "Diner's Club/Carte Blanche",
503   "enRoute",
504   "JCB",
505   "BankCard",
506   "Switch",
507   "Solo",
508 );
509
510 @base_items = qw (
511                    invoice_template
512                    invoice_latex
513                    invoice_latexreturnaddress
514                    invoice_latexfooter
515                    invoice_latexsmallfooter
516                    invoice_latexnotes
517                    invoice_html
518                    invoice_htmlreturnaddress
519                    invoice_htmlfooter
520                    invoice_htmlnotes
521                    logo.png
522                    logo.eps
523                  );
524
525 @base_items = qw (
526                    invoice_template
527                    invoice_latex
528                    invoice_latexreturnaddress
529                    invoice_latexfooter
530                    invoice_latexsmallfooter
531                    invoice_latexnotes
532                    invoice_html
533                    invoice_htmlreturnaddress
534                    invoice_htmlfooter
535                    invoice_htmlnotes
536                    logo.png
537                    logo.eps
538                  );
539
540 @config_items = map { new FS::ConfItem $_ } (
541
542   {
543     'key'         => 'address',
544     'section'     => 'deprecated',
545     'description' => 'This configuration option is no longer used.  See <a href="#invoice_template">invoice_template</a> instead.',
546     'type'        => 'text',
547   },
548
549   {
550     'key'         => 'alerter_template',
551     'section'     => 'billing',
552     'description' => 'Template file for billing method expiration alerts.  See the <a href="../docs/billing.html#invoice_template">billing documentation</a> for details.',
553     'type'        => 'textarea',
554   },
555
556   {
557     'key'         => 'apacheip',
558     'section'     => 'deprecated',
559     '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',
560     'type'        => 'text',
561   },
562
563   {
564     'key'         => 'encryption',
565     'section'     => 'billing',
566     'description' => 'Enable encryption of credit cards.',
567     'type'        => 'checkbox',
568   },
569
570   {
571     'key'         => 'encryptionmodule',
572     'section'     => 'billing',
573     'description' => 'Use which module for encryption?',
574     'type'        => 'text',
575   },
576
577   {
578     'key'         => 'encryptionpublickey',
579     'section'     => 'billing',
580     'description' => 'Your RSA Public Key - Required if Encryption is turned on.',
581     'type'        => 'textarea',
582   },
583
584   {
585     'key'         => 'encryptionprivatekey',
586     'section'     => 'billing',
587     '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.',
588     'type'        => 'textarea',
589   },
590
591   {
592     'key'         => 'business-onlinepayment',
593     'section'     => 'billing',
594     '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.',
595     'type'        => 'textarea',
596   },
597
598   {
599     'key'         => 'business-onlinepayment-ach',
600     'section'     => 'billing',
601     '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.',
602     'type'        => 'textarea',
603   },
604
605   {
606     'key'         => 'business-onlinepayment-description',
607     'section'     => 'billing',
608     '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)',
609     'type'        => 'text',
610   },
611
612   {
613     'key'         => 'business-onlinepayment-email-override',
614     'section'     => 'billing',
615     'description' => 'Email address used instead of customer email address when submitting a BOP transaction.',
616     'type'        => 'text',
617   },
618
619   {
620     'key'         => 'countrydefault',
621     'section'     => 'UI',
622     'description' => 'Default two-letter country code (if not supplied, the default is `US\')',
623     'type'        => 'text',
624   },
625
626   {
627     'key'         => 'date_format',
628     'section'     => 'UI',
629     'description' => 'Format for displaying dates',
630     'type'        => 'select',
631     'select_hash' => [
632                        '%m/%d/%Y' => 'MM/DD/YYYY',
633                        '%Y/%m/%d' => 'YYYY/MM/DD',
634                      ],
635   },
636
637   {
638     'key'         => 'deletecustomers',
639     'section'     => 'UI',
640     '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.',
641     'type'        => 'checkbox',
642   },
643
644   {
645     'key'         => 'deletepayments',
646     'section'     => 'billing',
647     '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.',
648     'type'        => [qw( checkbox text )],
649   },
650
651   {
652     'key'         => 'deletecredits',
653     'section'     => 'deprecated',
654     '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.',
655     'type'        => [qw( checkbox text )],
656   },
657
658   {
659     'key'         => 'deleterefunds',
660     'section'     => 'billing',
661     'description' => 'Enable deletion of unclosed refunds.  Be very careful!  Only delete refunds that were data-entry errors, not adjustments.',
662     'type'        => 'checkbox',
663   },
664
665   {
666     'key'         => 'dirhash',
667     'section'     => 'shell',
668     '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>',
669     'type'        => 'text',
670   },
671
672   {
673     'key'         => 'disable_customer_referrals',
674     'section'     => 'UI',
675     'description' => 'Disable new customer-to-customer referrals in the web interface',
676     'type'        => 'checkbox',
677   },
678
679   {
680     'key'         => 'editreferrals',
681     'section'     => 'UI',
682     'description' => 'Enable advertising source modification for existing customers',
683     'type'       => 'checkbox',
684   },
685
686   {
687     'key'         => 'emailinvoiceonly',
688     'section'     => 'billing',
689     'description' => 'Disables postal mail invoices',
690     'type'       => 'checkbox',
691   },
692
693   {
694     'key'         => 'disablepostalinvoicedefault',
695     'section'     => 'billing',
696     '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>.',
697     'type'       => 'checkbox',
698   },
699
700   {
701     'key'         => 'emailinvoiceauto',
702     'section'     => 'billing',
703     'description' => 'Automatically adds new accounts to the email invoice list',
704     'type'       => 'checkbox',
705   },
706
707   {
708     'key'         => 'emailinvoiceautoalways',
709     'section'     => 'billing',
710     'description' => 'Automatically adds new accounts to the email invoice list even when the list contains email addresses',
711     'type'       => 'checkbox',
712   },
713
714   {
715     'key'         => 'exclude_ip_addr',
716     'section'     => '',
717     'description' => 'Exclude these from the list of available broadband service IP addresses. (One per line)',
718     'type'        => 'textarea',
719   },
720   
721   {
722     'key'         => 'hidecancelledpackages',
723     'section'     => 'UI',
724     'description' => 'Prevent cancelled packages from showing up in listings (though they will still be in the database)',
725     'type'        => 'checkbox',
726   },
727
728   {
729     'key'         => 'hidecancelledcustomers',
730     'section'     => 'UI',
731     'description' => 'Prevent customers with only cancelled packages from showing up in listings (though they will still be in the database)',
732     'type'        => 'checkbox',
733   },
734
735   {
736     'key'         => 'home',
737     'section'     => 'required',
738     'description' => 'For new users, prefixed to username to create a directory name.  Should have a leading but not a trailing slash.',
739     'type'        => 'text',
740   },
741
742   {
743     'key'         => 'invoice_from',
744     'section'     => 'required',
745     'description' => 'Return address on email invoices',
746     'type'        => 'text',
747   },
748
749   {
750     'key'         => 'invoice_template',
751     'section'     => 'required',
752     'description' => 'Required template file for invoices.  See the <a href="../docs/billing.html">billing documentation</a> for details.',
753     'type'        => 'textarea',
754   },
755
756   {
757     'key'         => 'invoice_html',
758     'section'     => 'billing',
759     'description' => 'Optional HTML template for invoices.  See the <a href="../docs/billing.html">billing documentation</a> for details.',
760
761     'type'        => 'textarea',
762   },
763
764   {
765     'key'         => 'invoice_htmlnotes',
766     'section'     => 'billing',
767     'description' => 'Notes section for HTML invoices.  Defaults to the same data in invoice_latexnotes if not specified.',
768     'type'        => 'textarea',
769   },
770
771   {
772     'key'         => 'invoice_htmlfooter',
773     'section'     => 'billing',
774     'description' => 'Footer for HTML invoices.  Defaults to the same data in invoice_latexfooter if not specified.',
775     'type'        => 'textarea',
776   },
777
778   {
779     'key'         => 'invoice_htmlreturnaddress',
780     'section'     => 'billing',
781     'description' => 'Return address for HTML invoices.  Defaults to the same data in invoice_latexreturnaddress if not specified.',
782     'type'        => 'textarea',
783   },
784
785   {
786     'key'         => 'invoice_latex',
787     'section'     => 'billing',
788     'description' => 'Optional LaTeX template for typeset PostScript invoices.  See the <a href="../docs/billing.html">billing documentation</a> for details.',
789     'type'        => 'textarea',
790   },
791
792   {
793     'key'         => 'invoice_latexnotes',
794     'section'     => 'billing',
795     'description' => 'Notes section for LaTeX typeset PostScript invoices.',
796     'type'        => 'textarea',
797   },
798
799   {
800     'key'         => 'invoice_latexfooter',
801     'section'     => 'billing',
802     'description' => 'Footer for LaTeX typeset PostScript invoices.',
803     'type'        => 'textarea',
804   },
805
806   {
807     'key'         => 'invoice_latexreturnaddress',
808     'section'     => 'billing',
809     'description' => 'Return address for LaTeX typeset PostScript invoices.',
810     'type'        => 'textarea',
811   },
812
813   {
814     'key'         => 'invoice_latexsmallfooter',
815     'section'     => 'billing',
816     'description' => 'Optional small footer for multi-page LaTeX typeset PostScript invoices.',
817     'type'        => 'textarea',
818   },
819
820   {
821     'key'         => 'invoice_email_pdf',
822     'section'     => 'billing',
823     '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.',
824     'type'        => 'checkbox'
825   },
826
827   {
828     'key'         => 'invoice_email_pdf_note',
829     'section'     => 'billing',
830     'description' => 'If defined, this text will replace the default plain text invoice as the body of emailed PDF invoices.',
831     'type'        => 'textarea'
832   },
833
834
835   { 
836     'key'         => 'invoice_default_terms',
837     'section'     => 'billing',
838     'description' => 'Optional default invoice term, used to calculate a due date printed on invoices.',
839     'type'        => 'select',
840     'select_enum' => [ '', 'Payable upon receipt', 'Net 0', 'Net 10', 'Net 15', 'Net 30', 'Net 45', 'Net 60' ],
841   },
842
843   {
844     'key'         => 'payment_receipt_email',
845     'section'     => 'billing',
846     '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/~mjd/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>',
847     'type'        => [qw( checkbox textarea )],
848   },
849
850   {
851     'key'         => 'lpr',
852     'section'     => 'required',
853     'description' => 'Print command for paper invoices, for example `lpr -h\'',
854     'type'        => 'text',
855   },
856
857   {
858     'key'         => 'lpr-postscript_prefix',
859     'section'     => 'billing',
860     'description' => 'Raw printer commands prepended to the beginning of postscript print jobs (evaluated as a double-quoted perl string - backslash escapes are available)',
861     'type'        => 'text',
862   },
863
864   {
865     'key'         => 'lpr-postscript_suffix',
866     'section'     => 'billing',
867     'description' => 'Raw printer commands added to the end of postscript print jobs (evaluated as a double-quoted perl string - backslash escapes are available)',
868     'type'        => 'text',
869   },
870
871   {
872     'key'         => 'money_char',
873     'section'     => '',
874     'description' => 'Currency symbol - defaults to `$\'',
875     'type'        => 'text',
876   },
877
878   {
879     'key'         => 'defaultrecords',
880     'section'     => 'BIND',
881     'description' => 'DNS entries to add automatically when creating a domain',
882     'type'        => 'editlist',
883     'editlist_parts' => [ { type=>'text' },
884                           { type=>'immutable', value=>'IN' },
885                           { type=>'select',
886                             select_enum=>{ map { $_=>$_ } qw(A CNAME MX NS TXT)} },
887                           { type=> 'text' }, ],
888   },
889
890   {
891     'key'         => 'passwordmin',
892     'section'     => 'password',
893     'description' => 'Minimum password length (default 6)',
894     'type'        => 'text',
895   },
896
897   {
898     'key'         => 'passwordmax',
899     'section'     => 'password',
900     'description' => 'Maximum password length (default 8) (don\'t set this over 12 if you need to import or export crypt() passwords)',
901     'type'        => 'text',
902   },
903
904   {
905     'key' => 'password-noampersand',
906     'section' => 'password',
907     'description' => 'Disallow ampersands in passwords',
908     'type' => 'checkbox',
909   },
910
911   {
912     'key' => 'password-noexclamation',
913     'section' => 'password',
914     'description' => 'Disallow exclamations in passwords (Not setting this could break old text Livingston or Cistron Radius servers)',
915     'type' => 'checkbox',
916   },
917
918   {
919     'key'         => 'referraldefault',
920     'section'     => 'UI',
921     'description' => 'Default referral, specified by refnum',
922     'type'        => 'text',
923   },
924
925 #  {
926 #    'key'         => 'registries',
927 #    'section'     => 'required',
928 #    'description' => 'Directory which contains domain registry information.  Each registry is a directory.',
929 #  },
930
931   {
932     'key'         => 'maxsearchrecordsperpage',
933     'section'     => 'UI',
934     'description' => 'If set, number of search records to return per page.',
935     'type'        => 'text',
936   },
937
938   {
939     'key'         => 'session-start',
940     'section'     => 'session',
941     '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.',
942     'type'        => 'text',
943   },
944
945   {
946     'key'         => 'session-stop',
947     'section'     => 'session',
948     '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.',
949     'type'        => 'text',
950   },
951
952   {
953     'key'         => 'shells',
954     'section'     => 'required',
955     '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.',
956     'type'        => 'textarea',
957   },
958
959   {
960     'key'         => 'showpasswords',
961     'section'     => 'UI',
962     'description' => 'Display unencrypted user passwords in the backend (employee) web interface',
963     'type'        => 'checkbox',
964   },
965
966   {
967     'key'         => 'signupurl',
968     'section'     => 'UI',
969     'description' => 'if you are using customer-to-customer referrals, and you enter the URL of your <a href="../docs/signup.html">signup server CGI</a>, the customer view screen will display a customized link to the signup server with the appropriate customer as referral',
970     'type'        => 'text',
971   },
972
973   {
974     'key'         => 'smtpmachine',
975     'section'     => 'required',
976     'description' => 'SMTP relay for Freeside\'s outgoing mail',
977     'type'        => 'text',
978   },
979
980   {
981     'key'         => 'soadefaultttl',
982     'section'     => 'BIND',
983     'description' => 'SOA default TTL for new domains.',
984     'type'        => 'text',
985   },
986
987   {
988     'key'         => 'soaemail',
989     'section'     => 'BIND',
990     'description' => 'SOA email for new domains, in BIND form (`.\' instead of `@\'), with trailing `.\'',
991     'type'        => 'text',
992   },
993
994   {
995     'key'         => 'soaexpire',
996     'section'     => 'BIND',
997     'description' => 'SOA expire for new domains',
998     'type'        => 'text',
999   },
1000
1001   {
1002     'key'         => 'soamachine',
1003     'section'     => 'BIND',
1004     'description' => 'SOA machine for new domains, with trailing `.\'',
1005     'type'        => 'text',
1006   },
1007
1008   {
1009     'key'         => 'soarefresh',
1010     'section'     => 'BIND',
1011     'description' => 'SOA refresh for new domains',
1012     'type'        => 'text',
1013   },
1014
1015   {
1016     'key'         => 'soaretry',
1017     'section'     => 'BIND',
1018     'description' => 'SOA retry for new domains',
1019     'type'        => 'text',
1020   },
1021
1022   {
1023     'key'         => 'statedefault',
1024     'section'     => 'UI',
1025     'description' => 'Default state or province (if not supplied, the default is `CA\')',
1026     'type'        => 'text',
1027   },
1028
1029   {
1030     'key'         => 'unsuspendauto',
1031     'section'     => 'billing',
1032     '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',
1033     'type'        => 'checkbox',
1034   },
1035
1036   {
1037     'key'         => 'unsuspend-always_adjust_next_bill_date',
1038     'section'     => 'billing',
1039     '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.',
1040     'type'        => 'checkbox',
1041   },
1042
1043   {
1044     'key'         => 'usernamemin',
1045     'section'     => 'username',
1046     'description' => 'Minimum username length (default 2)',
1047     'type'        => 'text',
1048   },
1049
1050   {
1051     'key'         => 'usernamemax',
1052     'section'     => 'username',
1053     'description' => 'Maximum username length',
1054     'type'        => 'text',
1055   },
1056
1057   {
1058     'key'         => 'username-ampersand',
1059     'section'     => 'username',
1060     '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.',
1061     'type'        => 'checkbox',
1062   },
1063
1064   {
1065     'key'         => 'username-letter',
1066     'section'     => 'username',
1067     'description' => 'Usernames must contain at least one letter',
1068     'type'        => 'checkbox',
1069   },
1070
1071   {
1072     'key'         => 'username-letterfirst',
1073     'section'     => 'username',
1074     'description' => 'Usernames must start with a letter',
1075     'type'        => 'checkbox',
1076   },
1077
1078   {
1079     'key'         => 'username-noperiod',
1080     'section'     => 'username',
1081     'description' => 'Disallow periods in usernames',
1082     'type'        => 'checkbox',
1083   },
1084
1085   {
1086     'key'         => 'username-nounderscore',
1087     'section'     => 'username',
1088     'description' => 'Disallow underscores in usernames',
1089     'type'        => 'checkbox',
1090   },
1091
1092   {
1093     'key'         => 'username-nodash',
1094     'section'     => 'username',
1095     'description' => 'Disallow dashes in usernames',
1096     'type'        => 'checkbox',
1097   },
1098
1099   {
1100     'key'         => 'username-uppercase',
1101     'section'     => 'username',
1102     'description' => 'Allow uppercase characters in usernames',
1103     'type'        => 'checkbox',
1104   },
1105
1106   { 
1107     'key'         => 'username-percent',
1108     'section'     => 'username',
1109     'description' => 'Allow the percent character (%) in usernames.',
1110     'type'        => 'checkbox',
1111   },
1112
1113   {
1114     'key'         => 'safe-part_bill_event',
1115     'section'     => 'UI',
1116     'description' => 'Validates invoice event expressions against a preset list.  Useful for webdemos, annoying to powerusers.',
1117     'type'        => 'checkbox',
1118   },
1119
1120   {
1121     'key'         => 'show_ss',
1122     'section'     => 'UI',
1123     'description' => 'Turns on display/collection of social security numbers in the web interface.  Sometimes required by electronic check (ACH) processors.',
1124     'type'        => 'checkbox',
1125   },
1126
1127   {
1128     'key'         => 'show_stateid',
1129     'section'     => 'UI',
1130     'description' => "Turns on display/collection of driver's license/state issued id numbers in the web interface.  Sometimes required by electronic check (ACH) processors.",
1131     'type'        => 'checkbox',
1132   },
1133
1134   {
1135     'key'         => 'show_bankstate',
1136     'section'     => 'UI',
1137     'description' => "Turns on display/collection of state for bank accounts in the web interface.  Sometimes required by electronic check (ACH) processors.",
1138     'type'        => 'checkbox',
1139   },
1140
1141   { 
1142     'key'         => 'agent_defaultpkg',
1143     'section'     => 'UI',
1144     'description' => 'Setting this option will cause new packages to be available to all agent types by default.',
1145     'type'        => 'checkbox',
1146   },
1147
1148   {
1149     'key'         => 'legacy_link',
1150     'section'     => 'UI',
1151     'description' => 'Display options in the web interface to link legacy pre-Freeside services.',
1152     'type'        => 'checkbox',
1153   },
1154
1155   {
1156     'key'         => 'legacy_link-steal',
1157     'section'     => 'UI',
1158     'description' => 'Allow "stealing" an already-audited service from one customer (or package) to another using the link function.',
1159     'type'        => 'checkbox',
1160   },
1161
1162   {
1163     'key'         => 'queue_dangerous_controls',
1164     'section'     => 'UI',
1165     '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.',
1166     'type'        => 'checkbox',
1167   },
1168
1169   {
1170     'key'         => 'security_phrase',
1171     'section'     => 'password',
1172     'description' => 'Enable the tracking of a "security phrase" with each account.  Not recommended, as it is vulnerable to social engineering.',
1173     'type'        => 'checkbox',
1174   },
1175
1176   {
1177     'key'         => 'locale',
1178     'section'     => 'UI',
1179     'description' => 'Message locale',
1180     'type'        => 'select',
1181     'select_enum' => [ qw(en_US) ],
1182   },
1183
1184   {
1185     'key'         => 'signup_server-payby',
1186     'section'     => '',
1187     'description' => 'Acceptable payment types for the signup server',
1188     'type'        => 'selectmultiple',
1189     'select_enum' => [ qw(CARD DCRD CHEK DCHK LECB PREPAY BILL COMP) ],
1190   },
1191
1192   {
1193     'key'         => 'signup_server-default_agentnum',
1194     'section'     => '',
1195     'description' => 'Default agent for the signup server',
1196     'type'        => 'select-sub',
1197     'options_sub' => sub { require FS::Record;
1198                            require FS::agent;
1199                            map { $_->agentnum => $_->agent }
1200                                FS::Record::qsearch('agent', { disabled=>'' } );
1201                          },
1202     'option_sub'  => sub { require FS::Record;
1203                            require FS::agent;
1204                            my $agent = FS::Record::qsearchs(
1205                              'agent', { 'agentnum'=>shift }
1206                            );
1207                            $agent ? $agent->agent : '';
1208                          },
1209   },
1210
1211   {
1212     'key'         => 'signup_server-default_refnum',
1213     'section'     => '',
1214     'description' => 'Default advertising source for the signup server',
1215     'type'        => 'select-sub',
1216     'options_sub' => sub { require FS::Record;
1217                            require FS::part_referral;
1218                            map { $_->refnum => $_->referral }
1219                                FS::Record::qsearch( 'part_referral', 
1220                                                     { 'disabled' => '' }
1221                                                   );
1222                          },
1223     'option_sub'  => sub { require FS::Record;
1224                            require FS::part_referral;
1225                            my $part_referral = FS::Record::qsearchs(
1226                              'part_referral', { 'refnum'=>shift } );
1227                            $part_referral ? $part_referral->referral : '';
1228                          },
1229   },
1230
1231   {
1232     'key'         => 'signup_server-default_pkgpart',
1233     'section'     => '',
1234     'description' => 'Default pakcage for the signup server',
1235     'type'        => 'select-sub',
1236     'options_sub' => sub { require FS::Record;
1237                            require FS::part_pkg;
1238                            map { $_->pkgpart => $_->pkg.' - '.$_->comment }
1239                                FS::Record::qsearch( 'part_pkg',
1240                                                     { 'disabled' => ''}
1241                                                   );
1242                          },
1243     'option_sub'  => sub { require FS::Record;
1244                            require FS::part_pkg;
1245                            my $part_pkg = FS::Record::qsearchs(
1246                              'part_pkg', { 'pkgpart'=>shift }
1247                            );
1248                            $part_pkg
1249                              ? $part_pkg->pkg.' - '.$part_pkg->comment
1250                              : '';
1251                          },
1252   },
1253
1254   {
1255     'key'         => 'show-msgcat-codes',
1256     'section'     => 'UI',
1257     'description' => 'Show msgcat codes in error messages.  Turn this option on before reporting errors to the mailing list.',
1258     'type'        => 'checkbox',
1259   },
1260
1261   {
1262     'key'         => 'signup_server-realtime',
1263     'section'     => '',
1264     'description' => 'Run billing for signup server signups immediately, and do not provision accounts which subsequently have a balance.',
1265     'type'        => 'checkbox',
1266   },
1267   {
1268     'key'         => 'signup_server-classnum2',
1269     'section'     => '',
1270     'description' => 'Package Class for first optional purchase',
1271     'type'        => 'select-sub',
1272     'options_sub' => sub { require FS::Record;
1273                            require FS::pkg_class;
1274                            map { $_->classnum => $_->classname }
1275                                FS::Record::qsearch('pkg_class', {} );
1276                          },
1277     'option_sub'  => sub { require FS::Record;
1278                            require FS::pkg_class;
1279                            my $pkg_class = FS::Record::qsearchs(
1280                              'pkg_class', { 'classnum'=>shift }
1281                            );
1282                            $pkg_class ? $pkg_class->classname : '';
1283                          },
1284   },
1285
1286   {
1287     'key'         => 'signup_server-classnum3',
1288     'section'     => '',
1289     'description' => 'Package Class for second optional purchase',
1290     'type'        => 'select-sub',
1291     'options_sub' => sub { require FS::Record;
1292                            require FS::pkg_class;
1293                            map { $_->classnum => $_->classname }
1294                                FS::Record::qsearch('pkg_class', {} );
1295                          },
1296     'option_sub'  => sub { require FS::Record;
1297                            require FS::pkg_class;
1298                            my $pkg_class = FS::Record::qsearchs(
1299                              'pkg_class', { 'classnum'=>shift }
1300                            );
1301                            $pkg_class ? $pkg_class->classname : '';
1302                          },
1303   },
1304
1305   {
1306     'key'         => 'backend-realtime',
1307     'section'     => '',
1308     'description' => 'Run billing for backend signups immediately.',
1309     'type'        => 'checkbox',
1310   },
1311
1312   {
1313     'key'         => 'declinetemplate',
1314     'section'     => 'billing',
1315     'description' => 'Template file for credit card decline emails.',
1316     'type'        => 'textarea',
1317   },
1318
1319   {
1320     'key'         => 'emaildecline',
1321     'section'     => 'billing',
1322     'description' => 'Enable emailing of credit card decline notices.',
1323     'type'        => 'checkbox',
1324   },
1325
1326   {
1327     'key'         => 'emaildecline-exclude',
1328     'section'     => 'billing',
1329     'description' => 'List of error messages that should not trigger email decline notices, one per line.',
1330     'type'        => 'textarea',
1331   },
1332
1333   {
1334     'key'         => 'cancelmessage',
1335     'section'     => 'billing',
1336     'description' => 'Template file for cancellation emails.',
1337     'type'        => 'textarea',
1338   },
1339
1340   {
1341     'key'         => 'cancelsubject',
1342     'section'     => 'billing',
1343     'description' => 'Subject line for cancellation emails.',
1344     'type'        => 'text',
1345   },
1346
1347   {
1348     'key'         => 'emailcancel',
1349     'section'     => 'billing',
1350     'description' => 'Enable emailing of cancellation notices.  Make sure to fill in the cancelmessage and cancelsubject configuration values as well.',
1351     'type'        => 'checkbox',
1352   },
1353
1354   {
1355     'key'         => 'require_cardname',
1356     'section'     => 'billing',
1357     'description' => 'Require an "Exact name on card" to be entered explicitly; don\'t default to using the first and last name.',
1358     'type'        => 'checkbox',
1359   },
1360
1361   {
1362     'key'         => 'enable_taxclasses',
1363     'section'     => 'billing',
1364     'description' => 'Enable per-package tax classes',
1365     'type'        => 'checkbox',
1366   },
1367
1368   {
1369     'key'         => 'require_taxclasses',
1370     'section'     => 'billing',
1371     'description' => 'Require a taxclass to be entered for every package',
1372     'type'        => 'checkbox',
1373   },
1374
1375   {
1376     'key'         => 'welcome_email',
1377     'section'     => '',
1378     '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/~mjd/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>',
1379     'type'        => 'textarea',
1380     'per_agent'   => 1,
1381   },
1382
1383   {
1384     'key'         => 'welcome_email-from',
1385     'section'     => '',
1386     'description' => 'From: address header for welcome email',
1387     'type'        => 'text',
1388     'per_agent'   => 1,
1389   },
1390
1391   {
1392     'key'         => 'welcome_email-subject',
1393     'section'     => '',
1394     'description' => 'Subject: header for welcome email',
1395     'type'        => 'text',
1396     'per_agent'   => 1,
1397   },
1398   
1399   {
1400     'key'         => 'welcome_email-mimetype',
1401     'section'     => '',
1402     'description' => 'MIME type for welcome email',
1403     'type'        => 'select',
1404     'select_enum' => [ 'text/plain', 'text/html' ],
1405     'per_agent'   => 1,
1406   },
1407
1408   {
1409     'key'         => 'welcome_letter',
1410     'section'     => '',
1411     '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/~mjd/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>',
1412     'type'        => 'textarea',
1413   },
1414
1415   {
1416     'key'         => 'warning_email',
1417     'section'     => '',
1418     '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/~mjd/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>',
1419     'type'        => 'textarea',
1420   },
1421
1422   {
1423     'key'         => 'warning_email-from',
1424     'section'     => '',
1425     'description' => 'From: address header for warning email',
1426     'type'        => 'text',
1427   },
1428
1429   {
1430     'key'         => 'warning_email-cc',
1431     'section'     => '',
1432     'description' => 'Additional recipient(s) (comma separated) for warning email when remaining usage reaches zero.',
1433     'type'        => 'text',
1434   },
1435
1436   {
1437     'key'         => 'warning_email-subject',
1438     'section'     => '',
1439     'description' => 'Subject: header for warning email',
1440     'type'        => 'text',
1441   },
1442   
1443   {
1444     'key'         => 'warning_email-mimetype',
1445     'section'     => '',
1446     'description' => 'MIME type for warning email',
1447     'type'        => 'select',
1448     'select_enum' => [ 'text/plain', 'text/html' ],
1449   },
1450
1451   {
1452     'key'         => 'payby',
1453     'section'     => 'billing',
1454     'description' => 'Available payment types.',
1455     'type'        => 'selectmultiple',
1456     'select_enum' => [ qw(CARD DCRD CHEK DCHK LECB BILL CASH WEST MCRD COMP) ],
1457   },
1458
1459   {
1460     'key'         => 'payby-default',
1461     'section'     => 'UI',
1462     'description' => 'Default payment type.  HIDE disables display of billing information and sets customers to BILL.',
1463     'type'        => 'select',
1464     'select_enum' => [ '', qw(CARD DCRD CHEK DCHK LECB BILL CASH WEST MCRD COMP HIDE) ],
1465   },
1466
1467   {
1468     'key'         => 'paymentforcedtobatch',
1469     'section'     => 'UI',
1470     'description' => 'Causes per customer payment entry to be forced to a batch processor rather than performed realtime.',
1471     'type'        => 'checkbox',
1472   },
1473
1474   {
1475     'key'         => 'svc_acct-notes',
1476     'section'     => 'UI',
1477     'description' => 'Extra HTML to be displayed on the Account View screen.',
1478     'type'        => 'textarea',
1479   },
1480
1481   {
1482     'key'         => 'radius-password',
1483     'section'     => '',
1484     'description' => 'RADIUS attribute for plain-text passwords.',
1485     'type'        => 'select',
1486     'select_enum' => [ 'Password', 'User-Password' ],
1487   },
1488
1489   {
1490     'key'         => 'radius-ip',
1491     'section'     => '',
1492     'description' => 'RADIUS attribute for IP addresses.',
1493     'type'        => 'select',
1494     'select_enum' => [ 'Framed-IP-Address', 'Framed-Address' ],
1495   },
1496
1497   {
1498     'key'         => 'svc_acct-alldomains',
1499     'section'     => '',
1500     '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.',
1501     'type'        => 'checkbox',
1502   },
1503
1504   {
1505     'key'         => 'dump-scpdest',
1506     'section'     => '',
1507     'description' => 'destination for scp database dumps: user@host:/path',
1508     'type'        => 'text',
1509   },
1510
1511   {
1512     'key'         => 'dump-pgpid',
1513     'section'     => '',
1514     '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.",
1515     'type'        => 'text',
1516   },
1517
1518   {
1519     'key'         => 'cvv-save',
1520     'section'     => 'billing',
1521     '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.',
1522     'type'        => 'selectmultiple',
1523     'select_enum' => \@card_types,
1524   },
1525
1526   {
1527     'key'         => 'allow_negative_charges',
1528     'section'     => 'billing',
1529     'description' => 'Allow negative charges.  Normally not used unless importing data from a legacy system that requires this.',
1530     'type'        => 'checkbox',
1531   },
1532   {
1533       'key'         => 'auto_unset_catchall',
1534       'section'     => '',
1535       '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.',
1536       'type'        => 'checkbox',
1537   },
1538
1539   {
1540     'key'         => 'system_usernames',
1541     'section'     => 'username',
1542     '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.',
1543     'type'        => 'textarea',
1544   },
1545
1546   {
1547     'key'         => 'cust_pkg-change_svcpart',
1548     'section'     => '',
1549     'description' => "When changing packages, move services even if svcparts don't match between old and new pacakge definitions.",
1550     'type'        => 'checkbox',
1551   },
1552
1553   {
1554     'key'         => 'disable_autoreverse',
1555     'section'     => 'BIND',
1556     'description' => 'Disable automatic synchronization of reverse-ARPA entries.',
1557     'type'        => 'checkbox',
1558   },
1559
1560   {
1561     'key'         => 'svc_www-enable_subdomains',
1562     'section'     => '',
1563     'description' => 'Enable selection of specific subdomains for virtual host creation.',
1564     'type'        => 'checkbox',
1565   },
1566
1567   {
1568     'key'         => 'svc_www-usersvc_svcpart',
1569     'section'     => '',
1570     'description' => 'Allowable service definition svcparts for virtual hosts, one per line.',
1571     'type'        => 'textarea',
1572   },
1573
1574   {
1575     'key'         => 'selfservice_server-primary_only',
1576     'section'     => '',
1577     'description' => 'Only allow primary accounts to access self-service functionality.',
1578     'type'        => 'checkbox',
1579   },
1580
1581   {
1582     'key'         => 'card_refund-days',
1583     'section'     => 'billing',
1584     'description' => 'After a payment, the number of days a refund link will be available for that payment.  Defaults to 120.',
1585     'type'        => 'text',
1586   },
1587
1588   {
1589     'key'         => 'agent-showpasswords',
1590     'section'     => '',
1591     'description' => 'Display unencrypted user passwords in the agent (reseller) interface',
1592     'type'        => 'checkbox',
1593   },
1594
1595   {
1596     'key'         => 'global_unique-username',
1597     'section'     => 'username',
1598     '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.',
1599     'type'        => 'select',
1600     'select_enum' => [ 'none', 'username', 'username@domain', 'disabled' ],
1601   },
1602
1603   {
1604     'key'         => 'svc_external-skip_manual',
1605     'section'     => 'UI',
1606     '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).',
1607     'type'        => 'checkbox',
1608   },
1609
1610   {
1611     'key'         => 'svc_external-display_type',
1612     'section'     => 'UI',
1613     'description' => 'Select a specific svc_external type to enable some UI changes specific to that type (i.e. artera_turbo).',
1614     'type'        => 'select',
1615     'select_enum' => [ 'generic', 'artera_turbo', ],
1616   },
1617
1618   {
1619     'key'         => 'ticket_system',
1620     'section'     => '',
1621     'description' => 'Ticketing system integration.  <b>RT_Internal</b> uses the built-in RT ticketing system (see the <a href="../docs/install-rt">integrated ticketing installation instructions</a>).   <b>RT_External</b> accesses an external RT installation in a separate database (local or remote).',
1622     'type'        => 'select',
1623     #'select_enum' => [ '', qw(RT_Internal RT_Libs RT_External) ],
1624     'select_enum' => [ '', qw(RT_Internal RT_External) ],
1625   },
1626
1627   {
1628     'key'         => 'ticket_system-default_queueid',
1629     'section'     => '',
1630     'description' => 'Default queue used when creating new customer tickets.',
1631     'type'        => 'select-sub',
1632     'options_sub' => sub {
1633                            my $conf = new FS::Conf;
1634                            if ( $conf->config('ticket_system') ) {
1635                              eval "use FS::TicketSystem;";
1636                              die $@ if $@;
1637                              FS::TicketSystem->queues();
1638                            } else {
1639                              ();
1640                            }
1641                          },
1642     'option_sub'  => sub { 
1643                            my $conf = new FS::Conf;
1644                            if ( $conf->config('ticket_system') ) {
1645                              eval "use FS::TicketSystem;";
1646                              die $@ if $@;
1647                              FS::TicketSystem->queue(shift);
1648                            } else {
1649                              '';
1650                            }
1651                          },
1652   },
1653
1654   {
1655     'key'         => 'ticket_system-custom_priority_field',
1656     'section'     => '',
1657     'description' => 'Custom field from the ticketing system to use as a custom priority classification.',
1658     'type'        => 'text',
1659   },
1660
1661   {
1662     'key'         => 'ticket_system-custom_priority_field-values',
1663     'section'     => '',
1664     'description' => 'Values for the custom field from the ticketing system to break down and sort customer ticket lists.',
1665     'type'        => 'textarea',
1666   },
1667
1668   {
1669     'key'         => 'ticket_system-custom_priority_field_queue',
1670     'section'     => '',
1671     'description' => 'Ticketing system queue in which the custom field specified in ticket_system-custom_priority_field is located.',
1672     'type'        => 'text',
1673   },
1674
1675   {
1676     'key'         => 'ticket_system-rt_external_datasrc',
1677     'section'     => '',
1678     '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>',
1679     'type'        => 'text',
1680
1681   },
1682
1683   {
1684     'key'         => 'ticket_system-rt_external_url',
1685     'section'     => '',
1686     'description' => 'With external RT integration, the URL for the external RT installation, for example, <code>https://rt.example.com/rt</code>',
1687     'type'        => 'text',
1688   },
1689
1690   {
1691     'key'         => 'company_name',
1692     'section'     => 'required',
1693     'description' => 'Your company name',
1694     'type'        => 'text',
1695   },
1696
1697   {
1698     'key'         => 'address2-search',
1699     'section'     => 'UI',
1700     'description' => 'Enable a "Unit" search box which searches the second address field',
1701     'type'        => 'checkbox',
1702   },
1703
1704   { 'key'         => 'referral_credit',
1705     'section'     => 'billing',
1706     'description' => "Enables one-time referral credits in the amount of one month <i>referred</i> customer's recurring fee (irregardless of frequency).",
1707     'type'        => 'checkbox',
1708   },
1709
1710   { 'key'         => 'selfservice_server-cache_module',
1711     'section'     => '',
1712     '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.',
1713     'type'        => 'select',
1714     'select_enum' => [ 'Cache::SharedMemoryCache', 'Cache::FileCache', ], # '_Database' ],
1715   },
1716
1717   {
1718     'key'         => 'hylafax',
1719     'section'     => '',
1720     '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).',
1721     'type'        => [qw( checkbox textarea )],
1722   },
1723
1724   {
1725     'key'         => 'svc_acct-usage_suspend',
1726     'section'     => 'billing',
1727     '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.',
1728     'type'        => 'checkbox',
1729   },
1730
1731   {
1732     'key'         => 'svc_acct-usage_unsuspend',
1733     'section'     => 'billing',
1734     '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.',
1735     'type'        => 'checkbox',
1736   },
1737
1738   {
1739     'key'         => 'svc_acct-usage_threshold',
1740     'section'     => 'billing',
1741     '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.',
1742     'type'        => 'text',
1743   },
1744
1745   {
1746     'key'         => 'cust-fields',
1747     'section'     => 'UI',
1748     'description' => 'Which customer fields to display on reports by default',
1749     'type'        => 'select',
1750     'select_hash' => [ FS::ConfDefaults->cust_fields_avail() ],
1751   },
1752
1753   {
1754     'key'         => 'cust_pkg-display_times',
1755     'section'     => 'UI',
1756     'description' => 'Display full timestamps (not just dates) for customer packages.  Useful if you are doing real-time things like hourly prepaid.',
1757     'type'        => 'checkbox',
1758   },
1759
1760   {
1761     'key'         => 'svc_acct-edit_uid',
1762     'section'     => 'shell',
1763     'description' => 'Allow UID editing.',
1764     'type'        => 'checkbox',
1765   },
1766
1767   {
1768     'key'         => 'svc_acct-edit_gid',
1769     'section'     => 'shell',
1770     'description' => 'Allow GID editing.',
1771     'type'        => 'checkbox',
1772   },
1773
1774   {
1775     'key'         => 'zone-underscore',
1776     'section'     => 'BIND',
1777     'description' => 'Allow underscores in zone names.  As underscores are illegal characters in zone names, this option is not recommended.',
1778     'type'        => 'checkbox',
1779   },
1780
1781   {
1782     'key'         => 'echeck-nonus',
1783     'section'     => 'billing',
1784     'description' => 'Disable ABA-format account checking for Electronic Check payment info',
1785     'type'        => 'checkbox',
1786   },
1787
1788   {
1789     'key'         => 'voip-cust_cdr_spools',
1790     'section'     => '',
1791     'description' => 'Enable the per-customer option for individual CDR spools.',
1792     'type'        => 'checkbox',
1793   },
1794
1795   {
1796     'key'         => 'svc_forward-arbitrary_dst',
1797     'section'     => '',
1798     '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.",
1799     'type'        => 'checkbox',
1800   },
1801
1802   {
1803     'key'         => 'tax-ship_address',
1804     'section'     => 'billing',
1805     'description' => 'By default, tax calculations are done based on the billing address.  Enable this switch to calculate tax based on the shipping address instead.  Note: Tax reports can take a long time when enabled.',
1806     'type'        => 'checkbox',
1807   },
1808
1809   {
1810     'key'         => 'batch-enable',
1811     'section'     => 'billing',
1812     'description' => 'Enable credit card and/or ACH batching - leave disabled for real-time installations.',
1813     'type'        => 'checkbox',
1814   },
1815
1816   {
1817     'key'         => 'batch-default_format',
1818     'section'     => 'billing',
1819     'description' => 'Default format for batches.',
1820     'type'        => 'select',
1821     'select_enum' => [ 'csv-td_canada_trust-merchant_pc_batch',
1822                        'csv-chase_canada-E-xactBatch', 'BoM', 'PAP',
1823                        'ach-spiritone',
1824                     ]
1825   },
1826
1827   {
1828     'key'         => 'batch-fixed_format-CARD',
1829     'section'     => 'billing',
1830     'description' => 'Fixed (unchangeable) format for credit card batches.',
1831     'type'        => 'select',
1832     'select_enum' => [ 'csv-td_canada_trust-merchant_pc_batch', 'BoM', 'PAP' ,
1833                        'csv-chase_canada-E-xactBatch', 'BoM', 'PAP' ]
1834   },
1835
1836   {
1837     'key'         => 'batch-fixed_format-CHEK',
1838     'section'     => 'billing',
1839     'description' => 'Fixed (unchangeable) format for electronic check batches.',
1840     'type'        => 'select',
1841     'select_enum' => [ 'csv-td_canada_trust-merchant_pc_batch', 'BoM', 'PAP',
1842                        'ach-spiritone',
1843                      ]
1844   },
1845
1846   {
1847     'key'         => 'batch-increment_expiration',
1848     'section'     => 'billing',
1849     'description' => 'Increment expiration date years in batches until cards are current.  Make sure this is acceptable to your batching provider before enabling.',
1850     'type'        => 'checkbox'
1851   },
1852
1853   {
1854     'key'         => 'batchconfig-BoM',
1855     'section'     => 'billing',
1856     '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',
1857     'type'        => 'textarea',
1858   },
1859
1860   {
1861     'key'         => 'batchconfig-PAP',
1862     'section'     => 'billing',
1863     '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',
1864     'type'        => 'textarea',
1865   },
1866
1867   {
1868     'key'         => 'batchconfig-csv-chase_canada-E-xactBatch',
1869     'section'     => 'billing',
1870     'description' => 'Gateway ID for Chase Canada E-xact batching',
1871     'type'        => 'text',
1872   },
1873
1874   {
1875     'key'         => 'payment_history-years',
1876     'section'     => 'UI',
1877     'description' => 'Number of years of payment history to show by default.  Currently defaults to 2.',
1878     'type'        => 'text',
1879   },
1880
1881   {
1882     'key'         => 'cust_main-use_comments',
1883     'section'     => 'UI',
1884     'description' => 'Display free form comments on the customer edit screen.  Useful as a scratch pad.',
1885     'type'        => 'checkbox',
1886   },
1887
1888   {
1889     'key'         => 'cust_main-disable_notes',
1890     'section'     => 'UI',
1891     'description' => 'Disable new style customer notes - timestamped and user identified customer notes.  Useful in tracking who did what.',
1892     'type'        => 'checkbox',
1893   },
1894
1895   {
1896     'key'         => 'cust_main_note-display_times',
1897     'section'     => 'UI',
1898     'description' => 'Display full timestamps (not just dates) for customer notes.',
1899     'type'        => 'checkbox',
1900   },
1901
1902   {
1903     'key'         => 'cust_main-ticket_statuses',
1904     'section'     => 'UI',
1905     'description' => 'Show tickets with these statuses on the customer view page.',
1906     'type'        => 'selectmultiple',
1907     'select_enum' => [qw( new open stalled resolved rejected deleted )],
1908   },
1909
1910   {
1911     'key'         => 'cust_main-max_tickets',
1912     'section'     => 'UI',
1913     'description' => 'Maximum number of tickets to show on the customer view page.',
1914     'type'        => 'text',
1915   },
1916
1917   {
1918     'key'         => 'cust_main-skeleton_tables',
1919     'section'     => '',
1920     '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.',
1921     'type'        => 'textarea',
1922   },
1923
1924   {
1925     'key'         => 'cust_main-skeleton_custnum',
1926     'section'     => '',
1927     'description' => 'Customer number specifying the source data to copy into skeleton tables for new customers.',
1928     'type'        => 'text',
1929   },
1930
1931   {
1932     'key'         => 'cust_main-enable_birthdate',
1933     'section'     => 'UI',
1934     'descritpion' => 'Enable tracking of a birth date with each customer record',
1935     'type'        => 'checkbox',
1936   },
1937
1938   {
1939     'key'         => 'support-key',
1940     'section'     => '',
1941     '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.',
1942     'type'        => 'text',
1943   },
1944
1945   {
1946     'key'         => 'card-types',
1947     'section'     => 'billing',
1948     'description' => 'Select one or more card types to enable only those card types.  If no card types are selected, all card types are available.',
1949     'type'        => 'selectmultiple',
1950     'select_enum' => \@card_types,
1951   },
1952
1953   {
1954     'key'         => 'disable-fuzzy',
1955     'section'     => 'UI',
1956     'description' => 'Disable fuzzy searching.  Speeds up searching for large sites, but only shows exact matches.',
1957     'type'        => 'checkbox',
1958   },
1959
1960   { 'key'         => 'pkg_referral',
1961     'section'     => '',
1962     'description' => 'Enable package-specific advertising sources.',
1963     'type'        => 'checkbox',
1964   },
1965
1966   { 'key'         => 'pkg_referral-multiple',
1967     'section'     => '',
1968     'description' => 'In addition, allow multiple advertising sources to be associated with a single package.',
1969     'type'        => 'checkbox',
1970   },
1971
1972   {
1973     'key'         => 'dashboard-toplist',
1974     'section'     => 'UI',
1975     'description' => 'List of items to display on the top of the front page',
1976     'type'        => 'textarea',
1977   },
1978
1979   {
1980     'key'         => 'impending_recur_template',
1981     'section'     => 'billing',
1982     'description' => 'Template file for alerts about looming first time recurrant billing.  See the <a href="http://search.cpan.org/~mjd/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>',
1983 # <li><code>$payby</code> <li><code>$expdate</code> most likely only confuse
1984     'type'        => 'textarea',
1985   },
1986
1987   {
1988     'key'         => 'logo.png',
1989     'section'     => 'billing',  #? 
1990     'description' => 'An image to include in some types of invoices',
1991     'type'        => 'binary',
1992   },
1993
1994   {
1995     'key'         => 'logo.eps',
1996     'section'     => 'billing',  #? 
1997     'description' => 'An image to include in some types of invoices',
1998     'type'        => 'binary',
1999   },
2000
2001   {
2002     'key'         => 'selfservice-ignore_quantity',
2003     'section'     => '',
2004     'description' => 'Ignores service quantity restrictions in self-service context.  Strongly not recommended - just set your quantities correctly in the first place.',
2005     'type'        => 'checkbox',
2006   },
2007
2008   {
2009     'key'         => 'disable_setup_suspended_pkgs',
2010     'section'     => 'billing',
2011     'description' => 'Disables charging of setup fees for suspended packages.',
2012     'type'       => 'checkbox',
2013   },
2014
2015   {
2016     'key' => 'password-generated-allcaps',
2017     'section' => 'password',
2018     'description' => 'Causes passwords automatically generated to consist entirely of capital letters',
2019     'type' => 'checkbox',
2020   },
2021
2022   {
2023     'key'         => 'datavolume-forcemegabytes',
2024     'section'     => 'UI',
2025     'description' => 'All data volumes are expressed in megabytes',
2026     'type'        => 'checkbox',
2027   },
2028
2029   {
2030     'key'         => 'datavolume-significantdigits',
2031     'section'     => 'UI',
2032     'description' => 'number of significant digits to use to represent data volumes',
2033     'type'        => 'text',
2034   },
2035
2036   {
2037     'key'         => 'disable_void_after',
2038     'section'     => 'billing',
2039     'description' => 'Number of seconds after which freeside won\'t attempt to VOID a payment first when performing a refund.',
2040     'type'        => 'text',
2041   },
2042
2043   {
2044     'key'         => 'disable_line_item_date_ranges',
2045     'section'     => 'billing',
2046     'description' => 'Prevent freeside from automatically generating date ranges on invoice line items.',
2047     'type'        => 'checkbox',
2048   },
2049
2050 );
2051
2052 1;