[freeside-commits] freeside/FS/FS Misc.pm, 1.45, 1.46 cust_main_Mixin.pm, 1.10, 1.11 msg_template.pm, 1.19, 1.20
Mark Wells
mark at wavetail.420.am
Thu Jun 30 22:33:57 PDT 2011
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv17932/FS/FS
Modified Files:
Misc.pm cust_main_Mixin.pm msg_template.pm
Log Message:
send email from customer view, #13444
Index: msg_template.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/msg_template.pm,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -w -d -r1.19 -r1.20
--- msg_template.pm 20 May 2011 20:19:44 -0000 1.19
+++ msg_template.pm 1 Jul 2011 05:33:55 -0000 1.20
@@ -193,11 +193,6 @@
Destination address. The default is to use the customer's
invoicing_list addresses. Multiple addresses may be comma-separated.
-=item preview
-
-Set to true when preparing a message for previewing, rather than to actually
-send it. This turns off logging.
-
=back
=cut
@@ -318,16 +313,16 @@
$from_addr ||= scalar( $conf->config('invoice_from',
$cust_main->agentnum) );
}
- my @cust_msg = ();
- if ( $conf->exists('log_sent_mail') and !$opt{'preview'} ) {
- my $cust_msg = FS::cust_msg->new({
- 'custnum' => $cust_main->custnum,
- 'msgnum' => $self->msgnum,
- 'status' => 'prepared',
- });
- $cust_msg->insert;
- @cust_msg = ('cust_msg' => $cust_msg);
- }
+# my @cust_msg = ();
+# if ( $conf->exists('log_sent_mail') and !$opt{'preview'} ) {
+# my $cust_msg = FS::cust_msg->new({
+# 'custnum' => $cust_main->custnum,
+# 'msgnum' => $self->msgnum,
+# 'status' => 'prepared',
+# });
+# $cust_msg->insert;
+# @cust_msg = ('cust_msg' => $cust_msg);
+# }
(
'custnum' => $cust_main->custnum,
@@ -339,7 +334,6 @@
'html_body' => $body,
'text_body' => HTML::FormatText->new(leftmargin => 0, rightmargin => 70
)->format( HTML::TreeBuilder->new_from_content($body) ),
- @cust_msg,
);
}
Index: cust_main_Mixin.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_main_Mixin.pm,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -w -d -r1.10 -r1.11
--- cust_main_Mixin.pm 2 Oct 2010 00:32:21 -0000 1.10
+++ cust_main_Mixin.pm 1 Jul 2011 05:33:54 -0000 1.11
@@ -408,9 +408,6 @@
or die "msgnum $msgnum not found\n";
}
- $param->{'payby'} = [ split(/\0/, $param->{'payby'}) ]
- unless ref($param->{'payby'});
-
my $sql_query = $class->search($param->{'search'});
my $count_query = delete($sql_query->{'count_query'});
@@ -463,15 +460,16 @@
@message = $msg_template->prepare( 'cust_main' => $cust_main );
}
else {
- my $to = $cust_main->invoicing_list_emailonly_scalar;
- next if !$to;
+ my @to = $cust_main->invoicing_list_emailonly;
+ next if !@to;
@message = (
'from' => $from,
- 'to' => $to,
+ 'to' => \@to,
'subject' => $subject,
'html_body' => $html_body,
'text_body' => $text_body,
+ 'custnum' => $cust_main->custnum,
);
} #if $msg_template
Index: Misc.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Misc.pm,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -w -d -r1.45 -r1.46
--- Misc.pm 20 May 2011 20:19:43 -0000 1.45
+++ Misc.pm 1 Jul 2011 05:33:54 -0000 1.46
@@ -89,10 +89,14 @@
(optional) type parameter for multipart/related messages
-=item cust_msg
+=item custnum
-(optional) L<FS::cust_msg> object. If provided, it will be updated
-with the message envelope information, contents, and server response.
+(optional) L<FS::cust_main> key; if passed, the message will be logged
+(if logging is enabled) with this custnum.
+
+=item msgnum
+
+(optional) L<FS::msg_template> key, for logging.
=back
@@ -255,18 +259,20 @@
}
# Logging
- my $cust_msg = $options{'cust_msg'};
- if ( $cust_msg ) {
- $cust_msg->env_from($options{from});
- $cust_msg->env_to(join(",", @to));
- $cust_msg->header($message->header_as_string);
- $cust_msg->body($message->body_as_string);
- $cust_msg->_date($time);
- $cust_msg->error($error);
- $cust_msg->status( $error ? 'failed' : 'sent' );
- $cust_msg->replace;
- };
- return $error;
+ if ( $conf->exists('log_sent_mail') and $options{'custnum'} ) {
+ my $cust_msg = FS::cust_msg->new({
+ 'env_from' => $options{'from'},
+ 'env_to' => join(', ', @to),
+ 'header' => $message->header_as_string,
+ 'body' => $message->body_as_string,
+ '_date' => $time,
+ 'error' => $error,
+ 'custnum' => $options{'custnum'},
+ 'msgnum' => $options{'msgnum'},
+ 'status' => ($error ? 'failed' : 'sent'),
+ });
+ $cust_msg->insert; # ignore errors
+ }
}
@@ -302,9 +308,9 @@
Email body (Text alternative). Arrayref of lines, or scalar.
-=item cust_msg (optional)
+=item custnum, msgnum (optional)
-An L<FS::cust_msg> object. Will be passed through to send_email.
+Customer and template numbers, passed through to send_email for logging.
=back
@@ -322,21 +328,9 @@
my $me = '[FS::Misc::generate_email]';
- my %return = (
- 'from' => $args{'from'},
- 'to' => $args{'to'},
- 'bcc' => $args{'bcc'},
- 'subject' => $args{'subject'},
- 'cust_msg'=> $args{'cust_msg'},
- );
-
- #if (ref($args{'to'}) eq 'ARRAY') {
- # $return{'to'} = $args{'to'};
- #} else {
- # $return{'to'} = [ grep { $_ !~ /^(POST|FAX)$/ }
- # $self->cust_main->invoicing_list
- # ];
- #}
+ my @fields = qw(from to bcc subject custnum msgnum);
+ my %return;
+ @return{@fields} = @args{@fields};
warn "$me creating HTML/text multipart message"
if $DEBUG;
More information about the freeside-commits
mailing list