%# One nice thing about egotists: they don't talk about other people. <& /Edit/Elements/104Header, Focus => 'NewCategory', Buttons => [ Add => "index.html?Action-Add=1", Save => "javascript:document.getElementById('mainform').submit()", Delete => 1, Copy => '', Search => '', Lot => '', Count => '', Check => '', Import => '', Export => '', TransIn => '', TransOut => '', Info => '', Report => '', Help => '1', ], Top =>'/RG/Elements/Top', Tab => '/RG/Elements/SetupTab', BGColor => '#ADD6D6', Method => 'POST', &>

<& /RG/Elements/Tab, Text => 'Categories' &>
<& Top, Item => $Category &>
<& List, Delete => 1, Item => $Category, List => $List, Categories => \%Categories, Begin => $Begin, ARGS => \%ARGS &>

<%INIT> my $Reports = RTx::Reports->new($session{'CurrentUser'}); $Reports->UnLimit; my %Categories = map { $_ => 0 } @{ $Reports->Categories }; if ($Action eq 'Delete') { delete $Categories{$_} for @ListDelete; $Category = $NewCategory = ''; $Begin = 0; } while (my $report = $Reports->Next) { my $descr = $report->Category; if ($Action eq 'Save' and length($NewCategory) and $descr eq $Category) { $report->SetCategory($NewCategory); $descr = $NewCategory; } $Categories{$descr}++ if length $descr; } if ($Action eq 'Add') { $Category = ''; $Begin = 0; } if (length $NewCategory) { delete $Categories{$Category} if length($Category); $Categories{$Category = $NewCategory} = 0; } my $List = [ sort keys %Categories ]; $Reports->SetCategories( $List ); <%ARGS> $Category => '' $NewCategory => '' $Begin => 0 $Action => '' @ListDelete => ()