1 %# BEGIN BPS TAGGED BLOCK {{{
5 %# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
6 %# <sales@bestpractical.com>
8 %# (Except where explicitly superseded by other copyright notices)
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
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.
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.
30 %# CONTRIBUTION SUBMISSION POLICY:
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.)
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.
47 %# END BPS TAGGED BLOCK }}}
48 <& /Elements/Header, Title => $title &>
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">
53 % foreach my $var (qw(Query Format OrderBy Order Rows Page SavedSearchId SavedChartSearchId Token)) {
54 <input type="hidden" class="hidden" name="<%$var%>" value="<%$ARGS{$var} || ''%>" />
56 <& /Elements/CollectionList,
58 DisplayFormat => $DisplayFormat,
66 BaseURL => RT->Config->Get('WebPath')."/Search/Bulk.html?",
67 Class => 'RT::Tickets'
70 % $m->callback(CallbackName => 'AfterTicketList', ARGSRef => \%ARGS);
74 <& /Elements/Submit, Label => loc('Update'), CheckboxNameRegex => '/^UpdateTicket(All)?$/', CheckAll => 1, ClearAll => 1 &>
76 <&|/Widgets/TitleBox, title => $title &>
81 <tr><td class="label"> <&|/l&>Make Owner</&>: </td>
82 <td class="value"> <& /Elements/SelectOwner, Name => "Owner", Default => $ARGS{Owner} || '' &>
83 <label>(<input type="checkbox" class="checkbox" name="ForceOwnerChange"
84 <% $ARGS{ForceOwnerChange} ? 'checked="checked"' : '' %> /> <&|/l&>Force change</&>)</label></td></tr>
85 <tr><td class="label"> <&|/l&>Add Requestor</&>: </td>
86 <td class="value"> <& /Elements/EmailInput, Name => "AddRequestor", Size=> 20, Default => $ARGS{AddRequestor} &> </td></tr>
87 <tr><td class="label"> <&|/l&>Remove Requestor</&>: </td>
88 <td class="value"> <& /Elements/EmailInput, Name => "DeleteRequestor", Size=> 20, Default => $ARGS{DeleteRequestor} &> </td></tr>
89 <tr><td class="label"> <&|/l&>Add Cc</&>: </td>
90 <td class="value"> <& /Elements/EmailInput, Name => "AddCc", Size=> 20, Default => $ARGS{AddCc} &> </td></tr>
91 <tr><td class="label"> <&|/l&>Remove Cc</&>: </td>
92 <td class="value"> <& /Elements/EmailInput, Name => "DeleteCc", Size=> 20, Default => $ARGS{DeleteCc} &> </td></tr>
93 <tr><td class="label"> <&|/l&>Add AdminCc</&>: </td>
94 <td class="value"> <& /Elements/EmailInput, Name => "AddAdminCc", Size=> 20, Default => $ARGS{AddAdminCc} &> </td></tr>
95 <tr><td class="label"> <&|/l&>Remove AdminCc</&>: </td>
96 <td class="value"> <& /Elements/EmailInput, Name => "DeleteAdminCc", Size=> 20, Default => $ARGS{DeleteAdminCc} &> </td></tr>
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>
108 <td class="value"> <& /Ticket/Elements/SelectStatus, Name => "Status", Default => $ARGS{Status}, Queues => $seen_queues &> </td></tr>
109 <tr><td class="label"> <&|/l&>Make date Starts</&>: </td>
110 <td class="value"> <& /Elements/SelectDate, Name => "Starts_Date", Default => $ARGS{Starts_Date} || '' &> </td></tr>
111 <tr><td class="label"> <&|/l&>Make date Started</&>: </td>
112 <td class="value"> <& /Elements/SelectDate, Name => "Started_Date", Default => $ARGS{Started_Date} || '' &> </td></tr>
113 <tr><td class="label"> <&|/l&>Make date Told</&>: </td>
114 <td class="value"> <& /Elements/SelectDate, Name => "Told_Date", Default => $ARGS{Told_Date} || '' &> </td></tr>
115 <tr><td class="label"> <&|/l&>Make date Due</&>: </td>
116 <td class="value"> <& /Elements/SelectDate, Name => "Due_Date", Default => $ARGS{Due_Date} || '' &> </td></tr>
123 <&| /Widgets/TitleBox, title => loc('Add comments or replies to selected tickets') &>
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>
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()) {
135 <td align="right"><% $CF->Name %>:</td>
136 <td><& /Elements/EditCustomField,
138 Object => RT::Transaction->new( $session{'CurrentUser'} ),
139 &><em><% $CF->FriendlyType %></em></td>
143 <& /Ticket/Elements/AddAttachments, %ARGS &>
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 ),
158 my $cfs = RT::CustomFields->new($session{'CurrentUser'});
159 $cfs->LimitToGlobal();
160 $cfs->LimitToQueue($_) for keys %$seen_queues;
163 % if ( $cfs->Count ) {
164 <&|/Widgets/TitleBox, title => loc('Edit Custom Fields') &>
165 <& /Elements/BulkCustomFields, $ARGS{'AddMoreAttach'} ? %ARGS : (), CustomFields => $cfs &>
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 />
171 <& /Elements/BulkLinks, Collection => $Tickets, $ARGS{'AddMoreAttach'} ? %ARGS : () &>
174 <&| /Widgets/TitleBox, title => loc('Merge'), color => '#336633' &>
175 <& /Ticket/Elements/EditMerge, Tickets => $Tickets, %ARGS &>
178 <& /Elements/Submit, Label => loc('Update') &>
185 unless ( defined $Rows ) {
186 $Rows = $RowsPerPage;
187 $ARGS{Rows} = $RowsPerPage;
189 my $title = loc("Update multiple tickets");
191 # Iterate through the ARGS hash and remove anything with a null value.
192 map ( $ARGS{$_} =~ /^$/ && ( delete $ARGS{$_} ), keys %ARGS );
196 ProcessAttachments(ARGSRef => \%ARGS);
200 $Format ||= RT->Config->Get('DefaultSearchResultFormat');
202 my $DisplayFormat = "'__CheckBox.{UpdateTicket}__',". $Format;
203 $DisplayFormat =~ s/\s*,\s*('?__NEWLINE__'?)/,$1,''/gi;
205 $DECODED_ARGS->{'UpdateTicketAll'} = 1 unless @UpdateTicket;
207 my $Tickets = RT::Tickets->new( $session{'CurrentUser'} );
208 $Tickets->FromSQL($Query);
209 if ( $OrderBy =~ /\|/ ) {
212 my @OrderBy = split /\|/, $OrderBy;
213 my @Order = split /\|/, $Order;
214 $Tickets->OrderByCols(
215 map { { FIELD => $OrderBy[$_], ORDER => $Order[$_] } }
216 ( 0 .. $#OrderBy ) );
219 $Tickets->OrderBy( FIELD => $OrderBy, ORDER => $Order );
222 $Tickets->RowsPerPage($Rows) if ($Rows);
223 $Tickets->GotoPage( $Page - 1 ); # SB uses page 0 as the first page
225 Abort( loc("No search to operate on.") ) unless ($Tickets);
227 # build up a list of all custom fields for tickets that we're displaying, so
228 # we can display sane edit widgets.
231 my $seen_queues = {};
232 while ( my $ticket = $Tickets->Next ) {
233 next if $seen_queues->{ $ticket->Queue }++;
235 my $custom_fields = $ticket->CustomFields;
236 while ( my $field = $custom_fields->Next ) {
237 $fields->{ $field->id } = $field;
241 #Iterate through each ticket we've been handed
244 $Tickets->RedoSearch();
246 unless ( $ARGS{'AddMoreAttach'} ) {
247 while ( my $Ticket = $Tickets->Next ) {
248 my $tid = $Ticket->id;
249 next unless grep $tid == $_, @UpdateTicket;
252 $ARGS{'id'} = $Ticket->id;
254 my @updateresults = ProcessUpdateMessage(
255 TicketObj => $Ticket,
257 KeepAttachments => 1,
262 ProcessTicketBasics( TicketObj => $Ticket, ARGSRef => \%ARGS );
264 ProcessTicketDates( TicketObj => $Ticket, ARGSRef => \%ARGS );
268 ProcessTicketWatchers( TicketObj => $Ticket, ARGSRef => \%ARGS );
271 ProcessTicketLinks( TicketObj => $Ticket, TicketId => 'Ticket', ARGSRef => \%ARGS );
273 my @cfresults = ProcessRecordBulkCustomFields( RecordObj => $Ticket, ARGSRef => \%ARGS );
276 @watchresults, @basicresults, @dateresults,
277 @updateresults, @linkresults, @cfresults
281 map { loc( "Ticket [_1]: [_2]", $Ticket->Id, $_ ) } @tempresults;
283 @results = ( @results, @tempresults );
286 delete $session{'Attachments'}{ $ARGS{'Token'} };
289 my $TxnCFs = RT::CustomFields->new( $session{CurrentUser} );
290 $TxnCFs->LimitToLookupType( RT::Transaction->CustomFieldLookupType );
291 $TxnCFs->LimitToGlobalOrObjectId( keys %$seen_queues );
298 $RowsPerPage => undef