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