<& /Admin/Elements/Header, Title => 'Admin/Queue/Basics' &>
<& /Admin/Elements/QueueTabs, id => $QueueObj->id &>
<& /Elements/ListActions, actions => \@results &>



<& /Elements/TitleBoxStart, title => $title &>


<FORM ACTION="<%$RT::WebPath%>/Admin/Queues/Modify.html" METHOD=POST>
%if ($Create ) {
<INPUT TYPE=HIDDEN NAME=id VALUE="new">
% } else {
<INPUT TYPE=HIDDEN NAME=id VALUE="<%$QueueObj->Id%>">
% }

<TABLE>
<TR><TD ALIGN=RIGHT>
Queue Name: 
</TD>
<TD><INPUT name="Name" value="<%$QueueObj->Name%>"></TD>
</TR><TR>
<TD ALIGN=RIGHT>
Description:</TD><TD COLSPAN=3><INPUT name="Description" value="<%$QueueObj->Description%>" size=60></TD></TR>
<TR>
<TD ALIGN=RIGHT>
Correspondence Address:
</TD><TD>
<INPUT name="CorrespondAddress" value="<%$QueueObj->CorrespondAddress%>">
<BR><font size="-1"><i>(If left blank, will default to <%$RT::CorrespondAddress%></i></font>
</TD>
<TD ALIGN=RIGHT>

Comment Address: </TD><TD>
<INPUT NAME="CommentAddress" value="<%$QueueObj->CommentAddress%>">
<BR><font size="-1"><i>(If left blank, will default to <%$RT::CommentAddress%></i></font>
</TD>
</TR><TR>

<TD ALIGN=RIGHT>
Priority starts at: 
</TD><TD><INPUT NAME="InitialPriority" value="<%$QueueObj->InitialPriority %>">
</TD>
<TD ALIGN=RIGHT>
Over time, priority moves toward:
</TD><TD><INPUT NAME="FinalPriority" value="<%$QueueObj->FinalPriority %>">
</TD>
</TR>
<TR>
<TD ALIGN=RIGHT>
Requests should be due in:
</TD><TD>
<INPUT NAME="DefaultDueIn" VALUE="<%$QueueObj->DefaultDueIn%>"> days.
</TD>
</TR>
<TR>
<TD>
</TD>
<TD COLSPAN=4><INPUT TYPE=HIDDEN NAME="SetEnabled" VALUE="1">
<INPUT TYPE=CHECKBOX NAME="Enabled" VALUE="1" <%$EnabledChecked%>> Enabled (Unchecking this box disables this queue)<BR>
</TD>
</TR>

</TABLE>
<& /Elements/TitleBoxEnd &>
<& /Elements/Submit &>
</form>



<%INIT>

my $QueueObj = new RT::Queue($session{'CurrentUser'});
my  ($title, @results, $Disabled, $EnabledChecked);

if ($Create) {
    $title = "Create a queue";
}

else {
    if ($id eq 'new') {
       my ($val, $msg) =  $QueueObj->Create(Name => $Name);
       if ($val == 0 ) {
           Abort("Could not create queue: $msg");
	}
	else {
		push @results, $msg;
	}    
     }
     else {
        $QueueObj->Load($id) || $QueueObj->Load($Name) || Abort("Couldn't load queue '$Name'");
    }
        $title = 'Editing Configuration for queue '.$QueueObj->Name;
    
}
if ($QueueObj->Id()) {
my @attribs= qw(Description CorrespondAddress CommentAddress Name 
                InitialPriority FinalPriority DefaultDueIn);

  @results = UpdateRecordObject( AttributesRef => \@attribs, 
				    Object => $QueueObj, 
				    ARGSRef => \%ARGS);

}

#we're asking about enabled on the web page but really care about disabled.
if ($Enabled == 1) {
    $Disabled = 0;
}	
else {
    $Disabled = 1;
}
if  ( ($SetEnabled) and ( $Disabled != $QueueObj->Disabled) ) { 
    my  ($code, $msg) = $QueueObj->SetDisabled($Disabled);
    push @results, 'Enabled status '. $msg;
}

unless ($QueueObj->Disabled()) {
    $EnabledChecked ="CHECKED";
}
</%INIT>


<%ARGS>
$id => undef
$result => undef
$Name => undef
$Create => undef
$Description => undef
$CorrespondAddress => undef
$CommentAddress => undef
$InitialPriority => undef
$FinalPriority => undef
$DefaultDueIn => undef
$SetEnabled => undef
$Enabled => undef
</%ARGS>
