This commit was generated by cvs2svn to compensate for changes in r9232,
[freeside.git] / rt / share / html / Ticket / Update.html
1 %# BEGIN BPS TAGGED BLOCK {{{
2 %# 
3 %# COPYRIGHT:
4 %# 
5 %# This software is Copyright (c) 1996-2009 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., 51 Franklin Street, Fifth Floor, Boston, MA
26 %# 02110-1301 or visit their web page on the internet at
27 %# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
28 %# 
29 %# 
30 %# CONTRIBUTION SUBMISSION POLICY:
31 %# 
32 %# (The following paragraph is not intended to limit the rights granted
33 %# to you to modify and distribute this software under the terms of
34 %# the GNU General Public License and is only of importance to you if
35 %# you choose to contribute your changes and enhancements to the
36 %# community by submitting them to Best Practical Solutions, LLC.)
37 %# 
38 %# By intentionally submitting any modifications, corrections or
39 %# derivatives to this work, or any other work intended for use with
40 %# Request Tracker, to Best Practical Solutions, LLC, you confirm that
41 %# you are the copyright holder for those contributions and you grant
42 %# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
43 %# royalty-free, perpetual, license to use, copy, create derivative
44 %# works based on those contributions, and sublicense and distribute
45 %# those contributions and any derivatives thereof.
46 %# 
47 %# END BPS TAGGED BLOCK }}}
48 <& /Elements/Header, Title => $title &>
49 <& /Ticket/Elements/Tabs, 
50     Ticket => $TicketObj, 
51     Title=> $title &>
52     
53 % $m->callback(CallbackName => 'BeforeActionList', ARGSRef => \%ARGS, Ticket => $TicketObj);
54 <& /Elements/ListActions, actions => \@results &>
55
56 <form action="Update.html" name="TicketUpdate"
57     method="post" enctype="multipart/form-data">
58 % $m->callback( CallbackName => 'FormStart', ARGSRef => \%ARGS, Ticket => $TicketObj, CanRespond => $CanRespond, CanComment => $CanComment, ResponseDefault => $ResponseDefault, CommentDefault => $CommentDefault );
59 <input type="hidden" class="hidden" name="QuoteTransaction" value="<% $ARGS{QuoteTransaction}||'' %>" />
60 <input type="hidden" class="hidden" name="DefaultStatus" value="<% $DefaultStatus ||''%>" />
61 <input type="hidden" class="hidden" name="Action" value="<% $ARGS{Action}||'' %>" />
62
63 <& /Elements/GnuPG/SignEncryptWidget:ShowIssues, self => $gnupg_widget &>
64
65 <table width="100%" border="0">
66 % $m->callback(CallbackName => 'AfterTableOpens', ARGSRef => \%ARGS, Ticket => $TicketObj);
67
68 <tr><td class="label"><&|/l&>Status</&>:</td>
69 <td>
70 <& /Elements/SelectStatus, Name=>"Status", DefaultLabel => loc("[_1] (Unchanged)", loc($TicketObj->Status)), Default => $ARGS{'Status'} || ($TicketObj->Status eq $DefaultStatus ? undef : $DefaultStatus)&>
71 <span class="label"><&|/l&>Owner</&>:</span>
72 <& /Elements/SelectOwner,
73     Name         => "Owner",
74     TicketObj    => $TicketObj,
75     QueueObj     => $TicketObj->QueueObj,
76     DefaultLabel => loc("[_1] (Unchanged)", $TicketObj->OwnerObj->Name),
77     Default      => $ARGS{'Owner'}
78 &>
79 <span class="label"><&|/l&>Worked</&>:</span>
80 <& /Elements/EditTimeValue,
81     Name => 'UpdateTimeWorked',
82     Default => $ARGS{UpdateTimeWorked}||'',
83     InUnits => $ARGS{'UpdateTimeWorked-TimeUnits'}||'minutes',
84 &>
85 </td></tr>
86 % my $skip;
87 % $m->callback( %ARGS, CallbackName => 'BeforeUpdateType', skip => \$skip );
88 % if (!$skip) {
89 <input type="hidden" class="hidden" name="id" value="<%$TicketObj->Id%>" /><br />
90 % }
91 <tr><td class="label"><&|/l&>Update Type</&>:</td>
92 <td><select name="UpdateType">
93 % if ($CanComment) {
94 <option value="private" <% ($ARGS{'UpdateType'} &&  $ARGS{'UpdateType'} eq "private") ? qq[ selected="selected"] : !$ARGS{'UpdateType'}&&$CommentDefault |n %>><&|/l&>Comments (Not sent to requestors)</&></option>
95 % }
96 % if ($CanRespond) {
97 <option value="response" <% ($ARGS{'UpdateType'} && $ARGS{'UpdateType'} eq "response") ? qq[ selected="selected"] : !$ARGS{'UpdateType'}&&$ResponseDefault |n %>><&|/l&>Reply to requestors</&></option>
98 % }
99 </select> 
100 % $m->callback( %ARGS, CallbackName => 'AfterUpdateType' );
101 </td></tr>
102 <tr><td class="label"><&|/l&>Subject</&>:</td><td> <input name="UpdateSubject" size="60" value="<% $ARGS{UpdateSubject} || $TicketObj->Subject()%>" />
103 % $m->callback( %ARGS, CallbackName => 'AfterSubject' );
104 </td></tr>
105
106 <& /Ticket/Elements/UpdateCc, %ARGS, TicketObj => $TicketObj &>
107
108 <& /Ticket/Elements/EditTransactionCustomFields, %ARGS, TicketObj => $TicketObj &>
109
110 % if (exists $session{'Attachments'}) {
111 <tr><td><&|/l&>Attached file</&>:</td>
112 <td>
113 <&|/l&>Check box to delete</&><br />
114 % foreach my $attach_name (keys %{$session{'Attachments'}}) {
115 <input type="checkbox" class="checkbox" name="DeleteAttach-<%$attach_name%>" value="1" /><%$attach_name%><br />
116 % } # end of foreach
117 </td>
118 </tr>
119 % } # end of if
120
121 <tr><td class="label"><&|/l&>Attach</&>:</td><td><input name="Attach" type="file" /><input type="submit" class="button" name="AddMoreAttach" value="<&|/l&>Add More Files</&>" /><input type="hidden" class="hidden" name="UpdateAttach" value="1" />
122 </td></tr>
123
124 % if ( $gnupg_widget ) {
125 <tr><td>&nbsp;</td><td>
126 <& /Elements/GnuPG/SignEncryptWidget,
127     self => $gnupg_widget,
128     TicketObj => $TicketObj,
129 &>
130 </td></tr>
131 % }
132 % $m->callback( %ARGS, CallbackName => 'AfterGnuPG' );
133
134 <tr><td class="label" valign="top"><&|/l&>Message</&>:</td><td>
135 % $m->callback( %ARGS, CallbackName => 'BeforeMessageBox' );
136 % if (exists $ARGS{UpdateContent}) {
137 % # preserve QuoteTransaction so we can use it to set up sane references/in/reply to
138 % my $temp = $ARGS{'QuoteTransaction'};
139 % delete $ARGS{'QuoteTransaction'};
140 <& /Elements/MessageBox, Name=>"UpdateContent", Default=>$ARGS{UpdateContent}, IncludeSignature => 0, %ARGS&>
141 % $ARGS{'QuoteTransaction'} = $temp;
142 % } else {
143 % my $IncludeSignature = 1;
144 % $IncludeSignature = 0 if $Action ne 'Respond' && !RT->Config->Get('MessageBoxIncludeSignatureOnComment');
145 <& /Elements/MessageBox, Name=>"UpdateContent", IncludeSignature => $IncludeSignature, %ARGS &>
146 % }
147 </td></tr>
148 </table>
149
150
151
152
153 <& /Elements/Submit, Label => loc('Update Ticket'), Name => 'SubmitTicket' &>
154 % if ($TicketObj->CurrentUserHasRight('ShowOutgoingEmail')) {
155 <&|/Widgets/TitleBox, title => loc('Scrips and Recipients') &>
156 <& /Ticket/Elements/PreviewScrips, TicketObj => $TicketObj, %ARGS &>
157 </&>
158
159 % }
160 </form>
161 <%INIT>
162 my $CanRespond = 0;
163 my $CanComment = 0;
164 my $checks_failure = 0;
165 my $title;
166
167 my $TicketObj = LoadTicket($id);
168
169 my @results;
170
171 $m->callback( Ticket => $TicketObj, ARGSRef => \%ARGS, results => \@results, CallbackName => 'Initial' );
172
173 unless($DefaultStatus){
174     $DefaultStatus=($ARGS{'Status'} ||$TicketObj->Status());
175 }
176
177 if ($DefaultStatus eq 'new'){
178     $DefaultStatus='open';
179 }
180
181 if ($DefaultStatus eq 'resolved') {
182     $title = loc("Resolve ticket #[_1] ([_2])", $TicketObj->id, $TicketObj->Subject);
183 } else {
184     $title = loc("Update ticket #[_1] ([_2])", $TicketObj->id, $TicketObj->Subject);
185 }
186
187 # Things needed in the template - we'll do the processing here, just
188 # for the convenience:
189
190 my ($CommentDefault, $ResponseDefault);
191 if ($Action ne 'Respond') {
192     $CommentDefault = qq[ selected="selected"]; 
193     $ResponseDefault = "";
194 } else {
195     $CommentDefault = ""; 
196     $ResponseDefault = qq[ selected="selected"];
197 }
198
199
200
201 $CanRespond = 1 if ( $TicketObj->CurrentUserHasRight('ReplyToTicket') or
202                      $TicketObj->CurrentUserHasRight('ModifyTicket') ); 
203
204 $CanComment = 1 if ( $TicketObj->CurrentUserHasRight('CommentOnTicket') or
205                      $TicketObj->CurrentUserHasRight('ModifyTicket') ); 
206
207
208 # {{{ deal with deleting uploaded attachments
209 foreach my $key (keys %ARGS) {
210     if ($key =~ m/^DeleteAttach-(.+)$/) {
211         delete $session{'Attachments'}{$1};
212     }
213     $session{'Attachments'} = { %{$session{'Attachments'} || {}} };
214 }
215 # }}}
216
217 # {{{ store the uploaded attachment in session
218 if ($ARGS{'Attach'}) {            # attachment?
219     my $attachment = MakeMIMEEntity(
220         AttachmentFieldName => 'Attach'
221     );
222
223     my $file_path = Encode::decode_utf8("$ARGS{'Attach'}");
224     $session{'Attachments'} = {
225         %{$session{'Attachments'} || {}},
226         $file_path => $attachment,
227     };
228 }
229 # }}}
230
231 # delete temporary storage entry to make WebUI clean
232 unless (keys %{$session{'Attachments'}} and $ARGS{'UpdateAttach'}) {
233     delete $session{'Attachments'};
234 }
235 # }}}
236
237 my $gnupg_widget = $m->comp('/Elements/GnuPG/SignEncryptWidget:new', Arguments => \%ARGS );
238 $m->comp( '/Elements/GnuPG/SignEncryptWidget:Process',
239     self => $gnupg_widget,
240     TicketObj => $TicketObj,
241 );
242
243 if ( $ARGS{'SubmitTicket'} ) {
244     my $CFs = $TicketObj->TransactionCustomFields;
245     my $ValidCFs = $m->comp(
246         '/Elements/ValidateCustomFields',
247         CustomFields => $CFs,
248         NamePrefix => "Object-RT::Transaction--CustomField-",
249         ARGSRef => \%ARGS
250     );
251     unless ( $ValidCFs ) {
252         $checks_failure = 1;
253         while (my $CF = $CFs->Next) {
254             my $msg = $m->notes('InvalidField-' . $CF->Id) or next;
255             push @results, loc($CF->Name) . ': ' . $msg;
256         }
257     }
258     my $status = $m->comp('/Elements/GnuPG/SignEncryptWidget:Check',
259         self      => $gnupg_widget,
260         TicketObj => $TicketObj,
261     );
262     $checks_failure = 1 unless $status;
263 }
264
265 # check email addresses for RT's
266 {
267     foreach my $field ( qw(UpdateCc UpdateBcc) ) {
268         my $value = $ARGS{ $field };
269         next unless defined $value && length $value;
270
271         my @emails = Email::Address->parse( $value );
272         foreach my $email ( grep RT::EmailParser->IsRTAddress($_->address), @emails ) {
273             push @results, loc("[_1] is an address RT receives mail at. Adding it as a '[_2]' would create a mail loop", $email->format, loc(substr($field, 6)) );
274             $checks_failure = 1;
275             $email = undef;
276         }
277         $ARGS{ $field } = join ', ', map $_->format, grep defined, @emails;
278     }
279 }
280
281 if ( !$checks_failure && exists $ARGS{SubmitTicket} ) {
282     $m->callback( Ticket => $TicketObj, ARGSRef => \%ARGS, CallbackName => 'BeforeDisplay' );
283     return $m->comp('Display.html', TicketObj => $TicketObj, %ARGS);
284 }
285 </%INIT>
286
287 <%ARGS>
288 $id => undef
289 $Action => undef
290 $DefaultStatus => undef
291 </%ARGS>