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