chiark / gitweb /
wip
[nj-awaymsg.git] / mason / main
index 5997c3af035faf164ad6dc953b3a72ce68143101..43ef45a058a29088207fe6563fb2064bdf0e0774 100755 (executable)
@@ -1,25 +1,24 @@
 <%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>Email addresses and their configuration</h2>
-
 
+<h2>Email addresses and their configuration</h2>
 <%perl>
-my %row;
-my $sth = $dbh->prepare(<<END);
+$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
+$sth->execute();
 </%perl>
-
 <table rules="all">
 <tr>
 <td>Address</td>
@@ -27,7 +26,6 @@ END
 <td>Which message?</td>
 <td>Expiry date</td>
 </tr><tr>
-% $sth->execute();
 % while (my $row= $sth->fetchrow_hashref()) {
 <tr>
 <td><% $row->{'emailaddr'} |h %></td>
@@ -38,12 +36,8 @@ END
 %         } else {
 <td>active</td>
 %         }
-<td><% $row->{'name'} |h %></td>
-%         if (defined $expires) {
-<td><% $row->{'expires'} |h %></td>
-%         } else {
-<td>never</td>
-%         }
+<td><% $row->{'desc'} |h %></td>
+<td><% expirestime2show($expires) |h %></td>
 %     } else {
 <td>inactive</td>
 <td></td>
@@ -52,3 +46,35 @@ END
 </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()) {
+<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">
+% }
+<h3>Add new message</h3>
+<input type="submit" name="create"
+   value="Start adding new message">
+</form>