import rt 3.6.6
[freeside.git] / rt / html / Search / Results.html
1 %# BEGIN BPS TAGGED BLOCK {{{
2 %# 
3 %# COPYRIGHT:
4 %#  
5 %# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC 
6 %#                                          <jesse@bestpractical.com>
7 %# 
8 %# (Except where explicitly superseded by other copyright notices)
9 %# 
10 %# 
11 %# LICENSE:
12 %# 
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
16 %# from www.gnu.org.
17 %# 
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.
22 %# 
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.
28 %# 
29 %# 
30 %# CONTRIBUTION SUBMISSION POLICY:
31 %# 
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.)
37 %# 
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.
46 %# 
47 %# END BPS TAGGED BLOCK }}}
48 <& /Elements/Header, Title => $title, Refresh => $session{'tickets_refresh_interval'}, 
49     RSSAutoDiscovery => $RSSFeedURL &>
50 <& /Ticket/Elements/Tabs, 
51     current_tab => "Search/Results.html".$QueryString, 
52     Title => $title,
53     Format => $Format,
54     Query => $Query,
55     Rows => $Rows,
56     OrderBy => $OrderBy,
57     Order => $Order &>
58 <& /Elements/TicketList, 
59     Query => $Query,
60     AllowSorting => 1,
61     OrderBy => $OrderBy,
62     Order => $Order,
63     Rows => $Rows,
64     Page => $Page,
65     Format => $Format,
66     BaseURL => $RT::WebPath."/Search/Results.html?"
67
68    &>
69 % my %hiddens = (Query => $Query, Format => $Format,  Rows => $Rows, OrderBy => $OrderBy,  Order => $Order, HideResults => $HideResults, Page => $Page );
70 <div align="right">
71 <form method="get" action="<%$RT::WebPath%>/Search/Results.html">
72 %foreach my $key (keys(%hiddens)) {
73 <input type="hidden" class="hidden" name="<%$key%>" value="<%defined($hiddens{$key})?$hiddens{$key}:''%>"/>
74 %}
75 <& /Elements/Refresh, Name => 'TicketsRefreshInterval', Default => $session {'tickets_refresh_interval'} &>
76 <input type="submit" class="button" value="<&|/l&>Go!</&>" />
77 </form>
78 </div>
79 <div align="right">
80 <a href="<%$RT::WebPath%>/Search/Bulk.html<%$QueryString%>"><&|/l&>Update multiple tickets</&></a><br />
81 <a href="<%$RT::WebPath%>/Search/Results.html<%$QueryString%>"><&|/l&>Bookmarkable link</&></a><br />
82 <a href="<%$RT::WebPath%>/Search/Results.tsv<%$QueryString%>"><&|/l&>spreadsheet</&></a> |
83 <a href="<%$RSSFeedURL%>"><&|/l&>RSS</&></a> |
84 <a href="<%$RT::WebPath%>/Tools/Offline.html<%$ShortQueryString%>"><&|/l&>Work offline</&></a><br />
85 <form method="get" action="<%$RT::WebPath%>/Search/Chart.html"><&|/l&>chart</&>
86 % %hiddens = (Query => $Query, Format => $Format,  Rows => $Rows, OrderBy => $OrderBy,  Order => $Order);
87 %foreach my $key (keys(%hiddens)) {
88 <input type="hidden" class="hidden" name="<%$key%>" value="<%defined($hiddens{$key})?$hiddens{$key}:''%>"/>
89 %}
90 <&|/l, $m->scomp('Elements/SelectGroupBy', Name => 'PrimaryGroupBy', Query => $Query) &>grouped by [_1]</&>
91 <&|/l, $m->scomp('Elements/SelectChartType', Name => 'ChartStyle') &>style: [_1]</&>
92 <input type="submit" class="button" value="<%loc('Go!')%>" />
93 </form>
94 <& /Elements/Callback, _CallbackName => 'SearchActions', QueryString => $QueryString&>
95 </div>
96 <%INIT>
97 # Read from user preferences
98 my $prefs = $session{'CurrentUser'}->UserObj->Preferences("SearchDisplay") || {};
99
100 # These variables are what define a search_hash; this is also
101 # where we give sane defaults.
102 $Format      ||= $prefs->{'Format'};
103 $Order       ||= $prefs->{'Order'} || 'ASC';
104 $OrderBy     ||= $prefs->{'OrderBy'} || 'id';
105
106 # Some forms pass in "RowsPerPage" rather than "Rows"
107 # We call it RowsPerPage everywhere else.
108
109 if ( !defined($Rows) ) {
110     if ( $ARGS{'RowsPerPage'} ) {
111         $Rows = $ARGS{'RowsPerPage'};
112     } elsif ( defined $prefs->{'RowsPerPage'} ) {
113         $Rows = $prefs->{'RowsPerPage'};
114     } else {
115         $Rows = 50;
116     }
117 }
118
119 my ($title, $ticketcount);
120 $session{'i'}++;
121 $session{'tickets'} = RT::Tickets->new($session{'CurrentUser'}) ;
122 $session{'tickets'}->FromSQL($Query) if ($Query);
123
124 if ($OrderBy =~ /\|/) {
125     # Multiple Sorts
126     my @OrderBy = split /\|/,$OrderBy;
127     my @Order = split /\|/,$Order;
128     $session{'tickets'}->OrderByCols(
129         map { { FIELD => $OrderBy[$_], ORDER => $Order[$_] } } ( 0
130         .. $#OrderBy ) );; 
131 } else {
132     $session{'tickets'}->OrderBy(FIELD => $OrderBy, ORDER => $Order); 
133 }
134
135 $session{'CurrentSearchHash'} = {
136     Format      => $Format,
137     Query       => $Query,
138     Page       => $Page,
139     Order       => $Order,
140     OrderBy     => $OrderBy,
141     RowsPerPage => $Rows
142     };
143
144
145 if ( $session{'tickets'}->Query()) {
146     $ticketcount = $session{tickets}->CountAll();
147     $title = loc('Found [quant,_1,ticket]', $ticketcount);
148 } else {
149     $title = loc("Find tickets");
150 }
151
152 my $QueryString = "?".$m->comp('/Elements/QueryString',
153                                Query => $Query,
154                                Format => $Format,
155                                Rows => $Rows,
156                                OrderBy => $OrderBy,
157                                Order => $Order,
158                                Page => $Page);
159 my $ShortQueryString = "?".$m->comp('/Elements/QueryString', Query => $Query);
160 my $RSSFeedURL = "$RT::WebPath/Search/Results.rdf$ShortQueryString";
161
162 if ($ARGS{'TicketsRefreshInterval'}) {
163         $session{'tickets_refresh_interval'} = $ARGS{'TicketsRefreshInterval'};
164 }
165 </%INIT>
166 <%CLEANUP>
167 $session{'tickets'}->PrepForSerialization();
168 </%CLEANUP>
169 <%ARGS>
170 $Query => undef
171 $Format => undef 
172 $HideResults => 0
173 $Rows => undef
174 $Page => 1
175 $OrderBy => undef
176 $Order => undef
177 </%ARGS>