make the config directory configurable
[freeside.git] / FS / FS / Conf.pm
index 03b3766..270b61c 100644 (file)
@@ -1,9 +1,14 @@
 package FS::Conf;
 
-use vars qw($default_dir @config_items $DEBUG );
+use vars qw($default_dir $base_dir @config_items @card_types $DEBUG );
 use IO::File;
 use File::Basename;
 use FS::ConfItem;
+use FS::ConfDefaults;
+
+$base_dir = '%%%FREESIDE_CONF%%%';
+$default_dir = '%%%FREESIDE_CONF%%%';
+
 
 $DEBUG = 0;
 
@@ -51,13 +56,15 @@ $FS::Conf::default_dir has not been set.
 sub new {
   my($proto,$dir) = @_;
   my($class) = ref($proto) || $proto;
-  my($self) = { 'dir' => $dir || $default_dir } ;
+  my($self) = { 'dir'      => $dir || $default_dir,
+                'base_dir' => $base_dir,
+              };
   bless ($self, $class);
 }
 
 =item dir
 
-Returns the directory.
+Returns the conf directory.
 
 =cut
 
@@ -72,6 +79,23 @@ sub dir {
   $1;
 }
 
+=item base_dir
+
+Returns the base directory.  By default this is /usr/local/etc/freeside.
+
+=cut
+
+sub base_dir {
+  my($self) = @_;
+  my $base_dir = $self->{base_dir};
+  -e $base_dir or die "FATAL: $base_dir doesn't exist!";
+  -d $base_dir or die "FATAL: $base_dir isn't a directory!";
+  -r $base_dir or die "FATAL: Can't read $base_dir!";
+  -x $base_dir or die "FATAL: $base_dir not searchable (executable)!";
+  $base_dir =~ /^(.*)$/;
+  $1;
+}
+
 =item config KEY
 
 Returns the configuration value or values (depending on context) for key.
@@ -95,6 +119,21 @@ sub config {
   }
 }
 
+=item config_binary KEY
+
+Returns the exact scalar value for key.
+
+=cut
+
+sub config_binary {
+  my($self,$file)=@_;
+  my($dir)=$self->dir;
+  my $fh = new IO::File "<$dir/$file" or return;
+  local $/;
+  my $content = <$fh>;
+  $content;
+}
+
 =item exists KEY
 
 Returns true if the specified key exists, even if the corresponding value
@@ -108,6 +147,22 @@ sub exists {
   -e "$dir/$file";
 }
 
+=item config_orbase KEY SUFFIX
+
+Returns the configuration value or values (depending on context) for 
+KEY_SUFFIX, if it exists, otherwise for KEY
+
+=cut
+
+sub config_orbase {
+  my( $self, $file, $suffix ) = @_;
+  if ( $self->exists("${file}_$suffix") ) {
+    $self->config("${file}_$suffix");
+  } else {
+    $self->config($file);
+  }
+}
+
 =item touch KEY
 
 Creates the specified configuration key if it does not exist.
@@ -193,10 +248,47 @@ sub config_items {
         new FS::ConfItem {
                            'key'         => $basename,
                            'section'     => 'billing',
+                           'description' => 'Alternate HTML template for invoices.  See the <a href="../docs/billing.html">billing documentation</a> for details.',
+                           'type'        => 'textarea',
+                         }
+      } glob($self->dir. '/invoice_html_*')
+  ),
+  ( map { 
+        my $basename = basename($_);
+        $basename =~ /^(.*)$/;
+        $basename = $1;
+        ($latexname = $basename ) =~ s/latex/html/;
+        new FS::ConfItem {
+                           'key'         => $basename,
+                           'section'     => 'billing',
+                           'description' => "Alternate Notes section for HTML invoices.  Defaults to the same data in $latexname if not specified.",
+                           'type'        => 'textarea',
+                         }
+      } glob($self->dir. '/invoice_htmlnotes_*')
+  ),
+  ( map { 
+        my $basename = basename($_);
+        $basename =~ /^(.*)$/;
+        $basename = $1;
+        new FS::ConfItem {
+                           'key'         => $basename,
+                           'section'     => 'billing',
                            'description' => 'Alternate LaTeX template for invoices.  See the <a href="../docs/billing.html">billing documentation</a> for details.',
                            'type'        => 'textarea',
                          }
       } glob($self->dir. '/invoice_latex_*')
+  ),
+  ( map { 
+        my $basename = basename($_);
+        $basename =~ /^(.*)$/;
+        $basename = $1;
+        new FS::ConfItem {
+                           'key'         => $basename,
+                           'section'     => 'billing',
+                           'description' => 'Alternate Notes section for LaTeX typeset PostScript invoices.  See the <a href="../docs/billing.html">billing documentation</a> for details.',
+                           'type'        => 'textarea',
+                         }
+      } glob($self->dir. '/invoice_latexnotes_*')
   );
 }
 
@@ -215,6 +307,20 @@ httemplate/docs/config.html
 
 =cut
 
