summaryrefslogtreecommitdiff
path: root/rt/html/RTx/Statistics/OpenStalled/index.html
blob: d0cd9f158b78b50708dc0a6bb89af0dd5fbb06af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<& /Elements/Header, Title => loc('New, Open and Stalled tickets by Queue') &>
<& /RTx/Statistics/Elements/Tabs, Title => loc('New, Open and Stalled tickets by Queue') &>

<h3>Description</h3>
<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
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
viewed once (Open) and how many have had their status changed to stalled.</p>

<form method="POST" action="index.html">

%my $tix = new RT::Tickets($session{'CurrentUser'});
%if ($queue) {
%        $tix->LimitQueue (VALUE => $queue);
%}


%my $title = "New, Open and Stalled Tickets in " . join(', ', @queues);
<& /Elements/TitleBoxStart, title => $title, title_href => "/RTx/Statistics/OpenStalled/index.html?$QueryString"&>
<TABLE BORDER=0 cellspacing=0 cellpadding=1 WIDTH="100%">
% if ($ShowHeader) {
<& /RTx/Statistics/Elements/CollectionAsTable/Header, 
    Format => \@RowFormat, 
    FormatString => $RowFormat,
    AllowSorting => $AllowSorting, 
    Order => $Order, 
    Query => undef,
    Rows => $Rows,
    Page => $Page,
    OrderBy => $OrderBy , 
    BaseURL => $BaseURL,
    maxitems => $maxitems &> 
% }

%    for ( sort keys %queues_to_show) {
%        push @data, $_;
%    }
%    my @legend;
%    my $total = 0;
%    my $line = 0;
%# NOTE need to handle all status values (see share/html/Elements/SelectStatus).
%    foreach my $s (qw(new open stalled)) {
%      $line++;
%      push @legend, $s;
%      $total=0;
%      foreach my $q (sort keys %queues_to_show)  {
%        $tix = new RT::Tickets($session{'CurrentUser'});
%        $tix->LimitQueue(VALUE => "$q");
%        $tix->LimitStatus(VALUE => "$s");
%        push @data, $tix->Count;
%        $totals{$q} += $tix->Count; # Add up columns for each queue
%        $total += $tix->Count;
%        $values{$q} = $tix->Count;
%      }
%      $totals{"Totals"} += $total;
%      $values{Statistics_Status} = $s;
%      $values{Statistics_Totals} = $total;
<&     /RTx/Statistics/Elements/CollectionAsTable/Row, Format => \@RowFormat, i => $line, record => $record, maxitems => $maxitems &>
%    }
%    $values{Statistics_Status} = "Totals";
%    foreach my $q (sort keys %queues_to_show) {
%      $values{$q} = $totals{$q};
%    }
%    $values{Statistics_Totals} = $totals{"Totals"};
<&   /RTx/Statistics/Elements/CollectionAsTable/Row, Format => \@BoldRowFormat, i => $line+1, record => $record, maxitems => $maxitems &>
</table>
<& /Elements/TitleBoxEnd&>

<hr>

<BR />
<BR />

% use Data::Dumper;
% Statistics::DebugLog("Dump of data array is " . Dumper(@data) . "\n");
%  my $url = 'Elements/Chart?x_labels=';
%  for (1..(scalar keys %queues_to_show)) {
%    $url .=  $m->interp->apply_escapes((shift @data),'u')  . ',';
%  }
%  chop $url;
%  $url .= '&data1=' ;
%  for (1..(scalar keys %queues_to_show)) {
%    $url .=  $m->interp->apply_escapes((shift @data),'u') . ',';
%  }
%  chop $url;
%  $url .= '&data2=' ;
%  for (1..(scalar keys %queues_to_show)) {
%    $url .=  $m->interp->apply_escapes((shift @data),'u') . ',';
%  }
%  chop $url;
%  $url .= '&data3=' ;
%  for (1..(scalar keys %queues_to_show)) {
%    $url .=  $m->interp->apply_escapes((shift @data),'u') . ',';
%  }
%  $url .= '&set_legend='.(join ",", @legend);


<& /RTx/Statistics/Elements/GraphBox, GraphURL => $url &>

<& /RTx/Statistics/Elements/ControlsAsTable/ControlBox, Title => "Select Queues", ShowMultiQueues => 1, queues_ref => \@queues &>

<a href="<%$RT::WebPath%>/RTx/Statistics/OpenStalled/index.html?<% $QueryString %>"><&|/l&>Bookmarkable link</&></a>
%# | <a href="<%$RT::WebPath%>/RTx/Statistics/OpenStalled/Results.tsv?<%$QueryString%>"><&|/l&>spreadsheet</&></a>
<BR>
<BR>

</FORM>

% Statistics::DebugInit( $m );

<%ARGS>
@queues => @Statistics::OpenStalledQueueList
$AllowSorting => undef
$Order => undef
$OrderBy => undef
$ShowNavigation => 1
$ShowHeader => 1
$Rows => 50
$Page => 1
$BaseURL => undef
$AddAllCheck => undef
</%ARGS>

<%INIT>
  use RTx::Statistics;

  my $n = 0;
  my @data; 
  my @msgs;
  my %totals;
  my $QueryString;
  my %queues_to_show;
  my $maxitems;
  my $RowFormat;
  my $BoldRowFormat;
  my %record;
  my %values;
  my $record = \%record;

  $record{values} = \%values;

  Statistics::DebugClear();

  # Handle the Add All Checkbox
  if($AddAllCheck eq "on") {
    $AddAllCheck = undef;
    undef (@queues);
    my $q=new RT::Queues($session{'CurrentUser'});
    $q->UnLimit;
    while (my $queue=$q->Next) {
      next if !$queue->CurrentUserHasRight('SeeQueue');
      push @queues, $queue->Name;
    }
  }

  # If the user has the right to see the queue, put it into the map
  for my $q (@queues) {
      my $Queueobj = new RT::Queue($session{'CurrentUser'});
      $Queueobj->Load($q);
      next if !$Queueobj->CurrentUserHasRight('SeeQueue');
      $queues_to_show{$q} = 1;
  }

  $maxitems = (scalar @queues) + 2;

  # Build the new query string
  $QueryString = "queues=" . join("&queues=", @queues);

  # Build the format strings
  $RowFormat = "'__Statistics_Status__'";
  $BoldRowFormat = "'<B>__Statistics_Status__</B>'";
  for my $q (@queues) {
      $RowFormat .= ",'__Statistics_Dynamic__/KEY:$q/TITLE:$q/STYLE:text-align:right;'";
      $BoldRowFormat .= ",'<B>__Statistics_Dynamic__</B>/KEY:$q/TITLE:$q/STYLE:text-align:right;'";
  }
  $RowFormat .= ",'<B>__Statistics_Totals__</B>/STYLE:text-align:right;'";
  $BoldRowFormat .= ",'<B>__Statistics_Totals__</B>/STYLE:text-align:right;'";
  # Parse the formats into structures.
  my (@RowFormat) = $m->comp('/RTx/Statistics/Elements/CollectionAsTable/ParseFormat', Format => $RowFormat);
  my (@BoldRowFormat) = $m->comp('/RTx/Statistics/Elements/CollectionAsTable/ParseFormat', Format => $BoldRowFormat);


  my $queue = new RT::Queues($session{CurrentUser});
  $queue->UnLimit;

  my $QueueObj = new RT::Queue($session{'CurrentUser'});
  $QueueObj->Load($queue);

</%INIT>