%# The average woman would rather have beauty than brains, because the
%# average man can see better than he can think.
% $m->comp(ModifyEvents => %ARGS) unless $ReadOnly;

<form action="/Foundry/Project/Admin/Upload/" method="post">
<input type="hidden" name="Queue" value="<% $QueueObj->Id %>">
<input type="hidden" name="View" value="<% $ARGS{View} || 'Events' %>">
% if ($Parent) {
<input type="hidden" name="Release" value="<% $Parent->Id %>">
% }
<table border="2" width="100%">
<thead><tr>
<th><&|/l&>Event</&></th>
<th><&|/l&>Owner</&></th>
<th><&|/l&>Start</&></th>
<th><&|/l&>Due</&></th>
% if ($AllEvents) {
<th><&|/l&>Milestone</&></th>
% }
<th>&nbsp;</th>
</tr></thead>
<tbody>
% while (my $item = $Events->Next) {
<tr height="20">
<td><% eval { $item->Subject } %></td>
<td><% eval { $item->OwnerObj->Name } %></td>
<td><% eval { $item->CustomFieldValue('EventStarts') } %></td>
<td><% eval { $item->CustomFieldValue('EventDue') } %></td>
% if ($AllEvents) {
<td><% eval { 
    my $release = RT::Ticket->new($session{CurrentUser});
    $release->Load($item->__Value('Resolution'));
    $release->Subject;
} %></td>
% }
<td><& /Edit/Elements/Button, Name => "DeleteItem-".$item->Id, Image => "funcDelete", Text => "Delete" &></td>
</tr>
% }
</table>

<%INIT>
my $ReadOnly = ($AllEvents or !$Parent);
$m->comp('ProcessEvents' => %ARGS) if $Parent;
my $Events = $QueueObj->FunctionItems('Events');
$Events->Limit( FIELD => 'Resolution', VALUE => $Parent->Id ) if !$AllEvents and $Parent;

# XXX - order by parent's version sortorder instead?
# $Events->OrderBy( FIELD => 'Subject', ORDER => 'ASC' );
$Events->OrderByCols(
    { FIELD => 'Resolution', ORDER => 'DESC' },
    { FIELD => 'Id', ORDER => 'DESC' },
);
</%INIT>
<%ARGS>
$AllEvents => 0
$Parent => undef
$QueueObj
$ARGS
</%ARGS>
