1 %# BEGIN BPS TAGGED BLOCK {{{
5 %# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC
6 %# <jesse@bestpractical.com>
8 %# (Except where explicitly superseded by other copyright notices)
13 %# This work is made available to you under the terms of Version 2 of
14 %# the GNU General Public License. A copy of that license should have
15 %# been provided with this software, but in any event can be snarfed
18 %# This work is distributed in the hope that it will be useful, but
19 %# WITHOUT ANY WARRANTY; without even the implied warranty of
20 %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 %# General Public License for more details.
23 %# You should have received a copy of the GNU General Public License
24 %# along with this program; if not, write to the Free Software
25 %# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 %# 02110-1301 or visit their web page on the internet at
27 %# http://www.gnu.org/copyleft/gpl.html.
30 %# CONTRIBUTION SUBMISSION POLICY:
32 %# (The following paragraph is not intended to limit the rights granted
33 %# to you to modify and distribute this software under the terms of
34 %# the GNU General Public License and is only of importance to you if
35 %# you choose to contribute your changes and enhancements to the
36 %# community by submitting them to Best Practical Solutions, LLC.)
38 %# By intentionally submitting any modifications, corrections or
39 %# derivatives to this work, or any other work intended for use with
40 %# Request Tracker, to Best Practical Solutions, LLC, you confirm that
41 %# you are the copyright holder for those contributions and you grant
42 %# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
43 %# royalty-free, perpetual, license to use, copy, create derivative
44 %# works based on those contributions, and sublicense and distribute
45 %# those contributions and any derivatives thereof.
47 %# END BPS TAGGED BLOCK }}}
54 my $Tickets = RT::Tickets->new( $session{'CurrentUser'} );
55 $Tickets->FromSQL( $ARGS{'Query'} );
56 if ( $OrderBy =~ /\|/ ) {
59 my @OrderBy = split /\|/, $OrderBy;
60 my @Order = split /\|/, $Order;
61 $Tickets->OrderByCols(
62 map { { FIELD => $OrderBy[$_], ORDER => $Order[$_] } }
66 $Tickets->OrderBy( FIELD => $OrderBy, ORDER => $Order );
72 my @attrs = qw( id QueueObj->Name Subject Status TimeEstimated TimeWorked TimeLeft Priority FinalPriority OwnerObj->Name
73 Requestors->MemberEmailAddressesAsString Cc->MemberEmailAddressesAsString AdminCc->MemberEmailAddressesAsString
74 DueObj->ISO ToldObj->ISO CreatedObj->ISO ResolvedObj->ISO LastUpdatedObj->ISO);
76 $r->content_type('application/vnd.ms-excel');
77 while ( my $Ticket = $Tickets->Next()) {
79 foreach my $attr (@attrs) {
80 if ($attr =~ /(.*)->ISO$/ and $Ticket->$1->Unix <= 0) {
83 my $method = '$Ticket->'.$attr.'()';
84 $row->{$attr} = eval $method;
85 if ($@) {die "Failed to find $attr - ". $@};
89 my $cfs = $Ticket->QueueObj->TicketCustomFields();
90 while (my $cf = $cfs->Next) {
92 my $values = $Ticket->CustomFieldValues($cf->Id);
93 while (my $value = $values->Next) {
94 push @content, $value->Content;
96 $row->{'CustomField-'.$cf->Id} = join(', ',@content);
97 if ($row->{'CustomField-'.$cf->Id}) {
98 $known_cfs{$cf->Id} = $cf->Name;
106 foreach my $attr (@attrs) {
108 $label =~ s'Obj-.(?:AsString|Name|ISO)''g;
109 $label =~ s'-\>MemberEmailAddressesAsString''g;
110 push @header, $label;
112 foreach my $id (sort keys %known_cfs) {
113 push @header, "CF-".$known_cfs{$id};
115 $m->out(join("\t", @header));
119 foreach my $row (@rows) {
121 foreach my $attr(@attrs) {
122 push @row, $row->{"$attr"};
124 foreach my $id (sort keys %known_cfs) {
125 my $val = $row->{'CustomField-'.$id};
126 $val =~ s/(\n|\r)//g;
129 $m->out(join("\t",@row));