f0b70b578e3c4baf6e164ba13d25780a776cfa82
[freeside.git] / rt / share / html / Ticket / ModifyAll.html
1 %# BEGIN BPS TAGGED BLOCK {{{
2 %#
3 %# COPYRIGHT:
4 %#
5 %# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC
6 %#                                          <sales@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 => loc("Ticket #[_1] Jumbo update: [_2]", $Ticket->Id, $Ticket->Subject) &>
49 <& /Elements/Tabs &>
50
51 % $m->callback(CallbackName => 'BeforeActionList', Actions => \@results, ARGSRef => \%ARGS, Ticket => $Ticket);
52 <& /Elements/ListActions, actions => \@results &>
53
54 <form method="post" action="ModifyAll.html" name="TicketModifyAll" enctype="multipart/form-data">
55 % $m->callback( CallbackName => 'FormStart', ARGSRef => \%ARGS );
56 <input type="submit" name="SubmitTicket" value="Save Changes" style="display:none">
57 <input type="hidden" class="hidden" name="id" value="<%$Ticket->Id%>" />
58 <input type="hidden" class="hidden" name="Token" value="<% $ARGS{'Token'} %>" />
59
60 <&| /Widgets/TitleBox, title => loc('Modify ticket # [_1]', $Ticket->Id), class=>'ticket-info-basics' &>
61 <& Elements/EditBasics, TicketObj => $Ticket, defaults => \%ARGS &>
62 <& /Elements/EditCustomFields, Object => $Ticket, Grouping => 'Basics' &>
63 </&>
64
65 % $m->callback(CallbackName => 'AfterBasics', Ticket => $Ticket);
66
67 <& /Elements/EditCustomFieldCustomGroupings, Object => $Ticket &>
68
69 <&| /Widgets/TitleBox, title => loc('Dates'), class=>'ticket-info-dates'&>
70 <& Elements/EditDates, TicketObj => $Ticket &>
71 </&>
72
73 <br />
74
75
76 <&| /Widgets/TitleBox, title => loc('People'), class=>'ticket-info-people' &>
77 <& Elements/EditPeople, Ticket => $Ticket, UserField => $UserField, UserString => $UserString, UserOp => $UserOp, GroupString => $GroupString, GroupOp => $GroupOp, GroupField => $GroupField &>
78 </&>
79
80 <br />
81
82 <&| /Widgets/TitleBox, title => loc('Links'), class=>'ticket-info-links' &>
83 <& /Elements/EditLinks, Object => $Ticket &>
84 </&>
85
86 <br />
87
88 <&| /Widgets/TitleBox, title => loc('Merge'), class=>'ticket-info-merge' &>
89 <& Elements/EditMerge, Ticket => $Ticket, %ARGS &>
90 </&>
91
92 <br />
93
94 <&| /Widgets/TitleBox, title => loc('Update ticket') &>
95 <table>
96   <tr>
97     <td class="label"><&|/l&>Update Type</&>:</td>
98     <td class="entry">
99       <select name="UpdateType" id="UpdateType">
100 % if ($CanComment) {
101         <option value="private" ><&|/l&>Comments (Not sent to requestors)</&></option>
102 % }
103 % if ($CanRespond) {
104         <option value="response"><&|/l&>Reply to requestors</&></option>
105 % }
106       </select> 
107 % $m->callback( %ARGS, CallbackName => 'AfterUpdateType' );
108     </td>
109   </tr>
110   <tr>
111     <td class="label"><&|/l&>Subject</&>:</td>
112     <td class="entry"><input name="UpdateSubject" size="60" value="<%$Ticket->Subject%>" />
113 % $m->callback( %ARGS, CallbackName => 'AfterSubject' );
114     </td>
115   </tr>
116
117   <tr><td colspan="2"><& /Ticket/Elements/EditTransactionCustomFields, %ARGS, TicketObj => $Ticket, KeepValue => 1, &></td></tr>
118
119 <& /Ticket/Elements/AddAttachments, %ARGS, TicketObj => $Ticket &>
120
121   <tr>
122     <td class="labeltop"><&|/l&>Content</&>:</td>
123     <td class="entry messagebox-container action-<% $ARGS{UpdateType} || ($CanComment ? 'private' : 'response') %>">
124 % $m->callback( %ARGS, CallbackName => 'BeforeMessageBox' );
125 % if (defined $ARGS{UpdateContent} && length($ARGS{UpdateContent})) {
126     <& /Elements/MessageBox, Name=>"UpdateContent", Default=>$ARGS{UpdateContent}, IncludeSignature => 0 &>
127 % } else {
128     <& /Elements/MessageBox, Name=>"UpdateContent", QuoteTransaction=>$ARGS{QuoteTransaction} &>
129 % }
130   </td></tr>
131 </table>
132 </&>
133   
134
135 <& /Elements/Submit, 
136     Name    => 'SubmitTicket',
137     Label   => loc('Save Changes'), 
138     Caption => loc("If you've updated anything above, be sure to"), color => "#333399" &>
139 </form>
140
141 % $m->callback(CallbackName => 'AfterForm', ARGSRef => \%ARGS, Ticket => $Ticket);
142
143 <%INIT>
144
145
146
147 my $Ticket = LoadTicket($id);
148 my $CustomFields = $Ticket->CustomFields;
149
150 my $CanRespond = 0;
151 my $CanComment = 0;
152
153
154 $CanRespond = 1 if ( $Ticket->CurrentUserHasRight('ReplyToTicket') or
155                      $Ticket->CurrentUserHasRight('ModifyTicket') ); 
156
157 $CanComment = 1 if ( $Ticket->CurrentUserHasRight('CommentOnTicket') or
158                      $Ticket->CurrentUserHasRight('ModifyTicket') );
159
160 ProcessAttachments(ARGSRef => \%ARGS);
161
162 my @results;
163 my $skip_update = 0;
164 $m->callback( TicketObj => $Ticket, ARGSRef => \%ARGS, skip_update => \$skip_update, results => \@results );
165
166 {
167     my ($status, @msg) = $m->comp(
168         '/Elements/ValidateCustomFields',
169         Object       => $Ticket,
170         CustomFields => $CustomFields,
171         ARGSRef      => \%ARGS,
172     );
173     unless ($status) {
174         push @results, @msg;
175         $skip_update = 1;
176     }
177 }
178  
179 # There might be two owners.
180 if ( ref ($ARGS{'Owner'} )) {
181     my @owners =@{$ARGS{'Owner'}};
182     delete $ARGS{'Owner'};
183     foreach my $owner(@owners){
184         if (defined($owner) && $owner =~ /\D/) {
185             $ARGS{'Owner'} = $owner unless ($Ticket->OwnerObj->Name eq $owner);
186         }
187         elsif (length $owner) {
188             $ARGS{'Owner'} = $owner unless ($Ticket->OwnerObj->id == $owner);
189         }
190      }
191 }
192
193 unless ($skip_update or $OnlySearchForPeople or $OnlySearchForGroup or $ARGS{'AddMoreAttach'} ) {
194     push @results, ProcessTicketWatchers( TicketObj => $Ticket, ARGSRef => \%ARGS);
195     push @results, ProcessObjectCustomFieldUpdates( Object => $Ticket, ARGSRef => \%ARGS);
196     push @results, ProcessTicketDates( TicketObj => $Ticket, ARGSRef => \%ARGS);
197     push @results, ProcessUpdateMessage( TicketObj => $Ticket, ARGSRef=>\%ARGS );
198     push @results, ProcessTicketBasics( TicketObj => $Ticket, ARGSRef => \%ARGS );
199     push @results, ProcessTicketLinks( TicketObj => $Ticket, ARGSRef => \%ARGS);
200 }
201     push @results, ProcessTicketStatus( TicketObj => $Ticket, ARGSRef => \%ARGS );
202
203     $Ticket->ApplyTransactionBatch;
204
205     MaybeRedirectForResults(
206         Actions   => \@results,
207         Path      => "/Ticket/ModifyAll.html",
208         Arguments => { id => $Ticket->id },
209     );
210
211 }
212
213 # If they've gone and moved the ticket to somewhere they can't see, etc...
214 unless ($Ticket->CurrentUserHasRight('ShowTicket')) {
215     if (@results) {
216         Abort("A change was applied successfully, but you no longer have permissions to view the ticket", Actions => \@results);
217     } else {
218         Abort("No permission to view ticket");
219     }
220 }
221
222
223 </%INIT>
224
225
226
227 <%ARGS>
228 $OnlySearchForPeople => undef
229 $OnlySearchForGroup => undef
230 $UserField => undef
231 $UserOp => undef
232 $UserString => undef
233 $GroupString => undef
234 $GroupOp => undef
235 $GroupField => undef
236 $id => undef
237 </%ARGS>
238