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