1 <& /Elements/Header, Title => 'Time to Resolution' &>
2 <& /RTx/Statistics/Elements/Tabs, Title => loc("Time To Resolve tickets by Queue for : " .$QueueObj->Name()) &>
4 <p>This page shows details of resolution of tickets in the selected queue. It displays tickets created on each day in your selected date
5 range. Of those tickets created on that day, how many have been resolved and the total time it has taken for all tickets created on that
6 day to be resolved.</p>
7 <p>At the bottom of the chart is shows total time taken to resolve all tickets
8 in the selected date range and the average time per ticket to
11 <form method="POST" action="index.html">
13 %my $title = "Time to resolve in " . $QueueObj->Name() . " per day from " .
14 % Statistics::FormatDate($Statistics::PerDayDateFormat, $dates[0]) . " through " .
15 % Statistics::FormatDate($Statistics::PerDayDateFormat, $dates[$#dates-1]);
16 <&|/Elements/TitleBox,
18 title_href => "/RTx/Statistics/Resolution/index.html?$QueryString" &>
19 <TABLE BORDER=0 cellspacing=0 cellpadding=1 WIDTH=100%>
21 <& /RTx/Statistics/Elements/CollectionAsTable/Header,
23 FormatString => $Format,
24 AllowSorting => $AllowSorting,
31 maxitems => $maxitems &>
34 % LINE: for my $d (0..$#dates ) {
35 % if ($d == $#dates ){
39 % $values{Statistics_Date} = Statistics::FormatDate($Statistics::PerDayDateFormat, $dates[$d]);
40 % my $tix = new RT::Tickets($session{'CurrentUser'});
41 % $tix->LimitCreated(VALUE => $dates[$d]->ISO, OPERATOR => ">=");
43 % $tix->LimitCreated(VALUE => $dates[$d+1]->ISO, OPERATOR => "<=");
46 % $tix->LimitQueue (VALUE => $Queue);
48 % $values{Statistics_Created_Count} = $tix->Count;
49 % $tix->LimitStatus(VALUE => "resolved");
50 % $values{Statistics_Resolved_Count} = $tix->Count;
52 % my @tix = @{$tix->ItemsArrayRef};
54 % $total += ($_->ResolvedObj->Unix - $_->CreatedObj->Unix) for @tix;
56 % $grandtotal += $total;
57 % $values{Duration} = Statistics::DurationAsString($total);
58 % $data[$x++][$d] = int ($total );
60 % $values{Duration} = "N/A";
62 <& /RTx/Statistics/Elements/CollectionAsTable/Row, Format => \@Format, i => $line, record => $record, maxitems => $maxitems &>
65 % $size =1 if $size==0;
66 % $values{text} = "Average time to resolve = " . Statistics::DurationAsString($grandtotal / $size);
67 <& /RTx/Statistics/Elements/CollectionAsTable/Row, Format => \@OneCellFormat, i => $line, record => $record, maxitems => $maxitems &>
69 % $values{text} = "Total time to resolve = " . Statistics::DurationAsString( $grandtotal );
70 <& /RTx/Statistics/Elements/CollectionAsTable/Row, Format => \@OneCellFormat, i => $line, record => $record, maxitems => $maxitems &>
81 # Create the graph URL
83 # change the total time to resolve to a floating point number of days
84 foreach my $dat(@{$data[1]} ){
85 $dat = ($dat / $Statistics::secsPerDay);
86 $dat = sprintf("%0.4f", $dat);
89 my $url = 'Elements/Chart?x_labels=';
91 $url .= $data[0][$_] . ",";
97 $data[0][$_] = 0 if !$data[0][$_];
98 $url .= $data[0][$_] . ",";
102 <& /RTx/Statistics/Elements/GraphBox, GraphURL => $url &>
104 <& /RTx/Statistics/Elements/ControlsAsTable/ControlBox,
105 Title => "Change Queue or Dates",
106 ShowDates => 1, sMonth => \$sMonth, sDay => \$sDay, sYear => \$sYear,
107 eMonth => \$eMonth, eDay => \$eDay, eYear => \$eYear,
108 weekends => $weekends,
109 ShowSingleQueue => 1, Queue => $Queue
115 $max => $Statistics::TimeToResolveMaxRows
117 $weekends =>$Statistics::TimeToResolveWeekends
127 $AllowSorting => undef
155 my $record = \%record;
157 $record{values} = \%values;
160 # If debugging, set things up and display all the args
161 Statistics::DebugClear();
162 Statistics::DebugLog("CallsQueueDay/index.html ARGS:\n");
163 for my $key (keys %ARGS) {
164 Statistics::DebugLog("ARG{ $key }=" . $ARGS{$key} . "\n");
167 my $Format = qq{ Statistics_Date,
168 '__Statistics_Created_Count__/STYLE:text-align:right;',
169 '__Statistics_Resolved_Count__/STYLE:text-align:right;',
170 '__Statistics_Dynamic__/KEY:Duration/TITLE:Time To Resolve/STYLE:text-align:right;' };
171 my $BoldFormat = qq{ '<B>__Statistics_Date__</B>',
172 '<B>__Statistics_Created_Count__</B>/STYLE:text-align:right;',
173 '<B>__Statistics_Resolved_Count__</B>/STYLE:text-align:right;',
174 '<B>__Statistics_Dynamic__</B>/KEY:Duration/TITLE:Time To Resolve/STYLE:text-align:right;' };
176 # TODO need way to make this cell do colspan
177 my $OneCellFormat = qq{ '<B>__Statistics_Dynamic__</B>/KEY:text/STYLE:text-align:left;','','','' };
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 my (@OneCellFormat) = $m->comp('/RTx/Statistics/Elements/CollectionAsTable/ParseFormat', Format => $OneCellFormat);
183 Statistics::DebugLog("CallsQueueDay/index.html Format array=" . join(',', @Format) . "\n");
185 if ($sDay > $Statistics::monthsMaxDay{$sMonth}) {
186 $sDay = $Statistics::monthsMaxDay{$sMonth};
189 if ($eDay > $Statistics::monthsMaxDay{$eMonth}) {
190 $eDay = $Statistics::monthsMaxDay{$eMonth};
194 $sEpoch = timelocal(0, 0, 0, $sDay, $sMonth, $sYear-1900);
197 Statistics::DebugLog("eMonth = " . $eMonth . "\n");
198 $eEpoch = timelocal(0, 0, 0, $eDay, $eMonth, $eYear-1900);
200 # This case happens when the page is first loaded
201 my @local = localtime(time);
202 ($eDay, $eMonth, $eYear) = ($local[3], $local[4], $local[5]);
204 $eEpoch = timelocal(0, 0, 0, $local[3], $local[4], $local[5], $local[6], $local[7], $local[8]);
205 Statistics::DebugLog("Setting eEpoch=$eEpoch from current time.\n");
208 if (($eEpoch < $sEpoch) || ($sEpoch == 0)) {
209 # We have an end, but not a start, or, overlapping.
211 # if $currentMonth is set, just set the day to 1
213 # set start vars from end, but with day set to 1
214 (undef, undef, undef, $sDay, $sMonth, $sYear) = localtime($eEpoch);
216 $sEpoch = timelocal(0, 0, 0, $sDay, $sMonth, $sYear);
218 # If the user has specified how many days back to go, use that,
219 # If not, set start to configured default period before end
221 $sEpoch = $eEpoch - ($days * $Statistics::secsPerDay);
223 $sEpoch = $eEpoch - ($Statistics::PerDayPeriod * $Statistics::secsPerDay);
225 (undef, undef, undef, $sDay, $sMonth, $sYear) = localtime($sEpoch);
230 # Compute days to chart.
231 # The +1 is because we need to generate one more date. If the user
232 # selected a 10 day range, we need to generate 11 days.
233 $diff = int(($eEpoch - $sEpoch + $Statistics::secsPerDay - 1) / $Statistics::secsPerDay)+1;
234 Statistics::DebugLog("Setting diff=$diff\n");
236 Statistics::DebugLog("sEpoch=$sEpoch, components=" . join(',', localtime($sEpoch)) . "\n");
237 Statistics::DebugLog("eEpoch=$eEpoch, components=" . join(',', localtime($eEpoch)) . "\n");
239 my $QueueObj = new RT::Queue($session{'CurrentUser'});
240 if (!defined $Queue) {
241 $QueueObj->Load($Statistics::TimeToResolveQueue);
242 $Queue = $QueueObj->Id();
245 # Set up the string for the current query for bookmarkable link
246 $QueryString = "sDay=$sDay&sMonth=$sMonth&sYear=$sYear&eDay=$eDay&eMonth=$eMonth&eYear=$eYear&weekends=$weekends&Queue=$Queue";
248 # Set up the end date to be midnight(morning) of the date after the one the user wanted.
249 my $endRange = $eEpoch + $Statistics::secsPerDay;
250 $QueueObj->Load($Queue);
251 # NOTE: list loop starts at the end of the date range, unshifting dates onto
252 # the arrays, so that they end up in start to finish order.
253 $eEpoch += $Statistics::secsPerDay;
255 until ($#dates == $diff ) {
256 my $date = new RT::Date($session{CurrentUser});
257 $date->Set(Value=>$endRange - $n, Format => 'unix');
258 # Note: we used to adjust the time to local midnight, but
259 # none of the other date entry fields in RT seem to adjust, so we've stopped.
260 #Statistics::DebugLog("Before adjust to midnight date " . Statistics::FormatDate("%c", $date) . "\n");
261 $n+= $Statistics::secsPerDay;
262 # If we aren't showing weekends and this is one, decrement the number
263 # of days to show and skip to the next date.
264 if(!$weekends and Statistics::RTDateIsWeekend($date)) {$diff--; next;}
265 unshift @dates, $date;
266 Statistics::DebugLog("pushing date " . Statistics::FormatDate("%c", $date) . "\n");
267 unshift @{ $data[0] }, Statistics::FormatDate($Statistics::PerDayLabelDateFormat, $date);