DNS, RT#8933
[freeside.git] / FS / FS / Conf.pm
index 1353df8..fe010f7 100644 (file)
@@ -146,7 +146,7 @@ sub config_binary {
   return $self->_usecompat('config_binary', @_) if use_confcompat;
 
   my $cv = $self->_config(@_) or return;
-  decode_base64($cv->value);
+  length($cv->value) ? decode_base64($cv->value) : '';
 }
 
 =item exists KEY [ AGENTNUM [ NODEFAULT ] ]
@@ -230,6 +230,7 @@ sub invoice_templatenames {
     }
   }
   
+  map { $_ } #handle scalar context
   sort keys %templatenames;
 
 }
@@ -548,21 +549,43 @@ worry that config_items is freeside-specific and icky.
   "Solo",
 );
 
-@base_items = qw (
-                   invoice_template
-                   invoice_latex
-                   invoice_latexreturnaddress
-                   invoice_latexfooter
-                   invoice_latexsmallfooter
-                   invoice_latexnotes
-                   invoice_latexcoupon
-                   invoice_html
-                   invoice_htmlreturnaddress
-                   invoice_htmlfooter
-                   invoice_htmlnotes
-                   logo.png
-                   logo.eps
-                 );
+@base_items = qw(
+invoice_template
+invoice_latex
+invoice_latexreturnaddress
+invoice_latexfooter
+invoice_latexsmallfooter
+invoice_latexnotes
+invoice_latexcoupon
+invoice_html
+invoice_htmlreturnaddress
+invoice_htmlfooter
+invoice_htmlnotes
+logo.png
+logo.eps
+);
+
+my %msg_template_options = (
+  'type'        => 'select-sub',
+  'options_sub' => sub { require FS::Record;
+                         require FS::agent;
+                         require FS::msg_template;
+                         map { $_->msgnum, $_->msgname } 
+                            qsearch('msg_template', { disabled => '' });
+                       },
+  'option_sub'  => sub { require FS::msg_template;
+                         my $msg_template = FS::msg_template->by_key(shift);
+                         $msg_template ? $msg_template->msgname : ''
+                       },
+);
+
+
+#Billing (81 items)
+#Invoicing (50 items)
+#UI (69 items)
+#Self-service (29 items)
+#...
+#Unclassified (77 items)
 
 @config_items = map { new FS::ConfItem $_ } (
 
@@ -575,19 +598,26 @@ worry that config_items is freeside-specific and icky.
 
   {
     'key'         => 'alert_expiration',
-    'section'     => 'billing',
-    'description' => 'Enable alerts about billing method expiration.',
+    'section'     => 'notification',
+    'description' => 'Enable alerts about billing method expiration (i.e. expiring credit cards).',
     'type'        => 'checkbox',
     'per_agent'   => 1,
   },
 
   {
     'key'         => 'alerter_template',
-    'section'     => 'billing',
-    '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.',
+    'section'     => 'deprecated',
+    'description' => 'Template file for billing method expiration alerts (i.e. expiring credit cards).',
     'type'        => 'textarea',
     'per_agent'   => 1,
   },
+  
+  {
+    'key'         => 'alerter_msgnum',
+    'section'     => 'notification',
+    'description' => 'Template to use for credit card expiration alerts.',
+    %msg_template_options,
+  },
 
   {
     'key'         => 'apacheip',
@@ -689,7 +719,7 @@ worry that config_items is freeside-specific and icky.
   {
     'key'         => 'business-onlinepayment-description',
     'section'     => 'billing',
-    '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)',
+    '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 - not available in all situations)',
     'type'        => 'text',
   },
 
@@ -708,6 +738,13 @@ worry that config_items is freeside-specific and icky.
   },
 
   {
+    'key'         => 'business-onlinepayment-test_transaction',
+    'section'     => 'billing',
+    'description' => 'Turns on the Business::OnlinePayment test_transaction flag.  Note that not all gateway modules support this flag; if yours does not, transactions will still be sent live.',
+    'type'        => 'checkbox',
+  },
+
+  {
     'key'         => 'countrydefault',
     'section'     => 'UI',
     'description' => 'Default two-letter country code (if not supplied, the default is `US\')',
@@ -721,6 +758,7 @@ worry that config_items is freeside-specific and icky.
     'type'        => 'select',
     'select_hash' => [
                        '%m/%d/%Y' => 'MM/DD/YYYY',
+                       '%d/%m/%Y' => 'DD/MM/YYYY',
                       '%Y/%m/%d' => 'YYYY/MM/DD',
                      ],
   },
@@ -809,35 +847,42 @@ worry that config_items is freeside-specific and icky.
     'key'         => 'editreferrals',
     'section'     => 'UI',
     'description' => 'Enable advertising source modification for existing customers',
-    'type'       => 'checkbox',
+    'type'        => 'checkbox',
   },
 
   {
     'key'         => 'emailinvoiceonly',
-    'section'     => 'billing',
+    'section'     => 'invoicing',
     'description' => 'Disables postal mail invoices',
-    'type'       => 'checkbox',
+    'type'        => 'checkbox',
   },
 
   {
     'key'         => 'disablepostalinvoicedefault',
-    'section'     => 'billing',
+    'section'     => 'invoicing',
     '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>.',
-    'type'       => 'checkbox',
+    'type'        => 'checkbox',
   },
 
   {
     'key'         => 'emailinvoiceauto',
-    'section'     => 'billing',
+    'section'     => 'invoicing',
     'description' => 'Automatically adds new accounts to the email invoice list',
-    'type'       => 'checkbox',
+    'type'        => 'checkbox',
   },
 
   {
     'key'         => 'emailinvoiceautoalways',
-    'section'     => 'billing',
+    'section'     => 'invoicing',
     'description' => 'Automatically adds new accounts to the email invoice list even when the list contains email addresses',
-    'type'       => 'checkbox',
+    'type'        => 'checkbox',
+  },
+
+  {
+    'key'         => 'emailinvoice-apostrophe',
+    'section'     => 'invoicing',
+    'description' => 'Allows the apostrophe (single quote) character in the email addresses in the email invoice list.',
+    'type'        => 'checkbox',
   },
 
   {
@@ -885,7 +930,7 @@ worry that config_items is freeside-specific and icky.
 
   {
     'key'         => 'invoice_subject',
-    'section'     => 'billing',
+    'section'     => 'invoicing',
     'description' => 'Subject: header on email invoices.  Defaults to "Invoice".  The following substitutions are available: $name, $name_short, $invoice_number, and $invoice_date.',
     'type'        => 'text',
     'per_agent'   => 1,
@@ -893,21 +938,21 @@ worry that config_items is freeside-specific and icky.
 
   {
     'key'         => 'invoice_usesummary',
-    'section'     => 'billing',
+    'section'     => 'invoicing',
     'description' => 'Indicates that html and latex invoices should be in summary style and make use of invoice_latexsummary.',
     'type'        => 'checkbox',
   },
 
   {
     'key'         => 'invoice_template',
-    'section'     => 'billing',
+    'section'     => 'invoicing',
     '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.',
     'type'        => 'textarea',
   },
 
   {
     'key'         => 'invoice_html',
-    'section'     => 'billing',
+    'section'     => 'invoicing',
     '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.',
 
     'type'        => 'textarea',
@@ -915,7 +960,7 @@ worry that config_items is freeside-specific and icky.
 
   {
     'key'         => 'invoice_htmlnotes',
-    'section'     => 'billing',
+    'section'     => 'invoicing',
     'description' => 'Notes section for HTML invoices.  Defaults to the same data in invoice_latexnotes if not specified.',
     'type'        => 'textarea',
     'per_agent'   => 1,
@@ -923,7 +968,7 @@ worry that config_items is freeside-specific and icky.
 
   {
     'key'         => 'invoice_htmlfooter',
-    'section'     => 'billing',
+    'section'     => 'invoicing',
     'description' => 'Footer for HTML invoices.  Defaults to the same data in invoice_latexfooter if not specified.',
     'type'        => 'textarea',
     'per_agent'   => 1,
@@ -931,7 +976,7 @@ worry that config_items is freeside-specific and icky.
 
   {
     'key'         => 'invoice_htmlsummary',
-    'section'     => 'billing',
+    'section'     => 'invoicing',
     'description' => 'Summary initial page for HTML invoices.',
     'type'        => 'textarea',
     'per_agent'   => 1,
@@ -939,21 +984,70 @@ worry that config_items is freeside-specific and icky.
 
   {
     'key'         => 'invoice_htmlreturnaddress',
-    'section'     => 'billing',
+    'section'     => 'invoicing',
     'description' => 'Return address for HTML invoices.  Defaults to the same data in invoice_latexreturnaddress if not specified.',
     'type'        => 'textarea',
   },
 
   {
     'key'         => 'invoice_latex',
-    'section'     => 'billing',
+    'section'     => 'invoicing',
     '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.',
     'type'        => 'textarea',
   },
 
   {
+    'key'         => 'invoice_latextopmargin',
+    'section'     => 'invoicing',
+    'description' => 'Optional LaTeX invoice topmargin setting. Include units.',
+    'type'        => 'text',
+    'per_agent'   => 1,
+    'validate'    => sub { shift =~
+                             /^-?\d*\.?\d+(in|mm|cm|pt|em|ex|pc|bp|dd|cc|sp)$/
+                             ? '' : 'Invalid LaTex length';
+                         },
+  },
+
+  {
+    'key'         => 'invoice_latexheadsep',
+    'section'     => 'invoicing',
+    'description' => 'Optional LaTeX invoice headsep setting. Include units.',
+    'type'        => 'text',
+    'per_agent'   => 1,
+    'validate'    => sub { shift =~
+                             /^-?\d*\.?\d+(in|mm|cm|pt|em|ex|pc|bp|dd|cc|sp)$/
+                             ? '' : 'Invalid LaTex length';
+                         },
+  },
+
+  {
+    'key'         => 'invoice_latexaddresssep',
+    'section'     => 'invoicing',
+    'description' => 'Optional LaTeX invoice separation between invoice header
+and customer address. Include units.',
+    'type'        => 'text',
+    'per_agent'   => 1,
+    'validate'    => sub { shift =~
+                             /^-?\d*\.?\d+(in|mm|cm|pt|em|ex|pc|bp|dd|cc|sp)$/
+                             ? '' : 'Invalid LaTex length';
+                         },
+  },
+
+  {
+    'key'         => 'invoice_latextextheight',
+    'section'     => 'invoicing',
+    'description' => 'Optional LaTeX invoice textheight setting. Include units.',
+    'type'        => 'text',
+    'per_agent'   => 1,
+    'validate'    => sub { shift =~
+                             /^-?\d*\.?\d+(in|mm|cm|pt|em|ex|pc|bp|dd|cc|sp)$/
+                             ? '' : 'Invalid LaTex length';
+                         },
+  },
+
+  {
     'key'         => 'invoice_latexnotes',
-    'section'     => 'billing',
+    'section'     => 'invoicing',
     'description' => 'Notes section for LaTeX typeset PostScript invoices.',
     'type'        => 'textarea',
     'per_agent'   => 1,
@@ -961,7 +1055,7 @@ worry that config_items is freeside-specific and icky.
 
   {
     'key'         => 'invoice_latexfooter',
-    'section'     => 'billing',
+    'section'     => 'invoicing',
     'description' => 'Footer for LaTeX typeset PostScript invoices.',
     'type'        => 'textarea',
     'per_agent'   => 1,
@@ -969,7 +1063,7 @@ worry that config_items is freeside-specific and icky.
 
   {
     'key'         => 'invoice_latexsummary',
-    'section'     => 'billing',
+    'section'     => 'invoicing',
     'description' => 'Summary initial page for LaTeX typeset PostScript invoices.',
     'type'        => 'textarea',
     'per_agent'   => 1,
@@ -977,22 +1071,85 @@ worry that config_items is freeside-specific and icky.
 
   {
     'key'         => 'invoice_latexcoupon',
-    'section'     => 'billing',
+    'section'     => 'invoicing',
     'description' => 'Remittance coupon for LaTeX typeset PostScript invoices.',
     'type'        => 'textarea',
     'per_agent'   => 1,
   },
 
   {
+    'key'         => 'invoice_latexextracouponspace',
+    'section'     => 'invoicing',
+    'description' => 'Optional LaTeX invoice textheight space to reserve for a tear off coupon. Include units.',
+    'type'        => 'text',
+    'per_agent'   => 1,
+    'validate'    => sub { shift =~
+                             /^-?\d*\.?\d+(in|mm|cm|pt|em|ex|pc|bp|dd|cc|sp)$/
+                             ? '' : 'Invalid LaTex length';
+                         },
+  },
+
+  {
+    'key'         => 'invoice_latexcouponfootsep',
+    'section'     => 'invoicing',
+    'description' => 'Optional LaTeX invoice separation between tear off coupon and footer. Include units.',
+    'type'        => 'text',
+    'per_agent'   => 1,
+    'validate'    => sub { shift =~
+                             /^-?\d*\.?\d+(in|mm|cm|pt|em|ex|pc|bp|dd|cc|sp)$/
+                             ? '' : 'Invalid LaTex length';
+                         },
+  },
+
+  {
+    'key'         => 'invoice_latexcouponamountenclosedsep',
+    'section'     => 'invoicing',
+    'description' => 'Optional LaTeX invoice separation between total due and amount enclosed line. Include units.',
+    'type'        => 'text',
+    'per_agent'   => 1,
+    'validate'    => sub { shift =~
+                             /^-?\d*\.?\d+(in|mm|cm|pt|em|ex|pc|bp|dd|cc|sp)$/
+                             ? '' : 'Invalid LaTex length';
+                         },
+  },
+  {
+    'key'         => 'invoice_latexcoupontoaddresssep',
+    'section'     => 'invoicing',
+    'description' => 'Optional LaTeX invoice separation between invoice data and the to address (usually invoice_latexreturnaddress).  Include units.',
+    'type'        => 'text',
+    'per_agent'   => 1,
+    'validate'    => sub { shift =~
+                             /^-?\d*\.?\d+(in|mm|cm|pt|em|ex|pc|bp|dd|cc|sp)$/
+                             ? '' : 'Invalid LaTex length';
+                         },
+  },
+
+  {
     'key'         => 'invoice_latexreturnaddress',
-    'section'     => 'billing',
+    'section'     => 'invoicing',
     'description' => 'Return address for LaTeX typeset PostScript invoices.',
     'type'        => 'textarea',
   },
 
   {
+    'key'         => 'invoice_latexverticalreturnaddress',
+    'section'     => 'invoicing',
+    'description' => 'Place the return address under the company logo rather than beside it.',
+    'type'        => 'checkbox',
+    'per_agent'   => 1,
+  },
+
+  {
+    'key'         => 'invoice_latexcouponaddcompanytoaddress',
+    'section'     => 'invoicing',
+    'description' => 'Add the company name to the To address on the remittance coupon because the return address does not contain it.',
+    'type'        => 'checkbox',
+    'per_agent'   => 1,
+  },
+
+  {
     'key'         => 'invoice_latexsmallfooter',
-    'section'     => 'billing',
+    'section'     => 'invoicing',
     'description' => 'Optional small footer for multi-page LaTeX typeset PostScript invoices.',
     'type'        => 'textarea',
     'per_agent'   => 1,
@@ -1000,56 +1157,78 @@ worry that config_items is freeside-specific and icky.
 
   {
     'key'         => 'invoice_email_pdf',
-    'section'     => 'billing',
+    'section'     => 'invoicing',
     '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',
+    'section'     => 'invoicing',
     'description' => 'If defined, this text will replace the default plain text invoice as the body of emailed PDF invoices.',
     'type'        => 'textarea'
   },
 
+  {
+    'key'         => 'invoice_print_pdf',
+    'section'     => 'invoicing',
+    'description' => 'Store postal invoices for download in PDF format rather than printing them directly.',
+    'type'        => 'checkbox',
+  },
 
   { 
     'key'         => 'invoice_default_terms',
-    'section'     => 'billing',
+    'section'     => 'invoicing',
     'description' => 'Optional default invoice term, used to calculate a due date printed on invoices.',
     'type'        => 'select',
     'select_enum' => [ '', 'Payable upon receipt', 'Net 0', 'Net 10', 'Net 15', 'Net 20', 'Net 30', 'Net 45', 'Net 60' ],
   },
 
   { 
+    'key'         => 'invoice_show_prior_due_date',
+    'section'     => 'invoicing',
+    'description' => 'Show previous invoice due dates when showing prior balances.  Default is to show invoice date.',
+    'type'        => 'checkbox',
+  },
+
+  { 
+    'key'         => 'invoice_include_aging',
+    'section'     => 'invoicing',
+    'description' => 'Show an aging line after the prior balance section.  Only valud when invoice_sections is enabled.',
+    'type'        => 'checkbox',
+  },
+
+  { 
     'key'         => 'invoice_sections',
-    'section'     => 'billing',
+    'section'     => 'invoicing',
     'description' => 'Split invoice into sections and label according to package category when enabled.',
     'type'        => 'checkbox',
   },
 
+  { 
+    'key'         => 'usage_class_as_a_section',
+    'section'     => 'invoicing',
+    'description' => 'Split usage into sections and label according to usage class name when enabled.  Only valid when invoice_sections is enabled.',
+    'type'        => 'checkbox',
+  },
+
+  { 
+    'key'         => 'svc_phone_sections',
+    'section'     => 'invoicing',
+    'description' => 'Create a section for each svc_phone when enabled.  Only valid when invoice_sections is enabled.',
+    'type'        => 'checkbox',
+  },
+
   {
     'key'         => 'finance_pkgclass',
     'section'     => 'billing',
-    'description' => 'The package class for finance charges',
-    '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 : '';
-                        },
+    'description' => 'The default package class for late fee charges, used if the fee event does not specify a package class itself.',
+    'type'        => 'select-pkg_class',
   },
 
   { 
     'key'         => 'separate_usage',
-    'section'     => 'billing',
+    'section'     => 'invoicing',
     'description' => 'Split the rated call usage into a separate line from the recurring charges.',
     'type'        => 'checkbox',
   },
@@ -1062,15 +1241,22 @@ worry that config_items is freeside-specific and icky.
   },
 
   {
+    'key'         => 'payment_receipt_msgnum',
+    'section'     => 'notification',
+    'description' => 'Template to use for payment receipts.',
+    %msg_template_options,
+  },
+
+  {
     '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/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>',
+    'section'     => 'deprecated',
+    'description' => 'Template file for payment receipts.  Payment receipts are sent to the customer email invoice destination(s) when a payment is received.',
     'type'        => [qw( checkbox textarea )],
   },
 
   {
     'key'         => 'payment_receipt-trigger',
-    'section'     => 'billing',
+    'section'     => 'notification',
     'description' => 'When payment receipts are triggered.  Defaults to when payment is made.',
     'type'        => 'select',
     'select_hash' => [
@@ -1080,6 +1266,13 @@ worry that config_items is freeside-specific and icky.
   },
 
   {
+    'key'         => 'trigger_export_insert_on_payment',
+    'section'     => 'billing',
+    'description' => 'Enable exports on payment application.',
+    'type'        => 'checkbox',
+  },
+
+  {
     'key'         => 'lpr',
     'section'     => 'required',
     'description' => 'Print command for paper invoices, for example `lpr -h\'',
@@ -1115,7 +1308,12 @@ worry that config_items is freeside-specific and icky.
     'editlist_parts' => [ { type=>'text' },
                           { type=>'immutable', value=>'IN' },
                           { type=>'select',
-                            select_enum=>{ map { $_=>$_ } qw(A CNAME MX NS TXT)} },
+                            select_enum => {
+                              map { $_=>$_ }
+                                  #@{ FS::domain_record->rectypes }
+                                  qw(A AAAA CNAME MX NS PTR SPF SRV TXT)
+                            },
+                          },
                           { type=> 'text' }, ],
   },
 
@@ -1134,24 +1332,54 @@ worry that config_items is freeside-specific and icky.
   },
 
   {
-    'key' => 'password-noampersand',
-    'section' => 'password',
+    'key'         => 'password-noampersand',
+    'section'     => 'password',
     'description' => 'Disallow ampersands in passwords',
-    'type' => 'checkbox',
+    'type'        => 'checkbox',
   },
 
   {
-    'key' => 'password-noexclamation',
-    'section' => 'password',
+    'key'         => 'password-noexclamation',
+    'section'     => 'password',
     'description' => 'Disallow exclamations in passwords (Not setting this could break old text Livingston or Cistron Radius servers)',
-    'type' => 'checkbox',
+    'type'        => 'checkbox',
+  },
+
+  {
+    'key'         => 'default-password-encoding',
+    'section'     => 'password',
+    'description' => 'Default storage format for passwords',
+    'type'        => 'select',
+    'select_hash' => [
+      'plain'       => 'Plain text',
+      'crypt-des'   => 'Unix password (DES encrypted)',
+      'crypt-md5'   => 'Unix password (MD5 digest)',
+      'ldap-plain'  => 'LDAP (plain text)',
+      'ldap-crypt'  => 'LDAP (DES encrypted)',
+      'ldap-md5'    => 'LDAP (MD5 digest)',
+      'ldap-sha1'   => 'LDAP (SHA1 digest)',
+      'legacy'      => 'Legacy mode',
+    ],
   },
 
   {
     'key'         => 'referraldefault',
     'section'     => 'UI',
     'description' => 'Default referral, specified by refnum',
-    'type'        => 'text',
+    '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 : '';
+                        },
   },
 
 #  {
@@ -1203,6 +1431,13 @@ worry that config_items is freeside-specific and icky.
   },
 
   {
+    'key'         => 'report-showpasswords',
+    'section'     => 'UI',
+    'description' => 'This is a terrible idea.  Do not enable it.  STRONGLY NOT RECOMMENDED.  Enables display of passwords on services reports.',
+    'type'        => 'checkbox',
+  },
+
+  {
     'key'         => 'signupurl',
     'section'     => 'UI',
     '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',
@@ -1217,6 +1452,32 @@ worry that config_items is freeside-specific and icky.
   },
 
   {
+    'key'         => 'smtp-username',
+    'section'     => '',
+    'description' => 'Optional SMTP username for Freeside\'s outgoing mail',
+    'type'        => 'text',
+  },
+
+  {
+    'key'         => 'smtp-password',
+    'section'     => '',
+    'description' => 'Optional SMTP password for Freeside\'s outgoing mail',
+    'type'        => 'text',
+  },
+
+  {
+    'key'         => 'smtp-encryption',
+    'section'     => '',
+    'description' => 'Optional SMTP encryption method.  The STARTTLS methods require smtp-username and smtp-password to be set.',
+    'type'        => 'select',
+    'select_hash' => [ '25'           => 'None (port 25)',
+                       '25-starttls'  => 'STARTTLS (port 25)',
+                       '587-starttls' => 'STARTTLS / submission (port 587)',
+                       '465-tls'      => 'SMTPS (SSL) (port 465)',
+                     ],
+  },
+
+  {
     'key'         => 'soadefaultttl',
     'section'     => 'BIND',
     'description' => 'SOA default TTL for new domains.',
@@ -1430,15 +1691,22 @@ worry that config_items is freeside-specific and icky.
 
   {
     'key'         => 'signup_server-payby',
-    'section'     => '',
+    'section'     => 'self-service',
     'description' => 'Acceptable payment types for the signup server',
     'type'        => 'selectmultiple',
     'select_enum' => [ qw(CARD DCRD CHEK DCHK LECB PREPAY BILL COMP) ],
   },
 
   {
+    'key'         => 'selfservice-save_unchecked',
+    'section'     => 'self-service',
+    'description' => 'In self-service, uncheck "Remember information" checkboxes by default (normally, they are checked by default).',
+    'type'        => 'checkbox',
+  },
+
+  {
     'key'         => 'signup_server-default_agentnum',
-    'section'     => '',
+    'section'     => 'self-service',
     'description' => 'Default agent for the signup server',
     'type'        => 'select-sub',
     'options_sub' => sub { require FS::Record;
@@ -1457,7 +1725,7 @@ worry that config_items is freeside-specific and icky.
 
   {
     'key'         => 'signup_server-default_refnum',
-    'section'     => '',
+    'section'     => 'self-service',
     'description' => 'Default advertising source for the signup server',
     'type'        => 'select-sub',
     'options_sub' => sub { require FS::Record;
@@ -1477,21 +1745,21 @@ worry that config_items is freeside-specific and icky.
 
   {
     'key'         => 'signup_server-default_pkgpart',
-    'section'     => '',
+    'section'     => 'self-service',
     'description' => 'Default package for the signup server',
     'type'        => 'select-part_pkg',
   },
 
   {
     'key'         => 'signup_server-default_svcpart',
-    'section'     => '',
+    'section'     => 'self-service',
     'description' => 'Default service definition for the signup server - only necessary for services that trigger special provisioning widgets (such as DID provisioning).',
     'type'        => 'select-part_svc',
   },
 
   {
     'key'         => 'signup_server-mac_addr_svcparts',
-    'section'     => '',
+    'section'     => 'self-service',
     'description' => 'Service definitions which can receive mac addresses (current mapped to username for svc_acct).',
     'type'        => 'select-part_svc',
     'multiple'    => 1,
@@ -1499,14 +1767,14 @@ worry that config_items is freeside-specific and icky.
 
   {
     'key'         => 'signup_server-nomadix',
-    'section'     => '',
+    'section'     => 'self-service',
     'description' => 'Signup page Nomadix integration',
     'type'        => 'checkbox',
   },
 
   {
     'key'         => 'signup_server-service',
-    'section'     => '',
+    'section'     => 'self-service',
     'description' => 'Service for the signup server - "Account (svc_acct)" is the default setting, or "Phone number (svc_phone)" for ITSP signup',
     'type'        => 'select',
     'select_hash' => [
@@ -1517,7 +1785,7 @@ worry that config_items is freeside-specific and icky.
 
   {
     'key'         => 'selfservice_server-base_url',
-    'section'     => '',
+    'section'     => 'self-service',
     '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.',
     'type'        => 'text',
   },
@@ -1531,94 +1799,92 @@ worry that config_items is freeside-specific and icky.
 
   {
     'key'         => 'signup_server-realtime',
-    'section'     => '',
+    'section'     => 'self-service',
     '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'     => '',
+    'section'     => 'self-service',
     '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 : '';
-                        },
+    'type'        => 'select-pkg_class',
   },
 
   {
     'key'         => 'signup_server-classnum3',
-    'section'     => '',
+    'section'     => 'self-service',
     '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 : '';
-                        },
+    'type'        => 'select-pkg_class',
+  },
+
+  {
+    'key'         => 'selfservice-xmlrpc',
+    'section'     => 'self-service',
+    'description' => 'Run a standalone self-service XML-RPC server on the backend (on port 8080).',
+    'type'        => 'checkbox',
   },
 
   {
     'key'         => 'backend-realtime',
-    'section'     => '',
+    'section'     => 'billing',
     'description' => 'Run billing for backend signups immediately.',
     'type'        => 'checkbox',
   },
 
   {
+    'key'         => 'decline_msgnum',
+    'section'     => 'notification',
+    'description' => 'Template to use for credit card and electronic check decline messages.',
+    %msg_template_options,
+  },
+
+  {
     'key'         => 'declinetemplate',
-    'section'     => 'billing',
-    'description' => 'Template file for credit card decline emails.',
+    'section'     => 'deprecated',
+    'description' => 'Template file for credit card and electronic check decline emails.',
     'type'        => 'textarea',
   },
 
   {
     'key'         => 'emaildecline',
-    'section'     => 'billing',
-    'description' => 'Enable emailing of credit card decline notices.',
+    'section'     => 'notification',
+    'description' => 'Enable emailing of credit card and electronic check decline notices.',
     'type'        => 'checkbox',
   },
 
   {
     'key'         => 'emaildecline-exclude',
-    'section'     => 'billing',
+    'section'     => 'notification',
     'description' => 'List of error messages that should not trigger email decline notices, one per line.',
     'type'        => 'textarea',
   },
 
   {
+    'key'         => 'cancel_msgnum',
+    'section'     => 'notification',
+    'description' => 'Template to use for cancellation emails.',
+    %msg_template_options,
+  },
+
+  {
     'key'         => 'cancelmessage',
-    'section'     => 'billing',
+    'section'     => 'deprecated',
     'description' => 'Template file for cancellation emails.',
     'type'        => 'textarea',
   },
 
   {
     'key'         => 'cancelsubject',
-    'section'     => 'billing',
+    'section'     => 'deprecated',
     'description' => 'Subject line for cancellation emails.',
     'type'        => 'text',
   },
 
   {
     'key'         => 'emailcancel',
-    'section'     => 'billing',
-    'description' => 'Enable emailing of cancellation notices.  Make sure to fill in the cancelmessage and cancelsubject configuration values as well.',
+    'section'     => 'notification',
+    'description' => 'Enable emailing of cancellation notices.  Make sure to select the template in the cancel_msgnum option.',
     'type'        => 'checkbox',
   },
 
@@ -1660,8 +1926,8 @@ worry that config_items is freeside-specific and icky.
   {
     'key'         => 'taxdatadirectdownload',
     'section'     => 'billing',  #well
-    'description' => 'Enable downloading tax data directly from the vendor site',
-    'type'        => 'checkbox',
+    'description' => 'Enable downloading tax data directly from the vendor site. at least three lines: URL, username, and password.j',
+    'type'        => 'textarea',
   },
 
   {
@@ -1672,16 +1938,23 @@ worry that config_items is freeside-specific and icky.
   },
 
   {
+    'key'         => 'welcome_msgnum',
+    'section'     => 'notification',
+    'description' => 'Template to use for welcome messages when a svc_acct record is created.',
+    %msg_template_options,
+  },
+
+  {
     '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/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>',
+    'section'     => 'deprecated',
+    '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.',
     'type'        => 'textarea',
     'per_agent'   => 1,
   },
 
   {
     'key'         => 'welcome_email-from',
-    'section'     => '',
+    'section'     => 'deprecated',
     'description' => 'From: address header for welcome email',
     'type'        => 'text',
     'per_agent'   => 1,
@@ -1689,7 +1962,7 @@ worry that config_items is freeside-specific and icky.
 
   {
     'key'         => 'welcome_email-subject',
-    'section'     => '',
+    'section'     => 'deprecated',
     'description' => 'Subject: header for welcome email',
     'type'        => 'text',
     'per_agent'   => 1,
@@ -1697,7 +1970,7 @@ worry that config_items is freeside-specific and icky.
   
   {
     'key'         => 'welcome_email-mimetype',
-    'section'     => '',
+    'section'     => 'deprecated',
     'description' => 'MIME type for welcome email',
     'type'        => 'select',
     'select_enum' => [ 'text/plain', 'text/html' ],
@@ -1711,37 +1984,44 @@ worry that config_items is freeside-specific and icky.
     'type'        => 'textarea',
   },
 
+#  {
+#    'key'         => 'warning_msgnum',
+#    'section'     => 'notification',
+#    'description' => 'Template to use for warning messages, sent to the customer email invoice destination(s) when a svc_acct record has its usage drop below a threshold.',
+#    %msg_template_options,
+#  },
+
   {
     'key'         => 'warning_email',
-    'section'     => '',
+    'section'     => 'notification',
     '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>',
     'type'        => 'textarea',
   },
 
   {
     'key'         => 'warning_email-from',
-    'section'     => '',
+    'section'     => 'notification',
     'description' => 'From: address header for warning email',
     'type'        => 'text',
   },
 
   {
     'key'         => 'warning_email-cc',
-    'section'     => '',
+    'section'     => 'notification',
     'description' => 'Additional recipient(s) (comma separated) for warning email when remaining usage reaches zero.',
     'type'        => 'text',
   },
 
   {
     'key'         => 'warning_email-subject',
-    'section'     => '',
+    'section'     => 'notification',
     'description' => 'Subject: header for warning email',
     'type'        => 'text',
   },
   
   {
     'key'         => 'warning_email-mimetype',
-    'section'     => '',
+    'section'     => 'notification',
     'description' => 'MIME type for warning email',
     'type'        => 'select',
     'select_enum' => [ 'text/plain', 'text/html' ],
@@ -1772,7 +2052,7 @@ worry that config_items is freeside-specific and icky.
 
   {
     'key'         => 'svc_acct-notes',
-    'section'     => 'UI',
+    'section'     => 'deprecated',
     'description' => 'Extra HTML to be displayed on the Account View screen.',
     'type'        => 'textarea',
   },
@@ -1782,7 +2062,7 @@ worry that config_items is freeside-specific and icky.
     'section'     => '',
     'description' => 'RADIUS attribute for plain-text passwords.',
     'type'        => 'select',
-    'select_enum' => [ 'Password', 'User-Password' ],
+    'select_enum' => [ 'Password', 'User-Password', 'Cleartext-Password' ],
   },
 
   {
@@ -1863,6 +2143,24 @@ worry that config_items is freeside-specific and icky.
   },
 
   {
+    'key'         => 'manual_process-display',
+    'section'     => 'billing',
+    'description' => 'When using manual_process-pkgpart, add the fee to the amount entered (default), or subtract the fee from the amount entered.',
+    'type'        => 'select',
+    'select_hash' => [
+                       'add'      => 'Add fee to amount entered',
+                       'subtract' => 'Subtract fee from amount entered',
+                     ],
+  },
+
+  {
+    'key'         => 'manual_process-skip_first',
+    'section'     => 'billing',
+    'description' => "When using manual_process-pkgpart, omit the fee if it is the customer's first payment.",
+    'type'        => 'checkbox',
+  },
+
+  {
     'key'         => 'allow_negative_charges',
     'section'     => 'billing',
     'description' => 'Allow negative charges.  Normally not used unless importing data from a legacy system that requires this.',
@@ -1890,6 +2188,13 @@ worry that config_items is freeside-specific and icky.
   },
 
   {
+    'key'         => 'cust_pkg-change_pkgpart-bill_now',
+    'section'     => '',
+    'description' => "When changing packages, bill the new package immediately.  Useful for prepaid situations with RADIUS where an Expiration attribute based on the package must be present at all times.",
+    'type'        => 'checkbox',
+  },
+
+  {
     'key'         => 'disable_autoreverse',
     'section'     => 'BIND',
     'description' => 'Disable automatic synchronization of reverse-ARPA entries.',
@@ -1913,21 +2218,21 @@ worry that config_items is freeside-specific and icky.
 
   {
     'key'         => 'selfservice_server-primary_only',
-    'section'     => '',
+    'section'     => 'self-service',
     'description' => 'Only allow primary accounts to access self-service functionality.',
     'type'        => 'checkbox',
   },
 
   {
     'key'         => 'selfservice_server-phone_login',
-    'section'     => '',
+    'section'     => 'self-service',
     'description' => 'Allow login to self-service with phone number and PIN.',
     'type'        => 'checkbox',
   },
 
   {
     'key'         => 'selfservice_server-single_domain',
-    'section'     => '',
+    'section'     => 'self-service',
     'description' => 'If specified, only use this one domain for self-service access.',
     'type'        => 'text',
   },
@@ -1963,6 +2268,14 @@ worry that config_items is freeside-specific and icky.
   },
 
   {
+    'key'         => 'global_unique-pbx_title',
+    'section'     => '',
+    'description' => 'Global phone number uniqueness control: enabled (usual setting - svc_pbx.title must be unique), or disabled turns off duplicate checking for this field.',
+    'type'        => 'select',
+    'select_enum' => [ 'enabled', '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).',
@@ -2012,6 +2325,39 @@ worry that config_items is freeside-specific and icky.
                            }
                          },
   },
+  {
+    'key'         => 'ticket_system-force_default_queueid',
+    'section'     => '',
+    'description' => 'Disallow queue selection when creating new tickets from customer view.',
+    'type'        => 'checkbox',
+  },
+  {
+    'key'         => 'ticket_system-selfservice_queueid',
+    'section'     => '',
+    'description' => 'Queue used when creating new customer tickets from self-service.  Defautls to ticket_system-default_queueid if not specified.',
+    #false laziness w/above
+    '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-priority_reverse',
@@ -2094,6 +2440,13 @@ worry that config_items is freeside-specific and icky.
   },
 
   {
+    'key'         => 'address1-search',
+    'section'     => 'UI',
+    'description' => 'Enable the ability to search the address1 field from customer search.',
+    'type'        => 'checkbox',
+  },
+
+  {
     'key'         => 'address2-search',
     'section'     => 'UI',
     'description' => 'Enable a "Unit" search box which searches the second address field.  Useful for multi-tenant applications.  See also: cust_main-require_address2',
@@ -2121,7 +2474,7 @@ worry that config_items is freeside-specific and icky.
   },
 
   { 'key'         => 'selfservice_server-cache_module',
-    'section'     => '',
+    'section'     => 'self-service',
     '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' ],
@@ -2136,7 +2489,7 @@ worry that config_items is freeside-specific and icky.
 
   {
     'key'         => 'cust_bill-ftpformat',
-    'section'     => 'billing',
+    'section'     => 'invoicing',
     'description' => 'Enable FTP of raw invoice data - format.',
     'type'        => 'select',
     'select_enum' => [ '', 'default', 'billco', ],
@@ -2144,35 +2497,35 @@ worry that config_items is freeside-specific and icky.
 
   {
     'key'         => 'cust_bill-ftpserver',
-    'section'     => 'billing',
+    'section'     => 'invoicing',
     'description' => 'Enable FTP of raw invoice data - server.',
     'type'        => 'text',
   },
 
   {
     'key'         => 'cust_bill-ftpusername',
-    'section'     => 'billing',
+    'section'     => 'invoicing',
     'description' => 'Enable FTP of raw invoice data - server.',
     'type'        => 'text',
   },
 
   {
     'key'         => 'cust_bill-ftppassword',
-    'section'     => 'billing',
+    'section'     => 'invoicing',
     'description' => 'Enable FTP of raw invoice data - server.',
     'type'        => 'text',
   },
 
   {
     'key'         => 'cust_bill-ftpdir',
-    'section'     => 'billing',
+    'section'     => 'invoicing',
     'description' => 'Enable FTP of raw invoice data - server.',
     'type'        => 'text',
   },
 
   {
     'key'         => 'cust_bill-spoolformat',
-    'section'     => 'billing',
+    'section'     => 'invoicing',
     'description' => 'Enable spooling of raw invoice data - format.',
     'type'        => 'select',
     'select_enum' => [ '', 'default', 'billco', ],
@@ -2180,7 +2533,7 @@ worry that config_items is freeside-specific and icky.
 
   {
     'key'         => 'cust_bill-spoolagent',
-    'section'     => 'billing',
+    'section'     => 'invoicing',
     'description' => 'Enable per-agent spooling of raw invoice data.',
     'type'        => 'checkbox',
   },
@@ -2207,6 +2560,14 @@ worry that config_items is freeside-specific and icky.
   },
 
   {
+    'key'         => 'overlimit_groups',
+    'section'     => '',
+    'description' => 'RADIUS group (or comma-separated groups) to assign to svc_acct which has exceeded its bandwidth or time limit.',
+    'type'        => 'text',
+    'per_agent'   => 1,
+  },
+
+  {
     'key'         => 'cust-fields',
     'section'     => 'UI',
     'description' => 'Which customer fields to display on reports by default',
@@ -2229,6 +2590,13 @@ worry that config_items is freeside-specific and icky.
   },
 
   {
+    'key'         => 'cust_pkg-show_fcc_voice_grade_equivalent',
+    'section'     => 'UI',
+    'description' => "Show a field on package definitions for assigning a DSO equivalency number suitable for use on FCC form 477.",
+    'type'        => 'checkbox',
+  },
+
+  {
     'key'         => 'svc_acct-edit_uid',
     'section'     => 'shell',
     'description' => 'Allow UID editing.',
@@ -2285,6 +2653,20 @@ worry that config_items is freeside-specific and icky.
   },
 
   {
+    'key'         => 'cgp_rule-domain_templates',
+    'section'     => '',
+    'description' => 'Communigate Pro rule templates for domains, one per line, "svcnum Name"',
+    'type'        => 'textarea',
+  },
+
+  {
+    'key'         => 'svc_forward-no_srcsvc',
+    'section'     => '',
+    'description' => "Don't allow forwards from existing accounts, only arbitrary addresses.  Useful when exporting to systems such as Communigate Pro which treat forwards in this fashion.",
+    '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.",
@@ -2307,15 +2689,29 @@ worry that config_items is freeside-specific and icky.
 
   {
     'key'         => 'invoice-ship_address',
-    'section'     => 'billing',
-    'description' => 'Enable this switch to include the ship address on the invoice.',
+    'section'     => 'invoicing',
+    'description' => 'Include the shipping address on invoices.',
     'type'        => 'checkbox',
   },
 
   {
     'key'         => 'invoice-unitprice',
-    'section'     => 'billing',
-    'description' => 'This switch enables unit pricing on the invoice.',
+    'section'     => 'invoicing',
+    'description' => 'Enable unit pricing on invoices.',
+    'type'        => 'checkbox',
+  },
+
+  {
+    'key'         => 'invoice-smallernotes',
+    'section'     => 'invoicing',
+    'description' => 'Display the notes section in a smaller font on invoices.',
+    'type'        => 'checkbox',
+  },
+
+  {
+    'key'         => 'invoice-smallerfooter',
+    'section'     => 'invoicing',
+    'description' => 'Display footers in a smaller font on invoices.',
     'type'        => 'checkbox',
   },
 
@@ -2364,17 +2760,18 @@ worry that config_items is freeside-specific and icky.
     'type'        => 'select',
     'select_enum' => [ 'csv-td_canada_trust-merchant_pc_batch',
                        'csv-chase_canada-E-xactBatch', 'BoM', 'PAP',
-                       'ach-spiritone',
+                       'paymentech', 'ach-spiritone', 'RBC'
                     ]
   },
 
+  #lists could be auto-generated from pay_batch info
   {
     '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' ]
+                       'csv-chase_canada-E-xactBatch', 'paymentech' ]
   },
 
   {
@@ -2383,7 +2780,7 @@ worry that config_items is freeside-specific and icky.
     'description' => 'Fixed (unchangeable) format for electronic check batches.',
     'type'        => 'select',
     'select_enum' => [ 'csv-td_canada_trust-merchant_pc_batch', 'BoM', 'PAP',
-                       'ach-spiritone',
+                       'paymentech', 'ach-spiritone', 'RBC'
                      ]
   },
 
@@ -2418,7 +2815,14 @@ worry that config_items is freeside-specific and icky.
   {
     'key'         => 'batchconfig-paymentech',
     'section'     => 'billing',
-    'description' => 'Configuration for Chase Paymentech batching, four lines: 1. BIN, 2. Terminal ID, 3. Merchant ID, 4. Username',
+    'description' => 'Configuration for Chase Paymentech batching, five lines: 1. BIN, 2. Terminal ID, 3. Merchant ID, 4. Username, 5. Password (for batch uploads)',
+    'type'        => 'textarea',
+  },
+
+  {
+    'key'         => 'batchconfig-RBC',
+    'section'     => 'billing',
+    'description' => 'Configuration for Royal Bank of Canada PDS batching, four lines: 1. Client number, 2. Short name, 3. Long name, 4. Transaction code.',
     'type'        => 'textarea',
   },
 
@@ -2550,8 +2954,15 @@ worry that config_items is freeside-specific and icky.
   },
 
   {
+    'key'         => 'impending_recur_msgnum',
+    'section'     => 'notification',
+    'description' => 'Template to use for alerts about first-time recurring billing.',
+    %msg_template_options,
+  },
+
+  {
     'key'         => 'impending_recur_template',
-    'section'     => 'billing',
+    'section'     => 'deprecated',
     '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>',
 # <li><code>$payby</code> <li><code>$expdate</code> most likely only confuse
     'type'        => 'textarea',
@@ -2559,7 +2970,7 @@ worry that config_items is freeside-specific and icky.
 
   {
     'key'         => 'logo.png',
-    'section'     => 'billing',  #? 
+    'section'     => 'UI',  #'invoicing' ?
     'description' => 'Company logo for HTML invoices and the backoffice interface, in PNG format.  Suggested size somewhere near 92x62.',
     'type'        => 'image',
     'per_agent'   => 1, #XXX just view/logo.cgi, which is for the global
@@ -2568,7 +2979,7 @@ worry that config_items is freeside-specific and icky.
 
   {
     'key'         => 'logo.eps',
-    'section'     => 'billing',  #? 
+    'section'     => 'invoicing',
     'description' => 'Company logo for printed and PDF invoices, in EPS format.',
     'type'        => 'image',
     'per_agent'   => 1, #XXX as above, kinda
@@ -2576,14 +2987,14 @@ worry that config_items is freeside-specific and icky.
 
   {
     'key'         => 'selfservice-ignore_quantity',
-    'section'     => '',
+    'section'     => 'self-service',
     'description' => 'Ignores service quantity restrictions in self-service context.  Strongly not recommended - just set your quantities correctly in the first place.',
     'type'        => 'checkbox',
   },
 
   {
     'key'         => 'selfservice-session_timeout',
-    'section'     => '',
+    'section'     => 'self-service',
     'description' => 'Self-service session timeout.  Defaults to 1 hour.',
     'type'        => 'select',
     'select_enum' => [ '1 hour', '2 hours', '4 hours', '8 hours', '1 day', '1 week', ],
@@ -2593,14 +3004,14 @@ worry that config_items is freeside-specific and icky.
     'key'         => 'disable_setup_suspended_pkgs',
     'section'     => 'billing',
     'description' => 'Disables charging of setup fees for suspended packages.',
-    'type'       => 'checkbox',
+    'type'        => 'checkbox',
   },
 
   {
-    'key' => 'password-generated-allcaps',
-    'section' => 'password',
+    'key'         => 'password-generated-allcaps',
+    'section'     => 'password',
     'description' => 'Causes passwords automatically generated to consist entirely of capital letters',
-    'type' => 'checkbox',
+    'type'        => 'checkbox',
   },
 
   {
@@ -2700,7 +3111,7 @@ worry that config_items is freeside-specific and icky.
 
   {
     'key'         => 'signup_credit_type',
-    'section'     => 'billing',
+    'section'     => 'billing', #self-service?
     'description' => 'The group to use for new, automatically generated credit reasons resulting from signup and self-service declines.',
     'type'        => 'select-sub',
     'options_sub' => sub { require FS::Record;
@@ -2747,19 +3158,33 @@ worry that config_items is freeside-specific and icky.
 
   {
     'key'         => 'disable_previous_balance',
-    'section'     => 'billing',
-    'description' => 'Disable inclusion of previous balancem payment, and credit lines on invoices',
+    'section'     => 'invoicing',
+    'description' => 'Disable inclusion of previous balance, payment, and credit lines on invoices',
     'type'        => 'checkbox',
   },
 
   {
+    'key'         => 'previous_balance-exclude_from_total',
+    'section'     => 'invoicing',
+    'description' => 'Do not include previous balance in the \'Total\' line.  Only meaningful when invoice_sections is false.  Optionally provide text to override the Total New Charges description',
+    'type'        => [ qw(checkbox text) ],
+  },
+
+  {
     'key'         => 'previous_balance-summary_only',
-    'section'     => 'billing',
+    'section'     => 'invoicing',
     'description' => 'Only show a single line summarizing the total previous balance rather than one line per invoice.',
     'type'        => 'checkbox',
   },
 
   {
+    'key'         => 'balance_due_below_line',
+    'section'     => 'invoicing',
+    'description' => 'Place the balance due message below a line.  Only meaningful when when invoice_sections is false.',
+    'type'        => 'checkbox',
+  },
+
+  {
     'key'         => 'usps_webtools-userid',
     'section'     => 'UI',
     '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.',
@@ -2817,6 +3242,13 @@ worry that config_items is freeside-specific and icky.
   },
 
   {
+    'key'         => 'disable_settings_changes',
+    'section'     => '',
+    'description' => 'Disable all settings changes, for demos, except for the usernames given in the comma-separated list.',
+    'type'        => [qw( checkbox text )],
+  },
+
+  {
     'key'         => 'cust_main-edit_agent_custid',
     'section'     => 'UI',
     'description' => 'Enable editing of the agent_custid field.',
@@ -2831,6 +3263,13 @@ worry that config_items is freeside-specific and icky.
   },
 
   {
+    'key'         => 'cust_main-title-display_custnum',
+    'section'     => 'UI',
+    'description' => 'Add the display_custom (agent_custid or custnum) to the title on customer view pages.',
+    'type'        => 'checkbox',
+  },
+
+  {
     'key'         => 'cust_bill-default_agent_invid',
     'section'     => 'UI',
     'description' => 'Display the agent_invid field when available instead of the invnum field.',
@@ -2863,12 +3302,19 @@ worry that config_items is freeside-specific and icky.
 
   {
     'key'         => 'cust_bill-max_same_services',
-    'section'     => 'billing',
+    'section'     => 'invoicing',
     '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.',
     'type'        => 'text',
   },
 
   {
+    'key'         => 'cust_bill-consolidate_services',
+    'section'     => 'invoicing',
+    'description' => 'Consolidate service display into fewer lines on invoices rather than one per service.',
+    'type'        => 'checkbox',
+  },
+
+  {
     'key'         => 'suspend_email_admin',
     'section'     => '',
     'description' => 'Destination admin email address to enable suspension notices',
@@ -2884,44 +3330,200 @@ worry that config_items is freeside-specific and icky.
 
   {
     'key'         => 'selfservice-head',
-    'section'     => '',
+    'section'     => 'self-service',
     'description' => 'HTML for the HEAD section of the self-service interface, typically used for LINK stylesheet tags',
     'type'        => 'textarea', #htmlarea?
+    'per_agent'   => 1,
   },
 
 
   {
     'key'         => 'selfservice-body_header',
-    'section'     => '',
+    'section'     => 'self-service',
     'description' => 'HTML header for the self-service interface',
     'type'        => 'textarea', #htmlarea?
+    'per_agent'   => 1,
   },
 
   {
     'key'         => 'selfservice-body_footer',
-    'section'     => '',
-    'description' => 'HTML header for the self-service interface',
+    'section'     => 'self-service',
+    'description' => 'HTML footer for the self-service interface',
     'type'        => 'textarea', #htmlarea?
+    'per_agent'   => 1,
   },
 
 
   {
     'key'         => 'selfservice-body_bgcolor',
-    'section'     => '',
+    'section'     => 'self-service',
     'description' => 'HTML background color for the self-service interface, for example, #FFFFFF',
     'type'        => 'text',
+    'per_agent'   => 1,
   },
 
   {
     'key'         => 'selfservice-box_bgcolor',
-    'section'     => '',
-    'description' => 'HTML color for self-service interface input boxes, for example, #C0C0C0"',
+    'section'     => 'self-service',
+    'description' => 'HTML color for self-service interface input boxes, for example, #C0C0C0',
+    'type'        => 'text',
+    'per_agent'   => 1,
+  },
+
+  {
+    'key'         => 'selfservice-text_color',
+    'section'     => 'self-service',
+    'description' => 'HTML text color for the self-service interface, for example, #000000',
+    'type'        => 'text',
+    'per_agent'   => 1,
+  },
+
+  {
+    'key'         => 'selfservice-link_color',
+    'section'     => 'self-service',
+    'description' => 'HTML link color for the self-service interface, for example, #0000FF',
+    'type'        => 'text',
+    'per_agent'   => 1,
+  },
+
+  {
+    'key'         => 'selfservice-vlink_color',
+    'section'     => 'self-service',
+    'description' => 'HTML visited link color for the self-service interface, for example, #FF00FF',
+    'type'        => 'text',
+    'per_agent'   => 1,
+  },
+
+  {
+    'key'         => 'selfservice-hlink_color',
+    'section'     => 'self-service',
+    'description' => 'HTML hover link color for the self-service interface, for example, #808080',
+    'type'        => 'text',
+    'per_agent'   => 1,
+  },
+
+  {
+    'key'         => 'selfservice-alink_color',
+    'section'     => 'self-service',
+    'description' => 'HTML active (clicked) link color for the self-service interface, for example, #808080',
+    'type'        => 'text',
+    'per_agent'   => 1,
+  },
+
+  {
+    'key'         => 'selfservice-font',
+    'section'     => 'self-service',
+    'description' => 'HTML font CSS for the self-service interface, for example, 0.9em/1.5em Arial, Helvetica, Geneva, sans-serif',
+    'type'        => 'text',
+    'per_agent'   => 1,
+  },
+
+  {
+    'key'         => 'selfservice-title_color',
+    'section'     => 'self-service',
+    'description' => 'HTML color for the self-service title, for example, #000000',
+    'type'        => 'text',
+    'per_agent'   => 1,
+  },
+
+  {
+    'key'         => 'selfservice-title_align',
+    'section'     => 'self-service',
+    'description' => 'HTML alignment for the self-service title, for example, center',
     'type'        => 'text',
+    'per_agent'   => 1,
+  },
+  {
+    'key'         => 'selfservice-title_size',
+    'section'     => 'self-service',
+    'description' => 'HTML font size for the self-service title, for example, 3',
+    'type'        => 'text',
+    'per_agent'   => 1,
+  },
+
+  {
+    'key'         => 'selfservice-title_left_image',
+    'section'     => 'self-service',
+    'description' => 'Image used for the top of the menu in the self-service interface, in PNG format.',
+    'type'        => 'image',
+    'per_agent'   => 1,
+  },
+
+  {
+    'key'         => 'selfservice-title_right_image',
+    'section'     => 'self-service',
+    'description' => 'Image used for the top of the menu in the self-service interface, in PNG format.',
+    'type'        => 'image',
+    'per_agent'   => 1,
+  },
+
+  {
+    'key'         => 'selfservice-menu_skipblanks',
+    'section'     => 'self-service',
+    'description' => 'Skip blank (spacer) entries in the self-service menu',
+    'type'        => 'checkbox',
+    'per_agent'   => 1,
+  },
+
+  {
+    'key'         => 'selfservice-menu_skipheadings',
+    'section'     => 'self-service',
+    'description' => 'Skip the unclickable heading entries in the self-service menu',
+    'type'        => 'checkbox',
+    'per_agent'   => 1,
+  },
+
+  {
+    'key'         => 'selfservice-menu_bgcolor',
+    'section'     => 'self-service',
+    'description' => 'HTML color for the self-service menu, for example, #C0C0C0',
+    'type'        => 'text',
+    'per_agent'   => 1,
+  },
+
+  {
+    'key'         => 'selfservice-menu_fontsize',
+    'section'     => 'self-service',
+    'description' => 'HTML font size for the self-service menu, for example, -1',
+    'type'        => 'text',
+    'per_agent'   => 1,
+  },
+  {
+    'key'         => 'selfservice-menu_nounderline',
+    'section'     => 'self-service',
+    'description' => 'Styles menu links in the self-service without underlining.',
+    'type'        => 'checkbox',
+    'per_agent'   => 1,
+  },
+
+
+  {
+    'key'         => 'selfservice-menu_top_image',
+    'section'     => 'self-service',
+    'description' => 'Image used for the top of the menu in the self-service interface, in PNG format.',
+    'type'        => 'image',
+    'per_agent'   => 1,
+  },
+
+  {
+    'key'         => 'selfservice-menu_body_image',
+    'section'     => 'self-service',
+    'description' => 'Repeating image used for the body of the menu in the self-service interface, in PNG format.',
+    'type'        => 'image',
+    'per_agent'   => 1,
+  },
+
+  {
+    'key'         => 'selfservice-menu_bottom_image',
+    'section'     => 'self-service',
+    'description' => 'Image used for the bottom of the menu in the self-service interface, in PNG format.',
+    'type'        => 'image',
+    'per_agent'   => 1,
   },
 
   {
     'key'         => 'selfservice-bulk_format',
-    'section'     => '',
+    'section'     => 'deprecated',
     'description' => 'Parameter arrangement for selfservice bulk features',
     'type'        => 'select',
     'select_enum' => [ '', 'izoom-soap', 'izoom-ftp' ],
@@ -2930,7 +3532,7 @@ worry that config_items is freeside-specific and icky.
 
   {
     'key'         => 'selfservice-bulk_ftp_dir',
-    'section'     => '',
+    'section'     => 'deprecated',
     'description' => 'Enable bulk ftp provisioning in this folder',
     'type'        => 'text',
     'per_agent'   => 1,
@@ -2938,21 +3540,21 @@ worry that config_items is freeside-specific and icky.
 
   {
     'key'         => 'signup-no_company',
-    'section'     => '',
+    'section'     => 'self-service',
     'description' => "Don't display a field for company name on signup.",
     'type'        => 'checkbox',
   },
 
   {
     'key'         => 'signup-recommend_email',
-    'section'     => '',
+    'section'     => 'self-service',
     'description' => 'Encourage the entry of an invoicing email address on signup.',
     'type'        => 'checkbox',
   },
 
   {
     'key'         => 'signup-recommend_daytime',
-    'section'     => '',
+    'section'     => 'self-service',
     'description' => 'Encourage the entry of a daytime phone number  invoicing email address on signup.',
     'type'        => 'checkbox',
   },
@@ -2972,6 +3574,20 @@ worry that config_items is freeside-specific and icky.
   },
 
   {
+    'key'         => 'svc_phone-domain',
+    'section'     => '',
+    'description' => 'Track an optional domain association with each phone service.',
+    'type'        => 'checkbox',
+  },
+
+  {
+    'key'         => 'svc_phone-phone_name-max_length',
+    'section'     => '',
+    'description' => 'Maximum length of the phone service "Name" field (svc_phone.phone_name).  Sometimes useful to limit this (to 15?) when exporting as Caller ID data.',
+    'type'        => 'text',
+  },
+
+  {
     'key'         => 'default_phone_countrycode',
     'section'     => '',
     'description' => 'Default countrcode',
@@ -2979,6 +3595,22 @@ worry that config_items is freeside-specific and icky.
   },
 
   {
+    'key'         => 'cdr-charged_party-field',
+    'section'     => '',
+    'description' => 'Set the charged_party field of CDRs to this field.',
+    'type'        => 'select-sub',
+    'options_sub' => sub { my $fields = FS::cdr->table_info->{'fields'};
+                           map { $_ => $fields->{$_}||$_ }
+                           grep { $_ !~ /^(acctid|charged_party)$/ }
+                           FS::Schema::dbdef->table('cdr')->columns;
+                         },
+    'option_sub'  => sub { my $f = shift;
+                           FS::cdr->table_info->{'fields'}{$f} || $f;
+                         },
+  },
+
+  #probably deprecate in favor of cdr-charged_party-field above
+  {
     'key'         => 'cdr-charged_party-accountcode',
     'section'     => '',
     'description' => 'Set the charged_party field of CDRs to the accountcode.',
@@ -3024,7 +3656,7 @@ worry that config_items is freeside-specific and icky.
     'key'         => 'cust_pkg-show_autosuspend',
     'section'     => 'UI',
     'description' => 'Show package auto-suspend dates.  Use with caution for now; can slow down customer view for large insallations.',
-    'type'       => 'checkbox',
+    'type'        => 'checkbox',
   },
 
   {
@@ -3063,6 +3695,14 @@ worry that config_items is freeside-specific and icky.
   },
 
   {
+    'key'         => 'mc-outbound_packages',
+    'section'     => '',
+    'description' => "Don't use this.",
+    'type'        => 'select-part_pkg',
+    'multiple'    => 1,
+  },
+
+  {
     'key'         => 'disable-cust-pkg_class',
     'section'     => 'UI',
     'description' => 'Disable the two-step dropdown for selecting package class and package, and return to the classic single dropdown.',
@@ -3077,6 +3717,13 @@ worry that config_items is freeside-specific and icky.
   },
 
   {
+    'key'         => 'queued-sleep_time',
+    'section'     => '',
+    'description' => 'Time to sleep between attempts to find new jobs to process in the queue.  Defaults to 10.  Installations doing real-time CDR processing for prepaid may want to set it lower.',
+    'type'        => 'text',
+  },
+
+  {
     'key'         => 'cancelled_cust-noevents',
     'section'     => 'billing',
     'description' => "Don't run events for cancelled customers",
@@ -3085,7 +3732,7 @@ worry that config_items is freeside-specific and icky.
 
   {
     'key'         => 'agent-invoice_template',
-    'section'     => 'billing',
+    'section'     => 'invoicing',
     'description' => 'Enable display/edit of old-style per-agent invoice template selection',
     'type'        => 'checkbox',
   },
@@ -3158,6 +3805,13 @@ worry that config_items is freeside-specific and icky.
   },
 
   {
+    'key'         => 'pkg-addon_classnum',
+    'section'     => 'billing',
+    'description' => 'Enable the ability to restrict additional package orders based on package class.',
+    'type'        => 'checkbox',
+  },
+
+  {
     'key'         => 'cust_main-edit_signupdate',
     'section'     => 'UI',
     'descritpion' => 'Enable manual editing of the signup date.',
@@ -3171,6 +3825,111 @@ worry that config_items is freeside-specific and icky.
     'type'        => 'checkbox',
   },
 
+  {
+    'key'         => 'cust_bill_pay_pkg-manual',
+    'section'     => 'UI',
+    'description' => 'Allow manual application of payments to line items.',
+    'type'        => 'checkbox',
+  },
+
+  {
+    'key'         => 'cust_credit_bill_pkg-manual',
+    'section'     => 'UI',
+    'description' => 'Allow manual application of credits to line items.',
+    'type'        => 'checkbox',
+  },
+
+  {
+    'key'         => 'breakage-days',
+    'section'     => 'billing',
+    'description' => 'If set to a number of days, after an account goes that long without activity, recognizes any outstanding payments and credits as "breakage" by creating a breakage charge and invoice.',
+    'type'        => 'text',
+    'per_agent'   => 1,
+  },
+
+  {
+    'key'         => 'breakage-pkg_class',
+    'section'     => 'billing',
+    'description' => 'Package class to use for breakage reconciliation.',
+    'type'        => 'select-pkg_class',
+  },
+
+  {
+    'key'         => 'disable_cron_billing',
+    'section'     => 'billing',
+    'description' => 'Disable billing and collection from being run by freeside-daily and freeside-monthly, while still allowing other actions to run, such as notifications and backup.',
+    'type'        => 'checkbox',
+  },
+
+  {
+    'key'         => 'svc_domain-edit_domain',
+    'section'     => '',
+    'description' => 'Enable domain renaming',
+    'type'        => 'checkbox',
+  },
+
+  {
+    'key'         => 'enable_legacy_prepaid_income',
+    'section'     => '',
+    'description' => "Enable legacy prepaid income reporting.  Only useful when you have imported pre-Freeside packages with longer-than-monthly duration, and need to do prepaid income reporting on them before they've been invoiced the first time.",
+    'type'        => 'checkbox',
+  },
+
+  {
+    'key'         => 'cust_main-exports',
+    'section'     => '',
+    'description' => 'Export(s) to call on cust_main insert, modification and deletion.',
+    'type'        => 'select-sub',
+    'multiple'    => 1,
+    'options_sub' => sub {
+      require FS::Record;
+      require FS::part_export;
+      my @part_export =
+        map { qsearch( 'part_export', {exporttype => $_ } ) }
+          keys %{FS::part_export::export_info('cust_main')};
+      map { $_->exportnum => $_->exporttype.' to '.$_->machine } @part_export;
+    },
+    'option_sub'  => sub {
+      require FS::Record;
+      require FS::part_export;
+      my $part_export = FS::Record::qsearchs(
+        'part_export', { 'exportnum' => shift }
+      );
+      $part_export
+        ? $part_export->exporttype.' to '.$part_export->machine
+        : '';
+    },
+  },
+
+  {
+    'key'         => 'cust_tag-location',
+    'section'     => 'UI',
+    'description' => 'Location where customer tags are displayed.',
+    'type'        => 'select',
+    'select_enum' => [ 'misc_info', 'top' ],
+  },
+
+  {
+    'key'         => 'maestro-status_test',
+    'section'     => 'UI',
+    'description' => 'Display a link to the maestro status test page on the customer view page',
+    'type'        => 'checkbox',
+  },
+
+  {
+    'key'         => 'cust_main-custom_link',
+    'section'     => 'UI',
+    'description' => 'URL to use as source for the "Custom" tab in the View Customer page.  The custnum will be appended.',
+    'type'        => 'text',
+  },
+
+  {
+    'key'         => 'cust_main-custom_title',
+    'section'     => 'UI',
+    'description' => 'Title for the "Custom" tab in the View Customer page.',
+    'type'        => 'text',
+  },
+
   { key => "apacheroot", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
   { key => "apachemachine", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
   { key => "apachemachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },