import rt 3.2.2
[freeside.git] / rt / html / Elements / TicketList
1 %# BEGIN LICENSE BLOCK;
2 %# 
3 %# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
4 %# 
5 %# (Except where explictly superceded by other copyright notices)
6 %# 
7 %# This work is made available to you under the terms of Version 2 of
8 %# the GNU General Public License. A copy of that license should have
9 %# been provided with this software, but in any event can be snarfed
10 %# from www.gnu.org.
11 %# 
12 %# This work is distributed in the hope that it will be useful, but
13 %# WITHOUT ANY WARRANTY; without even the implied warranty of
14 %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 %# General Public License for more details.
16 %# 
17 %# Unless otherwise specified, all modifications, corrections or
18 %# extensions to this work which alter its source code become the
19 %# property of Best Practical Solutions, LLC when submitted for
20 %# inclusion in the work.
21 %# 
22 %# 
23 %# END LICENSE BLOCK
24
25 %# If you're having TicketList display a single record, you need
26 %# to wrap the calls in your own table(s).
27 % unless (defined $SingleRecord) {
28 <TABLE BORDER=0 cellspacing=0 cellpadding=1 WIDTH=100%>
29 % }
30
31 % if ($ShowHeader) {
32 <& /Elements/CollectionAsTable/Header, 
33     Format => \@Format, 
34     AllowSorting => $AllowSorting, 
35     Order => $Order, 
36     Query => $Query,
37     Rows => $Rows,
38     Page => $Page,
39     OrderBy => $OrderBy , 
40     BaseURL => $BaseURL,
41     maxitems => \$maxitems &> 
42 % }
43
44 % if (defined $SingleRecord) {
45 <&   /Elements/CollectionAsTable/Row, Format => \@Format, i => 0, record => $SingleRecord, maxitems => $maxitems &>
46 % } else {
47 %   my $i;
48 %   while (my $record = $Collection->Next) {
49 %   $i++;
50 <&   /Elements/CollectionAsTable/Row, Format => \@Format, i => $i, record => $record, maxitems => $maxitems &>
51 %   }
52 % }
53
54 % unless (defined $SingleRecord) {
55 </TABLE>
56 % }
57
58 % if ($ShowNavigation) {
59 <hr>
60 <&|/l, $Page, int($TotalFound/$Rows)+1&>Page [_1] of [_2]</&>
61
62 <%perl>
63 my $prev =  $m->comp('/Elements/QueryString',
64                      Query => $Query,
65                      Format => $Format,
66                      Rows => $Rows,
67                      OrderBy => $OrderBy,
68                      Order => $Order,
69                      Page => ($Page-1));
70 my $next =  $m->comp('/Elements/QueryString',
71                      Query => $Query,
72                      Format => $Format,
73                      Rows => $Rows,
74                      OrderBy => $OrderBy,
75                      Order => $Order,
76                      Page => ($Page+1));
77 </%perl>
78 % if ($Page > 1) {
79 <A href="<%$BaseURL%><%$prev%>"><&|/l&>Previous Page</&></a>
80 % }
81 % if (($Page * $Rows) < $TotalFound) {
82 <A href="<%$BaseURL%><%$next%>"><&|/l&>Next Page</&></a>
83 % }
84 % }
85 <%INIT>
86 my $maxitems;
87
88 $Format ||= $RT::DefaultSearchResultFormat;
89 # Scrub the html of the format string to remove any potential nasties.
90 $Format = $m->comp('/Elements/ScrubHTML', Content => $Format);
91
92 $Rows ||= '25'; # we need a positive value
93
94 unless ($Collection) {
95         $Collection = RT::Tickets->new($session{'CurrentUser'});
96         $Collection->FromSQL($Query);
97 }
98
99 my (@Format) = $m->comp('/Elements/CollectionAsTable/ParseFormat', Format => $Format);
100
101 $Collection->OrderBy(FIELD => $OrderBy, ORDER => $Order); 
102 $Collection->RowsPerPage($Rows);
103 $Collection->GotoPage($Page-1); # SB uses page 0 as the first page
104 my $TotalFound =  $Collection->CountAll();
105
106 </%INIT>
107 <%ARGS>
108 $Query => undef
109 $Rows => 10
110 $Page => 1
111 $Title => 'Ticket Search'
112 $Collection => undef
113 $SingleRecord => undef
114 $AllowSorting => undef
115 $Order => undef
116 $OrderBy => undef
117 $BaseURL => undef
118 $Format => $RT::DefaultSearchResultFormat
119 $ShowNavigation => 1
120 $ShowHeader => 1
121 </%ARGS>