chiark / gitweb /
run-mason.cgi: seems to work
[nj-awaymsg.git] / mason / main
index e0d35c9a46f859d62305fa91662c7ce2a3d41a3d..a9bc72e20621da1a183218ecba490259ef544095 100755 (executable)
@@ -1,6 +1,7 @@
 <%init>
 use AwayMsg;
 db_connect();
+www_begin($r,$m);
 my ($sth,$row,$sthi,$rowi);
 </%init>
 <&htmlhead, subpage => 'Overview' &>
@@ -39,7 +40,7 @@ $sth->execute();
 <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 = ?
@@ -53,15 +54,20 @@ $sth->execute();
 
 <&| 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>
 % }