import rt 3.8.7
[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 );
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 </td></tr>
101 <tr><td class="label"><&|/l&>Subject</&>:</td><td> <input name="UpdateSubject" size="60" value="<% $ARGS{UpdateSubject} || $TicketObj->Subject()%>" /></td></tr>
102
103 <& /Ticket/Elements/UpdateCc, %ARGS, TicketObj => $TicketObj &>
104
105 <& /Ticket/Elements/EditTransactionCustomFields, %ARGS, TicketObj => $TicketObj &>
106
107 % if (exists $session{'Attachments'}) {
108 <tr><td><&|/l&>Attached file</&>:</td>
109 <td>
110 <&|/l&>Check box to delete</&><br />
111 % foreach my $attach_name (keys %{$session{'Attachments'}}) {
112 <input type="checkbox" class="checkbox" name="DeleteAttach-<%$attach_name%>" value="1" /><%$attach_name%><br />
113 % } # end of foreach
114 </td>
115 </tr>
116 % } # end of if
117
118 <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" />
119 </td></tr>
120
121 % if ( $gnupg_widget ) {
122 <tr><td>&nbsp;</td><td>
123 <& /Elements/GnuPG/SignEncryptWidget,
124     self => $gnupg_widget,
125     TicketObj => $TicketObj,
126 &>
127 </td></tr>
128 % }
129
130 <tr><td class="label" valign="top"><&|/l&>Message</&>:</td><td>
131 % $m->callback( %ARGS, CallbackName => 'BeforeMessageBox' );
132 % if (exists $ARGS{UpdateContent}) {
133 % # preserve QuoteTransaction so we can use it to set up sane references/in/reply to
134 % my $temp = $ARGS{'QuoteTransaction'};
135 % delete $ARGS{'QuoteTransaction'};
136 <& /Elements/MessageBox, Name=>"UpdateContent", Default=>$ARGS{UpdateContent}, IncludeSignature => 0, %ARGS&>
137 % $ARGS{'QuoteTransaction'} = $temp;
138 % } else {
139 <& /Elements/MessageBox, Name=>"UpdateContent", %ARGS &>
140 % }
141 </td></tr>
142 </table>
143
144
145
146
147 <& /Elements/Submit, Label => loc('Update Ticket'), Name => 'SubmitTicket' &>
148 % if ($TicketObj->CurrentUserHasRight('ShowOutgoingEmail')) {
149 <&|/Widgets/TitleBox, title => loc('Scrips and Recipients') &>
150 <& /Ticket/Elements/PreviewScrips, TicketObj => $TicketObj, %ARGS &>
151 </&>
152
153 % }
154 </form>
155 <%INIT>
156 my $CanRespond = 0;
157 my $CanComment = 0;
158 my $checks_failure = 0;
159 my $title;
160
161 my $TicketObj = LoadTicket($id);
162
163 my @results;
164
165 $m->callback( Ticket => $TicketObj, ARGSRef => \%ARGS, results => \@results, CallbackName => 'Initial' );
166
167 unless($DefaultStatus){
168     $DefaultStatus=($ARGS{'Status'} ||$TicketObj->Status());
169 }
170
171 if ($DefaultStatus eq 'new'){
172     $DefaultStatus='open';
173 }
174
175 if ($DefaultStatus eq 'resolved') {
176     $title = loc("Resolve ticket #[_1] ([_2])", $TicketObj->id, $TicketObj->Subject);
177 } else {
178     $title = loc("Update ticket #[_1] ([_2])", $TicketObj->id, $TicketObj->Subject);
179 }
180
181 # Things needed in the template - we'll do the processing here, just
182 # for the convenience:
183
184 my ($CommentDefault, $ResponseDefault);
185 if ($Action ne 'Respond') {
186     $CommentDefault = qq[ selected="selected"]; 
187     $ResponseDefault = "";
188 } else {
189     $CommentDefault = ""; 
190     $ResponseDefault = qq[ selected="selected"];
191 }
192
193
194
195 $CanRespond = 1 if ( $TicketObj->CurrentUserHasRight('ReplyToTicket') or
196                      $TicketObj->CurrentUserHasRight('ModifyTicket') ); 
197
198 $CanComment = 1 if ( $TicketObj->CurrentUserHasRight('CommentOnTicket') or
199                      $TicketObj->CurrentUserHasRight('ModifyTicket') ); 
200
201
202 # {{{ deal with deleting uploaded attachments
203 foreach my $key (keys %ARGS) {
204     if ($key =~ m/^DeleteAttach-(.+)$/) {
205         delete $session{'Attachments'}{$1};
206     }
207     $session{'Attachments'} = { %{$session{'Attachments'} || {}} };
208 }
209 # }}}
210
211 # {{{ store the uploaded attachment in session
212 if ($ARGS{'Attach'}) {            # attachment?
213     my $attachment = MakeMIMEEntity(
214         AttachmentFieldName => 'Attach'
215     );
216
217     my $file_path = Encode::decode_utf8("$ARGS{'Attach'}");
218     $session{'Attachments'} = {
219         %{$session{'Attachments'} || {}},
220         $file_path => $attachment,
221     };
222 }
223 # }}}
224
225 # delete temporary storage entry to make WebUI clean
226 unless (keys %{$session{'Attachments'}} and $ARGS{'UpdateAttach'}) {
227     delete $session{'Attachments'};
228 }
229 # }}}
230
231 my $gnupg_widget = $m->comp('/Elements/GnuPG/SignEncryptWidget:new', Arguments => \%ARGS );
232 $m->comp( '/Elements/GnuPG/SignEncryptWidget:Process',
233     self => $gnupg_widget,
234     TicketObj => $TicketObj,
235 );
236
237 if ( $ARGS{'SubmitTicket'} ) {
238     my $CFs = $TicketObj->TransactionCustomFields;
239     my $ValidCFs = $m->comp(
240         '/Elements/ValidateCustomFields',
241         CustomFields => $CFs,
242         NamePrefix => "Object-RT::Transaction--CustomField-",
243         ARGSRef => \%ARGS
244     );
245     unless ( $ValidCFs ) {
246         $checks_failure = 1;
247         while (my $CF = $CFs->Next) {
248             my $msg = $m->notes('InvalidField-' . $CF->Id) or next;
249             push @results, loc($CF->Name) . ': ' . $msg;
250         }
251     }
252     my $status = $m->comp('/Elements/GnuPG/SignEncryptWidget:Check',
253         self      => $gnupg_widget,
254         TicketObj => $TicketObj,
255     );
256     $checks_failure = 1 unless $status;
257 }
258
259 if ( !$checks_failure && exists $ARGS{SubmitTicket} ) {
260     $m->callback( Ticket => $TicketObj, ARGSRef => \%ARGS, CallbackName => 'BeforeDisplay' );
261     return $m->comp('Display.html', TicketObj => $TicketObj, %ARGS);
262 }
263 </%INIT>
264
265 <%ARGS>
266 $id => undef
267 $Action => undef
268 $DefaultStatus => undef
269 </%ARGS>