<& /Elements/Header, Title =>loc('Tickets by Day Of Week in Queue:' . $QueueObj->Name()) &> <& /RTx/Statistics/Elements/Tabs, Title =>loc('Trends in ticket status by Day Of Week in Queue:' . $QueueObj->Name()) &>

### Description

The purpose of this page is to show historical trends for each day of the week. It displays details of number of tickets created in your selected queue for each day. It also hows how many of those created tickets were Resolved or Deleted

%my $title = "Ticket counts by day of week in " . $QueueObj->Name(); <&|/Elements/TitleBox, title => $title, title_href => "/RTx/Statistics/DayOfWeek/index.html?$QueryString" &>

% if ($ShowHeader) { <& /RTx/Statistics/Elements/CollectionAsTable/Header, Format => \@Format, FormatString => $Format, AllowSorting => $AllowSorting, Order => $Order, Query => undef, Rows => $Rows, Page => $Page, OrderBy => $OrderBy , BaseURL => $BaseURL, maxitems => $maxitems &> % } % my $line = 1; % for my $d (0..$#days) { % my $x = 1; % $values{Statistics_Date} = $days[$d]; %# NOTE Show all status values??? % $values{Statistics_Created_Count} = $counts[$d]{new}; % $values{Statistics_Resolved_Count} = $counts[$d]{resolved}; % $values{Statistics_Deleted_Count} = $counts[$d]{deleted}; <& /RTx/Statistics/Elements/CollectionAsTable/Row, Format => \@Format, i => $line, record => $record, maxitems => $maxitems &> % $line++; % } % $values {Statistics_Date} = "Totals"; % $values {Statistics_Created_Count} = $Totals{new}; % $values {Statistics_Resolved_Count} = $Totals{resolved}; % $values {Statistics_Deleted_Count} = $Totals{deleted}; <& /RTx/Statistics/Elements/CollectionAsTable/Row, Format => \@BoldFormat, i => $line, record => $record, maxitems => $maxitems &>

<%perl> my $url = 'Elements/Chart?&x_labels='; for (0..$#days) { $url .= $days[$_] . "," ; } chop $url; $url .= "&"; my @things = qw(new resolved deleted); for my $th (0..$#things) { $url .= "data".(1+$th)."=".(join ",", map { $counts[$_]{$things[$th]} } (0..6))."&"; } chop $url; $url .= '&set_legend=Created,Resolved,Deleted'; <& /RTx/Statistics/Elements/GraphBox, GraphURL => $url &> % Statistics::DebugLog("queue name=" . $QueueObj->Id() . "\n"); <& /RTx/Statistics/Elements/ControlsAsTable/ControlBox, Title => "Change Queue", ShowSingleQueue => 1, Queue => $QueueObj->Id() &> % Statistics::DebugInit( $m ); <%ARGS> $Queue => $Statistics::DayOfWeekQueue $AllowSorting => undef $Order => undef $OrderBy => undef $ShowNavigation => 1 $ShowHeader => 1 $Rows => 50 $Page => 1 $BaseURL => undef <%INIT> use GD::Graph; use RTx::Statistics; my @days = qw(Sun Mon Tue Wed Thu Fri Sat); my $n = 0; my @data = ([]); my @msgs; my @counts; my %Totals = ( resolved => 0, deleted => 0, new => 0 ); my $QueryString = "Queue=$Queue"; my $maxitems = 4; my %record; my %values; my $record = \%record; $record{values} = \%values; my $Format = qq{ Statistics_Date, '__Statistics_Created_Count__/STYLE:text-align:right;', '__Statistics_Resolved_Count__/STYLE:text-align:right;', '__Statistics_Deleted_Count__/STYLE:text-align:right;' }; my $BoldFormat = qq{ '__Statistics_Date__', '__Statistics_Created_Count__/STYLE:text-align:right;', '__Statistics_Resolved_Count__/STYLE:text-align:right;', '__Statistics_Deleted_Count__/STYLE:text-align:right;' }; my (@Format) = $m->comp('/RTx/Statistics/Elements/CollectionAsTable/ParseFormat', Format => $Format); my (@BoldFormat) = $m->comp('/RTx/Statistics/Elements/CollectionAsTable/ParseFormat', Format => $BoldFormat); my $QueueObj = new RT::Queue($session{'CurrentUser'}); $QueueObj->Load($Queue); $RT::Logger->warning("Loaded queue $Queue, name=". $QueueObj->Name()); my $tix = new RT::Tickets($session{'CurrentUser'}); $tix->LimitQueue (VALUE => $Queue); $tix->UnLimit; if ($tix->Count) { # Initialize the counters to zero, so that all the cells show up foreach my $day (0..@days) { $counts[$day]{resolved} = 0; $counts[$day]{deleted} = 0; $counts[$day]{new} = 0; } while (my $t = $tix->RT::SearchBuilder::Next) { # BLOODY HACK if($t->Status eq "resolved") { $counts[(localtime($t->ResolvedObj->Unix))[6]]{resolved}++; $Totals{resolved}++; } if($t->Status eq "deleted") { $counts[(localtime($t->LastUpdatedObj->Unix))[6]]{deleted}++; $Totals{deleted}++; } $counts[(localtime($t->CreatedObj->Unix))[6]]{new}++; $Totals{new}++; } }