From 4747bfbea3f4abb66d05a2bd1abed69e28a4aa3d Mon Sep 17 00:00:00 2001 From: Mitch Jackson Date: Sun, 28 Jan 2018 02:41:17 -0600 Subject: RT# 73421 Fixed E-Mail pipeline to obey contact opt-in flags --- httemplate/misc/email-customers.html | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'httemplate/misc') diff --git a/httemplate/misc/email-customers.html b/httemplate/misc/email-customers.html index fe637abe1..dc53f6d55 100644 --- a/httemplate/misc/email-customers.html +++ b/httemplate/misc/email-customers.html @@ -171,16 +171,18 @@ Template: Send to contacts:
- <& /elements/checkboxes.html, - 'style' => 'display: inline; vertical-align: top', - 'disable_links' => 1, - 'names_list' => \@contact_checkboxes, - 'element_name_prefix' => 'contact_class_', - 'checked_callback' => sub { - my($cgi, $name) = @_; - $name eq 'invoice' #others default to unchecked - }, - &> + <& /elements/checkboxes.html, + 'style' => 'display: inline; vertical-align: top', + 'disable_links' => 1, + 'names_list' => \@contact_checkboxes, + 'element_name_prefix' => 'contact_class_', + 'checked_callback' => sub { + # Called for each checkbox + # Return true to default as checked, false as unchecked + my($cgi, $name) = @_; + $name eq 'message' + }, + &>
% if ($send_to_domain) {
@@ -422,6 +424,8 @@ if ( !$cgi->param('preview') ) { push @contact_classnum, $1; if ( $1 eq 'invoice' ) { push @contact_classname, 'Invoice recipients'; + } elsif ( $1 eq 'message' ) { + push @contact_classname, 'Message recipients'; } else { my $contact_class = FS::contact_class->by_key($1); push @contact_classname, encode_entities($contact_class->classname); @@ -432,7 +436,8 @@ if ( !$cgi->param('preview') ) { } my @contact_checkboxes = ( - [ 'invoice' => { label => 'Invoice recipients' } ] + [ 'message' => { label => 'Message recipients' } ], + [ 'invoice' => { label => 'Invoice recipients' } ], ); foreach my $class (qsearch('contact_class', { disabled => '' })) { -- cgit v1.2.1 From e803d5f00368e951f7a4b82d5d390b53c4a6c827 Mon Sep 17 00:00:00 2001 From: Mitch Jackson Date: Tue, 30 Jan 2018 09:27:42 -0600 Subject: RT# 73422 Changes to report Customer Contacts --- httemplate/misc/email-customers.html | 75 +++++++++++++++++++++++++++++++----- 1 file changed, 66 insertions(+), 9 deletions(-) (limited to 'httemplate/misc') diff --git a/httemplate/misc/email-customers.html b/httemplate/misc/email-customers.html index dc53f6d55..4520c7514 100644 --- a/httemplate/misc/email-customers.html +++ b/httemplate/misc/email-customers.html @@ -174,7 +174,7 @@ Template: <& /elements/checkboxes.html, 'style' => 'display: inline; vertical-align: top', 'disable_links' => 1, - 'names_list' => \@contact_checkboxes, + 'names_list' => \@optin_checkboxes, 'element_name_prefix' => 'contact_class_', 'checked_callback' => sub { # Called for each checkbox @@ -199,6 +199,27 @@ Template:
% } +% if (@active_classes) { + + +Contact Type: + +
+ <& /elements/checkboxes.html, + 'style' => 'display: inline; vertical-align: top', + 'disable_links' => 1, + 'names_list' => \@classnum_checkboxes, + 'element_name_prefix' => 'contact_class_', + 'checked_callback' => sub { + # Called for each checkbox + # Return true to default as checked, false as unchecked + my($cgi, $name) = @_; + exists $classnum_ischecked{$name}; + }, + &> +
+ +% }
@@ -342,6 +363,21 @@ if ( !$cgi->param('preview') ) { } else { + my @checked_email_dest; + my @checked_contact_type; + for ($cgi->param) { + if (/^contact_class_(.+)$/) { + my $f = $1; + if ($f eq 'invoice' || $f eq 'message') { + push @checked_email_dest, $f; + } elsif ( $f =~ /^\d+$/ ) { + push @checked_contact_type, $f; + } + } + } + $search{with_email_dest} = \@checked_email_dest if @checked_email_dest; + $search{with_contact_type} = \@checked_contact_type if @checked_contact_type; + my $sql_query = "FS::$table"->search(\%search); my $count_query = delete($sql_query->{'count_query'}); my $count_sth = dbh->prepare($count_query) @@ -391,6 +427,8 @@ if ( !$cgi->param('preview') ) { $sql_query->{'select'} = "$table.*"; $sql_query->{'order_by'} = ''; my $object = qsearchs($sql_query); + # Could use better error handling here... + die "No customers match the search criteria" unless ref $object; $cust = $object->cust_main; my %msgopts = ( 'cust_main' => $cust, @@ -435,16 +473,35 @@ if ( !$cgi->param('preview') ) { } } -my @contact_checkboxes = ( +# Build data structures for "Opt In" and "Contact Type" checkboxes +# +# By default, message recipients will be selected, this is a message. +# By default, all Contact Types will be selected, but this may be +# overridden by passing 'classnums' get/post values. If no contact +# types have been defined, the option will not be presented. + +my @active_classes = qsearch(contact_class => {disabled => ''} ); + +$CGI::LIST_CONTEXT_WARN = 0; +my @classnums = grep{ /^\d+$/ } $cgi->param('classnums'); + +my %classnum_ischecked; +if (@classnums) { + # values passed to form + $classnum_ischecked{$_} = 1 for @classnums; +} else { + # default values + $classnum_ischecked{$_->classnum} = 1 for @active_classes; + $classnum_ischecked{0} = 1; +} + +my @optin_checkboxes = ( [ 'message' => { label => 'Message recipients' } ], [ 'invoice' => { label => 'Invoice recipients' } ], ); - -foreach my $class (qsearch('contact_class', { disabled => '' })) { - push @contact_checkboxes, [ - $class->classnum, - { label => $class->classname } - ]; -} +my @classnum_checkboxes = ( + [ '0' => { label => '(None)' }], + map { [ $_->classnum => {label => $_->classname} ] } @active_classes, +); -- cgit v1.2.1 From 560af69840e7e3fcebf65d5d56ca4efc0851efec Mon Sep 17 00:00:00 2001 From: Mitch Jackson Date: Sat, 3 Feb 2018 20:16:47 -0600 Subject: RT# 73422 Fix report Customer Contacts --- httemplate/misc/email-customers.html | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'httemplate/misc') diff --git a/httemplate/misc/email-customers.html b/httemplate/misc/email-customers.html index 4520c7514..f52c6b36a 100644 --- a/httemplate/misc/email-customers.html +++ b/httemplate/misc/email-customers.html @@ -180,7 +180,7 @@ Template: # Called for each checkbox # Return true to default as checked, false as unchecked my($cgi, $name) = @_; - $name eq 'message' + exists $dest_ischecked{$name}; }, &> @@ -466,7 +466,9 @@ if ( !$cgi->param('preview') ) { push @contact_classname, 'Message recipients'; } else { my $contact_class = FS::contact_class->by_key($1); - push @contact_classname, encode_entities($contact_class->classname); + push @contact_classname, encode_entities( + $contact_class ? $contact_class->classname : '(none)' + ); } } } @@ -482,19 +484,30 @@ if ( !$cgi->param('preview') ) { my @active_classes = qsearch(contact_class => {disabled => ''} ); +my %classnum_ischecked; +my %dest_ischecked; + $CGI::LIST_CONTEXT_WARN = 0; -my @classnums = grep{ /^\d+$/ } $cgi->param('classnums'); +if ( my @in_classnums = $cgi->param('classnums') ) { + # Set checked boxes from form input + for my $v (@in_classnums) { + + if ( $v =~ /^\d+$/ ) { + $classnum_ischecked{$v} = 1 + } elsif ( $v =~ /^(invoice|message)$/ ) { + $dest_ischecked{$v} = 1; + } -my %classnum_ischecked; -if (@classnums) { - # values passed to form - $classnum_ischecked{$_} = 1 for @classnums; + } } else { - # default values + # Checked boxes default values $classnum_ischecked{$_->classnum} = 1 for @active_classes; $classnum_ischecked{0} = 1; } +# At least one destination is required +$dest_ischecked{message} = 1 unless %dest_ischecked; + my @optin_checkboxes = ( [ 'message' => { label => 'Message recipients' } ], [ 'invoice' => { label => 'Invoice recipients' } ], -- cgit v1.2.1 From 15d596e3090f3bde642917b56563736cd1ee2e90 Mon Sep 17 00:00:00 2001 From: Christopher Burger Date: Tue, 6 Feb 2018 10:36:31 -0500 Subject: RT# 75095 - fixed ooma format to import all charges, and unified import process to allow new formats to be added quickly. consistant with cdr imports --- httemplate/misc/cust_main-import_charges.cgi | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'httemplate/misc') diff --git a/httemplate/misc/cust_main-import_charges.cgi b/httemplate/misc/cust_main-import_charges.cgi index 4eacce13a..215cc4c9d 100644 --- a/httemplate/misc/cust_main-import_charges.cgi +++ b/httemplate/misc/cust_main-import_charges.cgi @@ -28,9 +28,9 @@ Import a CSV file containing customer charges. Format @@ -94,6 +94,8 @@ Field information: die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Import'); + tie my %formats, 'Tie::IxHash', FS::cust_main::Import_Charges->import_formats; + my $custbatch = time2str('webimport-%Y/%m/%d-%T'. "-$$-". rand() * 2**32, time); -- cgit v1.2.1