+#Business::CreditCard
+@card_types = (
+  "VISA card",
+  "MasterCard",
+  "Discover card",
+  "American Express card",
+  "Diner's Club/Carte Blanche",
+  "enRoute",
+  "JCB",
+  "BankCard",
+  "Switch",
+  "Solo",
+);
+
 @config_items = map { new FS::ConfItem $_ } (
 
   {
@@ -274,6 +380,34 @@ httemplate/docs/config.html
   },
 
   {
+    'key'         => 'encryption',
+    'section'     => 'billing',
+    'description' => 'Enable encryption of credit cards.',
+    'type'        => 'checkbox',
+  },
+
+  {
+    'key'         => 'encryptionmodule',
+    'section'     => 'billing',
+    'description' => 'Use which module for encryption?',
+    'type'        => 'text',
+  },
+
+  {
+    'key'         => 'encryptionpublickey',
+    'section'     => 'billing',
+    'description' => 'Your RSA Public Key - Required if Encryption is turned on.',
+    'type'        => 'textarea',
+  },
+
+  {
+    'key'         => 'encryptionprivatekey',
+    'section'     => 'billing',
+    '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.',
+    'type'        => 'textarea',
+  },
+
+  {
     'key'         => 'business-onlinepayment',
     'section'     => 'billing',
     '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.',
@@ -295,6 +429,13 @@ httemplate/docs/config.html
   },
 
   {
+    'key'         => 'business-onlinepayment-email-override',
+    'section'     => 'billing',
+    'description' => 'Email address used instead of customer email address when submitting a BOP transaction.',
+    'type'        => 'text',
+  },
+
+  {
     'key'         => 'bsdshellmachines',
     'section'     => 'deprecated',
     'description' => '<b>DEPRECATED</b>, add a <i>bsdshell</i> <a href="../browse/part_export.cgi">export</a> instead.  Your BSD flavored shell (and mail) machines, one per line.  This enables export of `/etc/passwd\' and `/etc/master.passwd\'.',
@@ -309,6 +450,17 @@ httemplate/docs/config.html
   },
 
   {
+    'key'         => 'date_format',
+    'section'     => 'UI',
+    'description' => 'Format for displaying dates',
+    'type'        => 'select',
+    'select_hash' => [
+                       '%m/%d/%Y' => 'MM/DD/YYYY',
+                      '%Y/%m/%d' => 'YYYY/MM/DD',
+                     ],
+  },
+
+  {
     'key'         => 'cyrus',
     'section'     => 'deprecated',
     'description' => '<b>DEPRECATED</b>, add a <i>cyrus</i> <a href="../browse/part_export.cgi">export</a> instead.  This option used to integrate with <a href="http://asg.web.cmu.edu/cyrus/imapd/">Cyrus IMAP Server</a>, three lines: IMAP server, admin username, and admin password.  Cyrus::IMAP::Admin should be installed locally and the connection to the server secured.',
@@ -331,29 +483,29 @@ httemplate/docs/config.html
 
   {
     'key'         => 'deletepayments',
-    'section'     => 'UI',
-    'description' => 'Enable deletion of unclosed payments.  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.',
+    'section'     => 'billing',
+    '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.',
     'type'        => [qw( checkbox text )],
   },
 
   {
     'key'         => 'deletecredits',
-    'section'     => 'UI',
-    'description' => '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.',
+    'section'     => 'deprecated',
+    '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.',
     'type'        => [qw( checkbox text )],
   },
 
   {
     'key'         => 'unapplypayments',
-    'section'     => 'UI',
-    'description' => 'Enable "unapplication" of unclosed payments.',
+    'section'     => 'deprecated',
+    'description' => '<B>DEPRECATED</B>, now controlled by ACLs.  Used to enable "unapplication" of unclosed payments.',
     'type'        => 'checkbox',
   },
 
   {
     'key'         => 'unapplycredits',
-    'section'     => 'UI',
-    'description' => 'Enable "unapplication" of unclosed credits.',
+    'section'     => 'deprecated',
+    'description' => '<B>DEPRECATED</B>, now controlled by ACLs.  Used to nable "unapplication" of unclosed credits.',
     'type'        => 'checkbox',
   },
 
@@ -409,7 +561,7 @@ httemplate/docs/config.html
   {
     'key'         => 'erpcdmachines',
     'section'     => 'deprecated',
-    'description' => '<b>DEPRECATED</b>, ERPCD is no longer supported.  Used to be ERPCD authenticaion machines, one per line.  This enables export of `/usr/annex/acp_passwd\' and `/usr/annex/acp_dialup\'',
+    'description' => '<b>DEPRECATED</b>, ERPCD is no longer supported.  Used to be ERPCD authentication machines, one per line.  This enables export of `/usr/annex/acp_passwd\' and `/usr/annex/acp_dialup\'',
     'type'        => 'textarea',
   },
 
@@ -477,9 +629,38 @@ httemplate/docs/config.html
   },
 
   {
+    'key'         => 'invoice_html',
+    'section'     => 'billing',
+    'description' => 'Optional HTML template for invoices.  See the <a href="../docs/billing.html">billing documentation</a> for details.',
+
+    'type'        => 'textarea',
+  },
+
+  {
+    'key'         => 'invoice_htmlnotes',
+    'section'     => 'billing',
+    'description' => 'Notes section for HTML invoices.  Defaults to the same data in invoice_latexnotes if not specified.',
+    'type'        => 'textarea',
+  },
+
+  {
+    'key'         => 'invoice_htmlfooter',
+    'section'     => 'billing',
+    'description' => 'Footer for HTML invoices.  Defaults to the same data in invoice_latexfooter if not specified.',
+    'type'        => 'textarea',
+  },
+
+  {
+    'key'         => 'invoice_htmlreturnaddress',
+    'section'     => 'billing',
+    'description' => 'Return address for HTML invoices.  Defaults to the same data in invoice_latexreturnaddress if not specified.',
+    'type'        => 'textarea',
+  },
+
+  {
     'key'         => 'invoice_latex',
     'section'     => 'billing',
-    'description' => 'Optional LaTeX template for typeset PostScript invoices.',
+    'description' => 'Optional LaTeX template for typeset PostScript invoices.  See the <a href="../docs/billing.html">billing documentation</a> for details.',
     'type'        => 'textarea',
   },
 
@@ -498,12 +679,34 @@ httemplate/docs/config.html
   },
 
   {
+    'key'         => 'invoice_latexreturnaddress',
+    'section'     => 'billing',
+    'description' => 'Return address for LaTeX typeset PostScript invoices.',
+    'type'        => 'textarea',
+  },
+
+  {
     'key'         => 'invoice_latexsmallfooter',
     'section'     => 'billing',
     'description' => 'Optional small footer for multi-page LaTeX typeset PostScript invoices.',
     'type'        => 'textarea',
   },
 
