import rt 3.2.2
[freeside.git] / rt / html / Ticket / Elements / Tabs
1 %# {{{ BEGIN BPS TAGGED BLOCK
2 %# 
3 %# COPYRIGHT:
4 %#  
5 %# This software is Copyright (c) 1996-2004 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., 675 Mass Ave, Cambridge, MA 02139, USA.
26 %# 
27 %# 
28 %# CONTRIBUTION SUBMISSION POLICY:
29 %# 
30 %# (The following paragraph is not intended to limit the rights granted
31 %# to you to modify and distribute this software under the terms of
32 %# the GNU General Public License and is only of importance to you if
33 %# you choose to contribute your changes and enhancements to the
34 %# community by submitting them to Best Practical Solutions, LLC.)
35 %# 
36 %# By intentionally submitting any modifications, corrections or
37 %# derivatives to this work, or any other work intended for use with
38 %# Request Tracker, to Best Practical Solutions, LLC, you confirm that
39 %# you are the copyright holder for those contributions and you grant
40 %# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
41 %# royalty-free, perpetual, license to use, copy, create derivative
42 %# works based on those contributions, and sublicense and distribute
43 %# those contributions and any derivatives thereof.
44 %# 
45 %# }}} END BPS TAGGED BLOCK
46 <& /Elements/Callback, Ticket => $Ticket, actions=> $actions, tabs => $tabs, %ARGS &>
47 <& /Elements/Tabs, 
48     tabs => $tabs, 
49     actions => $actions, 
50     current_tab => $current_tab, 
51     current_toptab => $current_toptab,
52     Title => $Title &> 
53 <%INIT>
54
55 my $tabs = {};
56 my $current_toptab = "Search/Build.html",
57 my $searchtabs = {};
58 my $actions;
59
60 if ( $Ticket) {
61         
62 my $id   = $Ticket->id();
63
64 if ( defined $session{'tickets'} ) {
65
66         # we have to update session data if we get new ItemMap
67         my $updatesession = 1 unless($session{'tickets'}->{'item_map'});
68
69         my $item_map = $session{'tickets'}->ItemMap;
70
71         if ($updatesession) {
72                 $session{'i'}++;
73                 $session{'tickets'}->PrepForSerialization();
74         }
75
76         # Don't display prev links if we're on the first ticket
77         if ($item_map->{$Ticket->Id}->{prev}) {
78                 $searchtabs->{'_a'} = {
79                             class => "nav",
80                             path => "Ticket/Display.html?id=" . $item_map->{first},
81                             title => '<< ' . loc('First') };
82                 $searchtabs->{"_b"} = { class => "nav",
83                             path => "Ticket/Display.html?id=" . $item_map->{$Ticket->Id}->{prev},
84                                   title => '< ' . loc('Prev') };
85        } 
86
87
88         # Don't display next links if we're on the last ticket
89         if ($item_map->{$Ticket->Id}->{next}) {
90             $searchtabs->{'d'} = { class => "nav",
91                             path => "Ticket/Display.html?id=" . $item_map->{$Ticket->Id}->{next},
92                              title => loc('Next') . ' >' };
93             $searchtabs->{'e'} = {
94                            class => "nav",
95                            path => "Ticket/Display.html?id=" . $item_map->{last},
96                            title => loc('Last') . ' >>' };
97         }
98 }
99
100
101
102 $tabs->{"this"} = { class => "currentnav",
103                     path  => "Ticket/Display.html?id=" . $Ticket->id,
104                     title => "#" . $id,
105                     current_subtab => $current_subtab };
106
107 my $ticket_page_tabs = {
108     _A => { title => loc('Display'),
109             path  => "Ticket/Display.html?id=" . $id, },
110
111     _Ab => { title => loc('History'),
112              path  => "Ticket/History.html?id=" . $id, },
113     _B => { title => loc('Basics'),
114             path  => "Ticket/Modify.html?id=" . $id, },
115
116     _C => { title => loc('Dates'),
117             path  => "Ticket/ModifyDates.html?id=" . $id, },
118     _D =>
119       { title => loc('People'), path => "Ticket/ModifyPeople.html?id=" . $id, },
120     _E => { title => loc('Links'),
121             path  => "Ticket/ModifyLinks.html?id=" . $id, },
122     _F => { title => loc('Jumbo'),
123             path  => "Ticket/ModifyAll.html?id=" . $id,
124             seperator => 1
125  },
126
127 };
128
129 foreach my $tab ( sort keys %{$ticket_page_tabs} ) {
130     if ( $ticket_page_tabs->{$tab}->{'path'} eq $current_tab ) {
131         $ticket_page_tabs->{$tab}->{"subtabs"}        = $subtabs;
132         $tabs->{'this'}->{"current_subtab"}        = 
133         $ticket_page_tabs->{$tab}->{"path"};
134     }
135 }
136 $tabs->{'this'}->{"subtabs"} = $ticket_page_tabs;
137 $current_tab = "Ticket/Display.html?id=" . $id;
138
139
140
141
142
143 if (    $Ticket->CurrentUserHasRight('ModifyTicket')
144      or $Ticket->CurrentUserHasRight('ReplyToTicket') ) {
145     $actions->{'A'} = { title => loc('Reply'),
146                         path  => "Ticket/Update.html?Action=Respond&id=" . $id,
147     };
148 }
149
150 if ( $Ticket->CurrentUserHasRight('ModifyTicket') ) {
151     if ( $Ticket->Status ne 'resolved' ) {
152         $actions->{'B'} = {
153
154             path => "Ticket/Update.html?Action=Comment&DefaultStatus=resolved&id=" . $id,
155             title => loc('Resolve') };
156     }
157     if ( $Ticket->Status ne 'open' ) {
158         $actions->{'C'} = { path => "Ticket/Display.html?Status=open&id=" . $id,
159                             title => loc('Open it') };
160     }
161 }
162
163 if ( $Ticket->CurrentUserHasRight('OwnTicket') ) {
164     if ( $Ticket->OwnerObj->id == $RT::Nobody->id ) {
165         $actions->{'D'} = { path => "Ticket/Display.html?Action=Take&id=" . $id,
166                             title => loc('Take') };
167     }
168     elsif ( $Ticket->OwnerObj->id != $session{CurrentUser}->id ) {
169         $actions->{'E'} = {path => "Ticket/Display.html?Action=Steal&id=" . $id,
170                            title => loc('Steal') };
171     }
172 }
173
174 if (    $Ticket->CurrentUserHasRight('ModifyTicket')
175      or $Ticket->CurrentUserHasRight('CommentOnTicket') ) {
176     $actions->{'F'} = { title => loc('Comment'),
177                         path  => "Ticket/Update.html?Action=Comment&id=" . $id,
178     };
179 }
180 }
181
182 my $args = "?" . $m->comp(
183     '/Elements/QueryString',
184     Query   => $ARGS{'Query'}   || $session{'CurrentSearchHash'}->{'Query'},
185     Format  => $ARGS{'Format'}  || $session{'CurrentSearchHash'}->{'Format'},
186     OrderBy => $ARGS{'OrderBy'} || $session{'CurrentSearchHash'}->{'OrderBy'},
187     Order   => $ARGS{'Order'}   || $session{'CurrentSearchHash'}->{'Order'},
188     Rows    => $ARGS{'Rows'},
189   ) if ($ARGS{'Query'} or $session{'CurrentSearchHash'}->{'Query'});
190
191 $tabs->{"f"} = { path      => "Search/Build.html?NewQuery=1",
192                  title     => loc('New Query')};
193 $tabs->{"g"} = { path      => "Search/Build.html$args",
194                  title     => loc('Query Builder')};
195 $tabs->{"h"} = { path      => "Search/Edit.html$args",
196                  title     => loc('Advanced'),
197                  separator => 1 };
198 if (defined $session{'tickets'} and $session{'tickets'}->Count) {
199   $tabs->{"i"} = { path      => "Search/Results.html$args",
200                    title     => loc('Show Results'),
201                    separator => 1,
202                    subtabs   => $searchtabs };
203   if ($current_tab =~  "Search/Results.html") {
204     $current_tab = "Search/Results.html$args";
205   }
206 }
207
208 </%INIT>
209
210   
211 <%ARGS>
212 $Ticket => undef
213 $subtabs => undef
214 $current_tab => undef
215 $current_subtab => undef
216 $Title => undef
217 </%ARGS>