{{$pagePath := webPath "/manage/updateannouncements" -}}
{{$editing := (gt $.announcement.ID 0)}}
<table class="mgmt-table" id="announcements">
	<tr>
		<th style="width: 7%;">Actions</th>
		<th style="width: 18%;">Subject</th>
		<th style="width: 50%;">Message</th>
		<th style="width: 12.5%;">Staff</th>
		<th style="width: 12.5%;">Timestamp</th>
	</tr>
{{range $a, $announcement := $.announcements -}}<tr>
	<td>
		<a href="{{webPath $pagePath}}?edit={{$announcement.ID}}">Edit</a>
		<a href="{{webPath $pagePath}}?delete={{$announcement.ID}}"
			onclick="return confirm('Are you sure you want to delete this announcement?')">Delete</a>
	</td>
	<td>{{$announcement.Subject}}</td>
	<td>{{$announcement.Message}}</td>
	<td>{{$announcement.Staff}}</td>
	<td>{{formatTimestamp $announcement.Timestamp}}</td>
</tr>{{else}}<i>No announcements</i>{{end}}
</table>
<hr/>
<header><h1>{{if $editing}}Edit announcement{{else}}Create new announcement{{end}}</h1></header>
<form method="POST" action="{{$pagePath}}">
	{{if $editing}}<input type="hidden" name="edit" value="{{$.announcement.ID}}" />{{end}}
	<table id="postbox-static">
		<tr>
			<th class="postblock">Subject</th>
			<td>
				<input type="text" name="subject" size="25" maxlength="100" value="{{$.announcement.Subject}}"/>
				<input type="submit" name="{{if $editing}}doedit{{else}}newannouncement{{end}}" value="Submit"/>
			</td>
		</tr>
		<tr>
			<th class="postblock">Message</th>
			<td><textarea rows="5" cols="35" name="message" required>{{$.announcement.Message}}</textarea></td>
		</tr>
	</table>
</form>
