<& /Minimal/Elements/Header, 
    Title =>loc('Update ticket #[_1]', $Ticket->id) 
&>

% my $default_portlist = $Ticket->FirstCustomFieldValue('Service Portlist');
% my $default_protocol = $Ticket->FirstCustomFieldValue('Service Protocol');

<form action="Display.html" method="post" enctype="multipart/form-data">
<input type="hidden" class="hidden" name="UpdateType" value="response" />
<input type="hidden" class="hidden" name="id" value="<%$Ticket->Id%>" />
<table>
    <tr>
        <td class="label">
            <&|/l&>Status</&>
        </td>
        <td class="value">
            <%$Ticket->Status()%>
        </td>
    </tr>
    <tr>
        <td class="label">
            <&|/l&>Subject</&>
        </td>
        <td class="value">
            <% $Ticket->Subject %>
        </td>

    </tr>
% if($Ticket->CurrentUserHasRight('ModifyTicket')){
    <tr>
        <td class="label">Service Portlist</td>
        <td>
            <& /RTIR/Elements/EditRTIRField,
                TicketObj   => $Ticket,
                Name => 'Service Portlist', 
                Default => $default_portlist &>
        </td>
        <td><i>of the form: 21,22,80-89<br>if multiple addresses exist, entire portlist will be tagged with each address</i></td>
    </tr>
    <tr>
        <td class="label">Service Protocol</td>
        <td>
                 <& /RTIR/Elements/EditRTIRField,
                TicketObj   => $Ticket,
                Name => 'Service Protocol',       
                Default => $default_protocol &>
        </td>
        <td><i>ICMP - 1, TCP - 6, UDP - 17<br>if multiple protocols exist, leave blank to denote "all-ip"</i></td>
    </tr>
% }
% if (exists $session{'Attachments'}) {
<tr>
    <td class="label">
    <&|/l&>Attached file</&>
    </td>
    <td colspan="5" class="value">
    <&|/l&>Check box to delete</&><br />
% foreach my $attach_name (keys %{$session{'Attachments'}}) {
    <input type="checkbox" class="checkbox" name="DeleteAttach-<%$attach_name%>" value="1" /><%$attach_name%><br />
% } # end of foreach
    </td>
</tr>
% } # end of if
<tr>
    <td class="label">
        <&|/l&>Attach</&>
    </td>
    <td class="value">
            <input name="Attach" type="file" />
            <input type="hidden" class="hidden" name="UpdateAttach" value="1" />
    </td>
  </tr>
</table>
% unless ($Action eq 'Comment' || $Action eq 'Respond') {
%#<& /Ticket/Elements/EditCustomFields,  TicketObj => $Ticket &>
%} 
<& /Elements/MessageBox, 
    Name => "UpdateContent", 
    QuoteTransaction => $ARGS{QuoteTransaction} 
    &>
    <br />

<& /Elements/Submit &>
  </form>



<%INIT>
my ( $field, @results );

# {{{ Load the ticket
#If we get handed two ids, mason will make them an array. bleck.
# We want teh first one. Just because there's no other sensible way
# to deal
my @id = ( ref $id eq 'ARRAY' ) ? @{$id} : ($id);

my $Ticket = new RT::Ticket( $session{'CurrentUser'} );

unless ( $Ticket->Load( $id[0] ) ) {
    $m->comp( 'Error.html', Why => loc( "Couldn't load ticket '[_1]'", $id ) );
    $m->abort();
}
#my $Ticket = LoadTicket($id);
my $title = loc( "Update ticket #[_1]", $Ticket->id );
$DefaultStatus = $ARGS{Status} || $Ticket->Status() unless ($DefaultStatus);
my $queue = 'Incident Reports';
my $queueObj = RT::Queue->new($session{'CurrentUser'});
$queueObj->Load($queue);

Abort( loc("No permission to update ticket") )
  unless ( $Ticket->CurrentUserHasRight('ReplyToTicket') );

my $category = $Ticket->FirstCustomFieldValue('Address category');

</%INIT>

<%ARGS>
$id => undef
$Action => undef
$DefaultStatus => undef
</%ARGS>
