This commit was generated by cvs2svn to compensate for changes in r3921,
[freeside.git] / rt / html / Elements / CollectionAsTable / Header
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 <%ARGS>
26 @Format => undef
27 $AllowSorting => undef
28 $Order=>undef
29 $BaseURL => undef
30 $Query => undef
31 $Rows => undef
32 $Page => undef
33 $maxitems => undef
34 </%ARGS>
35 <TR>
36 <%perl>
37
38 my %generic_query_args = ( Query => $Query, Rows => $Rows, Page => $Page );
39
40 my $item = 0;
41 $$maxitems = 0;
42 foreach my $col (@Format) {
43     $item++;
44     $$maxitems = $item if $item > $$maxitems;
45     if ( $col->{title} eq 'NEWLINE' ) {
46         $m->out('</TR>       <TR>');
47         $item = 0;
48     }
49     else {
50         $m->out('<TH align="center">');
51         my $title = $col->{title};
52         $title =~ s/^__(.*)__$/$1/o;
53         $title = ( $m->comp('/Elements/RT__Ticket/ColumnMap', 
54                      Name => $title, 
55                      Attr => 'title' 
56                  )  
57                      || $title
58                  );
59         if (   $AllowSorting
60             && $col->{'attribute'}
61             && $m->comp('/Elements/RT__Ticket/ColumnMap',
62                           Name => $col->{'attribute'},
63                           Attr => 'attribute' ) 
64            )
65         {
66
67             $m->out(
68                 '<a href="' . $BaseURL 
69                   . $m->comp(
70                     '/Elements/QueryString',
71                     %generic_query_args,
72                     OrderBy => (
73                         $m->comp('/Elements/RT__Ticket/ColumnMap',
74                           Name => $col->{'attribute'},
75                           Attr => 'attribute' 
76                     )
77                           || $col->{'attribute'}
78                     ),
79                     Order => ( $ARGS{'Order'} eq 'ASC' ? 'DESC' : 'ASC' )
80                   ).
81                   '">' . loc($title) . '</a>'
82             );
83         }
84         else {
85             $m->out( loc($title) );
86         }
87         $m->out('</TH>');
88     }
89 }
90 </%perl>
91 </TR>