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