1 <& /Elements/Header, Title =>loc('Tickets by Day Of Week in Queue:' . $QueueObj->Name()) &>
2 <& /RTx/Statistics/Elements/Tabs, Title =>loc('Trends in ticket status by Day Of Week in Queue:' . $QueueObj->Name()) &>
5 <p>The purpose of this page is to show historical trends for each day of the week.
6 It displays details of number of tickets created in your
7 selected queue for each day. It also hows how many of those created tickets were Resolved or Deleted</p>
9 <form method="POST" action="index.html">
12 %my $title = "Ticket counts by day of week in " . $QueueObj->Name();
13 <&|/Elements/TitleBox,
15 title_href => $RT::WebPath."/RTx/Statistics/DayOfWeek/index.html?$QueryString" &>
16 <TABLE BORDER=0 cellspacing=0 cellpadding=1 WIDTH=100%>
18 <& /RTx/Statistics/Elements/CollectionAsTable/Header,
20 FormatString => $Format,
21 AllowSorting => $AllowSorting,
28 maxitems => $maxitems &>
31 % for my $d (0..$#days) {
33 % $values{Statistics_Date} = $days[$d];
34 %# NOTE Show all status values???
35 % $values{Statistics_Created_Count} = $counts[$d]{new};
36 % $values{Statistics_Resolved_Count} = $counts[$d]{resolved};
37 % $values{Statistics_Deleted_Count} = $counts[$d]{deleted};
38 <& /RTx/Statistics/Elements/CollectionAsTable/Row, Format => \@Format, i => $line, record => $record, maxitems => $maxitems &>
41 % $values {Statistics_Date} = "Totals";
42 % $values {Statistics_Created_Count} = $Totals{new};
43 % $values {Statistics_Resolved_Count} = $Totals{resolved};
44 % $values {Statistics_Deleted_Count} = $Totals{deleted};
45 <& /RTx/Statistics/Elements/CollectionAsTable/Row, Format => \@BoldFormat, i => $line, record => $record, maxitems => $maxitems &>
50 my $url = 'Elements/Chart?&x_labels=';
52 $url .= $days[$_] . "," ;
57 my @things = qw(new resolved deleted);
58 for my $th (0..$#things) {
59 $url .= "data".(1+$th)."=".(join ",", map { $counts[$_]{$things[$th]} } (0..6))."&";
62 $url .= '&set_legend=Created,Resolved,Deleted';
65 <& /RTx/Statistics/Elements/GraphBox, GraphURL => $url &>
67 % Statistics::DebugLog("queue name=" . $QueueObj->Id() . "\n");
69 <& /RTx/Statistics/Elements/ControlsAsTable/ControlBox,
70 Title => "Change Queue",
71 ShowSingleQueue => 1, Queue => $QueueObj->Id()
76 % Statistics::DebugInit( $m );
79 $Queue => $Statistics::DayOfWeekQueue
81 $AllowSorting => undef
94 my @days = qw(Sun Mon Tue Wed Thu Fri Sat);
104 my $QueryString = "Queue=$Queue";
108 my $record = \%record;
110 $record{values} = \%values;
112 my $Format = qq{ Statistics_Date,
113 '__Statistics_Created_Count__/STYLE:text-align:right;',
114 '__Statistics_Resolved_Count__/STYLE:text-align:right;',
115 '__Statistics_Deleted_Count__/STYLE:text-align:right;' };
116 my $BoldFormat = qq{ '<B>__Statistics_Date__</B>',
117 '<B>__Statistics_Created_Count__</B>/STYLE:text-align:right;',
118 '<B>__Statistics_Resolved_Count__</B>/STYLE:text-align:right;',
119 '<B>__Statistics_Deleted_Count__</B>/STYLE:text-align:right;' };
120 my (@Format) = $m->comp('/RTx/Statistics/Elements/CollectionAsTable/ParseFormat', Format => $Format);
121 my (@BoldFormat) = $m->comp('/RTx/Statistics/Elements/CollectionAsTable/ParseFormat', Format => $BoldFormat);
123 my $QueueObj = new RT::Queue($session{'CurrentUser'});
124 $QueueObj->Load($Queue);
125 $RT::Logger->warning("Loaded queue $Queue, name=". $QueueObj->Name());
127 my $tix = new RT::Tickets($session{'CurrentUser'});
128 $tix->LimitQueue (VALUE => $Queue);
131 # Initialize the counters to zero, so that all the cells show up
132 foreach my $day (0..@days) {
133 $counts[$day]{resolved} = 0;
134 $counts[$day]{deleted} = 0;
135 $counts[$day]{new} = 0;
137 while (my $t = $tix->RT::SearchBuilder::Next) { # BLOODY HACK
138 if($t->Status eq "resolved") {
139 $counts[(localtime($t->ResolvedObj->Unix))[6]]{resolved}++;
142 if($t->Status eq "deleted") {
143 $counts[(localtime($t->LastUpdatedObj->Unix))[6]]{deleted}++;
146 $counts[(localtime($t->CreatedObj->Unix))[6]]{new}++;