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 &>
90 # Create the graph URL
91 my $url= 'Elements/Chart?x_labels=';
93 $url .= $data[0][$_] . ",";
99 $url .= "data".(1+$_)."=".(join ",", @{$data[$_]})."&";
102 $url .= "&set_legend=Created,Resolved,Deleted";
105 <& /RTx/Statistics/Elements/GraphBox, GraphURL => $url &>
107 <& /RTx/Statistics/Elements/ControlsAsTable/ControlBox,
108 Title => "Change Queue or Dates",
109 ShowDates => 1, sMonth => \$sMonth, sDay => \$sDay, sYear => \$sYear,
110 eMonth => \$eMonth, eDay => \$eDay, eYear => \$eYear,
111 weekends => $weekends,
112 ShowSingleQueue => 1, Queue => $Queue
117 <a href="<%$RT::WebPath%>/RTx/Statistics/CallsQueueDay/index.html?<% $QueryString %>"><&|/l&>Bookmarkable link</&></a> |
118 <a href="<%$RT::WebPath%>/RTx/Statistics/CallsQueueDay/Results.tsv?<%$QueryString%>"><&|/l&>spreadsheet</&></a>
123 % Statistics::DebugLog("ref of eMonth is " . ref($eMonth) . "\n");
124 % Statistics::DebugInit( $m );
128 $weekends => $Statistics::PerDayWeekends;
138 $AllowSorting => undef
164 my $record = \%record;
166 $record{values} = \%values;
169 # If debugging, set things up and display all the args
170 Statistics::DebugClear();
171 Statistics::DebugLog("CallsQueueDay/index.html ARGS:\n");
172 for my $key (keys %ARGS) {
173 Statistics::DebugLog("ARG{ $key }=" . $ARGS{$key} . "\n");
176 my $Format = qq{ Statistics_Date,
177 '__Statistics_Created_Count__/STYLE:text-align:right;',
178 '__Statistics_Resolved_Count__/STYLE:text-align:right;',
179 '__Statistics_Deleted_Count__/STYLE:text-align:right;' };
180 my $BoldFormat = qq{ '<B>__Statistics_Date__</B>',
181 '<B>__Statistics_Created_Count__</B>/STYLE:text-align:right;',
182 '<B>__Statistics_Resolved_Count__</B>/STYLE:text-align:right;',
183 '<B>__Statistics_Deleted_Count__</B>/STYLE:text-align:right;' };
184 my (@Format) = $m->comp('/RTx/Statistics/Elements/CollectionAsTable/ParseFormat', Format => $Format);
185 my (@BoldFormat) = $m->comp('/RTx/Statistics/Elements/CollectionAsTable/ParseFormat', Format => $BoldFormat);
186 Statistics::DebugLog("CallsQueueDay/index.html Format array=" . join(',', @Format) . "\n");
188 if (!defined $Queue) {
189 my $QueueObj = new RT::Queue($session{'CurrentUser'});
190 $QueueObj->Load($Statistics::PerDayQueue);
191 $Queue = $QueueObj->Id();
194 if ($sDay > $Statistics::monthsMaxDay{$sMonth}) {
195 $sDay = $Statistics::monthsMaxDay{$sMonth};
198 if ($eDay > $Statistics::monthsMaxDay{$eMonth}) {
199 $eDay = $Statistics::monthsMaxDay{$eMonth};
203 $sEpoch = timelocal(0, 0, 0, $sDay, $sMonth, $sYear-1900);
206 Statistics::DebugLog("eMonth = " . $eMonth . "\n");
207 $eEpoch = timelocal(0, 0, 0, $eDay, $eMonth, $eYear-1900);
209 # This case happens when the page is first loaded
210 my @local = localtime(time);
211 ($eDay, $eMonth, $eYear) = ($local[3], $local[4], $local[5]);
213 $eEpoch = timelocal(0, 0, 0, $local[3], $local[4], $local[5], $local[6], $local[7], $local[8]);
214 Statistics::DebugLog("Setting eEpoch=$eEpoch from current time.\n");
217 if (($eEpoch < $sEpoch) || ($sEpoch == 0)) {
218 # We have an end, but not a start, or, overlapping.
220 # if $currentMonth is set, just set the day to 1
222 # set start vars from end, but with day set to 1
223 (undef, undef, undef, $sDay, $sMonth, $sYear) = localtime($eEpoch);
225 $sEpoch = timelocal(0, 0, 0, $sDay, $sMonth, $sYear);
227 # If the user has specified how many days back to go, use that,
228 # If not, set start to configured default period before end
230 $sEpoch = $eEpoch - ($days * $Statistics::secsPerDay);
232 $sEpoch = $eEpoch - ($Statistics::PerDayPeriod * $Statistics::secsPerDay);
234 (undef, undef, undef, $sDay, $sMonth, $sYear) = localtime($sEpoch);
239 # Compute days to chart.
240 # The +1 is because we need to generate one more date. If the user
241 # selected a 10 day range, we need to generate 11 days.
242 $diff = int(($eEpoch - $sEpoch + $Statistics::secsPerDay - 1) / $Statistics::secsPerDay)+1;
243 Statistics::DebugLog("Setting diff=$diff\n");
245 Statistics::DebugLog("sEpoch=$sEpoch, components=" . join(',', localtime($sEpoch)) . "\n");
246 Statistics::DebugLog("eEpoch=$eEpoch, components=" . join(',', localtime($eEpoch)) . "\n");
248 # Set up the string for the current query for bookmarkable link
249 $QueryString = "sDay=$sDay&sMonth=$sMonth&sYear=$sYear&eDay=$eDay&eMonth=$eMonth&eYear=$eYear&weekends=$weekends&Queue=$Queue";
251 # Set up the end date to be midnight(morning) of the date after the one the user wanted.
252 my $endRange = $eEpoch + $Statistics::secsPerDay;
253 my $QueueObj = new RT::Queue($session{'CurrentUser'});
254 $QueueObj->Load($Queue);
256 until ($#dates == $diff) {
257 my $date = new RT::Date($session{CurrentUser});
258 $date->Set(Value=>$endRange - $n, Format => 'unix');
259 # Note: we used to adjust the time to local midnight, but
260 # none of the other date entry fields in RT seem to adjust, so we've stopped.
261 #Statistics::DebugLog("Before adjust to midnight date " . Statistics::FormatDate("%c", $date) . "\n");
262 $n+= $Statistics::secsPerDay;
263 # If we aren't showing weekends and this is one, decrement the number
264 # of days to show and skip to the next date.
265 if(!$weekends and Statistics::RTDateIsWeekend($date)) {$diff--; next;}
266 unshift @dates, $date;
267 Statistics::DebugLog("pushing date " . Statistics::FormatDate("%c", $date) . "\n");
268 unshift @{ $data[0] }, Statistics::FormatDate($Statistics::PerDayLabelDateFormat, $date);
271 # We put an extra day into the lists to cover up till midnight of the next day,
272 # But we don't want that to appear in the labels, so pop it off.
273 pop( @{ $data[0] } );