chiark / gitweb /
wip
[nj-awaymsg.git] / mason / main
index ec7c6536abc0158f524c84bcae49484c4778b5fd..42cfaac56e48329390f41856deb226eb73c93593 100755 (executable)
@@ -1,49 +1,74 @@
 <%init>
 use AwayMsg;
 db_connect();
+my ($sth,$row,$sthi,$rowi);
 </%init>
 <html lang="en"><head>
-<title>Email "out of office" setup</title>
+<title>Email away message setup</title>
 </head><body>
-<h1>Email "out of office" setup</h1>
-<h2>Our email addresses</h2>
-
+<h1>Email away message setup</h1>
 
+<h2>Email addresses and their configuration</h2>
 <%perl>
-my %row;
-my $sth = $dbh->prepare(<<END);
-    SELECT emailaddr, textid, expires
+$sth = $dbh->prepare(<<END);
+    SELECT *
      FROM        config
        LEFT JOIN addresses 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 (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><% $row->{'desc'} |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");
+$sthi = $dbh->prepare(<<END);
+    SELECT * FROM addresses
+     WHERE textid = ?
+     ORDER BY emailaddr
+END
+$sth->execute();
+</%perl>
+% while (my $row= $sth->fetchrow_hashref()) {
+<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>
+%    }
+</&>
+<pre>
+<% $row->{'text'} |h %>
+</pre>
+
+<input type="submit" name="t<% $row->{'textid'} %>"
+   value="Edit or configure this message">
+<hr>
+% }
+<h3>Add new message</h3>
+<input type="submit" name="create"
+   value="Start adding new message">
+</form>