X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FConf.pm;h=855c9f42174785370845c3df8c883643c0bab308;hb=ae02d1178c6859f7a0a5e4a22c685de5f0477568;hp=bb04d9427fce917181bbc6a948bee2c1ddf7056a;hpb=7b40e0e045368d350529d78208be0e6124f94b5a;p=freeside.git diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index bb04d9427..855c9f421 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -1,6 +1,7 @@ package FS::Conf; -use vars qw($base_dir @config_items @base_items @card_types $DEBUG); +use strict; +use vars qw($base_dir @config_items @base_items @card_types $DEBUG $conf_cache); use Carp; use IO::File; use File::Basename; @@ -133,9 +134,13 @@ sub _config { foreach my $a (@a) { $hashref->{agentnum} = $a; foreach my $l (@l) { - $hashref->{locale} = $l; - $cv = FS::Record::qsearchs('conf', $hashref); - return $cv if $cv; + my $key = join(':',$name, $a, $l); + if (! exists $conf_cache->{$key}){ + $hashref->{locale} = $l; + # $conf_cache is reset in FS::UID during myconnect, so the cache is reset per connection + $conf_cache->{$key} = FS::Record::qsearchs('conf', $hashref); + } + return $conf_cache->{$key} if $conf_cache->{$key}; } } return undef; @@ -361,6 +366,12 @@ sub set { $error = $new->insert; } + if (! $error) { + # clean the object cache + my $key = join(':',$name, $agentnum, $self->{locale}); + $conf_cache->{ $key } = $new; + } + die "error setting configuration value: $error \n" if $error; @@ -733,6 +744,23 @@ my %batch_gateway_options = ( }, ); +my %invoice_mode_options = ( + 'type' => 'select-sub', + 'options_sub' => sub { + my @modes = qsearch({ + 'table' => 'invoice_mode', + 'extra_sql' => ' WHERE '. + $FS::CurrentUser::CurrentUser->agentnums_sql(null => 1), + }); + map { $_->modenum, $_->modename } @modes; + }, + 'option_sub' => sub { + my $mode = FS::invoice_mode->by_key(shift); + $mode ? $mode->modename : '', + }, + 'per_agent' => 1, +); + my @cdr_formats = ( '' => '', 'default' => 'Default', @@ -1562,6 +1590,13 @@ and customer address. Include units.', }, { + 'key' => 'invoice_email_pdf_msgnum', + 'section' => 'invoicing', + 'description' => 'Message template to send as the text and HTML part of PDF invoices. If not selected, a text and HTML version of the invoice will be sent.', + %msg_template_options, + }, + + { 'key' => 'invoice_email_pdf_note', 'section' => 'invoicing', 'description' => 'If defined, this text will replace the default HTML invoice as the body of emailed PDF invoices.', @@ -1714,9 +1749,16 @@ and customer address. Include units.', }, { + 'key' => 'payment_receipt_statement_mode', + 'section' => 'notification', + 'description' => 'Automatic payments will cause a post-payment statement to be sent to the customer. Select the invoice mode to use for this statement. If unspecified, it will use the "_statement" versions of invoice configuration settings, and have the notice name "Statement".', + %invoice_mode_options, + }, + + { 'key' => 'payment_receipt_msgnum', 'section' => 'notification', - 'description' => 'Template to use for payment receipts.', + 'description' => 'Template to use for manual payment receipts.', %msg_template_options, }, @@ -2147,8 +2189,6 @@ and customer address. Include units.', }, { - - { 'key' => 'show_ship_company', 'section' => 'UI', 'description' => 'Turns on display/collection of a "service company name" field for customers.', @@ -3049,7 +3089,7 @@ and customer address. Include units.', }, 'option_sub' => sub { require FS::Record; require FS::agent_type; - my $agent = FS::Record::qsearchs( + my $agent_type = FS::Record::qsearchs( 'agent_type', { 'typenum'=>shift } ); $agent_type ? $agent_type->atype : '';