+  {
+    'key'         => 'invoice_email_pdf',
+    'section'     => 'billing',
+    '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.',
+    'type'        => 'checkbox'
+  },
+
+  {
+    'key'         => 'invoice_email_pdf_note',
+    'section'     => 'billing',
+    'description' => 'If defined, this text will replace the default plain text invoice as the body of emailed PDF invoices.',
+    'type'        => 'textarea'
+  },
+
+
   { 
     'key'         => 'invoice_default_terms',
     'section'     => 'billing',
@@ -514,12 +717,19 @@ httemplate/docs/config.html
 
   {
     'key'         => 'invoice_send_receipts',
-    'section'     => 'billing',
-    'description' => 'Send receipts for payments and credits.',
+    'section'     => 'deprecated',
+    'description' => '<b>DEPRECATED</b>, this used to send an invoice copy on payments and credits.  See the payment_receipt_email and XXXX instead.',
     'type'        => 'checkbox',
   },
 
   {
+    'key'         => 'payment_receipt_email',
+    'section'     => 'billing',
+    'description' => 'Template file for payment receipts.  Payment receipts are sent to the customer email invoice destination(s) when a payment is received.  See the <a href="http://search.cpan.org/~mjd/Text-Template/lib/Text/Template.pm">Text::Template</a> documentation for details on the template substitution language.  The following variables are available: <ul><li><code>$date</code> <li><code>$name</code> <li><code>$paynum</code> - Freeside payment number <li><code>$paid</code> - Amount of payment <li><code>$payby</code> - Payment type (Card, Check, Electronic check, etc.) <li><code>$payinfo</code> - Masked credit card number or check number <li><code>$balance</code> - New balance</ul>',
+    'type'        => 'textarea',
+  },
+
+  {
     'key'         => 'lpr',
     'section'     => 'required',
     'description' => 'Print command for paper invoices, for example `lpr -h\'',
@@ -562,7 +772,7 @@ httemplate/docs/config.html
     'editlist_parts' => [ { type=>'text' },
                           { type=>'immutable', value=>'IN' },
                           { type=>'select',
-                            select_enum=>{ map { $_=>$_ } qw(A CNAME MX NS)} },
+                            select_enum=>{ map { $_=>$_ } qw(A CNAME MX NS TXT)} },
                           { type=> 'text' }, ],
   },
 
@@ -602,6 +812,20 @@ httemplate/docs/config.html
   },
 
   {
+    'key' => 'password-noampersand',
+    'section' => 'password',
+    'description' => 'Disallow ampersands in passwords',
+    'type' => 'checkbox',
+  },
+
+  {
+    'key' => 'password-noexclamation',
+    'section' => 'password',
+    'description' => 'Disallow exclamations in passwords (Not setting this could break old text Livingston or Cistron Radius servers)',
+    'type' => 'checkbox',
+  },
+
+  {
     'key'         => 'qmailmachines',
     'section'     => 'deprecated',
     'description' => '<b>DEPRECATED</b>, add <i>qmail</i> and <i>shellcommands</i> <a href="../browse/part_export.cgi">exports</a> instead.  This option used to export `/var/qmail/control/virtualdomains\', `/var/qmail/control/recipientmap\', and `/var/qmail/control/rcpthosts\'.  Setting this option (even if empty) also turns on user `.qmail-extension\' file maintenance in conjunction with the <b>shellmachine</b> option.',
@@ -630,8 +854,8 @@ httemplate/docs/config.html
 
   {
     'key'         => 'report_template',
-    'section'     => 'required',
-    'description' => 'Required template file for reports.  See the <a href="../docs/billing.html">billing documentation</a> for details.',
+    'section'     => 'deprecated',
+    'description' => 'Deprecated template file for reports.',
     'type'        => 'textarea',
   },
 
@@ -724,7 +948,7 @@ httemplate/docs/config.html
   {
     'key'         => 'showpasswords',
     'section'     => 'UI',
-    'description' => 'Display unencrypted user passwords in the web interface',
+    'description' => 'Display unencrypted user passwords in the backend (employee) web interface',
     'type'        => 'checkbox',
   },
 
@@ -813,6 +1037,13 @@ httemplate/docs/config.html
   },
 
   {
+    'key'         => 'unsuspend-always_adjust_next_bill_date',
+    'section'     => 'billing',
+    '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.',
+    'type'        => 'checkbox',
+  },
+
+  {
     'key'         => 'usernamemin',
     'section'     => 'username',
     'description' => 'Minimum username length (default 2)',
@@ -875,6 +1106,13 @@ httemplate/docs/config.html
     'type'        => 'checkbox',
   },
 
