RT# 81692 Update use of deprecated widgets in RT
[freeside.git] / rt / share / html / RTx / Statistics / OpenStalled / index.html
1 <& /Elements/Header, Title => loc('New, Open and Stalled tickets by Queue') &>
2 <& /RTx/Statistics/Elements/Tabs, Title => loc('New, Open and Stalled tickets by Queue') &>
3
4 <h3>Description</h3>
5 <p>The purpose of this page is to show a snapshot of the current status of tickets by Queue. You can multi select Queues from the dropdown
6 list or simply show all available queues. This will indicate how many tickets have not yet been viewed (New), how many have been at least
7 viewed once (Open) and how many have had their status changed to stalled.</p>
8
9 <form method="POST" action="index.html">
10
11 %my $tix = new RT::Tickets($session{'CurrentUser'});
12 %if ($queue) {
13 %        $tix->LimitQueue (VALUE => $queue);
14 %}
15
16
17 %my $title = "New, Open and Stalled Tickets in " . join(', ', @queues);
18 <& /Widgets/TitleBoxStart, title => $title, title_href => $RT::WebPath."/RTx/Statistics/OpenStalled/index.html?$QueryString"&>
19 <TABLE BORDER=0 cellspacing=0 cellpadding=1 WIDTH="100%">
20 % if ($ShowHeader) {
21 <& /RTx/Statistics/Elements/CollectionAsTable/Header, 
22     Format => \@RowFormat, 
23     FormatString => $RowFormat,
24     AllowSorting => $AllowSorting, 
25     Order => $Order, 
26     Query => undef,
27     Rows => $Rows,
28     Page => $Page,
29     OrderBy => $OrderBy , 
30     BaseURL => $BaseURL,
31     maxitems => $maxitems &> 
32 % }
33
34 %    for ( sort keys %queues_to_show) {
35 %        push @data, $_;
36 %    }
37 %    my @legend;
38 %    my $total = 0;
39 %    my $line = 0;
40 %# NOTE need to handle all status values (see share/html/Elements/SelectStatus).
41 %    foreach my $s (qw(new open stalled)) {
42 %      $line++;
43 %      push @legend, $s;
44 %      $total=0;
45 %      foreach my $q (sort keys %queues_to_show)  {
46 %        $tix = new RT::Tickets($session{'CurrentUser'});
47 %        $tix->LimitQueue(VALUE => "$q");
48 %        $tix->LimitStatus(VALUE => "$s");
49 %        push @data, $tix->Count;
50 %        $totals{$q} += $tix->Count; # Add up columns for each queue
51 %        $total += $tix->Count;
52 %        $values{$q} = $tix->Count;
53 %      }
54 %      $totals{"Totals"} += $total;
55 %      $values{Statistics_Status} = $s;
56 %      $values{Statistics_Totals} = $total;
57 <&     /RTx/Statistics/Elements/CollectionAsTable/Row, Format => \@RowFormat, i => $line, record => $record, maxitems => $maxitems &>
58 %    }
59 %    $values{Statistics_Status} = "Totals";
60 %    foreach my $q (sort keys %queues_to_show) {
61 %      $values{$q} = $totals{$q};
62 %    }
63 %    $values{Statistics_Totals} = $totals{"Totals"};
64 <&   /RTx/Statistics/Elements/CollectionAsTable/Row, Format => \@BoldRowFormat, i => $line+1, record => $record, maxitems => $maxitems &>
65 </table>
66 <& /Widgets/TitleBoxEnd&>
67
68 % use Data::Dumper;
69 % Statistics::DebugLog("Dump of data array is " . Dumper(@data) . "\n");
70 %  my $url = 'Elements/Chart?x_labels=';
71 %  for (1..(scalar keys %queues_to_show)) {
72 %    $url .=  $m->interp->apply_escapes((shift @data),'u')  . ',';
73 %  }
74 %  chop $url;
75 %  $url .= '&data1=' ;
76 %  for (1..(scalar keys %queues_to_show)) {
77 %    $url .=  $m->interp->apply_escapes((shift @data),'u') . ',';
78 %  }
79 %  chop $url;
80 %  $url .= '&data2=' ;
81 %  for (1..(scalar keys %queues_to_show)) {
82 %    $url .=  $m->interp->apply_escapes((shift @data),'u') . ',';
83 %  }
84 %  chop $url;
85 %  $url .= '&data3=' ;
86 %  for (1..(scalar keys %queues_to_show)) {
87 %    $url .=  $m->interp->apply_escapes((shift @data),'u') . ',';
88 %  }
89 %  $url .= '&set_legend='.(join ",", @legend);
90
91
92 <& /RTx/Statistics/Elements/GraphBox, GraphURL => $url &>
93
94 <& /RTx/Statistics/Elements/ControlsAsTable/ControlBox, Title => "Select Queues", ShowMultiQueues => 1, queues_ref => \@queues &>
95
96 <a href="<%$RT::WebPath%>/RTx/Statistics/OpenStalled/index.html?<% $QueryString %>"><&|/l&>Bookmarkable link</&></a>
97 %# | <a href="<%$RT::WebPath%>/RTx/Statistics/OpenStalled/Results.tsv?<%$QueryString%>"><&|/l&>spreadsheet</&></a>
98 <BR>
99 <BR>
100
101 </FORM>
102
103 % Statistics::DebugInit( $m );
104
105 <%ARGS>
106 @queues => @Statistics::OpenStalledQueueList
107 $AllowSorting => undef
108 $Order => undef
109 $OrderBy => undef
110 $ShowNavigation => 1
111 $ShowHeader => 1
112 $Rows => 50
113 $Page => 1
114 $BaseURL => undef
115 $AddAllCheck => undef
116 </%ARGS>
117
118 <%INIT>
119   use RTx::Statistics;
120
121   my $n = 0;
122   my @data; 
123   my @msgs;
124   my %totals;
125   my $QueryString;
126   my %queues_to_show;
127   my $maxitems;
128   my $RowFormat;
129   my $BoldRowFormat;
130   my %record;
131   my %values;
132   my $record = \%record;
133
134   $record{values} = \%values;
135
136   Statistics::DebugClear();
137
138   # Handle the Add All Checkbox
139   if($AddAllCheck eq "on") {
140     $AddAllCheck = undef;
141     undef (@queues);
142     my $q=new RT::Queues($session{'CurrentUser'});
143     $q->UnLimit;
144     while (my $queue=$q->Next) {
145       next if !$queue->CurrentUserHasRight('SeeQueue');
146       push @queues, $queue->Name;
147     }
148   }
149
150   # If the user has the right to see the queue, put it into the map
151   for my $q (@queues) {
152       my $Queueobj = new RT::Queue($session{'CurrentUser'});
153       $Queueobj->Load($q);
154       next if !$Queueobj->CurrentUserHasRight('SeeQueue');
155       $queues_to_show{$q} = 1;
156   }
157
158   $maxitems = (scalar @queues) + 2;
159
160   # Build the new query string
161   $QueryString = "queues=" . join("&queues=", @queues);
162
163   # Build the format strings
164   $RowFormat = "'__Statistics_Status__'";
165   $BoldRowFormat = "'<B>__Statistics_Status__</B>'";
166   for my $q (@queues) {
167       $RowFormat .= ",'__Statistics_Dynamic__/KEY:$q/TITLE:$q/STYLE:text-align:right;'";
168       $BoldRowFormat .= ",'<B>__Statistics_Dynamic__</B>/KEY:$q/TITLE:$q/STYLE:text-align:right;'";
169   }
170   $RowFormat .= ",'<B>__Statistics_Totals__</B>/STYLE:text-align:right;'";
171   $BoldRowFormat .= ",'<B>__Statistics_Totals__</B>/STYLE:text-align:right;'";
172   # Parse the formats into structures.
173   my (@RowFormat) = $m->comp('/RTx/Statistics/Elements/CollectionAsTable/ParseFormat', Format => $RowFormat);
174   my (@BoldRowFormat) = $m->comp('/RTx/Statistics/Elements/CollectionAsTable/ParseFormat', Format => $BoldRowFormat);
175
176
177   my $queue = new RT::Queues($session{CurrentUser});
178   $queue->UnLimit;
179
180   my $QueueObj = new RT::Queue($session{'CurrentUser'});
181   $QueueObj->Load($queue);
182
183 </%INIT>