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 => "/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 &>
55 my $url = 'Elements/Chart?&x_labels=';
57 $url .= $days[$_] . "," ;
62 my @things = qw(new resolved deleted);
63 for my $th (0..$#things) {
64 $url .= "data".(1+$th)."=".(join ",", map { $counts[$_]{$things[$th]} } (0..6))."&";
67 $url .= '&set_legend=Created,Resolved,Deleted';
70 <& /RTx/Statistics/Elements/GraphBox, GraphURL => $url &>
72 % Statistics::DebugLog("queue name=" . $QueueObj->Id() . "\n");
74 <& /RTx/Statistics/Elements/ControlsAsTable/ControlBox,
75 Title => "Change Queue",
76 ShowSingleQueue => 1, Queue => $QueueObj->Id()
81 % Statistics::DebugInit( $m );
84 $Queue => $Statistics::DayOfWeekQueue
86 $AllowSorting => undef
99 my @days = qw(Sun Mon Tue Wed Thu Fri Sat);
109 my $QueryString = "Queue=$Queue";
113 my $record = \%record;
115 $record{values} = \%values;
117 my $Format = qq{ Statistics_Date,
118 '__Statistics_Created_Count__/STYLE:text-align:right;',
119 '__Statistics_Resolved_Count__/STYLE:text-align:right;',
120 '__Statistics_Deleted_Count__/STYLE:text-align:right;' };
121 my $BoldFormat = qq{ '<B>__Statistics_Date__</B>',
122 '<B>__Statistics_Created_Count__</B>/STYLE:text-align:right;',
123 '<B>__Statistics_Resolved_Count__</B>/STYLE:text-align:right;',
124 '<B>__Statistics_Deleted_Count__</B>/STYLE:text-align:right;' };
125 my (@Format) = $m->comp('/RTx/Statistics/Elements/CollectionAsTable/ParseFormat', Format => $Format);
126 my (@BoldFormat) = $m->comp('/RTx/Statistics/Elements/CollectionAsTable/ParseFormat', Format => $BoldFormat);
128 my $QueueObj = new RT::Queue($session{'CurrentUser'});
129 $QueueObj->Load($Queue);
130 $RT::Logger->warning("Loaded queue $Queue, name=". $QueueObj->Name());
132 my $tix = new RT::Tickets($session{'CurrentUser'});
133 $tix->LimitQueue (VALUE => $Queue);
136 # Initialize the counters to zero, so that all the cells show up
137 foreach my $day (0..@days) {
138 $counts[$day]{resolved} = 0;
139 $counts[$day]{deleted} = 0;
140 $counts[$day]{new} = 0;
142 while (my $t = $tix->RT::SearchBuilder::Next) { # BLOODY HACK
143 if($t->Status eq "resolved") {
144 $counts[(localtime($t->ResolvedObj->Unix))[6]]{resolved}++;
147 if($t->Status eq "deleted") {
148 $counts[(localtime($t->LastUpdatedObj->Unix))[6]]{deleted}++;
151 $counts[(localtime($t->CreatedObj->Unix))[6]]{new}++;