+  { 
+    'key'         => 'username-percent',
+    'section'     => 'username',
+    'description' => 'Allow the percent character (%) in usernames.',
+    'type'        => 'checkbox',
+  },
+
   {
     'key'         => 'username_policy',
     'section'     => 'deprecated',
@@ -900,8 +1138,8 @@ httemplate/docs/config.html
 
   {
     'key'         => 'safe-part_pkg',
-    'section'     => 'UI',
-    'description' => 'Validates package definition setup and recur expressions against a preset list.  Useful for webdemos, annoying to powerusers.',
+    'section'     => 'deprecated',
+    'description' => '<b>DEPRECATED</b>, obsolete.  Used to validate package definition setup and recur expressions against a preset list.  Useful for webdemos, annoying to powerusers.',
     'type'        => 'checkbox',
   },
 
@@ -934,6 +1172,13 @@ httemplate/docs/config.html
   },
 
   {
+    'key'         => 'legacy_link-steal',
+    'section'     => 'UI',
+    'description' => 'Allow "stealing" an already-audited service from one customer (or package) to another using the link function.',
+    'type'        => 'checkbox',
+  },
+
+  {
     'key'         => 'queue_dangerous_controls',
     'section'     => 'UI',
     '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.',
@@ -987,15 +1232,63 @@ httemplate/docs/config.html
   {
     'key'         => 'signup_server-default_agentnum',
     'section'     => '',
-    'description' => 'Default agentnum for the signup server',
-    'type'        => 'text',
+    'description' => 'Default agent for the signup server',
+    'type'        => 'select-sub',
+    'options_sub' => sub { require FS::Record;
+                           require FS::agent;
+                          map { $_->agentnum => $_->agent }
+                               FS::Record::qsearch('agent', { disabled=>'' } );
+                        },
+    'option_sub'  => sub { require FS::Record;
+                           require FS::agent;
+                          my $agent = FS::Record::qsearchs(
+                            'agent', { 'agentnum'=>shift }
+                          );
+                           $agent ? $agent->agent : '';
+                        },
   },
 
   {
     'key'         => 'signup_server-default_refnum',
     'section'     => '',
-    'description' => 'Default advertising source number for the signup server',
-    'type'        => 'text',
+    'description' => 'Default advertising source for the signup server',
+    'type'        => 'select-sub',
+    'options_sub' => sub { require FS::Record;
+                           require FS::part_referral;
+                           map { $_->refnum => $_->referral }
+                               FS::Record::qsearch( 'part_referral', 
+                                                   { 'disabled' => '' }
+                                                 );
+                        },
+    'option_sub'  => sub { require FS::Record;
+                           require FS::part_referral;
+                           my $part_referral = FS::Record::qsearchs(
+                            'part_referral', { 'refnum'=>shift } );
+                           $part_referral ? $part_referral->referral : '';
+                        },
+  },
+
+  {
+    'key'         => 'signup_server-default_pkgpart',
+    'section'     => '',
+    'description' => 'Default pakcage for the signup server',
+    'type'        => 'select-sub',
+    'options_sub' => sub { require FS::Record;
+                           require FS::part_pkg;
+                           map { $_->pkgpart => $_->pkg.' - '.$_->comment }
+                               FS::Record::qsearch( 'part_pkg',
+                                                   { 'disabled' => ''}
+                                                 );
+                        },
+    'option_sub'  => sub { require FS::Record;
+                           require FS::part_pkg;
+                           my $part_pkg = FS::Record::qsearchs(
+                            'part_pkg', { 'pkgpart'=>shift }
+                          );
+                           $part_pkg
+                            ? $part_pkg->pkg.' - '.$part_pkg->comment
+                            : '';
+                        },
   },
 
   {
@@ -1008,7 +1301,51 @@ httemplate/docs/config.html
   {
     'key'         => 'signup_server-realtime',
     'section'     => '',
-    'description' => 'Run billing for signup server signups immediately, and suspend accounts which subsequently have a balance.',
+    'description' => 'Run billing for signup server signups immediately, and do not provision accounts which subsequently have a balance.',
+    'type'        => 'checkbox',
+  },
+  {
+    'key'         => 'signup_server-classnum2',
+    'section'     => '',
+    'description' => 'Package Class for first optional purchase',
+    'type'        => 'select-sub',
+    'options_sub' => sub { require FS::Record;
+                           require FS::pkg_class;
+                           map { $_->classnum => $_->classname }
+                               FS::Record::qsearch('pkg_class', {} );
+                        },
+    'option_sub'  => sub { require FS::Record;
+                           require FS::pkg_class;
+                           my $pkg_class = FS::Record::qsearchs(
+                            'pkg_class', { 'classnum'=>shift }
+                          );
+                           $pkg_class ? $pkg_class->classname : '';
+                        },
+  },
+
+  {
+    'key'         => 'signup_server-classnum3',
+    'section'     => '',
+    'description' => 'Package Class for second optional purchase',
+    'type'        => 'select-sub',
+    'options_sub' => sub { require FS::Record;
+                           require FS::pkg_class;
+                           map { $_->classnum => $_->classname }
+                               FS::Record::qsearch('pkg_class', {} );
+                        },
+    'option_sub'  => sub { require FS::Record;
+                           require FS::pkg_class;
+                           my $pkg_class = FS::Record::qsearchs(
+                            'pkg_class', { 'classnum'=>shift }
+                          );
+                           $pkg_class ? $pkg_class->classname : '';
+                        },
+  },
+
+  {
+    'key'         => 'backend-realtime',
+    'section'     => '',
+    'description' => 'Run billing for backend signups immediately.',
     'type'        => 'checkbox',
   },
 
@@ -1069,9 +1406,16 @@ httemplate/docs/config.html
   },
 
   {
+    'key'         => 'require_taxclasses',
+    'section'     => 'billing',
+    'description' => 'Require a taxclass to be entered for every package',
+    'type'        => 'checkbox',
+  },
+
+  {
     'key'         => 'welcome_email',
     'section'     => '',
-    '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/doc/MJD/Text-Template-1.42/Template.pm">Text::Template</a> documentation for details on the template substitution language.  The following variables are available: <code>$username</code>, <code>$password</code>, <code>$first</code>, <code>$last</code> and <code>$pkg</code>.',
+    'description' => 'Template file for welcome email.  Welcome emails are sent to the customer email invoice destination(s) each time a svc_acct record is created.  See the <a href="http://search.cpan.org/~mjd/Text-Template/lib/Text/Template.pm">Text::Template</a> documentation for details on the template substitution language.  The following variables are available<ul><li><code>$username</code> <li><code>$password</code> <li><code>$first</code> <li><code>$last</code> <li><code>$pkg</code></ul>',
     'type'        => 'textarea',
   },
 
@@ -1098,11 +1442,55 @@ httemplate/docs/config.html
   },
 
   {
+    'key'         => 'warning_email',
+    'section'     => '',
+    'description' => 'Template file for warning email.  Warning emails are sent to the customer email invoice destination(s) each time a svc_acct record has its usage drop below a threshold or 0.  See the <a href="http://search.cpan.org/~mjd/Text-Template/lib/Text/Template.pm">Text::Template</a> documentation for details on the template substitution language.  The following variables are available<ul><li><code>$username</code> <li><code>$password</code> <li><code>$first</code> <li><code>$last</code> <li><code>$pkg</code> <li><code>$column</code> <li><code>$amount</code> <li><code>$threshold</code></ul>',
+    'type'        => 'textarea',
+  },
+
+  {
+    'key'         => 'warning_email-from',
+    'section'     => '',
+    'description' => 'From: address header for warning email',
+    'type'        => 'text',
+  },
+
+  {
+    'key'         => 'warning_email-cc',
+    'section'     => '',
+    'description' => 'Additional recipient(s) (comma separated) for warning email when remaining usage reaches zero.',
+    'type'        => 'text',
+  },
+
+  {
+    'key'         => 'warning_email-subject',
+    'section'     => '',
+    'description' => 'Subject: header for warning email',
+    'type'        => 'text',
+  },
+  
+  {
+    'key'         => 'warning_email-mimetype',
+    'section'     => '',
+    'description' => 'MIME type for warning email',
+    'type'        => 'select',
+    'select_enum' => [ 'text/plain', 'text/html' ],
+  },
+
+  {
+    'key'         => 'payby',
+    'section'     => 'billing',
+    'description' => 'Available payment types.',
+    'type'        => 'selectmultiple',
+    'select_enum' => [ qw(CARD DCRD CHEK DCHK LECB BILL CASH WEST MCRD COMP) ],
+  },
+
+  {
     'key'         => 'payby-default',
     'section'     => 'UI',
     'description' => 'Default payment type.  HIDE disables display of billing information and sets customers to BILL.',
     'type'        => 'select',
-    'select_enum' => [ '', qw(CARD DCRD CHEK DCHK LECB BILL COMP HIDE) ],
+    'select_enum' => [ '', qw(CARD DCRD CHEK DCHK LECB BILL CASH WEST MCRD COMP HIDE) ],
   },
 
   {
@@ -1143,9 +1531,16 @@ httemplate/docs/config.html
   },
 
   {
-    'key'         => 'users-allow_comp',
+    'key'         => 'dump-pgpid',
     'section'     => '',
-    'description' => '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.',
+    '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.",
+    'type'        => 'text',
+  },
+
+  {
+    'key'         => 'users-allow_comp',
+    'section'     => 'deprecated',
+    '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.',
     'type'        => 'textarea',
   },
 
