delete invoices, RT#4048
[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::payby;
12 use FS::conf;
13 use FS::Record qw(qsearch qsearchs);
14 use FS::UID qw(dbh datasrc use_confcompat);
15
16 $base_dir = '%%%FREESIDE_CONF%%%';
17
18 $DEBUG = 0;
19
20 =head1 NAME
21
22 FS::Conf - Freeside configuration values
23
24 =head1 SYNOPSIS
25
26   use FS::Conf;
27
28   $conf = new FS::Conf;
29
30   $value = $conf->config('key');
31   @list  = $conf->config('key');
32   $bool  = $conf->exists('key');
33
34   $conf->touch('key');
35   $conf->set('key' => 'value');
36   $conf->delete('key');
37
38   @config_items = $conf->config_items;
39
40 =head1 DESCRIPTION
41
42 Read and write Freeside configuration values.  Keys currently map to filenames,
43 but this may change in the future.
44
45 =head1 METHODS
46
47 =over 4
48
49 =item new
50
51 Create a new configuration object.
52
53 =cut
54
55 sub new {
56   my($proto) = @_;
57   my($class) = ref($proto) || $proto;
58   my($self) = { 'base_dir' => $base_dir };
59   bless ($self, $class);
60 }
61
62 =item base_dir
63
64 Returns the base directory.  By default this is /usr/local/etc/freeside.
65
66 =cut
67
68 sub base_dir {
69   my($self) = @_;
70   my $base_dir = $self->{base_dir};
71   -e $base_dir or die "FATAL: $base_dir doesn't exist!";
72   -d $base_dir or die "FATAL: $base_dir isn't a directory!";
73   -r $base_dir or die "FATAL: Can't read $base_dir!";
74   -x $base_dir or die "FATAL: $base_dir not searchable (executable)!";
75   $base_dir =~ /^(.*)$/;
76   $1;
77 }
78
79 =item conf KEY [ AGENTNUM [ NODEFAULT ] ]
80
81 Returns the L<FS::conf> record for the key and agent.
82
83 =cut
84
85 sub conf {
86   my $self = shift;
87   $self->_config(@_);
88 }
89
90 =item config KEY [ AGENTNUM [ NODEFAULT ] ]
91
92 Returns the configuration value or values (depending on context) for key.
93 The optional agent number selects an agent specific value instead of the
94 global default if one is present.  If NODEFAULT is true only the agent
95 specific value(s) is returned.
96
97 =cut
98
99 sub _usecompat {
100   my ($self, $method) = (shift, shift);
101   carp "NO CONFIGURATION RECORDS FOUND -- USING COMPATIBILITY MODE"
102     if use_confcompat;
103   my $compat = new FS::Conf_compat17 ("$base_dir/conf." . datasrc);
104   $compat->$method(@_);
105 }
106
107 sub _config {
108   my($self,$name,$agentnum,$agentonly)=@_;
109   my $hashref = { 'name' => $name };
110   $hashref->{agentnum} = $agentnum;
111   local $FS::Record::conf = undef;  # XXX evil hack prevents recursion
112   my $cv = FS::Record::qsearchs('conf', $hashref);
113   if (!$agentonly && !$cv && defined($agentnum) && $agentnum) {
114     $hashref->{agentnum} = '';
115     $cv = FS::Record::qsearchs('conf', $hashref);
116   }
117   return $cv;
118 }
119
120 sub config {
121   my $self = shift;
122   return $self->_usecompat('config', @_) if use_confcompat;
123
124   carp "FS::Conf->config(". join(', ', @_). ") called"
125     if $DEBUG > 1;
126
127   my $cv = $self->_config(@_) or return;
128
129   if ( wantarray ) {
130     my $v = $cv->value;
131     chomp $v;
132     (split "\n", $v, -1);
133   } else {
134     (split("\n", $cv->value))[0];
135   }
136 }
137
138 =item config_binary KEY [ AGENTNUM [ NODEFAULT ] ]
139
140 Returns the exact scalar value for key.
141
142 =cut
143
144 sub config_binary {
145   my $self = shift;
146   return $self->_usecompat('config_binary', @_) if use_confcompat;
147
148   my $cv = $self->_config(@_) or return;
149   decode_base64($cv->value);
150 }
151
152 =item exists KEY [ AGENTNUM [ NODEFAULT ] ]
153
154 Returns true if the specified key exists, even if the corresponding value
155 is undefined.
156
157 =cut
158
159 sub exists {
160   my $self = shift;
161   return $self->_usecompat('exists', @_) if use_confcompat;
162
163   my($name, $agentnum)=@_;
164
165   carp "FS::Conf->exists(". join(', ', @_). ") called"
166     if $DEBUG > 1;
167
168   defined($self->_config(@_));
169 }
170
171 =item config_orbase KEY SUFFIX
172
173 Returns the configuration value or values (depending on context) for 
174 KEY_SUFFIX, if it exists, otherwise for KEY
175
176 =cut
177
178 # outmoded as soon as we shift to agentnum based config values
179 # well, mostly.  still useful for e.g. late notices, etc. in that we want
180 # these to fall back to standard values
181 sub config_orbase {
182   my $self = shift;
183   return $self->_usecompat('config_orbase', @_) if use_confcompat;
184
185   my( $name, $suffix ) = @_;
186   if ( $self->exists("${name}_$suffix") ) {
187     $self->config("${name}_$suffix");
188   } else {
189     $self->config($name);
190   }
191 }
192
193 =item key_orbase KEY SUFFIX
194
195 If the config value KEY_SUFFIX exists, returns KEY_SUFFIX, otherwise returns
196 KEY.  Useful for determining which exact configuration option is returned by
197 config_orbase.
198
199 =cut
200
201 sub key_orbase {
202   my $self = shift;
203   #no compat for this...return $self->_usecompat('config_orbase', @_) if use_confcompat;
204
205   my( $name, $suffix ) = @_;
206   if ( $self->exists("${name}_$suffix") ) {
207     "${name}_$suffix";
208   } else {
209     $name;
210   }
211 }
212
213 =item invoice_templatenames
214
215 Returns all possible invoice template names.
216
217 =cut
218
219 sub invoice_templatenames {
220   my( $self ) = @_;
221
222   my %templatenames = ();
223   foreach my $item ( $self->config_items ) {
224     foreach my $base ( @base_items ) {
225       my( $main, $ext) = split(/\./, $base);
226       $ext = ".$ext" if $ext;
227       if ( $item->key =~ /^${main}_(.+)$ext$/ ) {
228       $templatenames{$1}++;
229       }
230     }
231   }
232   
233   sort keys %templatenames;
234
235 }
236
237 =item touch KEY [ AGENT ];
238
239 Creates the specified configuration key if it does not exist.
240
241 =cut
242
243 sub touch {
244   my $self = shift;
245   return $self->_usecompat('touch', @_) if use_confcompat;
246
247   my($name, $agentnum) = @_;
248   unless ( $self->exists($name, $agentnum) ) {
249     $self->set($name, '', $agentnum);
250   }
251 }
252
253 =item set KEY VALUE [ AGENTNUM ];
254
255 Sets the specified configuration key to the given value.
256
257 =cut
258
259 sub set {
260   my $self = shift;
261   return $self->_usecompat('set', @_) if use_confcompat;
262
263   my($name, $value, $agentnum) = @_;
264   $value =~ /^(.*)$/s;
265   $value = $1;
266
267   warn "[FS::Conf] SET $name\n" if $DEBUG;
268
269   my $old = FS::Record::qsearchs('conf', {name => $name, agentnum => $agentnum});
270   my $new = new FS::conf { $old ? $old->hash 
271                                 : ('name' => $name, 'agentnum' => $agentnum)
272                          };
273   $new->value($value);
274
275   my $error;
276   if ($old) {
277     $error = $new->replace($old);
278   } else {
279     $error = $new->insert;
280   }
281
282   die "error setting configuration value: $error \n"
283     if $error;
284
285 }
286
287 =item set_binary KEY VALUE [ AGENTNUM ]
288
289 Sets the specified configuration key to an exact scalar value which
290 can be retrieved with config_binary.
291
292 =cut
293
294 sub set_binary {
295   my $self  = shift;
296   return if use_confcompat;
297
298   my($name, $value, $agentnum)=@_;
299   $self->set($name, encode_base64($value), $agentnum);
300 }
301
302 =item delete KEY [ AGENTNUM ];
303
304 Deletes the specified configuration key.
305
306 =cut
307
308 sub delete {
309   my $self = shift;
310   return $self->_usecompat('delete', @_) if use_confcompat;
311
312   my($name, $agentnum) = @_;
313   if ( my $cv = FS::Record::qsearchs('conf', {name => $name, agentnum => $agentnum}) ) {
314     warn "[FS::Conf] DELETE $name\n";
315
316     my $oldAutoCommit = $FS::UID::AutoCommit;
317     local $FS::UID::AutoCommit = 0;
318     my $dbh = dbh;
319
320     my $error = $cv->delete;
321
322     if ( $error ) {
323       $dbh->rollback if $oldAutoCommit;
324       die "error setting configuration value: $error \n"
325     }
326
327     $dbh->commit or die $dbh->errstr if $oldAutoCommit;
328
329   }
330 }
331
332 =item import_config_item CONFITEM DIR 
333
334   Imports the item specified by the CONFITEM (see L<FS::ConfItem>) into
335 the database as a conf record (see L<FS::conf>).  Imports from the file
336 in the directory DIR.
337
338 =cut
339
340 sub import_config_item { 
341   my ($self,$item,$dir) = @_;
342   my $key = $item->key;
343   if ( -e "$dir/$key" && ! use_confcompat ) {
344     warn "Inserting $key\n" if $DEBUG;
345     local $/;
346     my $value = readline(new IO::File "$dir/$key");
347     if ($item->type =~ /^(binary|image)$/ ) {
348       $self->set_binary($key, $value);
349     }else{
350       $self->set($key, $value);
351     }
352   }else {
353     warn "Not inserting $key\n" if $DEBUG;
354   }
355 }
356
357 =item verify_config_item CONFITEM DIR 
358
359   Compares the item specified by the CONFITEM (see L<FS::ConfItem>) in
360 the database to the legacy file value in DIR.
361
362 =cut
363
364 sub verify_config_item { 
365   return '' if use_confcompat;
366   my ($self,$item,$dir) = @_;
367   my $key = $item->key;
368   my $type = $item->type;
369
370   my $compat = new FS::Conf_compat17 $dir;
371   my $error = '';
372   
373   $error .= "$key fails existential comparison; "
374     if $self->exists($key) xor $compat->exists($key);
375
376   if ( $type !~ /^(binary|image)$/ ) {
377
378     {
379       no warnings;
380       $error .= "$key fails scalar comparison; "
381         unless scalar($self->config($key)) eq scalar($compat->config($key));
382     }
383
384     my (@new) = $self->config($key);
385     my (@old) = $compat->config($key);
386     unless ( scalar(@new) == scalar(@old)) { 
387       $error .= "$key fails list comparison; ";
388     }else{
389       my $r=1;
390       foreach (@old) { $r=0 if ($_ cmp shift(@new)); }
391       $error .= "$key fails list comparison; "
392         unless $r;
393     }
394
395   } else {
396
397     $error .= "$key fails binary comparison; "
398       unless scalar($self->config_binary($key)) eq scalar($compat->config_binary($key));
399
400   }
401
402 #remove deprecated config on our own terms, not freeside-upgrade's
403 #  if ($error =~ /existential comparison/ && $item->section eq 'deprecated') {
404 #    my $proto;
405 #    for ( @config_items ) { $proto = $_; last if $proto->key eq $key;  }
406 #    unless ($proto->key eq $key) { 
407 #      warn "removed config item $error\n" if $DEBUG;
408 #      $error = '';
409 #    }
410 #  }
411
412   $error;
413 }
414
415 #item _orbase_items OPTIONS
416 #
417 #Returns all of the possible extensible config items as FS::ConfItem objects.
418 #See #L<FS::ConfItem>.  OPTIONS consists of name value pairs.  Possible
419 #options include
420 #
421 # dir - the directory to search for configuration option files instead
422 #       of using the conf records in the database
423 #
424 #cut
425
426 #quelle kludge
427 sub _orbase_items {
428   my ($self, %opt) = @_; 
429
430   my $listmaker = sub { my $v = shift;
431                         $v =~ s/_/!_/g;
432                         if ( $v =~ /\.(png|eps)$/ ) {
433                           $v =~ s/\./!_%./;
434                         }else{
435                           $v .= '!_%';
436                         }
437                         map { $_->name }
438                           FS::Record::qsearch( 'conf',
439                                                {},
440                                                '',
441                                                "WHERE name LIKE '$v' ESCAPE '!'"
442                                              );
443                       };
444
445   if (exists($opt{dir}) && $opt{dir}) {
446     $listmaker = sub { my $v = shift;
447                        if ( $v =~ /\.(png|eps)$/ ) {
448                          $v =~ s/\./_*./;
449                        }else{
450                          $v .= '_*';
451                        }
452                        map { basename $_ } glob($opt{dir}. "/$v" );
453                      };
454   }
455
456   ( map { 
457           my $proto;
458           my $base = $_;
459           for ( @config_items ) { $proto = $_; last if $proto->key eq $base;  }
460           die "don't know about $base items" unless $proto->key eq $base;
461
462           map { new FS::ConfItem { 
463                   'key'         => $_,
464                   'base_key'    => $proto->key,
465                   'section'     => $proto->section,
466                   'description' => 'Alternate ' . $proto->description . '  See the <a href="http://www.freeside.biz/mediawiki/index.php/Freeside:1.7:Documentation:Administration#Invoice_templates">billing documentation</a> for details.',
467                   'type'        => $proto->type,
468                 };
469               } &$listmaker($base);
470         } @base_items,
471   );
472 }
473
474 =item config_items
475
476 Returns all of the possible global/default configuration items as
477 FS::ConfItem objects.  See L<FS::ConfItem>.
478
479 =cut
480
481 sub config_items {
482   my $self = shift; 
483   return $self->_usecompat('config_items', @_) if use_confcompat;
484
485   ( @config_items, $self->_orbase_items(@_) );
486 }
487
488 =back
489
490 =head1 SUBROUTINES
491
492 =over 4
493
494 =item init-config DIR
495
496 Imports the configuration items from DIR (1.7 compatible)
497 to conf records in the database.
498
499 =cut
500
501 sub init_config {
502   my $dir = shift;
503
504   {
505     local $FS::UID::use_confcompat = 0;
506     my $conf = new FS::Conf;
507     foreach my $item ( $conf->config_items(dir => $dir) ) {
508       $conf->import_config_item($item, $dir);
509       my $error = $conf->verify_config_item($item, $dir);
510       return $error if $error;
511     }
512   
513     my $compat = new FS::Conf_compat17 $dir;
514     foreach my $item ( $compat->config_items ) {
515       my $error = $conf->verify_config_item($item, $dir);
516       return $error if $error;
517     }
518   }
519
520   $FS::UID::use_confcompat = 0;
521   '';  #success
522 }
523
524 =back
525
526 =head1 BUGS
527
528 If this was more than just crud that will never be useful outside Freeside I'd
529 worry that config_items is freeside-specific and icky.
530
531 =head1 SEE ALSO
532
533 "Configuration" in the web interface (config/config.cgi).
534
535 =cut
536
537 #Business::CreditCard
538 @card_types = (
539   "VISA card",
540   "MasterCard",
541   "Discover card",
542   "American Express card",
543   "Diner's Club/Carte Blanche",
544   "enRoute",
545   "JCB",
546   "BankCard",
547   "Switch",
548   "Solo",
549 );
550
551 @base_items = qw (
552                    invoice_template
553                    invoice_latex
554                    invoice_latexreturnaddress
555                    invoice_latexfooter
556                    invoice_latexsmallfooter
557                    invoice_latexnotes
558                    invoice_latexcoupon
559                    invoice_html
560                    invoice_htmlreturnaddress
561                    invoice_htmlfooter
562                    invoice_htmlnotes
563                    logo.png
564                    logo.eps
565                  );
566
567 @config_items = map { new FS::ConfItem $_ } (
568
569   {
570     'key'         => 'address',
571     'section'     => 'deprecated',
572     'description' => 'This configuration option is no longer used.  See <a href="#invoice_template">invoice_template</a> instead.',
573     'type'        => 'text',
574   },
575
576   {
577     'key'         => 'alert_expiration',
578     'section'     => 'billing',
579     'description' => 'Enable alerts about billing method expiration.',
580     'type'        => 'checkbox',
581     'per_agent'   => 1,
582   },
583
584   {
585     'key'         => 'alerter_template',
586     'section'     => 'billing',
587     'description' => 'Template file for billing method expiration alerts.  See the <a href="http://www.freeside.biz/mediawiki/index.php/Freeside:1.7:Documentation:Administration#Credit_cards_and_Electronic_checks">billing documentation</a> for details.',
588     'type'        => 'textarea',
589     'per_agent'   => 1,
590   },
591
592   {
593     'key'         => 'apacheip',
594     #not actually deprecated yet
595     #'section'     => 'deprecated',
596     #'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',
597     'section'     => '',
598     'description' => 'IP address to assign to new virtual hosts',
599     'type'        => 'text',
600   },
601
602   {
603     'key'         => 'encryption',
604     'section'     => 'billing',
605     'description' => 'Enable encryption of credit cards.',
606     'type'        => 'checkbox',
607   },
608
609   {
610     'key'         => 'encryptionmodule',
611     'section'     => 'billing',
612     'description' => 'Use which module for encryption?',
613     'type'        => 'text',
614   },
615
616   {
617     'key'         => 'encryptionpublickey',
618     'section'     => 'billing',
619     'description' => 'Your RSA Public Key - Required if Encryption is turned on.',
620     'type'        => 'textarea',
621   },
622
623   {
624     'key'         => 'encryptionprivatekey',
625     'section'     => 'billing',
626     '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.',
627     'type'        => 'textarea',
628   },
629
630   {
631     'key'         => 'billco-url',
632     'section'     => 'billing',
633     'description' => 'The url to use for performing uploads to the invoice mailing service.',
634     'type'        => 'text',
635     'per_agent'   => 1,
636   },
637
638   {
639     'key'         => 'billco-username',
640     'section'     => 'billing',
641     'description' => 'The login name to use for uploads to the invoice mailing service.',
642     'type'        => 'text',
643     'per_agent'   => 1,
644     'agentonly'   => 1,
645   },
646
647   {
648     'key'         => 'billco-password',
649     'section'     => 'billing',
650     'description' => 'The password to use for uploads to the invoice mailing service.',
651     'type'        => 'text',
652     'per_agent'   => 1,
653     'agentonly'   => 1,
654   },
655
656   {
657     'key'         => 'billco-clicode',
658     'section'     => 'billing',
659     'description' => 'The clicode to use for uploads to the invoice mailing service.',
660     'type'        => 'text',
661     'per_agent'   => 1,
662   },
663
664   {
665     'key'         => 'business-onlinepayment',
666     'section'     => 'billing',
667     '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.',
668     'type'        => 'textarea',
669   },
670
671   {
672     'key'         => 'business-onlinepayment-ach',
673     'section'     => 'billing',
674     '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.',
675     'type'        => 'textarea',
676   },
677
678   {
679     'key'         => 'business-onlinepayment-namespace',
680     'section'     => 'billing',
681     'description' => 'Specifies which perl module namespace (which group of collection routines) is used by default.',
682     'type'        => 'select',
683     'select_hash' => [
684                        'Business::OnlinePayment' => 'Direct API (Business::OnlinePayment)',
685                        'Business::OnlineThirdPartyPayment' => 'Web API (Business::ThirdPartyPayment)',
686                      ],
687   },
688
689   {
690     'key'         => 'business-onlinepayment-description',
691     'section'     => 'billing',
692     '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)',
693     'type'        => 'text',
694   },
695
696   {
697     'key'         => 'business-onlinepayment-email-override',
698     'section'     => 'billing',
699     'description' => 'Email address used instead of customer email address when submitting a BOP transaction.',
700     'type'        => 'text',
701   },
702
703   {
704     'key'         => 'business-onlinepayment-email_customer',
705     'section'     => 'billing',
706     'description' => 'Controls the "email_customer" flag used by some Business::OnlinePayment processors to enable customer receipts.',
707     'type'        => 'checkbox',
708   },
709
710   {
711     'key'         => 'countrydefault',
712     'section'     => 'UI',
713     'description' => 'Default two-letter country code (if not supplied, the default is `US\')',
714     'type'        => 'text',
715   },
716
717   {
718     'key'         => 'date_format',
719     'section'     => 'UI',
720     'description' => 'Format for displaying dates',
721     'type'        => 'select',
722     'select_hash' => [
723                        '%m/%d/%Y' => 'MM/DD/YYYY',
724                        '%Y/%m/%d' => 'YYYY/MM/DD',
725                      ],
726   },
727
728   {
729     'key'         => 'deletecustomers',
730     'section'     => 'UI',
731     'description' => 'Enable customer deletions.  Be very careful!  Deleting a customer will remove all traces that the 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.',
732     'type'        => 'checkbox',
733   },
734
735   {
736     'key'         => 'deleteinvoices',
737     'section'     => 'UI',
738     'description' => 'Enable invoices deletions.  Be very careful!  Deleting an invoice will remove all traces that the invoice ever existed!  Normally, you would apply a credit against the invoice instead.',  #invoice voiding?
739     'type'        => 'checkbox',
740   },
741
742   {
743     'key'         => 'deletepayments',
744     'section'     => 'billing',
745     '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.',
746     'type'        => [qw( checkbox text )],
747   },
748
749   {
750     'key'         => 'deletecredits',
751     #not actually deprecated yet
752     #'section'     => 'deprecated',
753     #'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.',
754     'section'     => '',
755     'description' => 'One or more comma-separated email addresses to be notified when a credit is deleted.',
756     'type'        => [qw( checkbox text )],
757   },
758
759   {
760     'key'         => 'deleterefunds',
761     'section'     => 'billing',
762     'description' => 'Enable deletion of unclosed refunds.  Be very careful!  Only delete refunds that were data-entry errors, not adjustments.',
763     'type'        => 'checkbox',
764   },
765
766   {
767     'key'         => 'unapplypayments',
768     'section'     => 'deprecated',
769     'description' => '<B>DEPRECATED</B>, now controlled by ACLs.  Used to enable "unapplication" of unclosed payments.',
770     'type'        => 'checkbox',
771   },
772
773   {
774     'key'         => 'unapplycredits',
775     'section'     => 'deprecated',
776     'description' => '<B>DEPRECATED</B>, now controlled by ACLs.  Used to nable "unapplication" of unclosed credits.',
777     'type'        => 'checkbox',
778   },
779
780   {
781     'key'         => 'dirhash',
782     'section'     => 'shell',
783     '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>',
784     'type'        => 'text',
785   },
786
787   {
788     'key'         => 'disable_cust_attachment',
789     'section'     => '',
790     'description' => 'Disable customer file attachments',
791     'type'        => 'checkbox',
792   },
793
794   {
795     'key'         => 'max_attachment_size',
796     'section'     => '',
797     'description' => 'Maximum size for customer file attachments (leave blank for unlimited)',
798     'type'        => 'text',
799   },
800
801   {
802     'key'         => 'disable_customer_referrals',
803     'section'     => 'UI',
804     'description' => 'Disable new customer-to-customer referrals in the web interface',
805     'type'        => 'checkbox',
806   },
807
808   {
809     'key'         => 'editreferrals',
810     'section'     => 'UI',
811     'description' => 'Enable advertising source modification for existing customers',
812     'type'       => 'checkbox',
813   },
814
815   {
816     'key'         => 'emailinvoiceonly',
817     'section'     => 'billing',
818     'description' => 'Disables postal mail invoices',
819     'type'       => 'checkbox',
820   },
821
822   {
823     'key'         => 'disablepostalinvoicedefault',
824     'section'     => 'billing',
825     '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>.',
826     'type'       => 'checkbox',
827   },
828
829   {
830     'key'         => 'emailinvoiceauto',
831     'section'     => 'billing',
832     'description' => 'Automatically adds new accounts to the email invoice list',
833     'type'       => 'checkbox',
834   },
835
836   {
837     'key'         => 'emailinvoiceautoalways',
838     'section'     => 'billing',
839     'description' => 'Automatically adds new accounts to the email invoice list even when the list contains email addresses',
840     'type'       => 'checkbox',
841   },
842
843   {
844     'key'         => 'exclude_ip_addr',
845     'section'     => '',
846     'description' => 'Exclude these from the list of available broadband service IP addresses. (One per line)',
847     'type'        => 'textarea',
848   },
849   
850   {
851     'key'         => 'auto_router',
852     'section'     => '',
853     'description' => 'Automatically choose the correct router/block based on supplied ip address when possible while provisioning broadband services',
854     'type'        => 'checkbox',
855   },
856   
857   {
858     'key'         => 'hidecancelledpackages',
859     'section'     => 'UI',
860     'description' => 'Prevent cancelled packages from showing up in listings (though they will still be in the database)',
861     'type'        => 'checkbox',
862   },
863
864   {
865     'key'         => 'hidecancelledcustomers',
866     'section'     => 'UI',
867     'description' => 'Prevent customers with only cancelled packages from showing up in listings (though they will still be in the database)',
868     'type'        => 'checkbox',
869   },
870
871   {
872     'key'         => 'home',
873     'section'     => 'shell',
874     'description' => 'For new users, prefixed to username to create a directory name.  Should have a leading but not a trailing slash.',
875     'type'        => 'text',
876   },
877
878   {
879     'key'         => 'invoice_from',
880     'section'     => 'required',
881     'description' => 'Return address on email invoices',
882     'type'        => 'text',
883     'per_agent'   => 1,
884   },
885
886   {
887     'key'         => 'invoice_subject',
888     'section'     => 'billing',
889     'description' => 'Subject: header on email invoices.  Defaults to "Invoice".  The following substitutions are available: $name, $name_short, $invoice_number, and $invoice_date.',
890     'type'        => 'text',
891     'per_agent'   => 1,
892   },
893
894   {
895     'key'         => 'invoice_template',
896     'section'     => 'billing',
897     '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.freeside.biz/mediawiki/index.php/Freeside:1.7:Documentation:Administration#Plaintext_invoice_templates">billing documentation</a> for details.',
898     'type'        => 'textarea',
899   },
900
901   {
902     'key'         => 'invoice_html',
903     'section'     => 'billing',
904     'description' => 'Optional HTML template for invoices.  See the <a href="http://www.freeside.biz/mediawiki/index.php/Freeside:1.7:Documentation:Administration#HTML_invoice_templates">billing documentation</a> for details.',
905
906     'type'        => 'textarea',
907   },
908
909   {
910     'key'         => 'invoice_htmlnotes',
911     'section'     => 'billing',
912     'description' => 'Notes section for HTML invoices.  Defaults to the same data in invoice_latexnotes if not specified.',
913     'type'        => 'textarea',
914     'per_agent'   => 1,
915   },
916
917   {
918     'key'         => 'invoice_htmlfooter',
919     'section'     => 'billing',
920     'description' => 'Footer for HTML invoices.  Defaults to the same data in invoice_latexfooter if not specified.',
921     'type'        => 'textarea',
922     'per_agent'   => 1,
923   },
924
925   {
926     'key'         => 'invoice_htmlreturnaddress',
927     'section'     => 'billing',
928     'description' => 'Return address for HTML invoices.  Defaults to the same data in invoice_latexreturnaddress if not specified.',
929     'type'        => 'textarea',
930   },
931
932   {
933     'key'         => 'invoice_latex',
934     'section'     => 'billing',
935     'description' => 'Optional LaTeX template for typeset PostScript invoices.  See the <a href="http://www.freeside.biz/mediawiki/index.php/Freeside:1.7:Documentation:Administration#Typeset_.28LaTeX.29_invoice_templates">billing documentation</a> for details.',
936     'type'        => 'textarea',
937   },
938
939   {
940     'key'         => 'invoice_latexnotes',
941     'section'     => 'billing',
942     'description' => 'Notes section for LaTeX typeset PostScript invoices.',
943     'type'        => 'textarea',
944     'per_agent'   => 1,
945   },
946
947   {
948     'key'         => 'invoice_latexfooter',
949     'section'     => 'billing',
950     'description' => 'Footer for LaTeX typeset PostScript invoices.',
951     'type'        => 'textarea',
952     'per_agent'   => 1,
953   },
954
955   {
956     'key'         => 'invoice_latexcoupon',
957     'section'     => 'billing',
958     'description' => 'Remittance coupon for LaTeX typeset PostScript invoices.',
959     'type'        => 'textarea',
960     'per_agent'   => 1,
961   },
962
963   {
964     'key'         => 'invoice_latexreturnaddress',
965     'section'     => 'billing',
966     'description' => 'Return address for LaTeX typeset PostScript invoices.',
967     'type'        => 'textarea',
968   },
969
970   {
971     'key'         => 'invoice_latexsmallfooter',
972     'section'     => 'billing',
973     'description' => 'Optional small footer for multi-page LaTeX typeset PostScript invoices.',
974     'type'        => 'textarea',
975     'per_agent'   => 1,
976   },
977
978   {
979     'key'         => 'invoice_email_pdf',
980     'section'     => 'billing',
981     '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.',
982     'type'        => 'checkbox'
983   },
984
985   {
986     'key'         => 'invoice_email_pdf_note',
987     'section'     => 'billing',
988     'description' => 'If defined, this text will replace the default plain text invoice as the body of emailed PDF invoices.',
989     'type'        => 'textarea'
990   },
991
992
993   { 
994     'key'         => 'invoice_default_terms',
995     'section'     => 'billing',
996     'description' => 'Optional default invoice term, used to calculate a due date printed on invoices.',
997     'type'        => 'select',
998     'select_enum' => [ '', 'Payable upon receipt', 'Net 0', 'Net 10', 'Net 15', 'Net 20', 'Net 30', 'Net 45', 'Net 60' ],
999   },
1000
1001   { 
1002     'key'         => 'invoice_sections',
1003     'section'     => 'billing',
1004     'description' => 'Split invoice into sections and label according to package category when enabled.',
1005     'type'        => 'checkbox',
1006   },
1007
1008   { 
1009     'key'         => 'separate_usage',
1010     'section'     => 'billing',
1011     'description' => 'Split the rated call usage into a separate line from the recurring charges.',
1012     'type'        => 'checkbox',
1013   },
1014
1015   {
1016     'key'         => 'invoice_send_receipts',
1017     'section'     => 'deprecated',
1018     'description' => '<b>DEPRECATED</b>, this used to send an invoice copy on payments and credits.  See the payment_receipt_email and XXXX instead.',
1019     'type'        => 'checkbox',
1020   },
1021
1022   {
1023     'key'         => 'payment_receipt_email',
1024     'section'     => 'billing',
1025     '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/dist/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<li><code>$pkg</code> - Package (requires payment_receipt-trigger set to "when payment is applied".)</ul>',
1026     'type'        => [qw( checkbox textarea )],
1027   },
1028
1029   {
1030     'key'         => 'payment_receipt-trigger',
1031     'section'     => 'billing',
1032     'description' => 'When payment receipts are triggered.  Defaults to when payment is made.',
1033     'type'        => 'select',
1034     'select_hash' => [
1035                        'cust_pay'          => 'When payment is made.',
1036                        'cust_bill_pay_pkg' => 'When payment is applied.',
1037                      ],
1038   },
1039
1040   {
1041     'key'         => 'lpr',
1042     'section'     => 'required',
1043     'description' => 'Print command for paper invoices, for example `lpr -h\'',
1044     'type'        => 'text',
1045   },
1046
1047   {
1048     'key'         => 'lpr-postscript_prefix',
1049     'section'     => 'billing',
1050     'description' => 'Raw printer commands prepended to the beginning of postscript print jobs (evaluated as a double-quoted perl string - backslash escapes are available)',
1051     'type'        => 'text',
1052   },
1053
1054   {
1055     'key'         => 'lpr-postscript_suffix',
1056     'section'     => 'billing',
1057     'description' => 'Raw printer commands added to the end of postscript print jobs (evaluated as a double-quoted perl string - backslash escapes are available)',
1058     'type'        => 'text',
1059   },
1060
1061   {
1062     'key'         => 'money_char',
1063     'section'     => '',
1064     'description' => 'Currency symbol - defaults to `$\'',
1065     'type'        => 'text',
1066   },
1067
1068   {
1069     'key'         => 'defaultrecords',
1070     'section'     => 'BIND',
1071     'description' => 'DNS entries to add automatically when creating a domain',
1072     'type'        => 'editlist',
1073     'editlist_parts' => [ { type=>'text' },
1074                           { type=>'immutable', value=>'IN' },
1075                           { type=>'select',
1076                             select_enum=>{ map { $_=>$_ } qw(A CNAME MX NS TXT)} },
1077                           { type=> 'text' }, ],
1078   },
1079
1080   {
1081     'key'         => 'passwordmin',
1082     'section'     => 'password',
1083     'description' => 'Minimum password length (default 6)',
1084     'type'        => 'text',
1085   },
1086
1087   {
1088     'key'         => 'passwordmax',
1089     'section'     => 'password',
1090     'description' => 'Maximum password length (default 8) (don\'t set this over 12 if you need to import or export crypt() passwords)',
1091     'type'        => 'text',
1092   },
1093
1094   {
1095     'key' => 'password-noampersand',
1096     'section' => 'password',
1097     'description' => 'Disallow ampersands in passwords',
1098     'type' => 'checkbox',
1099   },
1100
1101   {
1102     'key' => 'password-noexclamation',
1103     'section' => 'password',
1104     'description' => 'Disallow exclamations in passwords (Not setting this could break old text Livingston or Cistron Radius servers)',
1105     'type' => 'checkbox',
1106   },
1107
1108   {
1109     'key'         => 'referraldefault',
1110     'section'     => 'UI',
1111     'description' => 'Default referral, specified by refnum',
1112     'type'        => 'text',
1113   },
1114
1115 #  {
1116 #    'key'         => 'registries',
1117 #    'section'     => 'required',
1118 #    'description' => 'Directory which contains domain registry information.  Each registry is a directory.',
1119 #  },
1120
1121   {
1122     'key'         => 'report_template',
1123     'section'     => 'deprecated',
1124     'description' => 'Deprecated template file for reports.',
1125     'type'        => 'textarea',
1126   },
1127
1128   {
1129     'key'         => 'maxsearchrecordsperpage',
1130     'section'     => 'UI',
1131     'description' => 'If set, number of search records to return per page.',
1132     'type'        => 'text',
1133   },
1134
1135   {
1136     'key'         => 'session-start',
1137     'section'     => 'session',
1138     '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.',
1139     'type'        => 'text',
1140   },
1141
1142   {
1143     'key'         => 'session-stop',
1144     'section'     => 'session',
1145     '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.',
1146     'type'        => 'text',
1147   },
1148
1149   {
1150     'key'         => 'shells',
1151     'section'     => 'shell',
1152     '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.',
1153     'type'        => 'textarea',
1154   },
1155
1156   {
1157     'key'         => 'showpasswords',
1158     'section'     => 'UI',
1159     'description' => 'Display unencrypted user passwords in the backend (employee) web interface',
1160     'type'        => 'checkbox',
1161   },
1162
1163   {
1164     'key'         => 'signupurl',
1165     'section'     => 'UI',
1166     'description' => 'if you are using customer-to-customer referrals, and you enter the URL of your <a href="http://www.freeside.biz/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',
1167     'type'        => 'text',
1168   },
1169
1170   {
1171     'key'         => 'smtpmachine',
1172     'section'     => 'required',
1173     'description' => 'SMTP relay for Freeside\'s outgoing mail',
1174     'type'        => 'text',
1175   },
1176
1177   {
1178     'key'         => 'soadefaultttl',
1179     'section'     => 'BIND',
1180     'description' => 'SOA default TTL for new domains.',
1181     'type'        => 'text',
1182   },
1183
1184   {
1185     'key'         => 'soaemail',
1186     'section'     => 'BIND',
1187     'description' => 'SOA email for new domains, in BIND form (`.\' instead of `@\'), with trailing `.\'',
1188     'type'        => 'text',
1189   },
1190
1191   {
1192     'key'         => 'soaexpire',
1193     'section'     => 'BIND',
1194     'description' => 'SOA expire for new domains',
1195     'type'        => 'text',
1196   },
1197
1198   {
1199     'key'         => 'soamachine',
1200     'section'     => 'BIND',
1201     'description' => 'SOA machine for new domains, with trailing `.\'',
1202     'type'        => 'text',
1203   },
1204
1205   {
1206     'key'         => 'soarefresh',
1207     'section'     => 'BIND',
1208     'description' => 'SOA refresh for new domains',
1209     'type'        => 'text',
1210   },
1211
1212   {
1213     'key'         => 'soaretry',
1214     'section'     => 'BIND',
1215     'description' => 'SOA retry for new domains',
1216     'type'        => 'text',
1217   },
1218
1219   {
1220     'key'         => 'statedefault',
1221     'section'     => 'UI',
1222     'description' => 'Default state or province (if not supplied, the default is `CA\')',
1223     'type'        => 'text',
1224   },
1225
1226   {
1227     'key'         => 'unsuspendauto',
1228     'section'     => 'billing',
1229     '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',
1230     'type'        => 'checkbox',
1231   },
1232
1233   {
1234     'key'         => 'unsuspend-always_adjust_next_bill_date',
1235     'section'     => 'billing',
1236     '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.',
1237     'type'        => 'checkbox',
1238   },
1239
1240   {
1241     'key'         => 'usernamemin',
1242     'section'     => 'username',
1243     'description' => 'Minimum username length (default 2)',
1244     'type'        => 'text',
1245   },
1246
1247   {
1248     'key'         => 'usernamemax',
1249     'section'     => 'username',
1250     'description' => 'Maximum username length',
1251     'type'        => 'text',
1252   },
1253
1254   {
1255     'key'         => 'username-ampersand',
1256     'section'     => 'username',
1257     '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.',
1258     'type'        => 'checkbox',
1259   },
1260
1261   {
1262     'key'         => 'username-letter',
1263     'section'     => 'username',
1264     'description' => 'Usernames must contain at least one letter',
1265     'type'        => 'checkbox',
1266     'per_agent'   => 1,
1267   },
1268
1269   {
1270     'key'         => 'username-letterfirst',
1271     'section'     => 'username',
1272     'description' => 'Usernames must start with a letter',
1273     'type'        => 'checkbox',
1274   },
1275
1276   {
1277     'key'         => 'username-noperiod',
1278     'section'     => 'username',
1279     'description' => 'Disallow periods in usernames',
1280     'type'        => 'checkbox',
1281   },
1282
1283   {
1284     'key'         => 'username-nounderscore',
1285     'section'     => 'username',
1286     'description' => 'Disallow underscores in usernames',
1287     'type'        => 'checkbox',
1288   },
1289
1290   {
1291     'key'         => 'username-nodash',
1292     'section'     => 'username',
1293     'description' => 'Disallow dashes in usernames',
1294     'type'        => 'checkbox',
1295   },
1296
1297   {
1298     'key'         => 'username-uppercase',
1299     'section'     => 'username',
1300     'description' => 'Allow uppercase characters in usernames.  Not recommended for use with FreeRADIUS with MySQL backend, which is case-insensitive by default.',
1301     'type'        => 'checkbox',
1302   },
1303
1304   { 
1305     'key'         => 'username-percent',
1306     'section'     => 'username',
1307     'description' => 'Allow the percent character (%) in usernames.',
1308     'type'        => 'checkbox',
1309   },
1310
1311   { 
1312     'key'         => 'username-colon',
1313     'section'     => 'username',
1314     'description' => 'Allow the colon character (:) in usernames.',
1315     'type'        => 'checkbox',
1316   },
1317
1318   {
1319     'key'         => 'safe-part_bill_event',
1320     'section'     => 'UI',
1321     'description' => 'Validates invoice event expressions against a preset list.  Useful for webdemos, annoying to powerusers.',
1322     'type'        => 'checkbox',
1323   },
1324
1325   {
1326     'key'         => 'show_ss',
1327     'section'     => 'UI',
1328     'description' => 'Turns on display/collection of social security numbers in the web interface.  Sometimes required by electronic check (ACH) processors.',
1329     'type'        => 'checkbox',
1330   },
1331
1332   {
1333     'key'         => 'show_stateid',
1334     'section'     => 'UI',
1335     'description' => "Turns on display/collection of driver's license/state issued id numbers in the web interface.  Sometimes required by electronic check (ACH) processors.",
1336     'type'        => 'checkbox',
1337   },
1338
1339   {
1340     'key'         => 'show_bankstate',
1341     'section'     => 'UI',
1342     'description' => "Turns on display/collection of state for bank accounts in the web interface.  Sometimes required by electronic check (ACH) processors.",
1343     'type'        => 'checkbox',
1344   },
1345
1346   { 
1347     'key'         => 'agent_defaultpkg',
1348     'section'     => 'UI',
1349     'description' => 'Setting this option will cause new packages to be available to all agent types by default.',
1350     'type'        => 'checkbox',
1351   },
1352
1353   {
1354     'key'         => 'legacy_link',
1355     'section'     => 'UI',
1356     'description' => 'Display options in the web interface to link legacy pre-Freeside services.',
1357     'type'        => 'checkbox',
1358   },
1359
1360   {
1361     'key'         => 'legacy_link-steal',
1362     'section'     => 'UI',
1363     'description' => 'Allow "stealing" an already-audited service from one customer (or package) to another using the link function.',
1364     'type'        => 'checkbox',
1365   },
1366
1367   {
1368     'key'         => 'queue_dangerous_controls',
1369     'section'     => 'UI',
1370     '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.',
1371     'type'        => 'checkbox',
1372   },
1373
1374   {
1375     'key'         => 'security_phrase',
1376     'section'     => 'password',
1377     'description' => 'Enable the tracking of a "security phrase" with each account.  Not recommended, as it is vulnerable to social engineering.',
1378     'type'        => 'checkbox',
1379   },
1380
1381   {
1382     'key'         => 'locale',
1383     'section'     => 'UI',
1384     'description' => 'Message locale',
1385     'type'        => 'select',
1386     'select_enum' => [ qw(en_US) ],
1387   },
1388
1389   {
1390     'key'         => 'signup_server-payby',
1391     'section'     => '',
1392     'description' => 'Acceptable payment types for the signup server',
1393     'type'        => 'selectmultiple',
1394     'select_enum' => [ qw(CARD DCRD CHEK DCHK LECB PREPAY BILL COMP) ],
1395   },
1396
1397   {
1398     'key'         => 'signup_server-default_agentnum',
1399     'section'     => '',
1400     'description' => 'Default agent for the signup server',
1401     'type'        => 'select-sub',
1402     'options_sub' => sub { require FS::Record;
1403                            require FS::agent;
1404                            map { $_->agentnum => $_->agent }
1405                                FS::Record::qsearch('agent', { disabled=>'' } );
1406                          },
1407     'option_sub'  => sub { require FS::Record;
1408                            require FS::agent;
1409                            my $agent = FS::Record::qsearchs(
1410                              'agent', { 'agentnum'=>shift }
1411                            );
1412                            $agent ? $agent->agent : '';
1413                          },
1414   },
1415
1416   {
1417     'key'         => 'signup_server-default_refnum',
1418     'section'     => '',
1419     'description' => 'Default advertising source for the signup server',
1420     'type'        => 'select-sub',
1421     'options_sub' => sub { require FS::Record;
1422                            require FS::part_referral;
1423                            map { $_->refnum => $_->referral }
1424                                FS::Record::qsearch( 'part_referral', 
1425                                                     { 'disabled' => '' }
1426                                                   );
1427                          },
1428     'option_sub'  => sub { require FS::Record;
1429                            require FS::part_referral;
1430                            my $part_referral = FS::Record::qsearchs(
1431                              'part_referral', { 'refnum'=>shift } );
1432                            $part_referral ? $part_referral->referral : '';
1433                          },
1434   },
1435
1436   {
1437     'key'         => 'signup_server-default_pkgpart',
1438     'section'     => '',
1439     'description' => 'Default package for the signup server',
1440     'type'        => 'select-part_pkg',
1441   },
1442
1443   {
1444     'key'         => 'signup_server-default_svcpart',
1445     'section'     => '',
1446     'description' => 'Default service definition for the signup server - only necessary for services that trigger special provisioning widgets (such as DID provisioning).',
1447     'type'        => 'select-part_svc',
1448   },
1449
1450   {
1451     'key'         => 'signup_server-mac_addr_svcparts',
1452     'section'     => '',
1453     'description' => 'Service definitions which can receive mac addresses (current mapped to username for svc_acct).',
1454     'type'        => 'select-part_svc',
1455     'multiple'    => 1,
1456   },
1457
1458   {
1459     'key'         => 'signup_server-nomadix',
1460     'section'     => '',
1461     'description' => 'Signup page Nomadix integration',
1462     'type'        => 'checkbox',
1463   },
1464
1465   {
1466     'key'         => 'signup_server-service',
1467     'section'     => '',
1468     'description' => 'Service for the signup server - "Account (svc_acct)" is the default setting, or "Phone number (svc_phone)" for ITSP signup',
1469     'type'        => 'select',
1470     'select_hash' => [
1471                        'svc_acct'  => 'Account (svc_acct)',
1472                        'svc_phone' => 'Phone number (svc_phone)',
1473                      ],
1474   },
1475
1476   {
1477     'key'         => 'selfservice_server-base_url',
1478     'section'     => '',
1479     'description' => 'Base URL for the self-service web interface - necessary for some widgets to find their way, including retrieval of non-US state information and phone number provisioning.',
1480     'type'        => 'text',
1481   },
1482
1483   {
1484     'key'         => 'show-msgcat-codes',
1485     'section'     => 'UI',
1486     'description' => 'Show msgcat codes in error messages.  Turn this option on before reporting errors to the mailing list.',
1487     'type'        => 'checkbox',
1488   },
1489
1490   {
1491     'key'         => 'signup_server-realtime',
1492     'section'     => '',
1493     'description' => 'Run billing for signup server signups immediately, and do not provision accounts which subsequently have a balance.',
1494     'type'        => 'checkbox',
1495   },
1496   {
1497     'key'         => 'signup_server-classnum2',
1498     'section'     => '',
1499     'description' => 'Package Class for first optional purchase',
1500     'type'        => 'select-sub',
1501     'options_sub' => sub { require FS::Record;
1502                            require FS::pkg_class;
1503                            map { $_->classnum => $_->classname }
1504                                FS::Record::qsearch('pkg_class', {} );
1505                          },
1506     'option_sub'  => sub { require FS::Record;
1507                            require FS::pkg_class;
1508                            my $pkg_class = FS::Record::qsearchs(
1509                              'pkg_class', { 'classnum'=>shift }
1510                            );
1511                            $pkg_class ? $pkg_class->classname : '';
1512                          },
1513   },
1514
1515   {
1516     'key'         => 'signup_server-classnum3',
1517     'section'     => '',
1518     'description' => 'Package Class for second optional purchase',
1519     'type'        => 'select-sub',
1520     'options_sub' => sub { require FS::Record;
1521                            require FS::pkg_class;
1522                            map { $_->classnum => $_->classname }
1523                                FS::Record::qsearch('pkg_class', {} );
1524                          },
1525     'option_sub'  => sub { require FS::Record;
1526                            require FS::pkg_class;
1527                            my $pkg_class = FS::Record::qsearchs(
1528                              'pkg_class', { 'classnum'=>shift }
1529                            );
1530                            $pkg_class ? $pkg_class->classname : '';
1531                          },
1532   },
1533
1534   {
1535     'key'         => 'backend-realtime',
1536     'section'     => '',
1537     'description' => 'Run billing for backend signups immediately.',
1538     'type'        => 'checkbox',
1539   },
1540
1541   {
1542     'key'         => 'declinetemplate',
1543     'section'     => 'billing',
1544     'description' => 'Template file for credit card decline emails.',
1545     'type'        => 'textarea',
1546   },
1547
1548   {
1549     'key'         => 'emaildecline',
1550     'section'     => 'billing',
1551     'description' => 'Enable emailing of credit card decline notices.',
1552     'type'        => 'checkbox',
1553   },
1554
1555   {
1556     'key'         => 'emaildecline-exclude',
1557     'section'     => 'billing',
1558     'description' => 'List of error messages that should not trigger email decline notices, one per line.',
1559     'type'        => 'textarea',
1560   },
1561
1562   {
1563     'key'         => 'cancelmessage',
1564     'section'     => 'billing',
1565     'description' => 'Template file for cancellation emails.',
1566     'type'        => 'textarea',
1567   },
1568
1569   {
1570     'key'         => 'cancelsubject',
1571     'section'     => 'billing',
1572     'description' => 'Subject line for cancellation emails.',
1573     'type'        => 'text',
1574   },
1575
1576   {
1577     'key'         => 'emailcancel',
1578     'section'     => 'billing',
1579     'description' => 'Enable emailing of cancellation notices.  Make sure to fill in the cancelmessage and cancelsubject configuration values as well.',
1580     'type'        => 'checkbox',
1581   },
1582
1583   {
1584     'key'         => 'bill_usage_on_cancel',
1585     'section'     => 'billing',
1586     'description' => 'Enable automatic generation of an invoice for usage when a package is cancelled.  Not all packages can do this.  Usage data must already be available.',
1587     'type'        => 'checkbox',
1588   },
1589
1590   {
1591     'key'         => 'require_cardname',
1592     'section'     => 'billing',
1593     'description' => 'Require an "Exact name on card" to be entered explicitly; don\'t default to using the first and last name.',
1594     'type'        => 'checkbox',
1595   },
1596
1597   {
1598     'key'         => 'enable_taxclasses',
1599     'section'     => 'billing',
1600     'description' => 'Enable per-package tax classes',
1601     'type'        => 'checkbox',
1602   },
1603
1604   {
1605     'key'         => 'require_taxclasses',
1606     'section'     => 'billing',
1607     'description' => 'Require a taxclass to be entered for every package',
1608     'type'        => 'checkbox',
1609   },
1610
1611   {
1612     'key'         => 'enable_taxproducts',
1613     'section'     => 'billing',
1614     'description' => 'Enable per-package mapping to vendor tax data from CCH or elsewhere.',
1615     'type'        => 'checkbox',
1616   },
1617
1618   {
1619     'key'         => 'taxdatadirectdownload',
1620     'section'     => 'billing',  #well
1621     'description' => 'Enable downloading tax data directly from the vendor site',
1622     'type'        => 'checkbox',
1623   },
1624
1625   {
1626     'key'         => 'ignore_incalculable_taxes',
1627     'section'     => 'billing',
1628     'description' => 'Prefer to invoice without tax over not billing at all',
1629     'type'        => 'checkbox',
1630   },
1631
1632   {
1633     'key'         => 'welcome_email',
1634     'section'     => '',
1635     '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/dist/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>',
1636     'type'        => 'textarea',
1637     'per_agent'   => 1,
1638   },
1639
1640   {
1641     'key'         => 'welcome_email-from',
1642     'section'     => '',
1643     'description' => 'From: address header for welcome email',
1644     'type'        => 'text',
1645     'per_agent'   => 1,
1646   },
1647
1648   {
1649     'key'         => 'welcome_email-subject',
1650     'section'     => '',
1651     'description' => 'Subject: header for welcome email',
1652     'type'        => 'text',
1653     'per_agent'   => 1,
1654   },
1655   
1656   {
1657     'key'         => 'welcome_email-mimetype',
1658     'section'     => '',
1659     'description' => 'MIME type for welcome email',
1660     'type'        => 'select',
1661     'select_enum' => [ 'text/plain', 'text/html' ],
1662     'per_agent'   => 1,
1663   },
1664
1665   {
1666     'key'         => 'welcome_letter',
1667     'section'     => '',
1668     '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/dist/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>',
1669     'type'        => 'textarea',
1670   },
1671
1672   {
1673     'key'         => 'warning_email',
1674     'section'     => '',
1675     '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/dist/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>',
1676     'type'        => 'textarea',
1677   },
1678
1679   {
1680     'key'         => 'warning_email-from',
1681     'section'     => '',
1682     'description' => 'From: address header for warning email',
1683     'type'        => 'text',
1684   },
1685
1686   {
1687     'key'         => 'warning_email-cc',
1688     'section'     => '',
1689     'description' => 'Additional recipient(s) (comma separated) for warning email when remaining usage reaches zero.',
1690     'type'        => 'text',
1691   },
1692
1693   {
1694     'key'         => 'warning_email-subject',
1695     'section'     => '',
1696     'description' => 'Subject: header for warning email',
1697     'type'        => 'text',
1698   },
1699   
1700   {
1701     'key'         => 'warning_email-mimetype',
1702     'section'     => '',
1703     'description' => 'MIME type for warning email',
1704     'type'        => 'select',
1705     'select_enum' => [ 'text/plain', 'text/html' ],
1706   },
1707
1708   {
1709     'key'         => 'payby',
1710     'section'     => 'billing',
1711     'description' => 'Available payment types.',
1712     'type'        => 'selectmultiple',
1713     'select_enum' => [ qw(CARD DCRD CHEK DCHK LECB BILL CASH WEST MCRD COMP) ],
1714   },
1715
1716   {
1717     'key'         => 'payby-default',
1718     'section'     => 'UI',
1719     'description' => 'Default payment type.  HIDE disables display of billing information and sets customers to BILL.',
1720     'type'        => 'select',
1721     'select_enum' => [ '', qw(CARD DCRD CHEK DCHK LECB BILL CASH WEST MCRD COMP HIDE) ],
1722   },
1723
1724   {
1725     'key'         => 'paymentforcedtobatch',
1726     'section'     => 'deprecated',
1727     'description' => 'See batch-enable_payby and realtime-disable_payby.  Used to (for CHEK): Cause per customer payment entry to be forced to a batch processor rather than performed realtime.',
1728     'type'        => 'checkbox',
1729   },
1730
1731   {
1732     'key'         => 'svc_acct-notes',
1733     'section'     => 'UI',
1734     'description' => 'Extra HTML to be displayed on the Account View screen.',
1735     'type'        => 'textarea',
1736   },
1737
1738   {
1739     'key'         => 'radius-password',
1740     'section'     => '',
1741     'description' => 'RADIUS attribute for plain-text passwords.',
1742     'type'        => 'select',
1743     'select_enum' => [ 'Password', 'User-Password' ],
1744   },
1745
1746   {
1747     'key'         => 'radius-ip',
1748     'section'     => '',
1749     'description' => 'RADIUS attribute for IP addresses.',
1750     'type'        => 'select',
1751     'select_enum' => [ 'Framed-IP-Address', 'Framed-Address' ],
1752   },
1753
1754   #http://dev.coova.org/svn/coova-chilli/doc/dictionary.chillispot
1755   {
1756     'key'         => 'radius-chillispot-max',
1757     'section'     => '',
1758     'description' => 'Enable ChilliSpot (and CoovaChilli) Max attributes, specifically ChilliSpot-Max-{Input,Output,Total}-{Octets,Gigawords}.',
1759     'type'        => 'checkbox',
1760   },
1761
1762   {
1763     'key'         => 'svc_acct-alldomains',
1764     'section'     => '',
1765     '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.',
1766     'type'        => 'checkbox',
1767   },
1768
1769   {
1770     'key'         => 'dump-scpdest',
1771     'section'     => '',
1772     'description' => 'destination for scp database dumps: user@host:/path',
1773     'type'        => 'text',
1774   },
1775
1776   {
1777     'key'         => 'dump-pgpid',
1778     'section'     => '',
1779     '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.",
1780     'type'        => 'text',
1781   },
1782
1783   {
1784     'key'         => 'users-allow_comp',
1785     'section'     => 'deprecated',
1786     'description' => '<b>DEPRECATED</b>, enable the <i>Complimentary customer</i> access right instead.  Was: Usernames (Freeside users, created with <a href="../docs/man/bin/freeside-adduser.html">freeside-adduser</a>) which can create complimentary customers, one per line.  If no usernames are entered, all users can create complimentary accounts.',
1787     'type'        => 'textarea',
1788   },
1789
1790   {
1791     'key'         => 'credit_card-recurring_billing_flag',
1792     'section'     => 'billing',
1793     'description' => 'This controls when the system passes the "recurring_billing" flag on credit card transactions.  If supported by your processor (and the Business::OnlinePayment processor module), passing the flag indicates this is a recurring transaction and may turn off the CVV requirement. ',
1794     'type'        => 'select',
1795     'select_hash' => [
1796                        'actual_oncard' => 'Default/classic behavior: set the flag if a customer has actual previous charges on the card.',
1797                        'transaction_is_recur' => 'Set the flag if the transaction itself is recurring, irregardless of previous charges on the card.',
1798                      ],
1799   },
1800
1801   {
1802     'key'         => 'credit_card-recurring_billing_acct_code',
1803     'section'     => 'billing',
1804     'description' => 'When the "recurring billing" flag is set, also set the "acct_code" to "rebill".  Useful for reporting purposes with supported gateways (PlugNPay, others?)',
1805     'type'        => 'checkbox',
1806   },
1807
1808   {
1809     'key'         => 'cvv-save',
1810     'section'     => 'billing',
1811     '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.',
1812     'type'        => 'selectmultiple',
1813     'select_enum' => \@card_types,
1814   },
1815
1816   {
1817     'key'         => 'manual_process-pkgpart',
1818     'section'     => 'billing',
1819     'description' => 'Package to add to each manual credit card and ACH payments entered from the backend.  Enabling this option may be in violation of your merchant agreement(s), so please check them carefully before enabling this option.',
1820     'type'        => 'select-part_pkg',
1821   },
1822
1823   {
1824     'key'         => 'allow_negative_charges',
1825     'section'     => 'billing',
1826     'description' => 'Allow negative charges.  Normally not used unless importing data from a legacy system that requires this.',
1827     'type'        => 'checkbox',
1828   },
1829   {
1830       'key'         => 'auto_unset_catchall',
1831       'section'     => '',
1832       '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.',
1833       'type'        => 'checkbox',
1834   },
1835
1836   {
1837     'key'         => 'system_usernames',
1838     'section'     => 'username',
1839     '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.',
1840     'type'        => 'textarea',
1841   },
1842
1843   {
1844     'key'         => 'cust_pkg-change_svcpart',
1845     'section'     => '',
1846     'description' => "When changing packages, move services even if svcparts don't match between old and new pacakge definitions.",
1847     'type'        => 'checkbox',
1848   },
1849
1850   {
1851     'key'         => 'disable_autoreverse',
1852     'section'     => 'BIND',
1853     'description' => 'Disable automatic synchronization of reverse-ARPA entries.',
1854     'type'        => 'checkbox',
1855   },
1856
1857   {
1858     'key'         => 'svc_www-enable_subdomains',
1859     'section'     => '',
1860     'description' => 'Enable selection of specific subdomains for virtual host creation.',
1861     'type'        => 'checkbox',
1862   },
1863
1864   {
1865     'key'         => 'svc_www-usersvc_svcpart',
1866     'section'     => '',
1867     'description' => 'Allowable service definition svcparts for virtual hosts, one per line.',
1868     'type'        => 'select-part_svc',
1869     'multiple'    => 1,
1870   },
1871
1872   {
1873     'key'         => 'selfservice_server-primary_only',
1874     'section'     => '',
1875     'description' => 'Only allow primary accounts to access self-service functionality.',
1876     'type'        => 'checkbox',
1877   },
1878
1879   {
1880     'key'         => 'selfservice_server-phone_login',
1881     'section'     => '',
1882     'description' => 'Allow login to self-service with phone number and PIN.',
1883     'type'        => 'checkbox',
1884   },
1885
1886   {
1887     'key'         => 'selfservice_server-single_domain',
1888     'section'     => '',
1889     'description' => 'If specified, only use this one domain for self-service access.',
1890     'type'        => 'text',
1891   },
1892
1893   {
1894     'key'         => 'card_refund-days',
1895     'section'     => 'billing',
1896     'description' => 'After a payment, the number of days a refund link will be available for that payment.  Defaults to 120.',
1897     'type'        => 'text',
1898   },
1899
1900   {
1901     'key'         => 'agent-showpasswords',
1902     'section'     => '',
1903     'description' => 'Display unencrypted user passwords in the agent (reseller) interface',
1904     'type'        => 'checkbox',
1905   },
1906
1907   {
1908     'key'         => 'global_unique-username',
1909     'section'     => 'username',
1910     '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.',
1911     'type'        => 'select',
1912     'select_enum' => [ 'none', 'username', 'username@domain', 'disabled' ],
1913   },
1914
1915   {
1916     'key'         => 'global_unique-phonenum',
1917     'section'     => '',
1918     'description' => 'Global phone number uniqueness control: none (usual setting - check countrycode+phonenumun uniqueness per exports), or countrycode+phonenum (all countrycode+phonenum 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.',
1919     'type'        => 'select',
1920     'select_enum' => [ 'none', 'countrycode+phonenum', 'disabled' ],
1921   },
1922
1923   {
1924     'key'         => 'svc_external-skip_manual',
1925     'section'     => 'UI',
1926     '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).',
1927     'type'        => 'checkbox',
1928   },
1929
1930   {
1931     'key'         => 'svc_external-display_type',
1932     'section'     => 'UI',
1933     'description' => 'Select a specific svc_external type to enable some UI changes specific to that type (i.e. artera_turbo).',
1934     'type'        => 'select',
1935     'select_enum' => [ 'generic', 'artera_turbo', ],
1936   },
1937
1938   {
1939     'key'         => 'ticket_system',
1940     'section'     => '',
1941     'description' => 'Ticketing system integration.  <b>RT_Internal</b> uses the built-in RT ticketing system (see the <a href="http://www.freeside.biz/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).',
1942     'type'        => 'select',
1943     #'select_enum' => [ '', qw(RT_Internal RT_Libs RT_External) ],
1944     'select_enum' => [ '', qw(RT_Internal RT_External) ],
1945   },
1946
1947   {
1948     'key'         => 'ticket_system-default_queueid',
1949     'section'     => '',
1950     'description' => 'Default queue used when creating new customer tickets.',
1951     'type'        => 'select-sub',
1952     'options_sub' => sub {
1953                            my $conf = new FS::Conf;
1954                            if ( $conf->config('ticket_system') ) {
1955                              eval "use FS::TicketSystem;";
1956                              die $@ if $@;
1957                              FS::TicketSystem->queues();
1958                            } else {
1959                              ();
1960                            }
1961                          },
1962     'option_sub'  => sub { 
1963                            my $conf = new FS::Conf;
1964                            if ( $conf->config('ticket_system') ) {
1965                              eval "use FS::TicketSystem;";
1966                              die $@ if $@;
1967                              FS::TicketSystem->queue(shift);
1968                            } else {
1969                              '';
1970                            }
1971                          },
1972   },
1973
1974   {
1975     'key'         => 'ticket_system-priority_reverse',
1976     'section'     => '',
1977     '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.',
1978     'type'        => 'checkbox',
1979   },
1980
1981   {
1982     'key'         => 'ticket_system-custom_priority_field',
1983     'section'     => '',
1984     'description' => 'Custom field from the ticketing system to use as a custom priority classification.',
1985     'type'        => 'text',
1986   },
1987
1988   {
1989     'key'         => 'ticket_system-custom_priority_field-values',
1990     'section'     => '',
1991     'description' => 'Values for the custom field from the ticketing system to break down and sort customer ticket lists.',
1992     'type'        => 'textarea',
1993   },
1994
1995   {
1996     'key'         => 'ticket_system-custom_priority_field_queue',
1997     'section'     => '',
1998     'description' => 'Ticketing system queue in which the custom field specified in ticket_system-custom_priority_field is located.',
1999     'type'        => 'text',
2000   },
2001
2002   {
2003     'key'         => 'ticket_system-rt_external_datasrc',
2004     'section'     => '',
2005     '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>',
2006     'type'        => 'text',
2007
2008   },
2009
2010   {
2011     'key'         => 'ticket_system-rt_external_url',
2012     'section'     => '',
2013     'description' => 'With external RT integration, the URL for the external RT installation, for example, <code>https://rt.example.com/rt</code>',
2014     'type'        => 'text',
2015   },
2016
2017   {
2018     'key'         => 'company_name',
2019     'section'     => 'required',
2020     'description' => 'Your company name',
2021     'type'        => 'text',
2022     'per_agent'   => 1, #XXX just FS/FS/ClientAPI/Signup.pm
2023   },
2024
2025   {
2026     'key'         => 'company_address',
2027     'section'     => 'required',
2028     'description' => 'Your company address',
2029     'type'        => 'textarea',
2030     'per_agent'   => 1,
2031   },
2032
2033   {
2034     'key'         => 'echeck-void',
2035     'section'     => 'deprecated',
2036     'description' => '<B>DEPRECATED</B>, now controlled by ACLs.  Used to enable local-only voiding of echeck payments in addition to refunds against the payment gateway',
2037     'type'        => 'checkbox',
2038   },
2039
2040   {
2041     'key'         => 'cc-void',
2042     'section'     => 'deprecated',
2043     'description' => '<B>DEPRECATED</B>, now controlled by ACLs.  Used to enable local-only voiding of credit card payments in addition to refunds against the payment gateway',
2044     'type'        => 'checkbox',
2045   },
2046
2047   {
2048     'key'         => 'unvoid',
2049     'section'     => 'deprecated',
2050     'description' => '<B>DEPRECATED</B>, now controlled by ACLs.  Used to enable unvoiding of voided payments',
2051     'type'        => 'checkbox',
2052   },
2053
2054   {
2055     'key'         => 'address2-search',
2056     'section'     => 'UI',
2057     'description' => 'Enable a "Unit" search box which searches the second address field.  Useful for multi-tenant applications.  See also: cust_main-require_address2',
2058     'type'        => 'checkbox',
2059   },
2060
2061   {
2062     'key'         => 'cust_main-require_address2',
2063     'section'     => 'UI',
2064     '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',
2065     'type'        => 'checkbox',
2066   },
2067
2068   {
2069     'key'         => 'agent-ship_address',
2070     'section'     => '',
2071     'description' => "Use the agent's master service address as the service address (only ship_address2 can be entered, if blank on the master address).  Useful for multi-tenant applications.",
2072     'type'        => 'checkbox',
2073   },
2074
2075   { 'key'         => 'referral_credit',
2076     'section'     => 'deprecated',
2077     'description' => "Used to enable one-time referral credits in the amount of one month <i>referred</i> customer's recurring fee (irregardless of frequency).  Replace with a billing event on appropriate packages.",
2078     'type'        => 'checkbox',
2079   },
2080
2081   { 'key'         => 'selfservice_server-cache_module',
2082     'section'     => '',
2083     '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.',
2084     'type'        => 'select',
2085     'select_enum' => [ 'Cache::SharedMemoryCache', 'Cache::FileCache', ], # '_Database' ],
2086   },
2087
2088   {
2089     'key'         => 'hylafax',
2090     'section'     => 'billing',
2091     '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).',
2092     'type'        => [qw( checkbox textarea )],
2093   },
2094
2095   {
2096     'key'         => 'cust_bill-ftpformat',
2097     'section'     => 'billing',
2098     'description' => 'Enable FTP of raw invoice data - format.',
2099     'type'        => 'select',
2100     'select_enum' => [ '', 'default', 'billco', ],
2101   },
2102
2103   {
2104     'key'         => 'cust_bill-ftpserver',
2105     'section'     => 'billing',
2106     'description' => 'Enable FTP of raw invoice data - server.',
2107     'type'        => 'text',
2108   },
2109
2110   {
2111     'key'         => 'cust_bill-ftpusername',
2112     'section'     => 'billing',
2113     'description' => 'Enable FTP of raw invoice data - server.',
2114     'type'        => 'text',
2115   },
2116
2117   {
2118     'key'         => 'cust_bill-ftppassword',
2119     'section'     => 'billing',
2120     'description' => 'Enable FTP of raw invoice data - server.',
2121     'type'        => 'text',
2122   },
2123
2124   {
2125     'key'         => 'cust_bill-ftpdir',
2126     'section'     => 'billing',
2127     'description' => 'Enable FTP of raw invoice data - server.',
2128     'type'        => 'text',
2129   },
2130
2131   {
2132     'key'         => 'cust_bill-spoolformat',
2133     'section'     => 'billing',
2134     'description' => 'Enable spooling of raw invoice data - format.',
2135     'type'        => 'select',
2136     'select_enum' => [ '', 'default', 'billco', ],
2137   },
2138
2139   {
2140     'key'         => 'cust_bill-spoolagent',
2141     'section'     => 'billing',
2142     'description' => 'Enable per-agent spooling of raw invoice data.',
2143     'type'        => 'checkbox',
2144   },
2145
2146   {
2147     'key'         => 'svc_acct-usage_suspend',
2148     'section'     => 'billing',
2149     '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.',
2150     'type'        => 'checkbox',
2151   },
2152
2153   {
2154     'key'         => 'svc_acct-usage_unsuspend',
2155     'section'     => 'billing',
2156     '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.',
2157     'type'        => 'checkbox',
2158   },
2159
2160   {
2161     'key'         => 'svc_acct-usage_threshold',
2162     'section'     => 'billing',
2163     '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.',
2164     'type'        => 'text',
2165   },
2166
2167   {
2168     'key'         => 'cust-fields',
2169     'section'     => 'UI',
2170     'description' => 'Which customer fields to display on reports by default',
2171     'type'        => 'select',
2172     'select_hash' => [ FS::ConfDefaults->cust_fields_avail() ],
2173   },
2174
2175   {
2176     'key'         => 'cust_pkg-display_times',
2177     'section'     => 'UI',
2178     'description' => 'Display full timestamps (not just dates) for customer packages.  Useful if you are doing real-time things like hourly prepaid.',
2179     'type'        => 'checkbox',
2180   },
2181
2182   {
2183     'key'         => 'cust_pkg-always_show_location',
2184     'section'     => 'UI',
2185     'description' => "Always display package locations, even when they're all the default service address.",
2186     'type'        => 'checkbox',
2187   },
2188
2189   {
2190     'key'         => 'svc_acct-edit_uid',
2191     'section'     => 'shell',
2192     'description' => 'Allow UID editing.',
2193     'type'        => 'checkbox',
2194   },
2195
2196   {
2197     'key'         => 'svc_acct-edit_gid',
2198     'section'     => 'shell',
2199     'description' => 'Allow GID editing.',
2200     'type'        => 'checkbox',
2201   },
2202
2203   {
2204     'key'         => 'zone-underscore',
2205     'section'     => 'BIND',
2206     'description' => 'Allow underscores in zone names.  As underscores are illegal characters in zone names, this option is not recommended.',
2207     'type'        => 'checkbox',
2208   },
2209
2210   {
2211     'key'         => 'echeck-nonus',
2212     'section'     => 'billing',
2213     'description' => 'Disable ABA-format account checking for Electronic Check payment info',
2214     'type'        => 'checkbox',
2215   },
2216
2217   {
2218     'key'         => 'voip-cust_cdr_spools',
2219     'section'     => '',
2220     'description' => 'Enable the per-customer option for individual CDR spools.',
2221     'type'        => 'checkbox',
2222   },
2223
2224   {
2225     'key'         => 'voip-cust_cdr_squelch',
2226     'section'     => '',
2227     'description' => 'Enable the per-customer option for not printing CDR on invoices.',
2228     'type'        => 'checkbox',
2229   },
2230
2231   {
2232     'key'         => 'voip-cdr_email',
2233     'section'     => '',
2234     'description' => 'Include the call details on emailed invoices even if the customer is configured for not printing them on the invoices.',
2235     'type'        => 'checkbox',
2236   },
2237
2238   {
2239     'key'         => 'voip-cust_email_csv_cdr',
2240     'section'     => '',
2241     'description' => 'Enable the per-customer option for including CDR information as a CSV attachment on emailed invoices.',
2242     'type'        => 'checkbox',
2243   },
2244
2245   {
2246     'key'         => 'svc_forward-arbitrary_dst',
2247     'section'     => '',
2248     '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.",
2249     'type'        => 'checkbox',
2250   },
2251
2252   {
2253     'key'         => 'tax-ship_address',
2254     'section'     => 'billing',
2255     'description' => 'By default, tax calculations are done based on the billing address.  Enable this switch to calculate tax based on the shipping address instead.',
2256     'type'        => 'checkbox',
2257   }
2258 ,
2259   {
2260     'key'         => 'tax-pkg_address',
2261     'section'     => 'billing',
2262     'description' => 'By default, tax calculations are done based on the billing address.  Enable this switch to calculate tax based on the package address instead (when present).  Note that this option is currently incompatible with vendor data taxation enabled by enable_taxproducts.',
2263     'type'        => 'checkbox',
2264   },
2265
2266   {
2267     'key'         => 'invoice-ship_address',
2268     'section'     => 'billing',
2269     'description' => 'Enable this switch to include the ship address on the invoice.',
2270     'type'        => 'checkbox',
2271   },
2272
2273   {
2274     'key'         => 'invoice-unitprice',
2275     'section'     => 'billing',
2276     'description' => 'This switch enables unit pricing on the invoice.',
2277     'type'        => 'checkbox',
2278   },
2279
2280   {
2281     'key'         => 'postal_invoice-fee_pkgpart',
2282     'section'     => 'billing',
2283     'description' => 'This allows selection of a package to insert on invoices for customers with postal invoices selected.',
2284     'type'        => 'select-part_pkg',
2285   },
2286
2287   {
2288     'key'         => 'postal_invoice-recurring_only',
2289     'section'     => 'billing',
2290     'description' => 'The postal invoice fee is omitted on invoices without reucrring charges when this is set.',
2291     'type'        => 'checkbox',
2292   },
2293
2294   {
2295     'key'         => 'batch-enable',
2296     'section'     => 'deprecated', #make sure batch-enable_payby is set for
2297                                    #everyone before removing
2298     'description' => 'Enable credit card and/or ACH batching - leave disabled for real-time installations.',
2299     'type'        => 'checkbox',
2300   },
2301
2302   {
2303     'key'         => 'batch-enable_payby',
2304     'section'     => 'billing',
2305     'description' => 'Enable batch processing for the specified payment types.',
2306     'type'        => 'selectmultiple',
2307     'select_enum' => [qw( CARD CHEK )],
2308   },
2309
2310   {
2311     'key'         => 'realtime-disable_payby',
2312     'section'     => 'billing',
2313     'description' => 'Disable realtime processing for the specified payment types.',
2314     'type'        => 'selectmultiple',
2315     'select_enum' => [qw( CARD CHEK )],
2316   },
2317
2318   {
2319     'key'         => 'batch-default_format',
2320     'section'     => 'billing',
2321     'description' => 'Default format for batches.',
2322     'type'        => 'select',
2323     'select_enum' => [ 'csv-td_canada_trust-merchant_pc_batch',
2324                        'csv-chase_canada-E-xactBatch', 'BoM', 'PAP',
2325                        'ach-spiritone',
2326                     ]
2327   },
2328
2329   {
2330     'key'         => 'batch-fixed_format-CARD',
2331     'section'     => 'billing',
2332     'description' => 'Fixed (unchangeable) format for credit card batches.',
2333     'type'        => 'select',
2334     'select_enum' => [ 'csv-td_canada_trust-merchant_pc_batch', 'BoM', 'PAP' ,
2335                        'csv-chase_canada-E-xactBatch', 'BoM', 'PAP' ]
2336   },
2337
2338   {
2339     'key'         => 'batch-fixed_format-CHEK',
2340     'section'     => 'billing',
2341     'description' => 'Fixed (unchangeable) format for electronic check batches.',
2342     'type'        => 'select',
2343     'select_enum' => [ 'csv-td_canada_trust-merchant_pc_batch', 'BoM', 'PAP',
2344                        'ach-spiritone',
2345                      ]
2346   },
2347
2348   {
2349     'key'         => 'batch-increment_expiration',
2350     'section'     => 'billing',
2351     'description' => 'Increment expiration date years in batches until cards are current.  Make sure this is acceptable to your batching provider before enabling.',
2352     'type'        => 'checkbox'
2353   },
2354
2355   {
2356     'key'         => 'batchconfig-BoM',
2357     'section'     => 'billing',
2358     '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',
2359     'type'        => 'textarea',
2360   },
2361
2362   {
2363     'key'         => 'batchconfig-PAP',
2364     'section'     => 'billing',
2365     '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',
2366     'type'        => 'textarea',
2367   },
2368
2369   {
2370     'key'         => 'batchconfig-csv-chase_canada-E-xactBatch',
2371     'section'     => 'billing',
2372     'description' => 'Gateway ID for Chase Canada E-xact batching',
2373     'type'        => 'text',
2374   },
2375
2376   {
2377     'key'         => 'batchconfig-paymentech',
2378     'section'     => 'billing',
2379     'description' => 'Configuration for Chase Paymentech batching, four lines: 1. BIN, 2. Terminal ID, 3. Merchant ID, 4. Username',
2380     'type'        => 'textarea',
2381   },
2382
2383   {
2384     'key'         => 'payment_history-years',
2385     'section'     => 'UI',
2386     'description' => 'Number of years of payment history to show by default.  Currently defaults to 2.',
2387     'type'        => 'text',
2388   },
2389
2390   {
2391     'key'         => 'change_history-years',
2392     'section'     => 'UI',
2393     'description' => 'Number of years of change history to show by default.  Currently defaults to 0.5.',
2394     'type'        => 'text',
2395   },
2396
2397   {
2398     'key'         => 'cust_main-packages-years',
2399     'section'     => 'UI',
2400     'description' => 'Number of years to show old (cancelled and one-time charge) packages by default.  Currently defaults to 2.',
2401     'type'        => 'text',
2402   },
2403
2404   {
2405     'key'         => 'cust_main-use_comments',
2406     'section'     => 'UI',
2407     'description' => 'Display free form comments on the customer edit screen.  Useful as a scratch pad.',
2408     'type'        => 'checkbox',
2409   },
2410
2411   {
2412     'key'         => 'cust_main-disable_notes',
2413     'section'     => 'UI',
2414     'description' => 'Disable new style customer notes - timestamped and user identified customer notes.  Useful in tracking who did what.',
2415     'type'        => 'checkbox',
2416   },
2417
2418   {
2419     'key'         => 'cust_main_note-display_times',
2420     'section'     => 'UI',
2421     'description' => 'Display full timestamps (not just dates) for customer notes.',
2422     'type'        => 'checkbox',
2423   },
2424
2425   {
2426     'key'         => 'cust_main-ticket_statuses',
2427     'section'     => 'UI',
2428     'description' => 'Show tickets with these statuses on the customer view page.',
2429     'type'        => 'selectmultiple',
2430     'select_enum' => [qw( new open stalled resolved rejected deleted )],
2431   },
2432
2433   {
2434     'key'         => 'cust_main-max_tickets',
2435     'section'     => 'UI',
2436     'description' => 'Maximum number of tickets to show on the customer view page.',
2437     'type'        => 'text',
2438   },
2439
2440   {
2441     'key'         => 'cust_main-skeleton_tables',
2442     'section'     => '',
2443     '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.',
2444     'type'        => 'textarea',
2445   },
2446
2447   {
2448     'key'         => 'cust_main-skeleton_custnum',
2449     'section'     => '',
2450     'description' => 'Customer number specifying the source data to copy into skeleton tables for new customers.',
2451     'type'        => 'text',
2452   },
2453
2454   {
2455     'key'         => 'cust_main-enable_birthdate',
2456     'section'     => 'UI',
2457     'descritpion' => 'Enable tracking of a birth date with each customer record',
2458     'type'        => 'checkbox',
2459   },
2460
2461   {
2462     'key'         => 'support-key',
2463     'section'     => '',
2464     '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.',
2465     'type'        => 'text',
2466   },
2467
2468   {
2469     'key'         => 'card-types',
2470     'section'     => 'billing',
2471     'description' => 'Select one or more card types to enable only those card types.  If no card types are selected, all card types are available.',
2472     'type'        => 'selectmultiple',
2473     'select_enum' => \@card_types,
2474   },
2475
2476   {
2477     'key'         => 'disable-fuzzy',
2478     'section'     => 'UI',
2479     'description' => 'Disable fuzzy searching.  Speeds up searching for large sites, but only shows exact matches.',
2480     'type'        => 'checkbox',
2481   },
2482
2483   { 'key'         => 'pkg_referral',
2484     'section'     => '',
2485     'description' => 'Enable package-specific advertising sources.',
2486     'type'        => 'checkbox',
2487   },
2488
2489   { 'key'         => 'pkg_referral-multiple',
2490     'section'     => '',
2491     'description' => 'In addition, allow multiple advertising sources to be associated with a single package.',
2492     'type'        => 'checkbox',
2493   },
2494
2495   {
2496     'key'         => 'dashboard-install_welcome',
2497     'section'     => 'UI',
2498     'description' => 'New install welcome screen.',
2499     'type'        => 'select',
2500     'select_enum' => [ '', 'ITSP_fsinc_hosted', ],
2501   },
2502
2503   {
2504     'key'         => 'dashboard-toplist',
2505     'section'     => 'UI',
2506     'description' => 'List of items to display on the top of the front page',
2507     'type'        => 'textarea',
2508   },
2509
2510   {
2511     'key'         => 'impending_recur_template',
2512     'section'     => 'billing',
2513     'description' => 'Template file for alerts about looming first time recurrant billing.  See the <a href="http://search.cpan.org/dist/Text-Template/lib/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>',
2514 # <li><code>$payby</code> <li><code>$expdate</code> most likely only confuse
2515     'type'        => 'textarea',
2516   },
2517
2518   {
2519     'key'         => 'logo.png',
2520     'section'     => 'billing',  #? 
2521     'description' => 'Company logo for HTML invoices and the backoffice interface, in PNG format.  Suggested size somewhere near 92x62.',
2522     'type'        => 'image',
2523     'per_agent'   => 1, #XXX just view/logo.cgi, which is for the global
2524                         #old-style editor anyway...?
2525   },
2526
2527   {
2528     'key'         => 'logo.eps',
2529     'section'     => 'billing',  #? 
2530     'description' => 'Company logo for printed and PDF invoices, in EPS format.',
2531     'type'        => 'image',
2532     'per_agent'   => 1, #XXX as above, kinda
2533   },
2534
2535   {
2536     'key'         => 'selfservice-ignore_quantity',
2537     'section'     => '',
2538     'description' => 'Ignores service quantity restrictions in self-service context.  Strongly not recommended - just set your quantities correctly in the first place.',
2539     'type'        => 'checkbox',
2540   },
2541
2542   {
2543     'key'         => 'selfservice-session_timeout',
2544     'section'     => '',
2545     'description' => 'Self-service session timeout.  Defaults to 1 hour.',
2546     'type'        => 'select',
2547     'select_enum' => [ '1 hour', '2 hours', '4 hours', '8 hours', '1 day', '1 week', ],
2548   },
2549
2550   {
2551     'key'         => 'disable_setup_suspended_pkgs',
2552     'section'     => 'billing',
2553     'description' => 'Disables charging of setup fees for suspended packages.',
2554     'type'       => 'checkbox',
2555   },
2556
2557   {
2558     'key' => 'password-generated-allcaps',
2559     'section' => 'password',
2560     'description' => 'Causes passwords automatically generated to consist entirely of capital letters',
2561     'type' => 'checkbox',
2562   },
2563
2564   {
2565     'key'         => 'datavolume-forcemegabytes',
2566     'section'     => 'UI',
2567     'description' => 'All data volumes are expressed in megabytes',
2568     'type'        => 'checkbox',
2569   },
2570
2571   {
2572     'key'         => 'datavolume-significantdigits',
2573     'section'     => 'UI',
2574     'description' => 'number of significant digits to use to represent data volumes',
2575     'type'        => 'text',
2576   },
2577
2578   {
2579     'key'         => 'disable_void_after',
2580     'section'     => 'billing',
2581     'description' => 'Number of seconds after which freeside won\'t attempt to VOID a payment first when performing a refund.',
2582     'type'        => 'text',
2583   },
2584
2585   {
2586     'key'         => 'disable_line_item_date_ranges',
2587     'section'     => 'billing',
2588     'description' => 'Prevent freeside from automatically generating date ranges on invoice line items.',
2589     'type'        => 'checkbox',
2590   },
2591
2592   {
2593     'key'         => 'support_packages',
2594     'section'     => '',
2595     '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...
2596     'type'        => 'select-part_pkg',
2597     'multiple'    => 1,
2598   },
2599
2600   {
2601     'key'         => 'cust_main-require_phone',
2602     'section'     => '',
2603     'description' => 'Require daytime or night phone for all customer records.',
2604     'type'        => 'checkbox',
2605   },
2606
2607   {
2608     'key'         => 'cust_main-require_invoicing_list_email',
2609     'section'     => '',
2610     'description' => 'Email address field is required: require at least one invoicing email address for all customer records.',
2611     'type'        => 'checkbox',
2612   },
2613
2614   {
2615     'key'         => 'svc_acct-display_paid_time_remaining',
2616     'section'     => '',
2617     'description' => 'Show paid time remaining in addition to time remaining.',
2618     'type'        => 'checkbox',
2619   },
2620
2621   {
2622     'key'         => 'cancel_credit_type',
2623     'section'     => 'billing',
2624     'description' => 'The group to use for new, automatically generated credit reasons resulting from cancellation.',
2625     'type'        => 'select-sub',
2626     'options_sub' => sub { require FS::Record;
2627                            require FS::reason_type;
2628                            map { $_->typenum => $_->type }
2629                                FS::Record::qsearch('reason_type', { class=>'R' } );
2630                          },
2631     'option_sub'  => sub { require FS::Record;
2632                            require FS::reason_type;
2633                            my $reason_type = FS::Record::qsearchs(
2634                              'reason_type', { 'typenum' => shift }
2635                            );
2636                            $reason_type ? $reason_type->type : '';
2637                          },
2638   },
2639
2640   {
2641     'key'         => 'referral_credit_type',
2642     'section'     => 'deprecated',
2643     'description' => 'Used to be the group to use for new, automatically generated credit reasons resulting from referrals.  Now set in a package billing event for the referral.',
2644     'type'        => 'select-sub',
2645     'options_sub' => sub { require FS::Record;
2646                            require FS::reason_type;
2647                            map { $_->typenum => $_->type }
2648                                FS::Record::qsearch('reason_type', { class=>'R' } );
2649                          },
2650     'option_sub'  => sub { require FS::Record;
2651                            require FS::reason_type;
2652                            my $reason_type = FS::Record::qsearchs(
2653                              'reason_type', { 'typenum' => shift }
2654                            );
2655                            $reason_type ? $reason_type->type : '';
2656                          },
2657   },
2658
2659   {
2660     'key'         => 'signup_credit_type',
2661     'section'     => 'billing',
2662     'description' => 'The group to use for new, automatically generated credit reasons resulting from signup and self-service declines.',
2663     'type'        => 'select-sub',
2664     'options_sub' => sub { require FS::Record;
2665                            require FS::reason_type;
2666                            map { $_->typenum => $_->type }
2667                                FS::Record::qsearch('reason_type', { class=>'R' } );
2668                          },
2669     'option_sub'  => sub { require FS::Record;
2670                            require FS::reason_type;
2671                            my $reason_type = FS::Record::qsearchs(
2672                              'reason_type', { 'typenum' => shift }
2673                            );
2674                            $reason_type ? $reason_type->type : '';
2675                          },
2676   },
2677
2678   {
2679     'key'         => 'cust_main-agent_custid-format',
2680     'section'     => '',
2681     'description' => 'Enables searching of various formatted values in cust_main.agent_custid',
2682     'type'        => 'select',
2683     'select_hash' => [
2684                        ''      => 'Numeric only',
2685                        'ww?d+' => 'Numeric with one or two letter prefix',
2686                      ],
2687   },
2688
2689   {
2690     'key'         => 'card_masking_method',
2691     'section'     => 'UI',
2692     '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.  Note: You should manually remove stored paymasks if you change this value on an existing database, to avoid problems using stored cards.',
2693     'type'        => 'select',
2694     'select_hash' => [
2695                        ''            => '123456xxxxxx1234',
2696                        'first6last2' => '123456xxxxxxxx12',
2697                        'first4last4' => '1234xxxxxxxx1234',
2698                        'first4last2' => '1234xxxxxxxxxx12',
2699                        'first2last4' => '12xxxxxxxxxx1234',
2700                        'first2last2' => '12xxxxxxxxxxxx12',
2701                        'first0last4' => 'xxxxxxxxxxxx1234',
2702                        'first0last2' => 'xxxxxxxxxxxxxx12',
2703                      ],
2704   },
2705
2706   {
2707     'key'         => 'disable_previous_balance',
2708     'section'     => 'billing',
2709     'description' => 'Disable inclusion of previous balancem payment, and credit lines on invoices',
2710     'type'        => 'checkbox',
2711   },
2712
2713   {
2714     'key'         => 'previous_balance-summary_only',
2715     'section'     => 'billing',
2716     'description' => 'Only show a single line summarizing the total previous balance rather than one line per invoice.',
2717     'type'        => 'checkbox',
2718   },
2719
2720   {
2721     'key'         => 'usps_webtools-userid',
2722     'section'     => 'UI',
2723     'description' => 'Production UserID for USPS web tools.   Enables USPS address standardization.  See the <a href="http://www.usps.com/webtools/">USPS website</a>, register and agree not to use the tools for batch purposes.',
2724     'type'        => 'text',
2725   },
2726
2727   {
2728     'key'         => 'usps_webtools-password',
2729     'section'     => 'UI',
2730     'description' => 'Production password for USPS web tools.   Enables USPS address standardization.  See <a href="http://www.usps.com/webtools/">USPS website</a>, register and agree not to use the tools for batch purposes.',
2731     'type'        => 'text',
2732   },
2733
2734   {
2735     'key'         => 'cust_main-auto_standardize_address',
2736     'section'     => 'UI',
2737     'description' => 'When using USPS web tools, automatically standardize the address without asking.',
2738     'type'        => 'checkbox',
2739   },
2740
2741   {
2742     'key'         => 'cust_main-require_censustract',
2743     'section'     => 'UI',
2744     'description' => 'Customer is required to have a census tract.  Useful for FCC form 477 reports. See also: cust_main-auto_standardize_address',
2745     'type'        => 'checkbox',
2746   },
2747
2748   {
2749     'key'         => 'census_year',
2750     'section'     => 'UI',
2751     'description' => 'The year to use in census tract lookups',
2752     'type'        => 'select',
2753     'select_enum' => [ qw( 2009 2008 2007 2006 ) ],
2754   },
2755
2756   {
2757     'key'         => 'company_latitude',
2758     'section'     => 'UI',
2759     'description' => 'Your company latitude (-90 through 90)',
2760     'type'        => 'text',
2761   },
2762
2763   {
2764     'key'         => 'company_longitude',
2765     'section'     => 'UI',
2766     'description' => 'Your company longitude (-180 thru 180)',
2767     'type'        => 'text',
2768   },
2769
2770   {
2771     'key'         => 'disable_acl_changes',
2772     'section'     => '',
2773     'description' => 'Disable all ACL changes, for demos.',
2774     'type'        => 'checkbox',
2775   },
2776
2777   {
2778     'key'         => 'cust_main-edit_agent_custid',
2779     'section'     => 'UI',
2780     'description' => 'Enable editing of the agent_custid field.',
2781     'type'        => 'checkbox',
2782   },
2783
2784   {
2785     'key'         => 'cust_main-default_agent_custid',
2786     'section'     => 'UI',
2787     'description' => 'Display the agent_custid field when available instead of the custnum field.',
2788     'type'        => 'checkbox',
2789   },
2790
2791   {
2792     'key'         => 'cust_bill-default_agent_invid',
2793     'section'     => 'UI',
2794     'description' => 'Display the agent_invid field when available instead of the invnum field.',
2795     'type'        => 'checkbox',
2796   },
2797
2798   {
2799     'key'         => 'cust_main-auto_agent_custid',
2800     'section'     => 'UI',
2801     'description' => 'Automatically assign an agent_custid - select format',
2802     'type'        => 'select',
2803     'select_hash' => [ '' => 'No',
2804                        '1YMMXXXXXXXX' => '1YMMXXXXXXXX',
2805                      ],
2806   },
2807
2808   {
2809     'key'         => 'cust_main-default_areacode',
2810     'section'     => 'UI',
2811     'description' => 'Default area code for customers.',
2812     'type'        => 'text',
2813   },
2814
2815   {
2816     'key'         => 'mcp_svcpart',
2817     'section'     => '',
2818     'description' => 'Master Control Program svcpart.  Leave this blank.',
2819     'type'        => 'text', #select-part_svc
2820   },
2821
2822   {
2823     'key'         => 'cust_bill-max_same_services',
2824     'section'     => 'billing',
2825     'description' => 'Maximum number of the same service to list individually on invoices before condensing to a single line listing the number of services.  Defaults to 5.',
2826     'type'        => 'text',
2827   },
2828
2829   {
2830     'key'         => 'suspend_email_admin',
2831     'section'     => '',
2832     'description' => 'Destination admin email address to enable suspension notices',
2833     'type'        => 'text',
2834   },
2835
2836   {
2837     'key'         => 'email_report-subject',
2838     'section'     => '',
2839     'description' => 'Subject for reports emailed by freeside-fetch.  Defaults to "Freeside report".',
2840     'type'        => 'text',
2841   },
2842
2843   {
2844     'key'         => 'selfservice-head',
2845     'section'     => '',
2846     'description' => 'HTML for the HEAD section of the self-service interface, typically used for LINK stylesheet tags',
2847     'type'        => 'textarea', #htmlarea?
2848   },
2849
2850
2851   {
2852     'key'         => 'selfservice-body_header',
2853     'section'     => '',
2854     'description' => 'HTML header for the self-service interface',
2855     'type'        => 'textarea', #htmlarea?
2856   },
2857
2858   {
2859     'key'         => 'selfservice-body_footer',
2860     'section'     => '',
2861     'description' => 'HTML header for the self-service interface',
2862     'type'        => 'textarea', #htmlarea?
2863   },
2864
2865
2866   {
2867     'key'         => 'selfservice-body_bgcolor',
2868     'section'     => '',
2869     'description' => 'HTML background color for the self-service interface, for example, #FFFFFF',
2870     'type'        => 'text',
2871   },
2872
2873   {
2874     'key'         => 'selfservice-box_bgcolor',
2875     'section'     => '',
2876     'description' => 'HTML color for self-service interface input boxes, for example, #C0C0C0"',
2877     'type'        => 'text',
2878   },
2879
2880   {
2881     'key'         => 'selfservice-bulk_format',
2882     'section'     => '',
2883     'description' => 'Parameter arrangement for selfservice bulk features',
2884     'type'        => 'select',
2885     'select_enum' => [ '', 'izoom-soap', 'izoom-ftp' ],
2886     'per_agent'   => 1,
2887   },
2888
2889   {
2890     'key'         => 'selfservice-bulk_ftp_dir',
2891     'section'     => '',
2892     'description' => 'Enable bulk ftp provisioning in this folder',
2893     'type'        => 'text',
2894     'per_agent'   => 1,
2895   },
2896
2897   {
2898     'key'         => 'signup-no_company',
2899     'section'     => '',
2900     'description' => "Don't display a field for company name on signup.",
2901     'type'        => 'checkbox',
2902   },
2903
2904   {
2905     'key'         => 'signup-recommend_email',
2906     'section'     => '',
2907     'description' => 'Encourage the entry of an invoicing email address on signup.',
2908     'type'        => 'checkbox',
2909   },
2910
2911   {
2912     'key'         => 'signup-recommend_daytime',
2913     'section'     => '',
2914     'description' => 'Encourage the entry of a daytime phone number  invoicing email address on signup.',
2915     'type'        => 'checkbox',
2916   },
2917
2918   {
2919     'key'         => 'svc_phone-radius-default_password',
2920     'section'     => '',
2921     'description' => 'Default password when exporting svc_phone records to RADIUS',
2922     'type'        => 'text',
2923   },
2924
2925   {
2926     'key'         => 'svc_phone-allow_alpha_phonenum',
2927     'section'     => '',
2928     'description' => 'Allow letters in phone numbers.',
2929     'type'        => 'checkbox',
2930   },
2931
2932   {
2933     'key'         => 'default_phone_countrycode',
2934     'section'     => '',
2935     'description' => 'Default countrcode',
2936     'type'        => 'text',
2937   },
2938
2939   {
2940     'key'         => 'cdr-charged_party-accountcode',
2941     'section'     => '',
2942     'description' => 'Set the charged_party field of CDRs to the accountcode.',
2943     'type'        => 'checkbox',
2944   },
2945
2946   {
2947     'key'         => 'cdr-charged_party-accountcode-trim_leading_0s',
2948     'section'     => '',
2949     'description' => 'When setting the charged_party field of CDRs to the accountcode, trim any leading zeros.',
2950     'type'        => 'checkbox',
2951   },
2952
2953 #  {
2954 #    'key'         => 'cdr-charged_party-truncate_prefix',
2955 #    'section'     => '',
2956 #    'description' => 'If the charged_party field has this prefix, truncate it to the length in cdr-charged_party-truncate_length.',
2957 #    'type'        => 'text',
2958 #  },
2959 #
2960 #  {
2961 #    'key'         => 'cdr-charged_party-truncate_length',
2962 #    'section'     => '',
2963 #    'description' => 'If the charged_party field has the prefix in cdr-charged_party-truncate_prefix, truncate it to this length.',
2964 #    'type'        => 'text',
2965 #  },
2966
2967   {
2968     'key'         => 'cdr-charged_party_rewrite',
2969     'section'     => '',
2970     'description' => 'Do charged party rewriting in the freeside-cdrrewrited daemon; useful if CDRs are being dropped off directly in the database and require special charged_party processing such as cdr-charged_party-accountcode or cdr-charged_party-truncate*.',
2971     'type'        => 'checkbox',
2972   },
2973
2974   {
2975     'key'         => 'cdr-taqua-da_rewrite',
2976     'section'     => '',
2977     'description' => 'For the Taqua CDR format, a comma-separated list of directory assistance 800 numbers.  Any CDRs with these numbers as "BilledNumber" will be rewritten to the "CallingPartyNumber" (and CallType "12") on import.',
2978     'type'        => 'text',
2979   },
2980
2981   {
2982     'key'         => 'cust_pkg-show_autosuspend',
2983     'section'     => 'UI',
2984     'description' => 'Show package auto-suspend dates.  Use with caution for now; can slow down customer view for large insallations.',
2985     'type'       => 'checkbox',
2986   },
2987
2988   {
2989     'key'         => 'cdr-asterisk_forward_rewrite',
2990     'section'     => '',
2991     'description' => 'Enable special processing for CDRs representing forwarded calls: For CDRs that have a dcontext that starts with "Local/" but does not match dst, set charged_party to dst, parse a new dst from dstchannel, and set amaflags to "2" ("BILL"/"BILLING").',
2992     'type'        => 'checkbox',
2993   },
2994
2995   {
2996     'key'         => 'sg-multicustomer_hack',
2997     'section'     => '',
2998     'description' => "Don't use this.",
2999     'type'        => 'checkbox',
3000   },
3001
3002   {
3003     'key'         => 'sg-ping_username',
3004     'section'     => '',
3005     'description' => "Don't use this.",
3006     'type'        => 'text',
3007   },
3008
3009   {
3010     'key'         => 'sg-ping_password',
3011     'section'     => '',
3012     'description' => "Don't use this.",
3013     'type'        => 'text',
3014   },
3015
3016   {
3017     'key'         => 'sg-login_username',
3018     'section'     => '',
3019     'description' => "Don't use this.",
3020     'type'        => 'text',
3021   },
3022
3023   {
3024     'key'         => 'disable-cust-pkg_class',
3025     'section'     => 'UI',
3026     'description' => 'Disable the two-step dropdown for selecting package class and package, and return to the classic single dropdown.',
3027     'type'        => 'checkbox',
3028   },
3029
3030   {
3031     'key'         => 'queued-max_kids',
3032     'section'     => '',
3033     'description' => 'Maximum number of queued processes.  Defaults to 10.',
3034     'type'        => 'text',
3035   },
3036
3037   {
3038     'key'         => 'cancelled_cust-noevents',
3039     'section'     => 'billing',
3040     'description' => "Don't run events for cancelled customers",
3041     'type'        => 'checkbox',
3042   },
3043
3044   {
3045     'key'         => 'agent-invoice_template',
3046     'section'     => 'billing',
3047     'description' => 'Enable display/edit of old-style per-agent invoice template selection',
3048     'type'        => 'checkbox',
3049   },
3050
3051   {
3052     'key'         => 'svc_broadband-manage_link',
3053     'section'     => 'UI',
3054     'description' => 'URL for svc_broadband "Manage Device" link.  The following substitutions are available: $ip_addr.',
3055     'type'        => 'text',
3056   },
3057
3058   #more fine-grained, service def-level control could be useful eventually?
3059   {
3060     'key'         => 'svc_broadband-allow_null_ip_addr',
3061     'section'     => '',
3062     'description' => '',
3063     'type'        => 'checkbox',
3064   },
3065
3066   {
3067     'key'         => 'tax-report_groups',
3068     'section'     => '',
3069     'description' => 'List of grouping possibilities for tax names on reports, one per line, "label op value" (op can be = or !=).',
3070     'type'        => 'textarea',
3071   },
3072
3073   {
3074     'key'         => 'tax-cust_exempt-groups',
3075     'section'     => '',
3076     'description' => 'List of grouping possibilities for tax names, for per-customer exemption purposes, one tax name per line.  For example, "GST" would indicate the ability to exempt customers individually from taxes named "GST" (but not other taxes).',
3077     'type'        => 'textarea',
3078   },
3079
3080   {
3081     'key'         => 'cust_main-default_view',
3082     'section'     => 'UI',
3083     'description' => 'Default customer view, for users who have not selected a default view in their preferences.',
3084     'type'        => 'select',
3085     'select_hash' => [
3086       #false laziness w/view/cust_main.cgi and pref/pref.html
3087       'basics'          => 'Basics',
3088       'notes'           => 'Notes',
3089       'tickets'         => 'Tickets',
3090       'packages'        => 'Packages',
3091       'payment_history' => 'Payment History',
3092       'change_history'  => 'Change History',
3093       'jumbo'           => 'Jumbo',
3094     ],
3095   },
3096
3097   {
3098     'key'         => 'enable_tax_adjustments',
3099     'section'     => 'billing',
3100     'description' => 'Enable the ability to add manual tax adjustments.',
3101     'type'        => 'checkbox',
3102   },
3103
3104   {
3105     'key'         => 'rt-crontool',
3106     'section'     => '',
3107     'description' => 'Enable the RT CronTool extension.',
3108     'type'        => 'checkbox',
3109   },
3110
3111   {
3112     'key'         => 'pkg-balances',
3113     'section'     => 'billing',
3114     'description' => 'Enable experimental package balances.  Not recommended for general use.',
3115     'type'        => 'checkbox',
3116   },
3117
3118   {
3119     'key'         => 'cust_main-edit_signupdate',
3120     'section'     => 'UI',
3121     'descritpion' => 'Enable manual editing of the signup date.',
3122     'type'        => 'checkbox',
3123   },
3124
3125   {
3126     'key'         => 'svc_acct-disable_access_number',
3127     'section'     => 'UI',
3128     'descritpion' => 'Disable access number selection.',
3129     'type'        => 'checkbox',
3130   },
3131
3132   { key => "apacheroot", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3133   { key => "apachemachine", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3134   { key => "apachemachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3135   { key => "bindprimary", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3136   { key => "bindsecondaries", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3137   { key => "bsdshellmachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3138   { key => "cyrus", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3139   { key => "cp_app", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3140   { key => "erpcdmachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3141   { key => "icradiusmachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3142   { key => "icradius_mysqldest", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3143   { key => "icradius_mysqlsource", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3144   { key => "icradius_secrets", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3145   { key => "maildisablecatchall", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3146   { key => "mxmachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3147   { key => "nsmachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3148   { key => "arecords", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3149   { key => "cnamerecords", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3150   { key => "nismachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3151   { key => "qmailmachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3152   { key => "radiusmachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3153   { key => "sendmailconfigpath", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3154   { key => "sendmailmachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3155   { key => "sendmailrestart", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3156   { key => "shellmachine", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3157   { key => "shellmachine-useradd", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3158   { key => "shellmachine-userdel", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3159   { key => "shellmachine-usermod", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3160   { key => "shellmachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3161   { key => "radiusprepend", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3162   { key => "textradiusprepend", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3163   { key => "username_policy", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3164   { key => "vpopmailmachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3165   { key => "vpopmailrestart", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3166   { key => "safe-part_pkg", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3167   { key => "selfservice_server-quiet", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3168   { key => "signup_server-quiet", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3169   { key => "signup_server-email", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3170   { key => "vonage-username", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3171   { key => "vonage-password", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3172   { key => "vonage-fromnumber", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
3173
3174 );
3175
3176 1;
3177