<& /Admin/Elements/Header, Title => loc("Admin Lifecycles") &>
<& /Elements/Tabs &>

<h1><&|/l&>Lifecycles</&></h1>

<table cellspacing="0" class="collection collection-as-table">
<tr class="collection-as-table">
  <th class="collection-as-table"><&|/l&>Name</&></th>
  <th class="collection-as-table"><&|/l&>Type</&></th>
  <th class="collection-as-table"><&|/l&>Display</&></th>
</tr>
% my $i = 0;
% for my $lifecycle (@lifecycles) {
% ++$i;
<tr class="<% $i % 2 ? 'oddline' : 'evenline' %>">
<td class="collection-as-table"><a href="<% RT->Config->Get('WebURL') %>Admin/Lifecycles/Modify.html?Type=<% $lifecycle->Type |u %>&Name=<% $lifecycle->Name |u %>"><% $lifecycle->Name %></a></td>
<td class="collection-as-table"><% loc($lifecycle->Type) %></td>
% my $display = $lifecycle->Type eq 'ticket' ? ($lifecycle->{data}{ticket_display} || 'hidden') : '';
<td class="collection-as-table"><% loc($display) %></td>
</tr>
% }
</table>
<%INIT>
my @types = List::MoreUtils::uniq(
    'ticket',
    'asset',
    sort keys %RT::Lifecycle::LIFECYCLES_TYPES,
);

my @lifecycles;

for my $type (@types) {
    push @lifecycles, map { RT::Lifecycle->Load(Name => $_, Type => $type) }
                      sort { loc($a) cmp loc($b) }
                      grep { $_ ne 'approvals' }
                      RT::Lifecycle->ListAll($type);
}
</%INIT>
