]>
Commit | Line | Data |
---|---|---|
84fb5b46 MKG |
1 | %# BEGIN BPS TAGGED BLOCK {{{ |
2 | %# | |
3 | %# COPYRIGHT: | |
4 | %# | |
403d7b0b | 5 | %# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC |
84fb5b46 MKG |
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 => $title &> | |
49 | <& /Elements/Tabs &> | |
50 | ||
51 | <& /Elements/ListActions, actions => \@results &> | |
52 | <form method="post" action="<% RT->Config->Get('WebPath') %>/Search/Bulk.html" enctype="multipart/form-data" name="BulkUpdate" id="BulkUpdate"> | |
af59614d | 53 | % foreach my $var (qw(Query Format OrderBy Order Rows Page SavedSearchId SavedChartSearchId Token)) { |
84fb5b46 MKG |
54 | <input type="hidden" class="hidden" name="<%$var%>" value="<%$ARGS{$var} || ''%>" /> |
55 | %} | |
56 | <& /Elements/CollectionList, | |
57 | Query => $Query, | |
af59614d MKG |
58 | DisplayFormat => $DisplayFormat, |
59 | Format => $Format, | |
84fb5b46 MKG |
60 | Verbatim => 1, |
61 | AllowSorting => 1, | |
62 | OrderBy => $OrderBy, | |
63 | Order => $Order, | |
64 | Rows => $Rows, | |
65 | Page => $Page, | |
66 | BaseURL => RT->Config->Get('WebPath')."/Search/Bulk.html?", | |
67 | Class => 'RT::Tickets' | |
68 | &> | |
69 | ||
70 | % $m->callback(CallbackName => 'AfterTicketList', ARGSRef => \%ARGS); | |
71 | ||
72 | <hr /> | |
73 | ||
af59614d | 74 | <& /Elements/Submit, Label => loc('Update'), CheckboxNameRegex => '/^UpdateTicket(All)?$/', CheckAll => 1, ClearAll => 1 &> |
84fb5b46 MKG |
75 | <br /> |
76 | <&|/Widgets/TitleBox, title => $title &> | |
77 | <table> | |
78 | <tr> | |
79 | <td valign="top"> | |
80 | <table> | |
81 | <tr><td class="label"> <&|/l&>Make Owner</&>: </td> | |
82 | <td class="value"> <& /Elements/SelectOwner, Name => "Owner", Default => $ARGS{Owner} || '' &> | |
af59614d MKG |
83 | <label>(<input type="checkbox" class="checkbox" name="ForceOwnerChange" |
84 | <% $ARGS{ForceOwnerChange} ? 'checked="checked"' : '' %> /> <&|/l&>Force change</&>)</label></td></tr> | |
84fb5b46 | 85 | <tr><td class="label"> <&|/l&>Add Requestor</&>: </td> |
af59614d | 86 | <td class="value"> <& /Elements/EmailInput, Name => "AddRequestor", Size=> 20, Default => $ARGS{AddRequestor} &> </td></tr> |
84fb5b46 | 87 | <tr><td class="label"> <&|/l&>Remove Requestor</&>: </td> |
af59614d | 88 | <td class="value"> <& /Elements/EmailInput, Name => "DeleteRequestor", Size=> 20, Default => $ARGS{DeleteRequestor} &> </td></tr> |
84fb5b46 | 89 | <tr><td class="label"> <&|/l&>Add Cc</&>: </td> |
af59614d | 90 | <td class="value"> <& /Elements/EmailInput, Name => "AddCc", Size=> 20, Default => $ARGS{AddCc} &> </td></tr> |
84fb5b46 | 91 | <tr><td class="label"> <&|/l&>Remove Cc</&>: </td> |
af59614d | 92 | <td class="value"> <& /Elements/EmailInput, Name => "DeleteCc", Size=> 20, Default => $ARGS{DeleteCc} &> </td></tr> |
84fb5b46 | 93 | <tr><td class="label"> <&|/l&>Add AdminCc</&>: </td> |
af59614d | 94 | <td class="value"> <& /Elements/EmailInput, Name => "AddAdminCc", Size=> 20, Default => $ARGS{AddAdminCc} &> </td></tr> |
84fb5b46 | 95 | <tr><td class="label"> <&|/l&>Remove AdminCc</&>: </td> |
af59614d | 96 | <td class="value"> <& /Elements/EmailInput, Name => "DeleteAdminCc", Size=> 20, Default => $ARGS{DeleteAdminCc} &> </td></tr> |
84fb5b46 MKG |
97 | </table> |
98 | </td> | |
99 | <td valign="top"> | |
100 | <table> | |
101 | <tr><td class="label"> <&|/l&>Make subject</&>: </td> | |
102 | <td class="value"> <input name="Subject" size="20" value="<% $ARGS{Subject} || '' %>"/> </td></tr> | |
103 | <tr><td class="label"> <&|/l&>Make priority</&>: </td> | |
104 | <td class="value"> <& /Elements/SelectPriority, Name => "Priority", Default => $ARGS{Priority} &> </td></tr> | |
105 | <tr><td class="label"> <&|/l&>Make queue</&>: </td> | |
106 | <td class="value"> <& /Elements/SelectQueue, Name => "Queue", Default => $ARGS{Queue} &> </td></tr> | |
107 | <tr><td class="label"> <&|/l&>Make Status</&>: </td> | |
af59614d | 108 | <td class="value"> <& /Ticket/Elements/SelectStatus, Name => "Status", Default => $ARGS{Status}, Queues => $seen_queues &> </td></tr> |
84fb5b46 | 109 | <tr><td class="label"> <&|/l&>Make date Starts</&>: </td> |
403d7b0b | 110 | <td class="value"> <& /Elements/SelectDate, Name => "Starts_Date", Default => $ARGS{Starts_Date} || '' &> </td></tr> |
84fb5b46 | 111 | <tr><td class="label"> <&|/l&>Make date Started</&>: </td> |
403d7b0b | 112 | <td class="value"> <& /Elements/SelectDate, Name => "Started_Date", Default => $ARGS{Started_Date} || '' &> </td></tr> |
84fb5b46 | 113 | <tr><td class="label"> <&|/l&>Make date Told</&>: </td> |
403d7b0b | 114 | <td class="value"> <& /Elements/SelectDate, Name => "Told_Date", Default => $ARGS{Told_Date} || '' &> </td></tr> |
84fb5b46 | 115 | <tr><td class="label"> <&|/l&>Make date Due</&>: </td> |
403d7b0b | 116 | <td class="value"> <& /Elements/SelectDate, Name => "Due_Date", Default => $ARGS{Due_Date} || '' &> </td></tr> |
84fb5b46 MKG |
117 | </table> |
118 | ||
119 | </td> | |
120 | </tr> | |
121 | </table> | |
122 | </&> | |
123 | <&| /Widgets/TitleBox, title => loc('Add comments or replies to selected tickets') &> | |
124 | <table> | |
125 | <tr><td align="right"><&|/l&>Update Type</&>:</td> | |
126 | <td><select name="UpdateType"> | |
127 | <option value="private" <% $ARGS{UpdateType} && $ARGS{UpdateType} eq 'private' ? 'selected="selected"' : '' %> ><&|/l&>Comments (Not sent to requestors)</&></option> | |
128 | <option value="response" <% $ARGS{UpdateType} && $ARGS{UpdateType} eq 'response' ? 'selected="selected"' : '' %>><&|/l&>Reply to requestors</&></option> | |
129 | </select> | |
130 | </td></tr> | |
131 | <tr><td align="right"><&|/l&>Subject</&>:</td><td> <input name="UpdateSubject" | |
132 | size="60" value="<% $ARGS{UpdateSubject} || "" %>" /></td></tr> | |
133 | % while (my $CF = $TxnCFs->Next()) { | |
134 | <tr> | |
135 | <td align="right"><% $CF->Name %>:</td> | |
af59614d MKG |
136 | <td><& /Elements/EditCustomField, |
137 | CustomField => $CF, | |
138 | Object => RT::Transaction->new( $session{'CurrentUser'} ), | |
84fb5b46 MKG |
139 | &><em><% $CF->FriendlyType %></em></td> |
140 | </td></tr> | |
141 | % } # end if while | |
142 | ||
143 | <& /Ticket/Elements/AddAttachments, %ARGS &> | |
144 | ||
145 | <tr><td class="labeltop"><&|/l&>Message</&>:</td><td> | |
146 | %# Currently, bulk update always starts with Comment not Reply selected, so we check this unconditionally | |
147 | % my $IncludeSignature = RT->Config->Get('MessageBoxIncludeSignatureOnComment'); | |
148 | <& /Elements/MessageBox, Name => "UpdateContent", | |
149 | $ARGS{UpdateContent} ? ( Default => $ARGS{UpdateContent}, IncludeSignature => 0 ) : | |
150 | ( IncludeSignature => $IncludeSignature ), | |
151 | &> | |
152 | </td></tr> | |
153 | </table> | |
154 | ||
155 | </&> | |
156 | ||
157 | <%perl> | |
158 | my $cfs = RT::CustomFields->new($session{'CurrentUser'}); | |
159 | $cfs->LimitToGlobal(); | |
160 | $cfs->LimitToQueue($_) for keys %$seen_queues; | |
161 | </%perl> | |
162 | ||
af59614d MKG |
163 | % if ( $cfs->Count ) { |
164 | <&|/Widgets/TitleBox, title => loc('Edit Custom Fields') &> | |
165 | <& /Elements/BulkCustomFields, $ARGS{'AddMoreAttach'} ? %ARGS : (), CustomFields => $cfs &> | |
84fb5b46 MKG |
166 | </&> |
167 | % } | |
168 | ||
169 | <&|/Widgets/TitleBox, title => loc('Edit Links'), color => "#336633"&> | |
170 | <em><&|/l&>Enter tickets or URIs to link tickets to. Separate multiple entries with spaces.</&></em><br /> | |
af59614d MKG |
171 | <& /Elements/BulkLinks, Collection => $Tickets, $ARGS{'AddMoreAttach'} ? %ARGS : () &> |
172 | </&> | |
173 | ||
174 | <&| /Widgets/TitleBox, title => loc('Merge'), color => '#336633' &> | |
175 | <& /Ticket/Elements/EditMerge, Tickets => $Tickets, %ARGS &> | |
84fb5b46 MKG |
176 | </&> |
177 | ||
178 | <& /Elements/Submit, Label => loc('Update') &> | |
179 | ||
180 | ||
181 | </form> | |
182 | ||
183 | ||
184 | <%INIT> | |
185 | unless ( defined $Rows ) { | |
186 | $Rows = $RowsPerPage; | |
187 | $ARGS{Rows} = $RowsPerPage; | |
188 | } | |
189 | my $title = loc("Update multiple tickets"); | |
190 | ||
191 | # Iterate through the ARGS hash and remove anything with a null value. | |
192 | map ( $ARGS{$_} =~ /^$/ && ( delete $ARGS{$_} ), keys %ARGS ); | |
193 | ||
194 | my (@results); | |
195 | ||
5b0d0914 | 196 | ProcessAttachments(ARGSRef => \%ARGS); |
84fb5b46 MKG |
197 | |
198 | $Page ||= 1; | |
199 | ||
200 | $Format ||= RT->Config->Get('DefaultSearchResultFormat'); | |
201 | ||
af59614d MKG |
202 | my $DisplayFormat = "'__CheckBox.{UpdateTicket}__',". $Format; |
203 | $DisplayFormat =~ s/\s*,\s*('?__NEWLINE__'?)/,$1,''/gi; | |
204 | ||
205 | $DECODED_ARGS->{'UpdateTicketAll'} = 1 unless @UpdateTicket; | |
84fb5b46 MKG |
206 | |
207 | my $Tickets = RT::Tickets->new( $session{'CurrentUser'} ); | |
208 | $Tickets->FromSQL($Query); | |
209 | if ( $OrderBy =~ /\|/ ) { | |
210 | ||
211 | # Multiple Sorts | |
212 | my @OrderBy = split /\|/, $OrderBy; | |
213 | my @Order = split /\|/, $Order; | |
214 | $Tickets->OrderByCols( | |
215 | map { { FIELD => $OrderBy[$_], ORDER => $Order[$_] } } | |
216 | ( 0 .. $#OrderBy ) ); | |
217 | } | |
218 | else { | |
219 | $Tickets->OrderBy( FIELD => $OrderBy, ORDER => $Order ); | |
220 | } | |
221 | ||
222 | $Tickets->RowsPerPage($Rows) if ($Rows); | |
223 | $Tickets->GotoPage( $Page - 1 ); # SB uses page 0 as the first page | |
224 | ||
225 | Abort( loc("No search to operate on.") ) unless ($Tickets); | |
226 | ||
227 | # build up a list of all custom fields for tickets that we're displaying, so | |
228 | # we can display sane edit widgets. | |
229 | ||
230 | my $fields = {}; | |
231 | my $seen_queues = {}; | |
232 | while ( my $ticket = $Tickets->Next ) { | |
233 | next if $seen_queues->{ $ticket->Queue }++; | |
234 | ||
235 | my $custom_fields = $ticket->CustomFields; | |
236 | while ( my $field = $custom_fields->Next ) { | |
237 | $fields->{ $field->id } = $field; | |
238 | } | |
239 | } | |
240 | ||
241 | #Iterate through each ticket we've been handed | |
242 | my @linkresults; | |
84fb5b46 MKG |
243 | |
244 | $Tickets->RedoSearch(); | |
245 | ||
84fb5b46 | 246 | unless ( $ARGS{'AddMoreAttach'} ) { |
84fb5b46 | 247 | while ( my $Ticket = $Tickets->Next ) { |
af59614d MKG |
248 | my $tid = $Ticket->id; |
249 | next unless grep $tid == $_, @UpdateTicket; | |
84fb5b46 MKG |
250 | |
251 | #Update the links | |
252 | $ARGS{'id'} = $Ticket->id; | |
84fb5b46 MKG |
253 | |
254 | my @updateresults = ProcessUpdateMessage( | |
af59614d MKG |
255 | TicketObj => $Ticket, |
256 | ARGSRef => \%ARGS, | |
257 | KeepAttachments => 1, | |
258 | ); | |
84fb5b46 MKG |
259 | |
260 | #Update the basics. | |
261 | my @basicresults = | |
262 | ProcessTicketBasics( TicketObj => $Ticket, ARGSRef => \%ARGS ); | |
263 | my @dateresults = | |
264 | ProcessTicketDates( TicketObj => $Ticket, ARGSRef => \%ARGS ); | |
265 | ||
266 | #Update the watchers | |
267 | my @watchresults = | |
268 | ProcessTicketWatchers( TicketObj => $Ticket, ARGSRef => \%ARGS ); | |
269 | ||
84fb5b46 | 270 | @linkresults = |
af59614d MKG |
271 | ProcessTicketLinks( TicketObj => $Ticket, TicketId => 'Ticket', ARGSRef => \%ARGS ); |
272 | ||
273 | my @cfresults = ProcessRecordBulkCustomFields( RecordObj => $Ticket, ARGSRef => \%ARGS ); | |
274 | ||
84fb5b46 MKG |
275 | my @tempresults = ( |
276 | @watchresults, @basicresults, @dateresults, | |
277 | @updateresults, @linkresults, @cfresults | |
278 | ); | |
279 | ||
280 | @tempresults = | |
281 | map { loc( "Ticket [_1]: [_2]", $Ticket->Id, $_ ) } @tempresults; | |
282 | ||
283 | @results = ( @results, @tempresults ); | |
284 | } | |
285 | ||
af59614d | 286 | delete $session{'Attachments'}{ $ARGS{'Token'} }; |
84fb5b46 MKG |
287 | } |
288 | ||
289 | my $TxnCFs = RT::CustomFields->new( $session{CurrentUser} ); | |
290 | $TxnCFs->LimitToLookupType( RT::Transaction->CustomFieldLookupType ); | |
01e3b242 | 291 | $TxnCFs->LimitToGlobalOrObjectId( keys %$seen_queues ); |
84fb5b46 MKG |
292 | |
293 | </%INIT> | |
294 | <%args> | |
295 | $Format => undef | |
296 | $Page => 1 | |
297 | $Rows => undef | |
298 | $RowsPerPage => undef | |
299 | $Order => 'ASC' | |
300 | $OrderBy => 'id' | |
301 | $Query => undef | |
af59614d | 302 | @UpdateTicket => () |
84fb5b46 | 303 | </%args> |