<%init>
use AwayMsg;
db_connect();
+www_begin($r,$m);
</%init>
<%args>
die unless defined $textid;
}
-my $sth = $dbh->prepare("SELECT * FROM texts WHERE textid=?");
-$sth->execute($textid);
-my $tx = $sth->fetchrow_hashref();#
+my $tx;
+
+if ($ARGS{'create'}) {
+ my $date = `date --iso-8601=minutes`; chomp $date or die;
+ $tx = { desc => "Message created $date",
+ subject => "Away from my email",
+ textid => "new",
+ text => "" };
+} else {
+ my $sth = $dbh->prepare("SELECT * FROM texts WHERE textid=?");
+ $sth->execute($textid);
+ $tx = $sth->fetchrow_hashref();#
+}
+
+my $usedq = $dbh->prepare("SELECT * FROM addresses ORDER BY emailaddr");
+$usedq->execute();
if (!$tx) { die "no such text $textid"; }
</%perl>
-<html lang="en"><head>
-<title>Editing - <% $tx->{'desc'} |h %> - Email away message setup</title>
-</head><body>
-<h1>Edit "<% $tx->{'desc'} |h %>"</h1>
+<& htmlhead, subpage => "Edit \"$tx->{'desc'}\"" &>
<form action="save" method="post">
<&| txtable, tx => $tx, inputs => 1 &>
-<tr><td colspan=2><textarea cols=79 rows=15><%
+<tr><td colspan=2><textarea name="text" cols="79" rows="15"><%
$tx->{'text'} |h %></textarea></td></tr>
</&>
-
-<input type="submit" name="t<% $tx->{'textid'} %>" value="Save">
+</table><br><table>
+% while (my $row = $usedq->fetchrow_hashref()) {
+<tr><td>Use for <% $row->{'emailaddr'} |h %></td>
+<td><input type="checkbox"
+% if ($usedq->
+></td></tr>
+% }
+<p>
+<input type="hidden" name="textid" value="<% $tx->{'textid'} %>">
+<input type="submit" name="save" value="Save">
+<input type="submit" name="cancel" value="Cancel edit">