From 5214a5560240667a3a914c45df046b420926a5ec Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Mon, 14 May 2012 15:13:12 -0700 Subject: [PATCH] option to keep an email address but not email it invoices, RT#17676 --- FS/FS/Schema.pm | 1 + FS/FS/cust_bill.pm | 13 ++++++++----- FS/FS/cust_main.pm | 1 + FS/FS/part_event/Action/cust_bill_email.pm | 2 +- httemplate/edit/cust_main/billing.html | 18 +++++++++++++++--- httemplate/edit/process/cust_main.cgi | 2 ++ httemplate/view/cust_main/billing.html | 12 +++++++++--- httemplate/view/cust_main/contacts.html | 2 +- 8 files changed, 38 insertions(+), 13 deletions(-) diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index e3f34a4fd..29689035d 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -928,6 +928,7 @@ sub tables_hashref { 'edit_subject', 'char', 'NULL', 1, '', '', 'locale', 'varchar', 'NULL', 16, '', '', 'calling_list_exempt', 'char', 'NULL', 1, '', '', + 'invoice_noemail', 'char', 'NULL', 1, '', '', ], 'primary_key' => 'custnum', 'unique' => [ [ 'agentnum', 'agent_custid' ] ], diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index a76170a9b..1f4943a28 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -1314,14 +1314,16 @@ sub send { $balance_over = shift if scalar(@_) && $_[0] !~ /^\s*$/; } + my $cust_main = $self->cust_main; + return 'N/A' unless ! $agentnums - or grep { $_ == $self->cust_main->agentnum } @$agentnums; + or grep { $_ == $cust_main->agentnum } @$agentnums; return '' - unless $self->cust_main->total_owed_date($self->_date) > $balance_over; + unless $cust_main->total_owed_date($self->_date) > $balance_over; $invoice_from ||= $self->_agent_invoice_from || #XXX should go away - $conf->config('invoice_from', $self->cust_main->agentnum ); + $conf->config('invoice_from', $cust_main->agentnum ); my %opt = ( 'template' => $template, @@ -1329,11 +1331,12 @@ sub send { 'notice_name' => ( $notice_name || 'Invoice' ), ); - my @invoicing_list = $self->cust_main->invoicing_list; + my @invoicing_list = $cust_main->invoicing_list; #$self->email_invoice(\%opt) $self->email(\%opt) - if grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list or !@invoicing_list; + if ( grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list or !@invoicing_list ) + && ! $self->invoice_noemail; #$self->print_invoice(\%opt) $self->print(\%opt) diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 6f4a4d76a..97665798c 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -1800,6 +1800,7 @@ sub check { || $self->ut_numbern('billday') || $self->ut_enum('edit_subject', [ '', 'Y' ] ) || $self->ut_enum('calling_list_exempt', [ '', 'Y' ] ) + || $self->ut_enum('invoice_noemail', [ '', 'Y' ] ) || $self->ut_enum('locale', [ '', FS::Locales->locales ]) ; diff --git a/FS/FS/part_event/Action/cust_bill_email.pm b/FS/FS/part_event/Action/cust_bill_email.pm index a5cd86145..1a3bca4b7 100644 --- a/FS/FS/part_event/Action/cust_bill_email.pm +++ b/FS/FS/part_event/Action/cust_bill_email.pm @@ -17,7 +17,7 @@ sub do_action { #my $cust_main = $self->cust_main($cust_bill); my $cust_main = $cust_bill->cust_main; - $cust_bill->email; + $cust_bill->email unless $cust_main->invoice_noemail; } 1; diff --git a/httemplate/edit/cust_main/billing.html b/httemplate/edit/cust_main/billing.html index 3f873174f..d7082f23a 100644 --- a/httemplate/edit/cust_main/billing.html +++ b/httemplate/edit/cust_main/billing.html @@ -481,7 +481,7 @@ ? 'CHECKED' : '' - %>> <% mt('Postal mail invoice') |h %> + %>> <% mt('Postal mail invoices') |h %> @@ -493,15 +493,27 @@ ? 'CHECKED' : '' - %>> <% mt('Fax invoice') |h %> + %>> <% mt('Fax invoices') |h %> % } -% unless ( $conf->exists('cust-email-high-visibility')) { + invoice_noemail eq 'Y' ) + ? '' + : 'CHECKED' + + %>> <% mt('Email invoices') |h %> + + + + +% unless ( $conf->exists('cust-email-high-visibility')) { + <% $conf->exists('cust_main-require_invoicing_list_email', $agentnum) ? $r : '' %>Email address(es) diff --git a/httemplate/edit/process/cust_main.cgi b/httemplate/edit/process/cust_main.cgi index 1cf7a3eb4..3f5e19ef3 100755 --- a/httemplate/edit/process/cust_main.cgi +++ b/httemplate/edit/process/cust_main.cgi @@ -66,6 +66,8 @@ my $new = new FS::cust_main ( { } fields('cust_main') } ); +$new->invoice_noemail( ($cgi->param('invoice_email') eq 'Y') ? '' : 'Y' ); + $cgi->param('duplicate_of_custnum') =~ /^(\d+)$/; my $duplicate_of = $1; if ( $duplicate_of ) { diff --git a/httemplate/view/cust_main/billing.html b/httemplate/view/cust_main/billing.html index ba60e13d1..2547ec11f 100644 --- a/httemplate/view/cust_main/billing.html +++ b/httemplate/view/cust_main/billing.html @@ -217,21 +217,27 @@ % } - <% mt('Postal invoices') |h %> + <% mt('Postal mail invoices') |h %> <% ( grep { $_ eq 'POST' } @invoicing_list ) ? $yes : $no %> - <% mt('FAX invoices') |h %> + <% mt('Fax invoices') |h %> <% ( grep { $_ eq 'FAX' } @invoicing_list ) ? $yes : $no %> -% unless ( $conf->exists('cust-email-high-visibility')) { <% mt('Email invoices') |h %> + <% $cust_main->invoice_noemail ? $no : $yes %> + + +% unless ( $conf->exists('cust-email-high-visibility')) { + + <% mt('Email address(es)') |h %> + <% join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ) || $no %> diff --git a/httemplate/view/cust_main/contacts.html b/httemplate/view/cust_main/contacts.html index b3e52b556..12b9391a0 100644 --- a/httemplate/view/cust_main/contacts.html +++ b/httemplate/view/cust_main/contacts.html @@ -20,7 +20,7 @@ % if ( $conf->exists('cust-email-high-visibility') && $which eq '') { - <% mt('Email invoices') |h %> + <% mt('Email address(es)') |h %> <% join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ) || $no %> -- 2.11.0