integrate RTx::Statistics package, part of merging spiritone RT changes (#1661)
[freeside.git] / rt / html / RTx / Statistics / TimeToResolve / index.html
1 <& /Elements/Header, Title => 'Time to Resolve in Queue' &>
2 <& /RTx/Statistics/Elements/Tabs,  Title => 'Time to Resolve, by ticket in Queue:' . $QueueObj->Name() &>
3
4 <h3>Description</h3>
5 <p>This page displays the same information as the Time to Resolve chart, but in a scattergraph format and only for the previous 7 calendar
6 days. It only displays data for tickets which have been resolved. Each division on the Days axis is one day and the granularity of this chart
7 is 30 minutes.</p>
8 <form method="POST">
9
10 <table>
11   <tr>
12   <td>Show Queue:</td>
13   <td COLSPAN=3><& /Elements/SelectQueue, Name=>"queue", Default=>$queue ,ShowNullOption=>0, 
14             CheckQueueRight=>'SeeQueue' &></td>
15   </tr>
16 </table>
17 <INPUT TYPE="submit" VALUE="Update Page"</INPUT>
18 </form>
19
20 <BR>
21 % my $url = 'Elements/Chart?x_labels=';
22 % my $i;
23 % $url .= join ",", (map {(int($_/2) == $_/2 && (++$i)%2) ? $_/2 : ""} grep {$counts[$_]} 0..($#counts-1)), "longer";
24 % $url .= '&';
25 % $url .= "marker_size=1&";
26 % $url .= "data1=".(join ",", map { $_ || () } @counts)."&";
27 % chop $url;
28 <IMG SRC="<% $url %>">
29
30 <BR>
31
32 %Statistics::DebugInit($m);
33
34 <%ARGS>
35 $queue => undef
36 </%ARGS>
37
38 <%INIT>
39 use RTx::Statistics;
40
41 my @days = qw(Sun Mon Tue Wed Thu Fri Sat);
42 my $n = 0;
43 my @data = ([]);
44 my @msgs;
45 my @counts;
46
47 Statistics::DebugClear();
48 Statistics::DebugLog("TimeToResolve/index.html ARGS:\n");
49 for my $key (keys %ARGS) {
50   Statistics::DebugLog("ARG{ $key }=" . $ARGS{$key} . "\n");
51 }
52
53 my $QueueObj = new RT::Queue($session{'CurrentUser'});
54 if (!defined $queue) {
55   $QueueObj->Load($Statistics::TimeToResolveGraphQueue);
56   $queue = $QueueObj->Id();
57 } else {
58   $QueueObj->Load($queue);
59 }
60
61
62 my $tix = new RT::Tickets($session{'CurrentUser'});
63 $tix->LimitQueue (VALUE => $queue) if $queue;
64 $tix->LimitStatus(VALUE => "resolved");
65 $tix->UnLimit;
66 if ($tix->Count) {
67     while (my $t = $tix->RT::SearchBuilder::Next) {  # BLOODY HACK
68         my $when = $t->ResolvedObj->Unix - $t->CreatedObj->Unix;
69         next unless $when > 0; # Doubly bloody hack
70         my $max = (60*60*24*2) / 1800;
71         my $x = int($when / 1800);
72         $counts[$x > $max ? $max : $x]++;
73     }
74 }
75 </%INIT>