From dfc85a4245f2d15f258d840b98f0508c50228e40 Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Mon, 25 Mar 2013 15:47:34 -0700 Subject: [PATCH] email opt-out flag, #19312 --- FS/FS/Schema.pm | 1 + FS/FS/cust_main.pm | 7 +- FS/FS/part_event/Condition/message_email.pm | 22 +++++ httemplate/edit/cust_main/billing.html | 8 +- httemplate/elements/menu.html | 2 + httemplate/misc/manage_cust_email.html | 106 +++++++++++++++++++++ httemplate/misc/process/manage_cust_email.html | 32 +++++++ .../misc/xmlhttp-cust_main-email_search.html | 29 ++++++ httemplate/view/cust_main/billing.html | 4 + 9 files changed, 207 insertions(+), 4 deletions(-) create mode 100644 FS/FS/part_event/Condition/message_email.pm create mode 100644 httemplate/misc/manage_cust_email.html create mode 100644 httemplate/misc/process/manage_cust_email.html create mode 100644 httemplate/misc/xmlhttp-cust_main-email_search.html diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index 29f8ea4b8..cd42e4e9c 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -1080,6 +1080,7 @@ sub tables_hashref { 'locale', 'varchar', 'NULL', 16, '', '', 'calling_list_exempt', 'char', 'NULL', 1, '', '', 'invoice_noemail', 'char', 'NULL', 1, '', '', + 'message_noemail', 'char', 'NULL', 1, '', '', 'bill_locationnum', 'int', 'NULL', '', '', '', 'ship_locationnum', 'int', 'NULL', '', '', '', ], diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 3e5d4c137..2a4602e19 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -1778,9 +1778,10 @@ sub check { || $self->ut_floatn('credit_limit') || $self->ut_numbern('billday') || $self->ut_numbern('prorate_day') - || $self->ut_enum('edit_subject', [ '', 'Y' ] ) - || $self->ut_enum('calling_list_exempt', [ '', 'Y' ] ) - || $self->ut_enum('invoice_noemail', [ '', 'Y' ] ) + || $self->ut_flag('edit_subject') + || $self->ut_flag('calling_list_exempt') + || $self->ut_flag('invoice_noemail') + || $self->ut_flag('message_noemail') || $self->ut_enum('locale', [ '', FS::Locales->locales ]) ; diff --git a/FS/FS/part_event/Condition/message_email.pm b/FS/FS/part_event/Condition/message_email.pm new file mode 100644 index 000000000..7cceba697 --- /dev/null +++ b/FS/FS/part_event/Condition/message_email.pm @@ -0,0 +1,22 @@ +package FS::part_event::Condition::message_email; +use base qw( FS::part_event::Condition ); +use strict; + +sub description { + 'Customer allows email notices' +} + +sub condition { + my( $self, $object ) = @_; + my $cust_main = $self->cust_main($object); + + $cust_main->message_noemail ? 0 : 1; +} + +sub condition_sql { + my( $self, $table ) = @_; + + "cust_main.message_noemail IS NULL" +} + +1; diff --git a/httemplate/edit/cust_main/billing.html b/httemplate/edit/cust_main/billing.html index 6ba73ad68..5a66f0a60 100644 --- a/httemplate/edit/cust_main/billing.html +++ b/httemplate/edit/cust_main/billing.html @@ -521,7 +521,13 @@ <% $conf->exists('cust_main-require_invoicing_list_email', $agentnum) ? $r : '' %>Email address(es) - + + message_noemail eq 'Y' ) + ? 'CHECKED' + : '' + %>> <% emt('Do not send notices') %> + % } diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html index 00c43bb09..14d36c31d 100644 --- a/httemplate/elements/menu.html +++ b/httemplate/elements/menu.html @@ -464,6 +464,8 @@ $tools_menu{'Job Queue'} = [ $fsurl.'search/queue.html', 'View pending job queu if $curuser->access_right('Job queue'); $tools_menu{'Ticketing'} = [ \%tools_ticketing, 'Ticketing tools' ] if $conf->config('ticket_system'); +$tools_menu{'Customer email settings'} = [ $fsurl.'misc/manage_cust_email.html' ] + if $curuser->access_right('Edit customer'); $tools_menu{'Business card scan'} = [ $fsurl.'edit/prospect_main-upload.html' ] if $curuser->access_right('New prospect'); $tools_menu{'Time Queue'} = [ $fsurl.'search/report_timeworked.html', 'View pending support time' ] diff --git a/httemplate/misc/manage_cust_email.html b/httemplate/misc/manage_cust_email.html new file mode 100644 index 000000000..3ece459bb --- /dev/null +++ b/httemplate/misc/manage_cust_email.html @@ -0,0 +1,106 @@ +<& /elements/header.html, 'Manage customer email settings' &> + +<& /elements/xmlhttp.html, + url => $p.'misc/xmlhttp-cust_main-email_search.html', + subs => ['email_search'] +&> + +
+
+% if ( $cgi->param('done') ) { +

Changes saved.

+% } elsif ( $cgi->param('error') ) { +

<% $cgi->param('error') |h %>

+% } + Email address: + + +
+ +