projects
/
freeside.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
1344575
)
log_sent_mail logs emailed invoices and receipts as well as msg_template messages...
author
Mark Wells
<mark@freeside.biz>
Wed, 5 Mar 2014 01:57:14 +0000
(17:57 -0800)
committer
Mark Wells
<mark@freeside.biz>
Wed, 5 Mar 2014 01:57:24 +0000
(17:57 -0800)
FS/FS/Misc.pm
patch
|
blob
|
history
FS/FS/Schema.pm
patch
|
blob
|
history
FS/FS/cust_bill.pm
patch
|
blob
|
history
FS/FS/cust_msg.pm
patch
|
blob
|
history
FS/FS/cust_pay.pm
patch
|
blob
|
history
FS/FS/cust_pkg.pm
patch
|
blob
|
history
FS/FS/part_export/send_email.pm
patch
|
blob
|
history
httemplate/search/cust_msg.html
patch
|
blob
|
history
httemplate/search/elements/search-html.html
patch
|
blob
|
history
diff --git
a/FS/FS/Misc.pm
b/FS/FS/Misc.pm
index
9c18961
..
c598507
100644
(file)
--- a/
FS/FS/Misc.pm
+++ b/
FS/FS/Misc.pm
@@
-267,7
+267,7
@@
sub send_email {
}
# Logging
}
# Logging
- if ( $conf->exists('log_sent_mail')
and $options{'custnum'}
) {
+ if ( $conf->exists('log_sent_mail') ) {
my $cust_msg = FS::cust_msg->new({
'env_from' => $options{'from'},
'env_to' => join(', ', @to),
my $cust_msg = FS::cust_msg->new({
'env_from' => $options{'from'},
'env_to' => join(', ', @to),
@@
-278,6
+278,7
@@
sub send_email {
'custnum' => $options{'custnum'},
'msgnum' => $options{'msgnum'},
'status' => ($error ? 'failed' : 'sent'),
'custnum' => $options{'custnum'},
'msgnum' => $options{'msgnum'},
'status' => ($error ? 'failed' : 'sent'),
+ 'msgtype' => $options{'msgtype'},
});
$cust_msg->insert; # ignore errors
}
});
$cust_msg->insert; # ignore errors
}
@@
-337,7
+338,7
@@
sub generate_email {
my $me = '[FS::Misc::generate_email]';
my $me = '[FS::Misc::generate_email]';
- my @fields = qw(from to bcc subject custnum msgnum);
+ my @fields = qw(from to bcc subject custnum msgnum
msgtype
);
my %return;
@return{@fields} = @args{@fields};
my %return;
@return{@fields} = @args{@fields};
diff --git
a/FS/FS/Schema.pm
b/FS/FS/Schema.pm
index
9b1ce00
..
a9fc13d
100644
(file)
--- a/
FS/FS/Schema.pm
+++ b/
FS/FS/Schema.pm
@@
-6013,7
+6013,7
@@
sub tables_hashref {
'cust_msg' => {
'columns' => [
'custmsgnum', 'serial', '', '', '', '',
'cust_msg' => {
'columns' => [
'custmsgnum', 'serial', '', '', '', '',
- 'custnum', 'int',
'
', '', '', '',
+ 'custnum', 'int',
'NULL
', '', '', '',
'msgnum', 'int', 'NULL', '', '', '',
'_date', @date_type, '', '',
'env_from', 'varchar', 'NULL', 255, '', '',
'msgnum', 'int', 'NULL', '', '', '',
'_date', @date_type, '', '',
'env_from', 'varchar', 'NULL', 255, '', '',
@@
-6022,6
+6022,7
@@
sub tables_hashref {
'body', 'blob', 'NULL', '', '', '',
'error', 'varchar', 'NULL', 255, '', '',
'status', 'varchar', '',$char_d, '', '',
'body', 'blob', 'NULL', '', '', '',
'error', 'varchar', 'NULL', 255, '', '',
'status', 'varchar', '',$char_d, '', '',
+ 'msgtype', 'varchar', 'NULL', 16, '', '',
],
'primary_key' => 'custmsgnum',
'unique' => [ ],
],
'primary_key' => 'custmsgnum',
'unique' => [ ],
diff --git
a/FS/FS/cust_bill.pm
b/FS/FS/cust_bill.pm
index
83ddb65
..
3c0e3e7
100644
(file)
--- a/
FS/FS/cust_bill.pm
+++ b/
FS/FS/cust_bill.pm
@@
-1065,6
+1065,8
@@
sub generate_email {
my %return = (
'from' => $args{'from'},
'subject' => ($args{'subject'} || $self->email_subject),
my %return = (
'from' => $args{'from'},
'subject' => ($args{'subject'} || $self->email_subject),
+ 'custnum' => $self->custnum,
+ 'msgtype' => 'invoice',
);
$args{'unsquelch_cdr'} = $conf->exists('voip-cdr_email');
);
$args{'unsquelch_cdr'} = $conf->exists('voip-cdr_email');
diff --git
a/FS/FS/cust_msg.pm
b/FS/FS/cust_msg.pm
index
c9cf686
..
8d57a54
100644
(file)
--- a/
FS/FS/cust_msg.pm
+++ b/
FS/FS/cust_msg.pm
@@
-22,9
+22,9
@@
FS::cust_msg - Object methods for cust_msg records
=head1 DESCRIPTION
=head1 DESCRIPTION
-An FS::cust_msg object represents a
template-generated message sent to
-a
customer (see L<FS::msg_template>). FS::cust_msg inherits from
-FS::Record. The following fields are currently supported:
+An FS::cust_msg object represents a
n email message generated by Freeside
+a
nd sent to a customer (see L<FS::msg_template>). FS::cust_msg inherits
+
from
FS::Record. The following fields are currently supported:
=over 4
=over 4
@@
-34,6
+34,8
@@
FS::Record. The following fields are currently supported:
=item msgnum - template number
=item msgnum - template number
+=item msgtype - the message type
+
=item _date - the time the message was sent
=item env_from - envelope From address
=item _date - the time the message was sent
=item env_from - envelope From address
@@
-125,8
+127,8
@@
sub check {
my $error =
$self->ut_numbern('custmsgnum')
my $error =
$self->ut_numbern('custmsgnum')
- || $self->ut_number('custnum')
- || $self->ut_foreign_key('custnum', 'cust_main', 'custnum')
+ || $self->ut_number
n
('custnum')
+ || $self->ut_foreign_key
n
('custnum', 'cust_main', 'custnum')
|| $self->ut_numbern('msgnum')
|| $self->ut_foreign_keyn('msgnum', 'msg_template', 'msgnum')
|| $self->ut_numbern('_date')
|| $self->ut_numbern('msgnum')
|| $self->ut_foreign_keyn('msgnum', 'msg_template', 'msgnum')
|| $self->ut_numbern('_date')
@@
-136,6
+138,11
@@
sub check {
|| $self->ut_anything('body')
|| $self->ut_enum('status', \@statuses)
|| $self->ut_textn('error')
|| $self->ut_anything('body')
|| $self->ut_enum('status', \@statuses)
|| $self->ut_textn('error')
+ || $self->ut_enum('msgtype', [ '',
+ 'invoice',
+ 'receipt',
+ 'admin',
+ ])
;
return $error if $error;
;
return $error if $error;
diff --git
a/FS/FS/cust_pay.pm
b/FS/FS/cust_pay.pm
index
0f643c9
..
10b51ad
100644
(file)
--- a/
FS/FS/cust_pay.pm
+++ b/
FS/FS/cust_pay.pm
@@
-616,11
+616,12
@@
sub send_receipt {
'custnum' => $cust_main->custnum,
};
$error = $queue->insert(
'custnum' => $cust_main->custnum,
};
$error = $queue->insert(
-
FS::msg_template->by_key($msgnum)->prepare(
+ FS::msg_template->by_key($msgnum)->prepare(
'cust_main' => $cust_main,
'object' => $self,
'from_config' => 'payment_receipt_from',
'cust_main' => $cust_main,
'object' => $self,
'from_config' => 'payment_receipt_from',
- )
+ ),
+ 'msgtype' => 'receipt', # override msg_template's default
);
} elsif ( $conf->exists('payment_receipt_email') ) {
);
} elsif ( $conf->exists('payment_receipt_email') ) {
@@
-663,6
+664,7
@@
sub send_receipt {
'job' => 'FS::Misc::process_send_generated_email',
'paynum' => $self->paynum,
'custnum' => $cust_main->custnum,
'job' => 'FS::Misc::process_send_generated_email',
'paynum' => $self->paynum,
'custnum' => $cust_main->custnum,
+ 'msgtype' => 'receipt',
};
$error = $queue->insert(
'from' => $conf->config('invoice_from', $cust_main->agentnum),
};
$error = $queue->insert(
'from' => $conf->config('invoice_from', $cust_main->agentnum),
diff --git
a/FS/FS/cust_pkg.pm
b/FS/FS/cust_pkg.pm
index
668de75
..
4ea3966
100644
(file)
--- a/
FS/FS/cust_pkg.pm
+++ b/
FS/FS/cust_pkg.pm
@@
-923,6
+923,8
@@
sub cancel {
'to' => \@invoicing_list,
'subject' => ( $conf->config('cancelsubject') || 'Cancellation Notice' ),
'body' => [ map "$_\n", $conf->config('cancelmessage') ],
'to' => \@invoicing_list,
'subject' => ( $conf->config('cancelsubject') || 'Cancellation Notice' ),
'body' => [ map "$_\n", $conf->config('cancelmessage') ],
+ 'custnum' => $self->custnum,
+ 'msgtype' => '', #admin?
);
}
#should this do something on errors?
);
}
#should this do something on errors?
@@
-1343,6
+1345,8
@@
sub suspend {
'Package : #'. $self->pkgnum. " (". $self->part_pkg->pkg_comment. ")\n",
( map { "Service : $_\n" } @labels ),
],
'Package : #'. $self->pkgnum. " (". $self->part_pkg->pkg_comment. ")\n",
( map { "Service : $_\n" } @labels ),
],
+ 'custnum' => $self->custnum,
+ 'msgtype' => 'admin'
);
if ( $error ) {
);
if ( $error ) {
@@
-1589,6
+1593,8
@@
sub unsuspend {
: ''
),
],
: ''
),
],
+ 'custnum' => $self->custnum,
+ 'msgtype' => 'admin',
);
if ( $error ) {
);
if ( $error ) {
diff --git
a/FS/FS/part_export/send_email.pm
b/FS/FS/part_export/send_email.pm
index
1fcb828
..
41f0409
100644
(file)
--- a/
FS/FS/part_export/send_email.pm
+++ b/
FS/FS/part_export/send_email.pm
@@
-6,7
+6,6
@@
use FS::part_export;
use FS::Record qw(qsearch qsearchs);
use FS::Conf;
use FS::msg_template;
use FS::Record qw(qsearch qsearchs);
use FS::Conf;
use FS::msg_template;
-use FS::Misc qw(send_email);
@ISA = qw(FS::part_export);
@ISA = qw(FS::part_export);
diff --git
a/httemplate/search/cust_msg.html
b/httemplate/search/cust_msg.html
index
f71a866
..
716addf
100644
(file)
--- a/
httemplate/search/cust_msg.html
+++ b/
httemplate/search/cust_msg.html
@@
-5,7
+5,7
@@
'count_query' => $count_query,
'header' => [
'Date',
'count_query' => $count_query,
'header' => [
'Date',
- 'T
emplat
e',
+ 'T
yp
e',
'Destination',
'Status',
'', #error
'Destination',
'Status',
'', #error
@@
-15,7
+15,9
@@
my $date = $_[0]->_date;
$date ? time2str('%Y-%m-%d %T',$_[0]->_date) : ''
},
my $date = $_[0]->_date;
$date ? time2str('%Y-%m-%d %T',$_[0]->_date) : ''
},
- 'msgname',
+ sub {
+ ucfirst($_[0]->msgtype) || $_[0]->msgname
+ },
sub {
join('<BR>', split(/,\s*/, $_[0]->env_to) )
},
sub {
join('<BR>', split(/,\s*/, $_[0]->env_to) )
},
@@
-31,9
+33,11
@@
'',
'',
],
'',
'',
],
- 'color' => [ ('') x 3,
- $statuscolor,
- $statuscolor,
+ 'color' => [ '',
+ $typecolor,
+ '',
+ $statuscolor,
+ $statuscolor,
],
'html_init' => $html_init,
'really_disable_download' => 1,
],
'html_init' => $html_init,
'really_disable_download' => 1,
@@
-51,6
+55,9
@@
my @where;
if ( $cgi->param('status') =~ /^(\w+)$/ ) {
push @where, "status = '$1'";
}
if ( $cgi->param('status') =~ /^(\w+)$/ ) {
push @where, "status = '$1'";
}
+if ( $cgi->param('msgtype') =~ /^(\w+)$/ ) {
+ push @where, "msgtype = '$1'";
+}
my ($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi, '');
push @where, "(_date >= $beginning AND _date <= $ending)";
my ($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi, '');
push @where, "(_date >= $beginning AND _date <= $ending)";
@@
-79,16
+86,22
@@
my $sub_popup_link = sub {
include('/elements/popup_link_onclick.html',
'action' => $p. 'view/cust_msg.html?' . $custmsgnum,
'actionlabel' => 'Message detail',
include('/elements/popup_link_onclick.html',
'action' => $p. 'view/cust_msg.html?' . $custmsgnum,
'actionlabel' => 'Message detail',
- 'width' => 6
0
0,
- 'height' => 5
0
0,
+ 'width' => 6
8
0,
+ 'height' => 5
5
0,
);
};
my %color = (
'failed' => 'FF0000',
'sent' => '',
);
};
my %color = (
'failed' => 'FF0000',
'sent' => '',
+
+ 'invoice' => '00CC00',
+ 'receipt' => '0000CC',
+ 'admin' => 'CC0000',
+ '' => '000000',
);
my $statuscolor = sub { $color{$_[0]->status} };
);
my $statuscolor = sub { $color{$_[0]->status} };
+my $typecolor = sub { $color{$_[0]->msgtype} };
my $html_init = qq!<FORM ACTION="$p/search/cust_msg.html" METHOD="GET">
<TABLE cellspacing="10">!.
my $html_init = qq!<FORM ACTION="$p/search/cust_msg.html" METHOD="GET">
<TABLE cellspacing="10">!.
@@
-110,6
+123,17
@@
include('/elements/select.html',
'failed' => 'failed',
'sent' => 'sent', },
) .
'failed' => 'failed',
'sent' => 'sent', },
) .
+'</TD><TD> Type '.
+include('/elements/select.html',
+ 'field' => 'msgtype',
+ 'curr_value' => $cgi->param('msgtype') || '',
+ 'options' => [ '', 'invoice', 'receipt', 'admin' ],
+ 'labels' => { '' => '(any)',
+ 'invoice' => 'Invoices',
+ 'receipt' => 'Receipts',
+ 'admin' => 'Admin notices',
+ },
+) .
'</TD>
<TD><INPUT type="submit" value="Search"></TD></TR>
</TABLE></FORM><BR>
'</TD>
<TD><INPUT type="submit" value="Search"></TD></TR>
</TABLE></FORM><BR>
diff --git
a/httemplate/search/elements/search-html.html
b/httemplate/search/elements/search-html.html
index
bee33cf
..
10cc955
100644
(file)
--- a/
httemplate/search/elements/search-html.html
+++ b/
httemplate/search/elements/search-html.html
@@
-446,7
+446,7
@@
% $cstyle = qq(STYLE="$cstyle")
% if $cstyle;
% $cstyle = qq(STYLE="$cstyle")
% if $cstyle;
- <TD CLASS="<% $class %>" BGCOLOR="<% $bgcolor %>" <% $align %> <% $cstyle %>><% $
font %><% $a %><% $s %><% $field %><% $es %><% $a ? '</A>' : '' %><% $font ? '</FONT
>' : '' %></TD>
+ <TD CLASS="<% $class %>" BGCOLOR="<% $bgcolor %>" <% $align %> <% $cstyle %>><% $
a %><% $font %><% $s %><% $field %><% $es %><% $font ? '</FONT>' : '' %><% $a ? '</A
>' : '' %></TD>
% }
%
% }
%