1 <& /Elements/Header, Title => loc("Tickets per day in Queue:" . $QueueObj->Name()) &>
2 <& /RTx/Statistics/Elements/Tabs, Title => loc("Tickets by status per day in Queue:" . $QueueObj->Name()) &>
5 <p>This page displays details about tickets in the selected queue over the date range chosen. It shows how many tickets were created on
6 each day in the chosen range, and how many of those were either Resolved or Deleted.</p>
7 <p>To always show the current month to date, bookmark this <a href="<%$RT::WebPath%>/RTx/Statistics/CallsQueueDay/index.html?currentMonth=1">link</a>, or
8 for a spreadsheet, use this <a href="<%$RT::WebPath%>/RTx/Statistics/CallsQueueDay/Results.tsv?currentMonth=1">link</a>.</p>
10 <form method="POST" action="index.html">
12 % Statistics::DebugLog("queue name=" . $QueueObj->Name() . "\n");
14 %my $title = "Ticket counts in " . $QueueObj->Name() . " by status per day from " .
15 % Statistics::FormatDate($Statistics::PerDayDateFormat, $dates[0]) . " through " .
16 % Statistics::FormatDate($Statistics::PerDayDateFormat, $dates[$#dates-1]);
17 <&|/Elements/TitleBox,
19 title_href => "/RTx/Statistics/CallsQueueDay/index.html?$QueryString" &>
20 <TABLE BORDER=0 cellspacing=0 cellpadding=1 WIDTH=100%>
22 <& /RTx/Statistics/Elements/CollectionAsTable/Header,
24 FormatString => $Format,
25 AllowSorting => $AllowSorting,
32 maxitems => $maxitems &>
35 % LINE: for my $d (0..$#dates) {
40 % $values{Statistics_Date} = Statistics::FormatDate($Statistics::PerDayDateFormat, $dates[$d]);
41 %# NOTE need to handle all status values here....
42 % for my $status (qw(created resolved deleted)) {
43 % my $tix = new RT::Tickets($session{'CurrentUser'});
44 % $tix->LimitQueue (VALUE => $Queue);
45 % if ($status eq "created") {
46 % $tix->LimitCreated(VALUE => $dates[$d]->ISO, OPERATOR => ">=");
48 % $tix->LimitCreated(VALUE => $dates[$d+1]->ISO, OPERATOR => "<=");
50 % $values{Statistics_Created_Count} = $tix->Count;
51 % $Totals{Statistics_Created_Count} += $tix->Count;
53 % elsif ($status eq "resolved") {
54 % $tix->LimitStatus(VALUE => $status);
55 % $tix->LimitResolved(VALUE => $dates[$d]->ISO, OPERATOR => ">=");
57 % $tix->LimitResolved(VALUE => $dates[$d+1]->ISO, OPERATOR => "<=");
59 % $values{Statistics_Resolved_Count} = $tix->Count;
60 % $Totals{Statistics_Resolved_Count} += $tix->Count;
62 % elsif ($status eq "deleted") {
63 % $tix->LimitStatus(VALUE => $status);
64 % $tix->LimitLastUpdated(VALUE => $dates[$d]->ISO, OPERATOR => ">=");
66 % $tix->LimitLastUpdated(VALUE => $dates[$d+1]->ISO, OPERATOR => "<=");
68 % $values{Statistics_Deleted_Count} = $tix->Count;
69 % $Totals{Statistics_Deleted_Count} += $tix->Count;
71 % $data[$x++][$d] = $tix->Count;
73 <& /RTx/Statistics/Elements/CollectionAsTable/Row, Format => \@Format, i => $line, record => $record, maxitems => $maxitems &>
76 % $values {Statistics_Date} = "Totals";
77 % $values {Statistics_Created_Count} = $Totals{Statistics_Created_Count};
78 % $values {Statistics_Resolved_Count} = $Totals{Statistics_Resolved_Count};
79 % $values {Statistics_Deleted_Count} = $Totals{Statistics_Deleted_Count};
80 <& /RTx/Statistics/Elements/CollectionAsTable/Row, Format => \@BoldFormat, i => $line, record => $record, maxitems => $maxitems &>
85 # Create the graph URL
86 my $url= 'Elements/Chart?x_labels=';
88 $url .= $data[0][$_] . ",";
94 $url .= "data".(1+$_)."=".(join ",", @{$data[$_]})."&";
97 $url .= "&set_legend=Created,Resolved,Deleted";
100 <& /RTx/Statistics/Elements/GraphBox, GraphURL => $url &>
102 <& /RTx/Statistics/Elements/ControlsAsTable/ControlBox,
103 Title => "Change Queue or Dates",
104 ShowDates => 1, sMonth => \$sMonth, sDay => \$sDay, sYear => \$sYear,
105 eMonth => \$eMonth, eDay => \$eDay, eYear => \$eYear,
106 weekends => $weekends,
107 ShowSingleQueue => 1, Queue => $Queue
112 <a href="<%$RT::WebPath%>/RTx/Statistics/CallsQueueDay/index.html?<% $QueryString %>"><&|/l&>Bookmarkable link</&></a> |
113 <a href="<%$RT::WebPath%>/RTx/Statistics/CallsQueueDay/Results.tsv?<%$QueryString%>"><&|/l&>spreadsheet</&></a>
118 % Statistics::DebugLog("ref of eMonth is " . ref($eMonth) . "\n");
119 % Statistics::DebugInit( $m );
123 $weekends => $Statistics::PerDayWeekends;
133 $AllowSorting => undef
159 my $record = \%record;
161 $record{values} = \%values;
164 # If debugging, set things up and display all the args
165 Statistics::DebugClear();
166 Statistics::DebugLog("CallsQueueDay/index.html ARGS:\n");
167 for my $key (keys %ARGS) {
168 Statistics::DebugLog("ARG{ $key }=" . $ARGS{$key} . "\n");
171 my $Format = qq{ Statistics_Date,
172 '__Statistics_Created_Count__/STYLE:text-align:right;',
173 '__Statistics_Resolved_Count__/STYLE:text-align:right;',
174 '__Statistics_Deleted_Count__/STYLE:text-align:right;' };
175 my $BoldFormat = qq{ '<B>__Statistics_Date__</B>',
176 '<B>__Statistics_Created_Count__</B>/STYLE:text-align:right;',
177 '<B>__Statistics_Resolved_Count__</B>/STYLE:text-align:right;',
178 '<B>__Statistics_Deleted_Count__</B>/STYLE:text-align:right;' };
179 my (@Format) = $m->comp('/RTx/Statistics/Elements/CollectionAsTable/ParseFormat', Format => $Format);
180 my (@BoldFormat) = $m->comp('/RTx/Statistics/Elements/CollectionAsTable/ParseFormat', Format => $BoldFormat);
181 Statistics::DebugLog("CallsQueueDay/index.html Format array=" . join(',', @Format) . "\n");
183 if (!defined $Queue) {
184 my $QueueObj = new RT::Queue($session{'CurrentUser'});
185 $QueueObj->Load($Statistics::PerDayQueue);
186 $Queue = $QueueObj->Id();
189 if ($sDay > $Statistics::monthsMaxDay{$sMonth}) {
190 $sDay = $Statistics::monthsMaxDay{$sMonth};
193 if ($eDay > $Statistics::monthsMaxDay{$eMonth}) {
194 $eDay = $Statistics::monthsMaxDay{$eMonth};
198 $sEpoch = timelocal(0, 0, 0, $sDay, $sMonth, $sYear-1900);
201 Statistics::DebugLog("eMonth = " . $eMonth . "\n");
202 $eEpoch = timelocal(0, 0, 0, $eDay, $eMonth, $eYear-1900);
204 # This case happens when the page is first loaded
205 my @local = localtime(time);
206 ($eDay, $eMonth, $eYear) = ($local[3], $local[4], $local[5]);
208 $eEpoch = timelocal(0, 0, 0, $local[3], $local[4], $local[5], $local[6], $local[7], $local[8]);
209 Statistics::DebugLog("Setting eEpoch=$eEpoch from current time.\n");
212 if (($eEpoch < $sEpoch) || ($sEpoch == 0)) {
213 # We have an end, but not a start, or, overlapping.
215 # if $currentMonth is set, just set the day to 1
217 # set start vars from end, but with day set to 1
218 (undef, undef, undef, $sDay, $sMonth, $sYear) = localtime($eEpoch);
220 $sEpoch = timelocal(0, 0, 0, $sDay, $sMonth, $sYear);
222 # If the user has specified how many days back to go, use that,
223 # If not, set start to configured default period before end
225 $sEpoch = $eEpoch - ($days * $Statistics::secsPerDay);
227 $sEpoch = $eEpoch - ($Statistics::PerDayPeriod * $Statistics::secsPerDay);
229 (undef, undef, undef, $sDay, $sMonth, $sYear) = localtime($sEpoch);
234 # Compute days to chart.
235 # The +1 is because we need to generate one more date. If the user
236 # selected a 10 day range, we need to generate 11 days.
237 $diff = int(($eEpoch - $sEpoch + $Statistics::secsPerDay - 1) / $Statistics::secsPerDay)+1;
238 Statistics::DebugLog("Setting diff=$diff\n");
240 Statistics::DebugLog("sEpoch=$sEpoch, components=" . join(',', localtime($sEpoch)) . "\n");
241 Statistics::DebugLog("eEpoch=$eEpoch, components=" . join(',', localtime($eEpoch)) . "\n");
243 # Set up the string for the current query for bookmarkable link
244 $QueryString = "sDay=$sDay&sMonth=$sMonth&sYear=$sYear&eDay=$eDay&eMonth=$eMonth&eYear=$eYear&weekends=$weekends&Queue=$Queue";
246 # Set up the end date to be midnight(morning) of the date after the one the user wanted.
247 my $endRange = $eEpoch + $Statistics::secsPerDay;
248 my $QueueObj = new RT::Queue($session{'CurrentUser'});
249 $QueueObj->Load($Queue);
251 until ($#dates == $diff) {
252 my $date = new RT::Date($session{CurrentUser});
253 $date->Set(Value=>$endRange - $n, Format => 'unix');
254 # Note: we used to adjust the time to local midnight, but
255 # none of the other date entry fields in RT seem to adjust, so we've stopped.
256 #Statistics::DebugLog("Before adjust to midnight date " . Statistics::FormatDate("%c", $date) . "\n");
257 $n+= $Statistics::secsPerDay;
258 # If we aren't showing weekends and this is one, decrement the number
259 # of days to show and skip to the next date.
260 if(!$weekends and Statistics::RTDateIsWeekend($date)) {$diff--; next;}
261 unshift @dates, $date;
262 Statistics::DebugLog("pushing date " . Statistics::FormatDate("%c", $date) . "\n");
263 unshift @{ $data[0] }, Statistics::FormatDate($Statistics::PerDayLabelDateFormat, $date);
266 # We put an extra day into the lists to cover up till midnight of the next day,
267 # But we don't want that to appear in the labels, so pop it off.
268 pop( @{ $data[0] } );