chiark / gitweb /
wip
[nj-awaymsg.git] / mason / main
index 8a2533f3dec18ece1ce9ec8efc8139ad5f29bf60..ec7c6536abc0158f524c84bcae49484c4778b5fd 100755 (executable)
@@ -1,5 +1,6 @@
 <%init>
 use AwayMsg;
+db_connect();
 </%init>
 <html lang="en"><head>
 <title>Email "out of office" setup</title>
@@ -10,11 +11,13 @@ use AwayMsg;
 
 <%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");
+my $sth = $dbh->prepare(<<END);
+    SELECT emailaddr, textid, expires
+     FROM        config
+       LEFT JOIN addresses USING (emailaddr)
+       LEFT JOIN texts     USING (textid)
+     ORDER BY emailaddr
+END
 </%perl>
 
 <table>
@@ -24,12 +27,23 @@ my $sth = $dbh->prepare("SELECT emailaddr, textid, expires"
 <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) {
 <td>active</td>
+%         } else {
+<td>expired</td>
+%         }
 <td><% $row->{'textid'} |h %></td>
 <td><% $row->{'expires'} |h %></td>
-<td>
+%     } else {
+<td>inactive</td>
+<td></td>
+<td></td>
+%     }
+</tr>
+% }
+</table>