This commit was generated by cvs2svn to compensate for changes in r2523,
[freeside.git] / rt / webrt / SelfService / Display.html
1 %# $Header: /home/cvs/cvsroot/freeside/rt/webrt/SelfService/Attic/Display.html,v 1.1 2002-08-12 06:17:09 ivan Exp $
2 %# Copyright 1996-2001 Jesse Vincent <jesse@fsck.com>
3
4 <& /SelfService/Elements/Header, Title => 'Display ticket #'.$Ticket->id &>
5
6
7 <& /Elements/ListActions, actions => \@results &>
8
9 <TABLE>
10     <TR>
11         <TD VALIGN=TOP WIDTH="20%" ALIGN=RIGHT>
12         Ticket Id
13         </TD>
14       <TD>
15         <%$Ticket->Id%>
16         </TD>
17       </TR>
18     <TR>        
19       <TD VALIGN=TOP WIDTH="20%" ALIGN=RIGHT>
20         Requestors
21         </TD>
22       <TD>
23         <%$Ticket->RequestorsAsString%>
24       </TD>
25       </TR>
26     <TR>        
27       <TD VALIGN=TOP WIDTH="20%" ALIGN=RIGHT>
28         Cc
29         </TD>
30       <TD>
31         <%$Ticket->CcAsString%>
32       </TD>
33     </TR>
34
35   <TR>  
36       <TD VALIGN=TOP WIDTH="20%" ALIGN=RIGHT>
37         Status
38         </TD>
39       <TD>
40         <%$Ticket->Status%>
41       </TD>
42     </TR>
43
44     <TR>        
45       <TD VALIGN=TOP WIDTH="20%" ALIGN=RIGHT>
46         Queue
47         </TD>
48       <TD>
49         <%$Ticket->QueueObj->Name%> (<%$Ticket->QueueObj->Description%>)
50       </TD>
51     </TR>
52     <TR>        
53       <TD VALIGN=TOP WIDTH="20%" ALIGN=RIGHT>
54         Priority
55       </TD>
56       <TD>
57         <%$Ticket->Priority %>
58       </TD>
59     </TR>
60  
61 %  if ($Ticket->TimeWorked) {
62    <TR> 
63       <TD VALIGN=TOP WIDTH="20%" ALIGN=RIGHT>
64         Worked
65       </TD>
66       <TD>
67         <%$Ticket->TimeWorked %> minutes
68       </TD>
69     </TR>
70 % }
71     
72 % my $selects = $Ticket->QueueObj->KeywordSelects;
73 % while (my $select = $selects->Next) {
74     <TR>
75       <TD VALIGN=TOP WIDTH="20%" ALIGN=RIGHT>
76         <%$select->Name%>
77       </TD>
78       <TD>
79 % my $object_keywords = $Ticket->KeywordsObj($select->id);      
80 % while (my $keyword = $object_keywords->Next) {
81         <%$keyword->KeywordObj->RelativePath($select->KeywordObj)%>
82 % }
83 %}
84         </TD>
85       </TR>
86
87
88
89
90         </TABLE>
91 <TABLE BORDER=0 CELLSPACING=0>
92 % my ($i);
93 %while (my $Transaction = $Transactions->Next) {
94 % $i++;
95 %       if ($Transactions->IsLast) {
96         <a name="lasttrans"></a>
97 %       }
98         <& /Ticket/Elements/ShowTransaction, Transaction => $Transaction, 
99                                              RowNum => $i,
100                                              Ticket => $Ticket &>
101
102 %}
103 </TABLE>
104
105
106 <%INIT>
107
108 my ($field, @results);
109
110 # {{{ Load the ticket
111 #If we get handed two ids, mason will make them an array. bleck.
112 # We want teh first one. Just because there's no other sensible way
113 # to deal
114 my @id = (ref $id eq 'ARRAY') ? @{$id} : ($id);                
115
116
117 my $Ticket = new RT::Ticket($session{'CurrentUser'});
118 if ($id[0] eq 'new') {
119     # {{{ Create a new ticket
120     
121     my $Queue = new RT::Queue($session{'CurrentUser'}); 
122     unless ($Queue->Load($ARGS{'Queue'})) {
123         $m->comp('Error.html', Why => 'Queue not found');
124         $m->abort;
125     }
126     
127     unless ($Queue->CurrentUserHasRight('CreateTicket')) {
128         $m->comp('Error.html', Why => 'You have no permission to create tickets in that queue.');
129         $m->abort; 
130     }
131     
132     my @Requestors = split(/,/,$ARGS{'Requestors'});
133     my @Cc = split(/,/,$ARGS{'Cc'});
134     
135
136     my $MIMEObj = MakeMIMEEntity ( Subject => $ARGS{'Subject'},
137                                    From => $ARGS{'From'},
138                                    Cc => $ARGS{'Cc'},
139                                    Body => $ARGS{'Content'},
140                                    AttachmentFieldName => 'Attach');
141
142     #TODO in Create_Details.html: priorities and due-date      
143     my ($id, $Trans, $ErrMsg)= $Ticket->Create(Queue=>$ARGS{Queue},
144                                                Requestor=> \@Requestors,
145                                                Cc => \@Cc,
146                                                Subject=>$ARGS{Subject},
147                                                MIMEObj => $MIMEObj        
148                                               );         
149     unless ($id && $Trans) {
150         $m->comp('Error.html', Why => $ErrMsg);
151         $m->abort(); 
152     }
153
154     push(@results, $ErrMsg);
155
156     # }}}
157 }
158 else {
159     unless ($Ticket->Load($id[0])) {
160         $m->comp('Error.html', Why =>"Couldn't load ticket '$id'");
161         $m->abort();
162     }
163 }
164 # }}}
165
166 unless ($session{'CurrentUser'}->HasQueueRight ( TicketObj => $Ticket,
167                                                  Right => 'ShowTicket')) {
168     $m->comp('Error.html', Why => "No permission to display that ticket");
169     $m->abort();
170 }
171
172 my ($code, $msg);
173
174 #Update the status
175 if ((defined $ARGS{'Status'}) and 
176     ($ARGS{'Status'} ne $Ticket->Status)) {
177     ($code, $msg) = $Ticket->SetStatus($ARGS{'Status'});
178     push @results, "$msg";
179 }
180
181 ProcessUpdateMessage(ARGSRef=>\%ARGS, Actions=>\@results, TicketObj=>$Ticket);
182
183 my $Transactions = $Ticket->Transactions;
184
185 </%INIT>
186
187
188 <%ARGS>
189 $id => undef
190 </%ARGS>