[freeside-commits] branch FREESIDE_3_BRANCH updated. 3f36e519d061f6ca0102ba7887e9fee9b1bda874
Mark Wells
mark at 420.am
Wed May 6 16:58:27 PDT 2015
The branch, FREESIDE_3_BRANCH has been updated
via 3f36e519d061f6ca0102ba7887e9fee9b1bda874 (commit)
from 9673c3dd4b15d76e4df583b1ec1df2e6964e948e (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 3f36e519d061f6ca0102ba7887e9fee9b1bda874
Author: Mark Wells <mark at freeside.biz>
Date: Wed May 6 16:56:58 2015 -0700
display N most recent emails in customer view, #30164
diff --git a/httemplate/pref/pref-process.html b/httemplate/pref/pref-process.html
index 0d1a45a..74a1493 100644
--- a/httemplate/pref/pref-process.html
+++ b/httemplate/pref/pref-process.html
@@ -54,6 +54,7 @@ unless ( $error ) { # if ($access_user) {
enable_fuzzy_on_exact
disable_html_editor disable_enter_submit_onetimecharge
enable_mask_clipboard_hack dashboard_customers
+ customer_view_emails
email_address
snom-ip snom-username snom-password
vonage-fromnumber vonage-username vonage-password
diff --git a/httemplate/pref/pref.html b/httemplate/pref/pref.html
index 1b0ea06..24c6a4d 100644
--- a/httemplate/pref/pref.html
+++ b/httemplate/pref/pref.html
@@ -149,6 +149,15 @@ Interface
</TD>
</TR>
+ <TR>
+ <TH ALIGN="right">How many recent outbound emails to show in customer view</TH>
+ <TD ALIGN="left" COLSPAN=2>
+ <INPUT TYPE="text" NAME="customer_view_emails" VALUE="<% $curuser->option('customer_view_emails') %>"></TD>
+ </TD>
+ </TR>
+
+
+
</TABLE>
<BR>
diff --git a/httemplate/search/cust_msg.html b/httemplate/search/cust_msg.html
index 486c7b0..c5222e1 100644
--- a/httemplate/search/cust_msg.html
+++ b/httemplate/search/cust_msg.html
@@ -47,7 +47,7 @@
],
'html_init' => $html_init,
'really_disable_download' => 1,
- @_
+ 'order_by' => '_date DESC',
&>
<%init>
#hmm...
diff --git a/httemplate/search/elements/search.html b/httemplate/search/elements/search.html
index b70b82d..053da47 100644
--- a/httemplate/search/elements/search.html
+++ b/httemplate/search/elements/search.html
@@ -386,10 +386,7 @@ unless ( $type =~ /^(csv|xml|\w*.xls)$/) {
}
#order by override
-my $order_by = '';
-#if ( $cgi->param('order_by') =~ /^([\w\, ]+)$/ ) {
-# $order_by = $1;
-#}
+my $order_by = $opt{order_by} || '';
$order_by = $cgi->param('order_by') if $cgi->param('order_by');
# run the query
@@ -415,6 +412,8 @@ if ( ref($opt{query}) ) {
}
}
+ $opt{query}->{'order_by'} .= " $limit";
+
} elsif (ref($opt{query}) eq 'ARRAY') {
@query = @{ $opt{query} };
} else {
@@ -434,7 +433,7 @@ if ( ref($opt{query}) ) {
}
@query
],
- 'order_by' => $opt{order_by}. " ". $limit,
+ #'order_by' => $opt{order_by}. " ". $limit,
)
];
} else {
diff --git a/httemplate/view/cust_main/notes.html b/httemplate/view/cust_main/notes.html
index 1cd6e09..deba956 100755
--- a/httemplate/view/cust_main/notes.html
+++ b/httemplate/view/cust_main/notes.html
@@ -77,15 +77,8 @@
% if ( $curuser->access_right('View email logs')
% and FS::cust_msg->count("custnum = $custnum")) {
<BR>
-% if (!$cgi->param('order_by')) {
-% my $order_by = '_date';
-% $order_by .= ' DESC' if $curuser->option('history_order') eq 'newest';
-% $cgi->param('order_by', $order_by);
-% }
-<& /search/cust_msg.html,
- nohtmlheader => 1,
- html_init => mt('Mail sent to this customer: '),
-&>
+<& notes/email.html, 'cust_main' => $cust_main &>
+<BR>
% }
<%init>
diff --git a/httemplate/view/cust_main/notes/email.html b/httemplate/view/cust_main/notes/email.html
new file mode 100644
index 0000000..da2c352
--- /dev/null
+++ b/httemplate/view/cust_main/notes/email.html
@@ -0,0 +1,106 @@
+% if ( scalar(@rows) ) {
+<STYLE type="text/css">
+#cust_msg td.grid a:link {text-decoration: none}
+#cust_msg td.grid a:visited {text-decoration: none}
+#cust_msg td.grid a:hover {text-decoration: underline}
+#cust_msg th {background-color: #cccccc}
+.row0 {background-color: #eeeeee}
+.row1 {background-color: #ffffff}
+</STYLE>
+<DIV id="cust_msg">
+<FONT SIZE="+1"> <% mt('Email sent to this customer') %> </FONT><BR>
+% if ($maxrecords < $total) {
+<% mt('Showing [_1] most recent of [quant,_2,total message]', $maxrecords, $total) %>
+ <A HREF="<%$p%>search/cust_msg.html?custnum=<%$custnum%>">
+ <i>(<% mt('view all') %>)</i>
+ </A>
+% } else {
+<% mt('[quant,_1,total message]', $total) %>
+% }
+<BR>
+<& /elements/table-grid.html &>
+ <TR>
+ <TH CLASS="grid"><% mt('Date') %></TH>
+ <TH CLASS="grid"><% mt('Type') %></TH>
+ <TH CLASS="grid"><% mt('Destination') %></TH>
+ <TH CLASS="grid"><% mt('Subject') %></TH>
+ <TH CLASS="grid"></TH>
+ </TR>
+% my $i = 0;
+% foreach my $row (@rows) {
+% my $onclick = $sub_popup_link->($row);
+% my $link = qq!<A onclick="$onclick">!;
+ <TR CLASS="row<%$i%>">
+ <TD CLASS="grid"><% $link %>
+ <% $row->_date ? time2str('%Y-%m-%d %T', $row->_date) : '' %>
+ </A></TD>
+ <TD CLASS="grid" STYLE="color: <% $typecolor->($row) %>"><% $link %>
+ <% ucfirst($row->msgtype) || $row->msgname %>
+ </A></TD>
+ <TD CLASS="grid"><% $link %>
+ <% join('<BR>', split(/,\s*/, $row->env_to)) %>
+ </A></TD>
+ <TD CLASS="grid" STYLE="color: <% $statuscolor->($row) %>">
+ <% $row->status %>
+ </TD>
+ <TD CLASS="grid">
+ <% $row->error |h %>
+ </TD>
+ </TR>
+% $i = 1 - $i;
+% }
+</TABLE>
+</DIV>
+% }
+<%init>
+my %opt = @_;
+
+my $curuser = $FS::CurrentUser::CurrentUser;
+my $cust_main = $opt{'cust_main'}
+ or die "cust_main required";
+my $custnum = $cust_main->custnum;
+
+my $where = "WHERE cust_msg.custnum = $custnum";
+my $maxrecords = $curuser->option('customer_view_emails') || 10;
+
+my $order_by = '_date DESC';
+
+my $query = {
+ 'table' => 'cust_msg',
+ 'select' => join(', ',
+ 'cust_msg.*',
+ 'msg_template.msgname',
+ ),
+ 'addl_from' => ' LEFT JOIN msg_template USING ( msgnum ) ',
+ 'hashref' => {},
+ 'extra_sql' => $where,
+ 'order_by' => "ORDER BY $order_by LIMIT $maxrecords",
+};
+my $count_query = "SELECT COUNT(*) FROM cust_msg $where";
+
+my @rows = qsearch($query);
+my $total = FS::Record->scalar_sql($count_query);
+
+my $sub_popup_link = sub {
+ my $custmsgnum = $_[0]->custmsgnum;
+ include('/elements/popup_link_onclick.html',
+ 'action' => $p. 'view/cust_msg.html?' . $custmsgnum,
+ 'actionlabel' => 'Message detail',
+ 'width' => 680,
+ 'height' => 550,
+ );
+};
+
+my %color = (
+ 'failed' => '#FF0000',
+ 'sent' => '#000000',
+
+ 'invoice' => '#00CC00',
+ 'receipt' => '#0000CC',
+ 'admin' => '#CC0000',
+ '' => '#000000',
+);
+my $statuscolor = sub { $color{$_[0]->status} };
+my $typecolor = sub { $color{$_[0]->msgtype} };
+
+</%init>
-----------------------------------------------------------------------
Summary of changes:
httemplate/pref/pref-process.html | 1 +
httemplate/pref/pref.html | 9 +++
httemplate/search/cust_msg.html | 2 +-
httemplate/search/elements/search.html | 9 ++-
httemplate/view/cust_main/notes.html | 11 +--
httemplate/view/cust_main/notes/email.html | 106 ++++++++++++++++++++++++++++
6 files changed, 123 insertions(+), 15 deletions(-)
create mode 100644 httemplate/view/cust_main/notes/email.html
More information about the freeside-commits
mailing list