import of rt 3.0.4
[freeside.git] / rt / html / Ticket / Update.html
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/Header, Title => $title &>
25 <& /Ticket/Elements/Tabs, 
26     Ticket => $Ticket , 
27     Title=> $title &>
28
29 <FORM ACTION="Update.html" NAME="TicketUpdate" 
30         METHOD=POST enctype="multipart/form-data">
31 <input type="hidden" name="QuoteTransaction" value="<% $ARGS{QuoteTransaction} %>">
32 <input type="hidden" name="DefaultStatus" value="<% $DefaultStatus %>">
33 <input type="hidden" name="Action" value="<% $ARGS{Action} %>">
34 <font size=-1>
35
36 <TABLE>
37 <TR><TD>
38 <a href="ModifyPeople.html?id=<%$Ticket->Id%>"><&|/l&>Ticket watchers</&></A></TD><TD align=right>
39 <&|/l&>Requestor</&>:
40 </TD><TD>
41 <b><% $Ticket->RequestorAddresses %></b>
42 </TD></TR>
43 <TR><TD>&nbsp;</TD><TD align=right>
44 <&|/l&>Cc</&>:
45 </TD><TD>
46 <b><% $Ticket->CcAddresses %></b>
47 </TD></TR>
48 <TR><TD>&nbsp;</TD><TD align=right>
49 <&|/l&>AdminCc</&>:
50 </TD><TD>
51 <b><% $Ticket->AdminCcAddresses %></b>
52 </TD></TR>
53 </TR>
54 </TABLE>
55 <hr>
56
57 <TABLE BORDER=0>
58
59 <tr><td align=right><&|/l&>Status</&>:</td>
60 <td>
61 <& /Elements/SelectStatus, Name=>"Status", Default => $DefaultStatus &>
62 <&|/l&>Owner</&>:  
63 <& /Elements/SelectOwner, Name=>"Owner", Default => ($ARGS{'Owner'} || $Ticket->OwnerObj->Id()), QueueObj => $Ticket->QueueObj, TicketObj => $Ticket &>
64 <&|/l&>Worked</&>: <input size=4 name="UpdateTimeWorked" value="<% $ARGS{UpdateTimeWorked}%>"> <&|/l&>minutes</&></td></tr>
65 <tr><td align=right><&|/l&>Update Type</&>:</td>
66 <td><select name="UpdateType">
67 % if ($CanComment) {
68   <option value="private" <%$CommentDefault%>><&|/l&>Comments (Not sent to requestors)</&></option>
69 % }
70 % if ($CanRespond) {
71    <option value="response" <%$ResponseDefault%>><&|/l&>Response to requestors</&></option>
72 % }
73 </select> 
74 </td></tr>
75 <tr><td align=right><&|/l&>Subject</&>:</td><td> <input name="UpdateSubject" size=60 value="<% ($ARGS{UpdateSubject}) ? $ARGS{UpdateSubject} : $Ticket->Subject()%>"></td></tr>
76 <tr><td align=right><&|/l&>Cc</&>:</td><td> <input name="UpdateCc" size=60
77 value=<% $ARGS{UpdateCc} %>><BR>
78 <i><font size=-2>
79 <&|/l&>(Sends a carbon-copy of this update to a comma-delimited list of email addresses. Does <b>not</b> change who will receive future updates.)</&></font></i>
80 </td></tr>
81 <tr><td align=right><&|/l&>Bcc</&>:</td><td> <input name="UpdateBcc" size=60 VALUE="<%$ARGS{UpdateBcc}%>"><BR>
82 <i><font size=-2>
83 <&|/l&>(Sends a blind carbon-copy of this update to a comma-delimited list of email addresses. Does <b>not</b> change who will receive future updates.)</&></font></i>
84 </td></tr>
85 % if (exists $session{'Attachments'}) {
86 <TD>
87 <&|/l&>Attached file</&>:
88 </TD>
89 <TD COLSPAN=5>
90 <&|/l&>Check box to delete</&><BR>
91 % foreach my $attach_name (keys %{$session{'Attachments'}}) {
92 <input type="checkbox" name="DeleteAttach-<%$attach_name%>"><%$attach_name%><BR>
93 % } # end of foreach
94 </TD>
95 </TR>
96 <TR>
97 % } # end of if
98 <tr><td align=right><&|/l&>Attach</&>:</td><td><input name="Attach" type="file"><INPUT TYPE=SUBMIT NAME="AddMoreAttach" VALUE="<&|/l&>Add More Files</&>"><input type="hidden" name="UpdateAttach" value="1">
99 </td></tr>
100 <tr><td align="right" valign="top"><&|/l&>Message</&>:</td><td>
101 <& /Elements/Callback, _CallbackName => 'BeforeMessageBox', %ARGS &>
102 % if (exists $ARGS{UpdateContent}) {
103 % delete $ARGS{'QuoteTransaction'};
104 <& /Elements/MessageBox, Name=>"UpdateContent", Default=>$ARGS{UpdateContent}, %ARGS&>
105 % } else {
106 <& /Elements/MessageBox, Name=>"UpdateContent", %ARGS &>
107 % }
108 </td></tr>
109                 <INPUT TYPE=HIDDEN NAME=id VALUE="<%$Ticket->Id%>"><br>
110 </table>
111
112
113
114
115 <& /Elements/Submit, Name => 'SubmitTicket' &>
116   </FORM>
117
118
119
120 <%INIT>
121
122 my $CanRespond = 0;
123 my $CanComment = 0;
124 my $title;
125
126 my $Ticket = LoadTicket($id);
127
128 unless($DefaultStatus){
129     $DefaultStatus=($ARGS{'Status'} ||$Ticket->Status());
130 }
131
132 if ($DefaultStatus =~ '^new$'){
133         $DefaultStatus='open';
134 }
135
136 if ($DefaultStatus eq 'resolved') {
137     $title = loc("Resolve ticket #[_1] ([_2])", $Ticket->id, $Ticket->Subject);
138 } else {
139     $title = loc("Update ticket #[_1] ([_2])", $Ticket->id, $Ticket->Subject);
140 }
141
142 # Things needed in the template - we'll do the processing here, just
143 # for the convenience:
144
145 my ($CommentDefault, $ResponseDefault);
146 if (($Action eq 'Comment') or ($ARGS{'UpdateType'} eq 'private')) {
147    $CommentDefault = "SELECTED"; 
148 } else {
149     $ResponseDefault = "SELECTED";
150 }
151
152
153 $CanRespond = 1 if ( $Ticket->CurrentUserHasRight('ReplyToTicket') or
154                      $Ticket->CurrentUserHasRight('ModifyTicket') ); 
155
156 $CanComment = 1 if ( $Ticket->CurrentUserHasRight('CommentOnTicket') or
157                      $Ticket->CurrentUserHasRight('ModifyTicket') ); 
158
159
160 # {{{ deal with deleting uploaded attachments
161 foreach my $key (keys %ARGS) {
162     if ($key =~ m/^DeleteAttach-(.+)$/) {
163         delete $session{'Attachments'}{$1};
164     }
165     $session{'Attachments'} = { %{$session{'Attachments'} || {}} };
166 }
167
168 # {{{ store the uploaded attachment in session
169 if ($ARGS{'Attach'}) {                  # attachment?
170     $session{'Attachments'} = {} unless defined $session{'Attachments'};
171
172     my $subject = "$ARGS{'Attach'}";
173     # since CGI.pm deutf8izes the magic field, we need to add it back.
174     Encode::_utf8_on($subject);
175     # strip leading directories
176     $subject =~ s#^.*[\\/]##;
177
178     my $attachment = MakeMIMEEntity(
179         Subject             => $subject,
180         Body                => "",
181         AttachmentFieldName => 'Attach'
182     );
183
184     $session{'Attachments'} = { %{$session{'Attachments'} || {}},
185                                 $ARGS{'Attach'} => $attachment };
186 }
187 # }}}
188
189 # delete temporary storage entry to make WebUI clean
190 unless (keys %{$session{'Attachments'}} and $ARGS{'UpdateAttach'}) {
191     delete $session{'Attachments'};
192 }
193 # }}}
194
195 if ( exists $ARGS{SubmitTicket} ) {
196     $m->comp('Display.html', %ARGS);
197     return;
198 }
199 </%INIT>
200
201 <%ARGS>
202 $id => undef
203 $Action => undef
204 $DefaultStatus => undef
205 </%ARGS>