1 <& /Elements/Header, Title => loc('Tickets per day in Multiple queues') &>
2 <& /RTx/Statistics/Elements/Tabs, Title => loc('Tickets per day in Multiple Queues by status') &>
5 <p>This chart shows details of tickets per day by their status. You can select multiple queues to display at the same time, but only one status. You can chose any of the defined status values.
6 There is also the option to display all available queues at the same time.
7 The default display shows tickets resolved in your default queue (General unless altered locally).
8 The line chart below shows the same information in a graphical form.
12 <form method="POST" action="index.html">
16 % for (sort keys %queues_to_show) {
20 %my $title = "Tickets with Status $status in " . join(', ', @queues) . ", per day from " .
21 % Statistics::FormatDate($Statistics::PerDayDateFormat, $dates[0]) . " through " .
22 % Statistics::FormatDate($Statistics::PerDayDateFormat, $dates[$#dates-1]);
24 <& /Elements/TitleBoxStart, title => $title, title_href => "/RTx/Statistics/OpenStalled/index.html?$QueryString"&>
25 <TABLE BORDER=0 cellspacing=0 cellpadding=1 WIDTH="100%">
27 <& /RTx/Statistics/Elements/CollectionAsTable/Header,
28 Format => \@RowFormat,
29 FormatString => $RowFormat,
30 AllowSorting => $AllowSorting,
37 maxitems => $maxitems &>
40 % LINE: for my $d (0..$#dates) {
41 % if ($d == $#dates ){
46 % $values{Statistics_Date} = Statistics::FormatDate($dateformat, $dates[$d]);
48 % foreach my $q (sort keys %queues_to_show) {
49 % my $tix = new RT::Tickets($session{'CurrentUser'});
50 % if ($status eq "resolved") {
51 % $tix->LimitStatus(VALUE => $status);
52 % $tix->LimitResolved(VALUE => $dates[$d]->ISO, OPERATOR => ">=");
54 % $tix->LimitResolved(VALUE => $dates[$d+1]->ISO, OPERATOR => "<=");
57 % elsif ($status eq "new") {
58 % $tix->LimitCreated(VALUE => $dates[$d]->ISO, OPERATOR => ">=");
60 % $tix->LimitCreated(VALUE => $dates[$d+1]->ISO, OPERATOR => "<=");
63 % elsif ($status eq "deleted") {
64 % $tix->LimitStatus(VALUE => $status);
65 % $tix->LimitLastUpdated(VALUE => $dates[$d]->ISO, OPERATOR => ">=");
67 % $tix->LimitLastUpdated(VALUE => $dates[$d+1]->ISO, OPERATOR => "<=");
70 % elsif ($status eq "stalled") {
71 % $tix->LimitStatus(VALUE => $status);
72 % $tix->LimitLastUpdated(VALUE => $dates[$d]->ISO, OPERATOR => ">=");
74 % $tix->LimitLastUpdated(VALUE => $dates[$d+1]->ISO, OPERATOR => "<=");
77 % elsif ($status eq "open") {
78 % $tix->LimitStatus(VALUE => $status);
79 % $tix->LimitLastUpdated(VALUE => $dates[$d]->ISO, OPERATOR => ">=");
81 % $tix->LimitLastUpdated(VALUE => $dates[$d+1]->ISO, OPERATOR => "<=");
84 % elsif ($status eq "rejected") {
85 % $tix->LimitStatus(VALUE => $status);
86 % $tix->LimitLastUpdated(VALUE => $dates[$d]->ISO, OPERATOR => ">=");
88 % $tix->LimitLastUpdated(VALUE => $dates[$d+1]->ISO, OPERATOR => "<=");
91 % $tix->LimitQueue (VALUE => $q);
92 % $values{$q} = $tix->Count;
93 % $row_total += $tix->Count;
94 % $data[$x++][$d] = $tix->Count;
96 % $values{Statistics_Totals} = $row_total;
97 <& /RTx/Statistics/Elements/CollectionAsTable/Row, Format => \@RowFormat, i => $line, record => $record, maxitems => $maxitems &>
100 <& /Elements/TitleBoxEnd&>
108 <td COLSPAN=2><SELECT NAME="status">
109 % for (qw(resolved new deleted stalled rejected open)) {
110 <OPTION VALUE="<% $_ %>" <% $_ eq $status && "SELECTED" %>>
111 <% loc($_) %></OPTION>
116 # Create the graph URL
117 my $url = 'Elements/Chart?x_labels=';
118 #$url .= join ",", @{ shift @data } . "&";
120 $url .= $m->interp->apply_escapes($data[0][$_],'u') . ",";
125 $url .= 'set_legend='.(join ",", @legend)."&";
127 $url .= "data".(1+$_)."=". (join ",", @{$data[$_]})."&";
132 <& /RTx/Statistics/Elements/GraphBox, GraphURL => $url &>
134 <& /RTx/Statistics/Elements/ControlsAsTable/ControlBox,
135 Title => "Change Status, Queues or Dates",
136 ShowDates => 1, sMonth => \$sMonth, sDay => \$sDay, sYear => \$sYear,
137 eMonth => \$eMonth, eDay => \$eDay, eYear => \$eYear,
138 weekends => $weekends,
139 ShowMultiQueues => 1, queues_ref => \@queues,
140 ShowStatus => 1, Status => $status
145 <a href="<%$RT::WebPath%>/RTx/Statistics/CallsMultiQueue/index.html?<% $QueryString %>"><&|/l&>Bookmarkable link</&></a>
146 %# | <a href="<%$RT::WebPath%>/RTx/Statistics/CallsMultiQueue/Results.tsv?<%$QueryString%>"><&|/l&>spreadsheet</&></a>
151 $status => $Statistics::MultiQueueStatus
152 $max => $Statistics::MultiQueueMaxRows
153 @queues => @Statistics::MultiQueueQueueList
154 $weekends => $Statistics::PerDayWeekends;
162 $dateformat => $Statistics::MultiQueueDateFormat
165 $AllowSorting => undef
173 $AddAllCheck => undef
187 my $secsPerDay=86400;
196 my $record = \%record;
198 $record{values} = \%values;
200 Statistics::DebugClear();
201 Statistics::DebugLog("CallsQueueDay/index.html ARGS:\n");
202 for my $key (keys %ARGS) {
203 Statistics::DebugLog("ARG{ $key }=" . $ARGS{$key} . "\n");
207 # Handle the Add All Checkbox
208 if($AddAllCheck eq "on") {
209 $AddAllCheck = undef;
211 my $q=new RT::Queues($session{'CurrentUser'});
213 while (my $queue=$q->Next) {
214 next if !$queue->CurrentUserHasRight('SeeQueue');
215 push @queues, $queue->Name;
219 # If the user has the right to see the queue, put it into the map
220 for my $q (@queues) {
221 my $Queueobj = new RT::Queue($session{'CurrentUser'});
223 next if !$Queueobj->CurrentUserHasRight('SeeQueue');
224 $queues_to_show{$q} = 1;
227 $maxitems = (scalar @queues) + 2;
229 # Build the format strings
230 $RowFormat = "'__Statistics_Date__'";
231 $BoldRowFormat = "'<B>__Statistics_Date__</B>'";
232 for my $q (@queues) {
233 $RowFormat .= ",'__Statistics_Dynamic__/KEY:$q/TITLE:$q/STYLE:text-align:right;'";
234 $BoldRowFormat .= ",'<B>__Statistics_Dynamic__</B>/KEY:$q/TITLE:$q/STYLE:text-align:right;'";
236 $RowFormat .= ",'<B>__Statistics_Totals__</B>/STYLE:text-align:right;'";
237 $BoldRowFormat .= ",'<B>__Statistics_Totals__</B>/STYLE:text-align:right;'";
238 # Parse the formats into structures.
239 my (@RowFormat) = $m->comp('/RTx/Statistics/Elements/CollectionAsTable/ParseFormat', Format => $RowFormat);
240 my (@BoldRowFormat) = $m->comp('/RTx/Statistics/Elements/CollectionAsTable/ParseFormat', Format => $BoldRowFormat);
242 if ($sDay > $Statistics::monthsMaxDay{$sMonth}) {
243 $sDay = $Statistics::monthsMaxDay{$sMonth};
246 if ($eDay > $Statistics::monthsMaxDay{$eMonth}) {
247 $eDay = $Statistics::monthsMaxDay{$eMonth};
251 $sEpoch = timelocal(0, 0, 0, $sDay, $sMonth, $sYear-1900);
254 Statistics::DebugLog("eMonth = " . $eMonth . "\n");
255 $eEpoch = timelocal(0, 0, 0, $eDay, $eMonth, $eYear-1900);
257 # This case happens when the page is first loaded
258 my @local = localtime(time);
259 ($eDay, $eMonth, $eYear) = ($local[3], $local[4], $local[5]);
261 $eEpoch = timelocal(0, 0, 0, $local[3], $local[4], $local[5], $local[6], $local[7], $local[8]);
262 Statistics::DebugLog("Setting eEpoch=$eEpoch from current time.\n");
265 if (($eEpoch < $sEpoch) || ($sEpoch == 0)) {
266 # We have an end, but not a start, or, overlapping.
268 # if $currentMonth is set, just set the day to 1
270 # set start vars from end, but with day set to 1
271 (undef, undef, undef, $sDay, $sMonth, $sYear) = localtime($eEpoch);
273 $sEpoch = timelocal(0, 0, 0, $sDay, $sMonth, $sYear);
275 # If the user has specified how many days back to go, use that,
276 # If not, set start to configured default period before end
278 $sEpoch = $eEpoch - ($days * $Statistics::secsPerDay);
280 $sEpoch = $eEpoch - ($Statistics::PerDayPeriod * $Statistics::secsPerDay);
282 (undef, undef, undef, $sDay, $sMonth, $sYear) = localtime($sEpoch);
287 # Compute days to chart.
288 # The +1 is because we need to generate one more date. If the user
289 # selected a 10 day range, we need to generate 11 days.
290 $diff = int(($eEpoch - $sEpoch + $Statistics::secsPerDay - 1) / $Statistics::secsPerDay)+1;
291 Statistics::DebugLog("Setting diff=$diff\n");
293 Statistics::DebugLog("sEpoch=$sEpoch, components=" . join(',', localtime($sEpoch)) . "\n");
294 Statistics::DebugLog("eEpoch=$eEpoch, components=" . join(',', localtime($eEpoch)) . "\n");
296 # Build the new query string
297 $QueryString = "queues=" . join("&queues=", @queues);
298 $QueryString .= "&sDay=$sDay&sMonth=$sMonth&sYear=$sYear&eDay=$eDay&eMonth=$eMonth&eYear=$eYear&weekends=$weekends";
303 # Set up the end date to be midnight(morning) of the date after the one the user wanted.
304 my $endRange = $eEpoch + $Statistics::secsPerDay;
306 until ($#dates == $diff) {
307 my $date = new RT::Date($session{CurrentUser});
308 $date->Set(Value=>$endRange - $n, Format => 'unix');
309 # Note: we used to adjust the time to local midnight, but
310 # none of the other date entry fields in RT seem to adjust, so we've stopped.
311 #Statistics::DebugLog("Before adjust to midnight date " . Statistics::FormatDate("%c", $date) . "\n");
312 $n+= $Statistics::secsPerDay;
313 # If we aren't showing weekends and this is one, decrement the number
314 # of days to show and skip to the next date.
315 if(!$weekends and Statistics::RTDateIsWeekend($date)) {$diff--; next;}
316 unshift @dates, $date;
317 Statistics::DebugLog("pushing date " . Statistics::FormatDate("%c", $date) . "\n");
318 unshift @{ $data[0] }, Statistics::FormatDate($Statistics::PerDayLabelDateFormat, $date);
321 # We put an extra day into the lists to cover up till midnight of the next day,
322 # But we don't want that to appear in the labels, so pop it off.
323 pop( @{ $data[0] } );
325 my $queue = new RT::Queues($session{CurrentUser});
328 my $QueueObj = new RT::Queue($session{'CurrentUser'});
329 $QueueObj->Load($queue);