import of rt 3.0.4
[freeside.git] / rt / html / Ticket / Elements / Tabs
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 <& /Elements/Callback, Ticket => $Ticket, actions=> $actions, tabs => $tabs, %ARGS &>
25 <& /Elements/Tabs, 
26     tabs => $tabs, 
27     actions => $actions, 
28     current_tab => $current_tab, 
29     current_toptab => $current_toptab,
30     Title => $Title &> 
31 <%INIT>
32
33 my $tabs = {};
34 my $current_toptab = "Search/Listing.html",
35     my $searchtabs = { new => { title => loc('New Search'),
36                                 path => 'Search/Listing.html?ClearRestrictions=1'}
37                         
38
39 } ;
40 my $actions;
41
42 if ( $Ticket) {
43         
44 my $id   = $Ticket->id();
45
46 if ( defined $session{'tickets'} ) {
47
48
49 my $item_map = $session{'tickets'}->ItemMap;
50
51             # Don't $current_toptab = display prev links if we're on the first ticket
52
53         if ($item_map->{$Ticket->Id}->{prev}) {
54                 $searchtabs->{'_a'} = {
55                             class => "nav",
56                             path => "Ticket/Display.html?id=" . $item_map->{first},
57                             title => '<< ' . loc('First') };
58                 $searchtabs->{"_b"} = { class => "nav",
59                             path => "Ticket/Display.html?id=" . $item_map->{$Ticket->Id}->{prev},
60                                   title => '< ' . loc('Prev') };
61        } 
62
63
64         # Don't display next links if we're on the last ticket
65         if ($item_map->{$Ticket->Id}->{next}) {
66             $searchtabs->{'d'} = { class => "nav",
67                             path => "Ticket/Display.html?id=" . $item_map->{$Ticket->Id}->{next},
68                              title => loc('Next') . ' >' };
69             $searchtabs->{'e'} = {
70                            class => "nav",
71                            path => "Ticket/Display.html?id=" . $item_map->{last},
72                            title => loc('Last') . ' >>' };
73         }
74 }
75
76
77
78 $tabs->{"this"} = { class => "currentnav",
79                     path  => "Ticket/Display.html?id=" . $Ticket->id,
80                     title => "#" . $id,
81                     current_subtab => $current_subtab };
82
83 my $ticket_page_tabs = {
84     _A => { title => loc('Display'),
85             path  => "Ticket/Display.html?id=" . $id, },
86
87     _Ab => { title => loc('History'),
88              path  => "Ticket/History.html?id=" . $id, },
89     _B => { title => loc('Basics'),
90             path  => "Ticket/Modify.html?id=" . $id, },
91
92     _C => { title => loc('Dates'),
93             path  => "Ticket/ModifyDates.html?id=" . $id, },
94     _D =>
95       { title => loc('People'), path => "Ticket/ModifyPeople.html?id=" . $id, },
96     _E => { title => loc('Links'),
97             path  => "Ticket/ModifyLinks.html?id=" . $id, },
98     _F => { title => loc('Jumbo'),
99             path  => "Ticket/ModifyAll.html?id=" . $id,
100             seperator => 1
101  },
102
103 };
104
105 foreach my $tab ( sort keys %{$ticket_page_tabs} ) {
106     if ( $ticket_page_tabs->{$tab}->{'path'} eq $current_tab ) {
107         $ticket_page_tabs->{$tab}->{"subtabs"}        = $subtabs;
108         $tabs->{'this'}->{"current_subtab"}        = 
109         $ticket_page_tabs->{$tab}->{"path"};
110     }
111 }
112 $tabs->{'this'}->{"subtabs"} = $ticket_page_tabs;
113 $current_tab = "Ticket/Display.html?id=" . $id;
114
115
116
117
118
119 if (    $Ticket->CurrentUserHasRight('ModifyTicket')
120      or $Ticket->CurrentUserHasRight('ReplyToTicket') ) {
121     $actions->{'A'} = { title => loc('Reply'),
122                         path  => "Ticket/Update.html?Action=Respond&id=" . $id,
123     };
124 }
125
126 if ( $Ticket->CurrentUserHasRight('ModifyTicket') ) {
127     if ( $Ticket->Status ne 'resolved' ) {
128         $actions->{'B'} = {
129
130             path => "Ticket/Update.html?Action=Comment&DefaultStatus=resolved&id=" . $id,
131             title => loc('Resolve') };
132     }
133     if ( $Ticket->Status ne 'open' ) {
134         $actions->{'C'} = { path => "Ticket/Display.html?Status=open&id=" . $id,
135                             title => loc('Open it') };
136     }
137 }
138
139 if ( $Ticket->CurrentUserHasRight('OwnTicket') ) {
140     if ( $Ticket->OwnerObj->id == $RT::Nobody->id ) {
141         $actions->{'D'} = { path => "Ticket/Display.html?Action=Take&id=" . $id,
142                             title => loc('Take') };
143     }
144     elsif ( $Ticket->OwnerObj->id != $session{CurrentUser}->id ) {
145         $actions->{'E'} = {path => "Ticket/Display.html?Action=Steal&id=" . $id,
146                            title => loc('Steal') };
147     }
148 }
149
150 if (    $Ticket->CurrentUserHasRight('ModifyTicket')
151      or $Ticket->CurrentUserHasRight('CommentOnTicket') ) {
152     $actions->{'F'} = { title => loc('Comment'),
153                         path  => "Ticket/Update.html?Action=Comment&id=" . $id,
154     };
155 }
156 }
157 $tabs->{"g"} = { path      => 'Search/Listing.html',
158                  title     => loc('Search'),
159                  separator => 1,
160                  subtabs   => $searchtabs };
161 </%INIT>
162
163   
164 <%ARGS>
165 $Ticket => undef
166 $subtabs => undef
167 $current_tab => undef
168 $current_subtab => undef
169 $Title => undef
170 </%ARGS>