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&>
103 <td COLSPAN=2><SELECT NAME="status">
104 % for (qw(resolved new deleted stalled rejected open)) {
105 <OPTION VALUE="<% $_ %>" <% $_ eq $status && "SELECTED" %>>
106 <% loc($_) %></OPTION>
111 # Create the graph URL
112 my $url = 'Elements/Chart?x_labels=';
113 #$url .= join ",", @{ shift @data } . "&";
115 $url .= $m->interp->apply_escapes($data[0][$_],'u') . ",";
120 $url .= 'set_legend='.(join ",", @legend)."&";
122 $url .= "data".(1+$_)."=". (join ",", @{$data[$_]})."&";
127 <& /RTx/Statistics/Elements/GraphBox, GraphURL => $url &>
129 <& /RTx/Statistics/Elements/ControlsAsTable/ControlBox,
130 Title => "Change Status, Queues or Dates",
131 ShowDates => 1, sMonth => \$sMonth, sDay => \$sDay, sYear => \$sYear,
132 eMonth => \$eMonth, eDay => \$eDay, eYear => \$eYear,
133 weekends => $weekends,
134 ShowMultiQueues => 1, queues_ref => \@queues,
135 ShowStatus => 1, Status => $status
140 <a href="<%$RT::WebPath%>/RTx/Statistics/CallsMultiQueue/index.html?<% $QueryString %>"><&|/l&>Bookmarkable link</&></a>
141 %# | <a href="<%$RT::WebPath%>/RTx/Statistics/CallsMultiQueue/Results.tsv?<%$QueryString%>"><&|/l&>spreadsheet</&></a>
146 $status => $Statistics::MultiQueueStatus
147 $max => $Statistics::MultiQueueMaxRows
148 @queues => @Statistics::MultiQueueQueueList
149 $weekends => $Statistics::PerDayWeekends;
157 $dateformat => $Statistics::MultiQueueDateFormat
160 $AllowSorting => undef
168 $AddAllCheck => undef
182 my $secsPerDay=86400;
191 my $record = \%record;
193 $record{values} = \%values;
195 Statistics::DebugClear();
196 Statistics::DebugLog("CallsQueueDay/index.html ARGS:\n");
197 for my $key (keys %ARGS) {
198 Statistics::DebugLog("ARG{ $key }=" . $ARGS{$key} . "\n");
202 # Handle the Add All Checkbox
203 if($AddAllCheck eq "on") {
204 $AddAllCheck = undef;
206 my $q=new RT::Queues($session{'CurrentUser'});
208 while (my $queue=$q->Next) {
209 next if !$queue->CurrentUserHasRight('SeeQueue');
210 push @queues, $queue->Name;
214 # If the user has the right to see the queue, put it into the map
215 for my $q (@queues) {
216 my $Queueobj = new RT::Queue($session{'CurrentUser'});
218 next if !$Queueobj->CurrentUserHasRight('SeeQueue');
219 $queues_to_show{$q} = 1;
222 $maxitems = (scalar @queues) + 2;
224 # Build the format strings
225 $RowFormat = "'__Statistics_Date__'";
226 $BoldRowFormat = "'<B>__Statistics_Date__</B>'";
227 for my $q (@queues) {
228 $RowFormat .= ",'__Statistics_Dynamic__/KEY:$q/TITLE:$q/STYLE:text-align:right;'";
229 $BoldRowFormat .= ",'<B>__Statistics_Dynamic__</B>/KEY:$q/TITLE:$q/STYLE:text-align:right;'";
231 $RowFormat .= ",'<B>__Statistics_Totals__</B>/STYLE:text-align:right;'";
232 $BoldRowFormat .= ",'<B>__Statistics_Totals__</B>/STYLE:text-align:right;'";
233 # Parse the formats into structures.
234 my (@RowFormat) = $m->comp('/RTx/Statistics/Elements/CollectionAsTable/ParseFormat', Format => $RowFormat);
235 my (@BoldRowFormat) = $m->comp('/RTx/Statistics/Elements/CollectionAsTable/ParseFormat', Format => $BoldRowFormat);
237 if ($sDay > $Statistics::monthsMaxDay{$sMonth}) {
238 $sDay = $Statistics::monthsMaxDay{$sMonth};
241 if ($eDay > $Statistics::monthsMaxDay{$eMonth}) {
242 $eDay = $Statistics::monthsMaxDay{$eMonth};
246 $sEpoch = timelocal(0, 0, 0, $sDay, $sMonth, $sYear-1900);
249 Statistics::DebugLog("eMonth = " . $eMonth . "\n");
250 $eEpoch = timelocal(0, 0, 0, $eDay, $eMonth, $eYear-1900);
252 # This case happens when the page is first loaded
253 my @local = localtime(time);
254 ($eDay, $eMonth, $eYear) = ($local[3], $local[4], $local[5]);
256 $eEpoch = timelocal(0, 0, 0, $local[3], $local[4], $local[5], $local[6], $local[7], $local[8]);
257 Statistics::DebugLog("Setting eEpoch=$eEpoch from current time.\n");
260 if (($eEpoch < $sEpoch) || ($sEpoch == 0)) {
261 # We have an end, but not a start, or, overlapping.
263 # if $currentMonth is set, just set the day to 1
265 # set start vars from end, but with day set to 1
266 (undef, undef, undef, $sDay, $sMonth, $sYear) = localtime($eEpoch);
268 $sEpoch = timelocal(0, 0, 0, $sDay, $sMonth, $sYear);
270 # If the user has specified how many days back to go, use that,
271 # If not, set start to configured default period before end
273 $sEpoch = $eEpoch - ($days * $Statistics::secsPerDay);
275 $sEpoch = $eEpoch - ($Statistics::PerDayPeriod * $Statistics::secsPerDay);
277 (undef, undef, undef, $sDay, $sMonth, $sYear) = localtime($sEpoch);
282 # Compute days to chart.
283 # The +1 is because we need to generate one more date. If the user
284 # selected a 10 day range, we need to generate 11 days.
285 $diff = int(($eEpoch - $sEpoch + $Statistics::secsPerDay - 1) / $Statistics::secsPerDay)+1;
286 Statistics::DebugLog("Setting diff=$diff\n");
288 Statistics::DebugLog("sEpoch=$sEpoch, components=" . join(',', localtime($sEpoch)) . "\n");
289 Statistics::DebugLog("eEpoch=$eEpoch, components=" . join(',', localtime($eEpoch)) . "\n");
291 # Build the new query string
292 $QueryString = "queues=" . join("&queues=", @queues);
293 $QueryString .= "&sDay=$sDay&sMonth=$sMonth&sYear=$sYear&eDay=$eDay&eMonth=$eMonth&eYear=$eYear&weekends=$weekends";
298 # Set up the end date to be midnight(morning) of the date after the one the user wanted.
299 my $endRange = $eEpoch + $Statistics::secsPerDay;
301 until ($#dates == $diff) {
302 my $date = new RT::Date($session{CurrentUser});
303 $date->Set(Value=>$endRange - $n, Format => 'unix');
304 # Note: we used to adjust the time to local midnight, but
305 # none of the other date entry fields in RT seem to adjust, so we've stopped.
306 #Statistics::DebugLog("Before adjust to midnight date " . Statistics::FormatDate("%c", $date) . "\n");
307 $n+= $Statistics::secsPerDay;
308 # If we aren't showing weekends and this is one, decrement the number
309 # of days to show and skip to the next date.
310 if(!$weekends and Statistics::RTDateIsWeekend($date)) {$diff--; next;}
311 unshift @dates, $date;
312 Statistics::DebugLog("pushing date " . Statistics::FormatDate("%c", $date) . "\n");
313 unshift @{ $data[0] }, Statistics::FormatDate($Statistics::PerDayLabelDateFormat, $date);
316 # We put an extra day into the lists to cover up till midnight of the next day,
317 # But we don't want that to appear in the labels, so pop it off.
318 pop( @{ $data[0] } );
320 my $queue = new RT::Queues($session{CurrentUser});
323 my $QueueObj = new RT::Queue($session{'CurrentUser'});
324 $QueueObj->Load($queue);