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