From: mark Date: Tue, 7 Dec 2010 22:26:17 +0000 (+0000) Subject: per-agent notification options, RT#10797 X-Git-Tag: TORRUS_1_0_9~31 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=8aa8e80791b7b99f4ac2e8e242fe83e1421c98d2 per-agent notification options, RT#10797 --- diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index f5b2451b0..bcebdf6de 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -568,16 +568,20 @@ 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; + 'options_sub' => sub { + my @templates = qsearch({ + 'table' => 'msg_template', + 'hashref' => { 'disabled' => '' }, + 'extra_sql' => ' AND '. + $FS::CurrentUser::CurrentUser->agentnums_sql(null => 1), + }); + map { $_->msgnum, $_->msgname } @templates; + }, + 'option_sub' => sub { my $msg_template = FS::msg_template->by_key(shift); $msg_template ? $msg_template->msgname : '' }, + 'per_agent' => 1, ); @@ -1246,6 +1250,7 @@ and customer address. Include units.', 'section' => 'notification', 'description' => 'Send payment receipts.', 'type' => 'checkbox', + 'per_agent' => 1, }, { @@ -1271,6 +1276,7 @@ and customer address. Include units.', 'cust_pay' => 'When payment is made.', 'cust_bill_pay_pkg' => 'When payment is applied.', ], + 'per_agent' => 1, }, { @@ -1874,6 +1880,7 @@ and customer address. Include units.', 'section' => 'notification', 'description' => 'Enable emailing of credit card and electronic check decline notices.', 'type' => 'checkbox', + 'per_agent' => 1, }, { @@ -1881,6 +1888,7 @@ and customer address. Include units.', 'section' => 'notification', 'description' => 'List of error messages that should not trigger email decline notices, one per line.', 'type' => 'textarea', + 'per_agent' => 1, }, { @@ -1909,6 +1917,7 @@ and customer address. Include units.', 'section' => 'notification', 'description' => 'Enable emailing of cancellation notices. Make sure to select the template in the cancel_msgnum option.', 'type' => 'checkbox', + 'per_agent' => 1, }, { @@ -2930,6 +2939,13 @@ and customer address. Include units.', 'type' => 'textarea', }, +# { +# 'key' => 'batch-manual_approval', +# 'section' => 'billing', +# 'description' => 'Allow manual batch closure, which will approve all payments that do not yet have a status. This is dangerous, but may be needed if your processor does not provide a list of approved payments.', +# 'type' => 'checkbox', +# }, +# { 'key' => 'payment_history-years', 'section' => 'UI', diff --git a/FS/FS/cust_main/Billing_Realtime.pm b/FS/FS/cust_main/Billing_Realtime.pm index 212407518..ba1e9c86e 100644 --- a/FS/FS/cust_main/Billing_Realtime.pm +++ b/FS/FS/cust_main/Billing_Realtime.pm @@ -902,10 +902,10 @@ sub _realtime_bop_result { } if ( !$options{'quiet'} && !$realtime_bop_decline_quiet - && $conf->exists('emaildecline') + && $conf->exists('emaildecline', $self->agentnum) && grep { $_ ne 'POST' } $self->invoicing_list && ! grep { $transaction->error_message =~ /$_/ } - $conf->config('emaildecline-exclude') + $conf->config('emaildecline-exclude', $self->agentnum) ) { # Send a decline alert to the customer. diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm index 014affeae..71bc70764 100644 --- a/FS/FS/cust_pay.pm +++ b/FS/FS/cust_pay.pm @@ -297,7 +297,8 @@ sub insert { $dbh->commit or die $dbh->errstr if $oldAutoCommit; #payment receipt - my $trigger = $conf->config('payment_receipt-trigger') || 'cust_pay'; + my $trigger = $conf->config('payment_receipt-trigger', + $self->cust_main->agentnum) || 'cust_pay'; if ( $trigger eq 'cust_pay' ) { my $error = $self->send_receipt( 'manual' => $options{'manual'}, @@ -533,7 +534,7 @@ sub send_receipt { my $conf = new FS::Conf; - return '' unless $conf->exists('payment_receipt'); + return '' unless $conf->exists('payment_receipt', $cust_main->agentnum); my @invoicing_list = $cust_main->invoicing_list_emailonly; return '' unless @invoicing_list; @@ -547,13 +548,9 @@ sub send_receipt { || ! $cust_bill ) { - - if ( $conf->exists('payment_receipt_msgnum') - && $conf->config('payment_receipt_msgnum') - ) - { - my $msg_template = - FS::msg_template->by_key($conf->config('payment_receipt_msgnum')); + my $msgnum = $conf->config('payment_receipt_msgnum', $cust_main->agentnum); + if ( $msgnum ) { + my $msg_template = FS::msg_template->by_key($msgnum); $error = $msg_template->send('cust_main'=> $cust_main, 'object'=> $self); } elsif ( $conf->exists('payment_receipt_email') ) { diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm index 66d8baec3..a946de4da 100644 --- a/FS/FS/cust_pkg.pm +++ b/FS/FS/cust_pkg.pm @@ -707,7 +707,9 @@ sub cancel { return '' if $date; #no errors my @invoicing_list = grep { $_ !~ /^(POST|FAX)$/ } $self->cust_main->invoicing_list; - if ( !$options{'quiet'} && $conf->exists('emailcancel') && @invoicing_list ) { + if ( !$options{'quiet'} && + $conf->exists('emailcancel', $self->cust_main->agentnum) && + @invoicing_list ) { my $msgnum = $conf->config('cancel_msgnum', $self->cust_main->agentnum); my $error = ''; if ( $msgnum ) {