RTx-Statistics in 2.1 / 3.8, RT#10046
[freeside.git] / rt / share / 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
9 <form method="POST">
10
11 % my $url = 'Elements/Chart?x_labels=';
12 % my $i;
13 % $url .= join ",", (map {(int($_/2) == $_/2 && (++$i)%2) ? $_/2 : ""} grep {$counts[$_]} 0..($#counts-1)), "longer";
14 % $url .= '&';
15 % $url .= "marker_size=1&";
16 % $url .= "data1=".(join ",", map { $_ || () } @counts)."&";
17 % chop $url;
18 <& /RTx/Statistics/Elements/GraphBox, GraphURL => $url &>
19
20 <& /RTx/Statistics/Elements/ControlsAsTable/ControlBox, 
21         Title => "Change Queue",
22         ShowSingleQueue => 1, Queue=>$Queue,
23 &>
24
25 </form>
26
27 %Statistics::DebugInit($m);
28
29 <%ARGS>
30 $Queue => undef
31 </%ARGS>
32
33 <%INIT>
34 use RTx::Statistics;
35
36 my @days = qw(Sun Mon Tue Wed Thu Fri Sat);
37 my $n = 0;
38 my @data = ([]);
39 my @msgs;
40 my @counts;
41
42 Statistics::DebugClear();
43 Statistics::DebugLog("TimeToResolve/index.html ARGS:\n");
44 for my $key (keys %ARGS) {
45   Statistics::DebugLog("ARG{ $key }=" . $ARGS{$key} . "\n");
46 }
47
48 my $QueueObj = new RT::Queue($session{'CurrentUser'});
49 #if (!defined $queue) {
50 #  $QueueObj->Load($Statistics::TimeToResolveGraphQueue);
51 #  $queue = $QueueObj->Id();
52 #} else {
53   $QueueObj->Load($Queue);
54 #}
55
56
57 my $tix = new RT::Tickets($session{'CurrentUser'});
58 $tix->LimitQueue (VALUE => $Queue) if $Queue;
59 $tix->LimitStatus(VALUE => "resolved");
60 $tix->UnLimit;
61 if ($tix->Count) {
62     while (my $t = $tix->RT::SearchBuilder::Next) {  # BLOODY HACK
63         my $when = $t->ResolvedObj->Unix - $t->CreatedObj->Unix;
64         next unless $when > 0; # Doubly bloody hack
65         my $max = (60*60*24*2) / 1800;
66         my $x = int($when / 1800);
67         $counts[$x > $max ? $max : $x]++;
68     }
69 }
70 </%INIT>