@@ -1154,15 +1549,7 @@ httemplate/docs/config.html
     'section'     => 'billing',
     '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.',
     'type'        => 'selectmultiple',
-    'select_enum' => [ "VISA card",
-                       "MasterCard",
-                       "Discover card",
-                       "American Express card",
-                       "Diner's Club/Carte Blanche",
-                       "enRoute",
-                       "JCB",
-                       "BankCard",
-                     ],
+    'select_enum' => \@card_types,
   },
 
   {
@@ -1188,10 +1575,426 @@ httemplate/docs/config.html
   {
     'key'         => 'cust_pkg-change_svcpart',
     'section'     => '',
-    'description' => "When changing packages, move services even if svcparts don't match between old and new pacakge definitions.  Use with caution!  No provision is made for export differences between the old and new service definitions.  Probably only should be used when your exports for all service definitions of a given svcdb are identical.",
+    'description' => "When changing packages, move services even if svcparts don't match between old and new pacakge definitions.",
+    'type'        => 'checkbox',
+  },
+
+  {
+    'key'         => 'disable_autoreverse',
+    'section'     => 'BIND',
+    'description' => 'Disable automatic synchronization of reverse-ARPA entries.',
+    'type'        => 'checkbox',
+  },
+
+  {
+    'key'         => 'svc_www-enable_subdomains',
+    'section'     => '',
+    'description' => 'Enable selection of specific subdomains for virtual host creation.',
+    'type'        => 'checkbox',
+  },
+
+  {
+    'key'         => 'svc_www-usersvc_svcpart',
+    'section'     => '',
+    'description' => 'Allowable service definition svcparts for virtual hosts, one per line.',
+    'type'        => 'textarea',
+  },
+
+  {
+    'key'         => 'selfservice_server-primary_only',
+    'section'     => '',
+    'description' => 'Only allow primary accounts to access self-service functionality.',
+    'type'        => 'checkbox',
+  },
+
+  {
+    'key'         => 'card_refund-days',
+    'section'     => 'billing',
+    'description' => 'After a payment, the number of days a refund link will be available for that payment.  Defaults to 120.',
+    'type'        => 'text',
+  },
+
+  {
+    'key'         => 'agent-showpasswords',
+    'section'     => '',
+    'description' => 'Display unencrypted user passwords in the agent (reseller) interface',
+    'type'        => 'checkbox',
+  },
+
+  {
+    'key'         => 'global_unique-username',
+    'section'     => 'username',
+    '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.',
+    'type'        => 'select',
+    'select_enum' => [ 'none', 'username', 'username@domain', 'disabled' ],
+  },
+
+  {
+    'key'         => 'svc_external-skip_manual',
+    'section'     => 'UI',
+    '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).',
+    'type'        => 'checkbox',
+  },
+
+  {
+    'key'         => 'svc_external-display_type',
+    'section'     => 'UI',
+    'description' => 'Select a specific svc_external type to enable some UI changes specific to that type (i.e. artera_turbo).',
+    'type'        => 'select',
+    'select_enum' => [ 'generic', 'artera_turbo', ],
+  },
+
+  {
+    'key'         => 'ticket_system',
+    'section'     => '',
+    'description' => 'Ticketing system integration.  <b>RT_Internal</b> uses the built-in RT ticketing system (see the <a href="../docs/install-rt">integrated ticketing installation instructions</a>).   <b>RT_External</b> accesses an external RT installation in a separate database (local or remote).',
+    'type'        => 'select',
+    #'select_enum' => [ '', qw(RT_Internal RT_Libs RT_External) ],
+    'select_enum' => [ '', qw(RT_Internal RT_External) ],
+  },
+
+  {
+    'key'         => 'ticket_system-default_queueid',
+    'section'     => '',
+    'description' => 'Default queue used when creating new customer tickets.',
+    'type'        => 'select-sub',
+    'options_sub' => sub {
+                           my $conf = new FS::Conf;
+                           if ( $conf->config('ticket_system') ) {
+                             eval "use FS::TicketSystem;";
+                             die $@ if $@;
+                             FS::TicketSystem->queues();
+                           } else {
+                             ();
+                           }
+                         },
+    'option_sub'  => sub { 
+                           my $conf = new FS::Conf;
+                           if ( $conf->config('ticket_system') ) {
+                             eval "use FS::TicketSystem;";
+                             die $@ if $@;
+                             FS::TicketSystem->queue(shift);
+                           } else {
+                             '';
+                           }
+                         },
+  },
+
+  {
+    'key'         => 'ticket_system-custom_priority_field',
+    'section'     => '',
+    'description' => 'Custom field from the ticketing system to use as a custom priority classification.',
+    'type'        => 'text',
+  },
+
+  {
+    'key'         => 'ticket_system-custom_priority_field-values',
+    'section'     => '',
+    'description' => 'Values for the custom field from the ticketing system to break down and sort customer ticket lists.',
+    'type'        => 'textarea',
+  },
+
+  {
+    'key'         => 'ticket_system-custom_priority_field_queue',
+    'section'     => '',
+    'description' => 'Ticketing system queue in which the custom field specified in ticket_system-custom_priority_field is located.',
+    'type'        => 'text',
+  },
+
+  {
+    'key'         => 'ticket_system-rt_external_datasrc',
+    'section'     => '',
+    '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>',
+    'type'        => 'text',
+
+  },
+
+  {
+    'key'         => 'ticket_system-rt_external_url',
+    'section'     => '',
+    'description' => 'With external RT integration, the URL for the external RT installation, for example, <code>https://rt.example.com/rt</code>',
+    'type'        => 'text',
+  },
+
+  {
+    'key'         => 'company_name',
+    'section'     => 'required',
+    'description' => 'Your company name',
+    'type'        => 'text',
+  },
+
+  {
+    'key'         => 'echeck-void',
+    'section'     => 'deprecated',
+    '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',
+    'type'        => 'checkbox',
+  },
+
+  {
+    'key'         => 'cc-void',
+    'section'     => 'deprecated',
+    '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',
+    'type'        => 'checkbox',
+  },
+
+  {
+    'key'         => 'unvoid',
+    'section'     => 'deprecated',
+    'description' => '<B>DEPRECATED</B>, now controlled by ACLs.  Used to enable unvoiding of voided payments',
+    'type'        => 'checkbox',
+  },
+
+  {
+    'key'         => 'address2-search',
+    'section'     => 'UI',
+    'description' => 'Enable a "Unit" search box which searches the second address field',
+    'type'        => 'checkbox',
+  },
+
+  { 'key'         => 'referral_credit',
+    'section'     => 'billing',
+    'description' => "Enables one-time referral credits in the amount of one month <i>referred</i> customer's recurring fee (irregardless of frequency).",
+    'type'        => 'checkbox',
+  },
+
+  { 'key'         => 'selfservice_server-cache_module',
+    'section'     => '',
+    '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.',
+    'type'        => 'select',
+    'select_enum' => [ 'Cache::SharedMemoryCache', 'Cache::FileCache', ], # '_Database' ],
+  },
+
+  {
+    'key'         => 'hylafax',
+    'section'     => '',
+    '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).',
+    'type'        => [qw( checkbox textarea )],
+  },
+
+  {
+    'key'         => 'svc_acct-usage_suspend',
+    'section'     => 'billing',
+    '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.',
+    'type'        => 'checkbox',
+  },
+
+  {
+    'key'         => 'svc_acct-usage_unsuspend',
+    'section'     => 'billing',
+    '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.',
+    'type'        => 'checkbox',
+  },
+
+  {
+    'key'         => 'svc_acct-usage_threshold',
+    'section'     => 'billing',
+    'description' => 'The threshold (expressed as percentage) of acct.seconds or acct.up|down|totalbytes at which a warning message is sent to a service holder.  Typically used in conjunction with prepaid packages and freeside-sqlradius-radacctd.  Defaults to 80.',
+    'type'        => 'text',
+  },
+
+  {
+    'key'         => 'cust-fields',
+    'section'     => 'UI',
+    'description' => 'Which customer fields to display on reports by default',
+    'type'        => 'select',
+    'select_hash' => [ FS::ConfDefaults->cust_fields_avail() ],
+  },
+
+  {
+    'key'         => 'cust_pkg-display_times',
+    'section'     => 'UI',
+    'description' => 'Display full timestamps (not just dates) for customer packages.  Useful if you are doing real-time things like hourly prepaid.',
     'type'        => 'checkbox',
   },
 
+  {
+    'key'         => 'svc_acct-edit_uid',
+    'section'     => 'shell',
+    'description' => 'Allow UID editing.',
+    'type'        => 'checkbox',
+  },
+
+  {
+    'key'         => 'svc_acct-edit_gid',
+    'section'     => 'shell',
+    'description' => 'Allow GID editing.',
+    'type'        => 'checkbox',
+  },
+
+  {
+    'key'         => 'zone-underscore',
+    'section'     => 'BIND',
+    'description' => 'Allow underscores in zone names.  As underscores are illegal characters in zone names, this option is not recommended.',
+    'type'        => 'checkbox',
+  },
+
+  #these should become per-user...
+  {
+    'key'         => 'vonage-username',
+    'section'     => '',
+    'description' => 'Vonage Click2Call username (see <a href="https://secure.click2callu.com/">https://secure.click2callu.com/</a>)',
+    'type'        => 'text',
+  },
+  {
+    'key'         => 'vonage-password',
+    'section'     => '',
+    'description' => 'Vonage Click2Call username (see <a href="https://secure.click2callu.com/">https://secure.click2callu.com/</a>)',
+    'type'        => 'text',
+  },
+  {
+    'key'         => 'vonage-fromnumber',
+    'section'     => '',
+    'description' => 'Vonage Click2Call number (see <a href="https://secure.click2callu.com/">https://secure.click2callu.com/</a>)',
+    'type'        => 'text',
+  },
+
+  {
+    'key'         => 'echeck-nonus',
+    'section'     => 'billing',
+    'description' => 'Disable ABA-format account checking for Electronic Check payment info',
+    'type'        => 'checkbox',
+  },
+
+  {
+    'key'         => 'voip-cust_cdr_spools',
+    'section'     => '',
+    'description' => 'Enable the per-customer option for individual CDR spools.',
+    'type'        => 'checkbox',
+  },
+
+  {
+    'key'         => 'svc_forward-arbitrary_dst',
+    'section'     => '',
+    '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.",
+    'type'        => 'checkbox',
+  },
+
+  {
+    'key'         => 'tax-ship_address',
+    'section'     => 'billing',
+    'description' => 'By default, tax calculations are done based on the billing address.  Enable this switch to calculate tax based on the shipping address instead.  Note: Tax reports can take a long time when enabled.',
+    'type'        => 'checkbox',
+  },
+
+  {
+    'key'         => 'batch-enable',
+    'section'     => 'billing',
+    'description' => 'Enable credit card batching - leave disabled for real-time installations.',
+    'type'        => 'checkbox',
+  },
+
+  {
+    'key'         => 'batch-default_format',
+    'section'     => 'billing',
+    'description' => 'Default format for batches.',
+    'type'        => 'select',
+    'select_enum' => [ 'csv-td_canada_trust-merchant_pc_batch',
+                       'csv-chase_canada-E-xactBatch', 'BoM', 'PAP' ]
+  },
+
+  {
+    'key'         => 'batch-fixed_format-CARD',
+    'section'     => 'billing',
+    'description' => 'Fixed (unchangeable) format for credit card batches.',
+    'type'        => 'select',
+    'select_enum' => [ 'csv-td_canada_trust-merchant_pc_batch', 'BoM', 'PAP' ,
+                       'csv-chase_canada-E-xactBatch', 'BoM', 'PAP' ]
+  },
+
+  {
+    'key'         => 'batch-fixed_format-CHEK',
+    'section'     => 'billing',
+    'description' => 'Fixed (unchangeable) format for electronic check batches.',
+    'type'        => 'select',
+    'select_enum' => [ 'csv-td_canada_trust-merchant_pc_batch', 'BoM', 'PAP' ]
+  },
+
+  {
+    'key'         => 'batchconfig-BoM',
+    'section'     => 'billing',
+    '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',
+    'type'        => 'textarea',
+  },
+
+  {
+    'key'         => 'payment_history-years',
+    'section'     => 'UI',
+    'description' => 'Number of years of payment history to show by default.  Currently defaults to 2.',
+    'type'        => 'text',
+  },
+
+  {
+    'key'         => 'cust_main-use_comments',
+    'section'     => 'UI',
+    'description' => 'Display free form comments on the customer edit screen.  Useful as a scratch pad.',
+    'type'        => 'checkbox',
+  },
+
+  {
+    'key'         => 'cust_main-disable_notes',
+    'section'     => 'UI',
+    'description' => 'Disable new style customer notes - timestamped and user identified customer notes.  Useful in tracking who did what.',
+    'type'        => 'checkbox',
+  },
+
+  {
+    'key'         => 'cust_main_note-display_times',
+    'section'     => 'UI',
+    'description' => 'Display full timestamps (not just dates) for customer notes.',
+    'type'        => 'checkbox',
+  },
+
+  {
+    'key'         => 'cust_main-ticket_statuses',
+    'section'     => 'UI',
+    'description' => 'Show tickets with these statuses on the customer view page.',
+    'type'        => 'selectmultiple',
+    'select_enum' => [qw( new open stalled resolved rejected deleted )],
+  },
+
+  {
+    'key'         => 'cust_main-max_tickets',
+    'section'     => 'UI',
+    'description' => 'Maximum number of tickets to show on the customer view page.',
+    'type'        => 'text',
+  },
+
+  {
+    'key'         => 'cust_main-skeleton_tables',
+    'section'     => '',
+    '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.',
+    'type'        => 'textarea',
+  },
+
+  {
+    'key'         => 'cust_main-skeleton_custnum',
+    'section'     => '',
+    'description' => 'Customer number specifying the source data to copy into skeleton tables for new customers.',
+    'type'        => 'text',
+  },
+
+  {
+    'key'         => 'cust_main-enable_birthdate',
+    'section'     => 'UI',
+    'descritpion' => 'Enable tracking of a birth date with each customer record',
+    'type'        => 'checkbox',
+  },
+
+  {
+    'key'         => 'support-key',
+    'section'     => '',
+    '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.',
+    'type'        => 'text',
+  },
+
+  {
+    'key'         => 'card-types',
+    'section'     => 'billing',
+    'description' => 'Select one or more card types to enable only those card types.  If no card types are selected, all card types are available.',
+    'type'        => 'selectmultiple',
+    'select_enum' => \@card_types,
+  },
+
 );
 
 1;