-<%doc>
-<%/doc>
<%init>
use AwayMsg;
+db_connect();
+my ($sth,$row,$sthi,$rowi);
+</%init>
<html lang="en"><head>
<title>Email "out of office" setup</title>
</head><body>
<h1>Email "out of office" setup</h1>
-<h2>Our email addresses</h2>
-
+<h2>Email addresses and their configuration</h2>
<%perl>
-my %row;
-my $sth = $dbh->prepare("SELECT emailaddr, textid, expires"
- " FROM schema
- " RIGHT JOIN addresses USING (emailaddr)".
- " JOIN texts USING (textid)",
- " ORDER BY emailaddr");
+$sth = $dbh->prepare(<<END);
+ SELECT *
+ FROM addresses
+ LEFT JOIN config USING (emailaddr)
+ LEFT JOIN texts USING (textid)
+ ORDER BY emailaddr
+END
+$sth->execute();
</%perl>
-
-<table>
+<table rules="all">
<tr>
<td>Address</td>
-<td>O-o-o status</td>
+<td>Status</td>
<td>Which message?</td>
<td>Expiry date</td>
</tr><tr>
-% while ($row= $sth->fetchrow_hashref()) {
+% while (my $row= $sth->fetchrow_hashref()) {
+<tr>
<td><% $row->{'emailaddr'} |h %></td>
% if (defined $row->{'textid'}) {
-% my $expiry = expires2timet($row->{'expires'});
-% if ($expiry > time) {
+% my $expires = expires2timet($row->{'expires'});
+% if (defined($expires) && $expires < time) {
+<td>expired</td>
+% } else {
<td>active</td>
-<td><% $row->{'textid'} |h %></td>
-<td><% $row->{'expires'} |h %></td>
-<td>
+% }
+<td><% $row->{'desc'} |h %></td>
+<td><% expirestime2show($expires) |h %></td>
+% } else {
+<td>inactive</td>
+<td></td>
+<td></td>
+% }
+</tr>
+% }
+</table>
+
+<h2>Outbound messages</h2>
+<%perl>
+$sth = $dbh->prepare("SELECT * FROM texts ORDER BY desc");
+$sthi = $dbh->prepare(<<END);
+ SELECT * FROM addresses
+ WHERE textid = ?
+ ORDER BY emailaddr
+END
+$sth->execute();
+</%perl>
+% while (my $row= $sth->fetchrow_hashref()) {
+<h3>Message "<% $row->{'desc'} |h %>"</h3>
+<table>
+<tr><td>Short name:</td><td><% $row->{'desc'} |h %></td></tr>
+<tr><td>Expires:</td><td><%
+ expirestime2show(expires2timet($row->{'expires'}))
+ |h %></td></tr>
+<tr><td>Subject:</td>
+ <td><code><% $row->{'subject'} |h %></code></td></tr>
+</table>
+<p>
+<pre>
+<% $row->{'text'} |h %>
+</pre>
+% }