chiark / gitweb /
run-mason.cgi: seems to work
[nj-awaymsg.git] / mason / main
index b70a3de9e395e86c22e5ea54411cff70dbedd72a..a9bc72e20621da1a183218ecba490259ef544095 100755 (executable)
@@ -1,19 +1,17 @@
 <%init>
 use AwayMsg;
 db_connect();
+www_begin($r,$m);
 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>
+<&htmlhead, subpage => 'Overview' &>
 
 <h2>Email addresses and their configuration</h2>
 <%perl>
 $sth = $dbh->prepare(<<END);
     SELECT *
-     FROM        addresses
-       LEFT JOIN config    USING (emailaddr)
+     FROM        config
+       LEFT JOIN addresses USING (emailaddr)
        LEFT JOIN texts     USING (textid)
      ORDER BY emailaddr
 END
@@ -24,32 +22,25 @@ $sth->execute();
 <td>Address</td>
 <td>Status</td>
 <td>Which message?</td>
-<td>Expiry date</td>
 </tr><tr>
 % while (my $row= $sth->fetchrow_hashref()) {
 <tr>
 <td><% $row->{'emailaddr'} |h %></td>
 %     if (defined $row->{'textid'}) {
-%         my $expires = expires2timet($row->{'expires'});
-%        if (defined($expires) && $expires < time) {
-<td>expired</td>
-%         } else {
 <td>active</td>
-%         }
 <td><% $row->{'desc'} |h %></td>
-<td><% expirestime2show($expires) |h %></td>
 %     } else {
 <td>inactive</td>
 <td></td>
-<td></td>
 %     }
 </tr>
 % }
 </table>
 
+<hr>
 <h2>Outbound messages</h2>
 <%perl>
-$sth = $dbh->prepare("SELECT * FROM texts ORDER BY desc");
+$sth = $dbh->prepare("SELECT * FROM texts ORDER BY textid");
 $sthi = $dbh->prepare(<<END);
     SELECT * FROM addresses
      WHERE textid = ?
@@ -61,18 +52,24 @@ $sth->execute();
 <form action="edit" method="get">
 <h3>Message "<% $row->{'desc'} |h %>"</h3>
 
-<& txtable, tx => $row &>
-%#    $sthi->execute($row->{'textid'});
-% #   while (my $rowi= $sthi->fetchrow_hashref()) {
-%#<tr><td>Used for:</td><td><% $rowi->{'emailaddr'} |h %></td></tr>
-%#    }
-%#</&>
+<&| txtable, tx => $row &>
+%    $sthi->execute($row->{'textid'});
+%    my $anyused = 0;
+%    while (my $rowi= $sthi->fetchrow_hashref()) {
+<tr><td>Used for:</td><td><% $rowi->{'emailaddr'} |h %></td></tr>
+%        $anyused++;
+%    }
+%    if ($anyused) {
+<tr><td colspan=2>Not currently in use</td></tr>
+%    }
+</&>
 <pre>
 <% $row->{'text'} |h %>
 </pre>
 
-<input type="submit" name="t<% $row->{'textid'} %>"
+<input type="submit" name="t_<% $row->{'textid'} %>"
    value="Edit or configure this message">
+<hr>
 % }
 <h3>Add new message</h3>
 <input type="submit" name="create"