1 %# BEGIN BPS TAGGED BLOCK {{{
5 %# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC
6 %# <jesse@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., 675 Mass Ave, Cambridge, MA 02139, USA.
28 %# CONTRIBUTION SUBMISSION POLICY:
30 %# (The following paragraph is not intended to limit the rights granted
31 %# to you to modify and distribute this software under the terms of
32 %# the GNU General Public License and is only of importance to you if
33 %# you choose to contribute your changes and enhancements to the
34 %# community by submitting them to Best Practical Solutions, LLC.)
36 %# By intentionally submitting any modifications, corrections or
37 %# derivatives to this work, or any other work intended for use with
38 %# Request Tracker, to Best Practical Solutions, LLC, you confirm that
39 %# you are the copyright holder for those contributions and you grant
40 %# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
41 %# royalty-free, perpetual, license to use, copy, create derivative
42 %# works based on those contributions, and sublicense and distribute
43 %# those contributions and any derivatives thereof.
45 %# END BPS TAGGED BLOCK }}}
46 <& /Elements/Header, Title => loc("Bulk ticket update") &>
47 <& /Elements/Tabs, Title => loc("Bulk ticket update") &>
49 <& /Elements/ListActions, actions => \@results &>
50 <FORM METHOD="POST" ACTION="<%$RT::WebPath%>/Search/Bulk.html" >
51 <input type="hidden" name="Query" value="<%$ARGS{'Query'}%>">
52 <TABLE WIDTH=100% border=0 cellpadding=3 CELLSPACING=0>
54 <TH><&|/l&>Update</&></TH>
55 %foreach my $col (@cols) {
56 % my $colalias = $col;
57 % $colalias =~ s/(Obj\-\>|)(Name|AsString)//;
59 <TH><% loc($colalias) %> </TH>
67 $Tickets->RedoSearch();
68 while (my $Ticket = $Tickets->Next) {
77 <TR bgcolor="<%$bgcolor%>">
78 <TD><input type=checkbox name="UpdateTicket<%$Ticket->Id%>" value="1" CHECKED></TD>
79 %foreach my $col (@cols) {
82 <A HREF="<% $RT::WebPath%>/Ticket/Display.html?id=<%$Ticket->Id%>"><%$Ticket->Id()%></A>
85 <% eval "\$Ticket->$col()" %>
99 <& /Elements/TitleBoxStart, title => loc('Update selected tickets') &>
104 <tr><td class=label> <&|/l&>Make Owner</&>: </td>
105 <td class=value> <& /Elements/SelectOwner, Name => "Owner" &> (<input type=checkbox name="ForceOwnerChange"> <&|/l&>Force change</&>) </td></tr>
106 <tr><td class=label> <&|/l&>Add Requestor</&>: </td>
107 <td class=value> <INPUT Name="AddRequestor" SIZE=20> </td></tr>
108 <tr><td class=label> <&|/l&>Remove Requestor</&>: </td>
109 <td class=value> <INPUT Name="DeleteRequestor" SIZE=20> </td></tr>
110 <tr><td class=label> <&|/l&>Add Cc</&>: </td>
111 <td class=value> <INPUT Name="AddCc" SIZE=20> </td></tr>
112 <tr><td class=label> <&|/l&>Remove Cc</&>: </td>
113 <td class=value> <INPUT Name="DeleteCc" SIZE=20> </td></tr>
114 <tr><td class=label> <&|/l&>Add AdminCc</&>: </td>
115 <td class=value> <INPUT Name="AddAdminCc" SIZE=20> </td></tr>
116 <tr><td class=label> <&|/l&>Remove AdminCc</&>: </td>
117 <td class=value> <INPUT Name="DeleteAdminCc" SIZE=20> </td></tr>
122 <tr><td class=label> <&|/l&>Make subject</&>: </td>
123 <td class=value> <INPUT Name="Subject" SIZE=20> </td></tr>
124 <tr><td class=label> <&|/l&>Make priority</&>: </td>
125 <td class=value> <INPUT Name="Priority" SIZE=4> </td></tr>
126 <tr><td class=label> <&|/l&>Make queue</&>: </td>
127 <td class=value> <& /Elements/SelectQueue, Name => "Queue" &> </td></tr>
128 <tr><td class=label> <&|/l&>Make Status</&>: </td>
129 <td class=value> <& /Elements/SelectStatus, Name => "Status" &> </td></tr>
130 <tr><td class=label> <&|/l&>Make date Starts</&>: </td>
131 <td class=value> <& /Elements/SelectDate, Name => "Starts_Date", ShowTime => 0, Default => '' &> </td></tr>
132 <tr><td class=label> <&|/l&>Make date Started</&>: </td>
133 <td class=value> <& /Elements/SelectDate, Name => "Started_Date", ShowTime => 0, Default => '' &> </td></tr>
134 <tr><td class=label> <&|/l&>Make date Told</&>: </td>
135 <td class=value> <& /Elements/SelectDate, Name => "Told_Date", ShowTime => 0, Default => '' &> </td></tr>
136 <tr><td class=label> <&|/l&>Make date Due</&>: </td>
137 <td class=value> <& /Elements/SelectDate, Name => "Due_Date", ShowTime => 0, Default => '' &> </td></tr>
138 <tr><td class=label> <&|/l&>Make date Resolved</&>: </td>
139 <td class=value> <& /Elements/SelectDate, Name => "Resolved_Date", ShowTime => 0, Default => '' &> </td></tr>
145 <& /Elements/TitleBoxEnd&>
146 <& /Elements/TitleBoxStart, title => loc('Add comments or replies to selected tickets') &>
148 <tr><td align=right><&|/l&>Update Type</&>:</td>
149 <td><select name="UpdateType">
150 <option value="private" ><&|/l&>Comments (not sent to requestors)</&></option>
151 <option value="response" ><&|/l&>Reply to requestors</&></option>
154 <tr><td align=right><&|/l&>Subject</&>:</td><td> <input name="UpdateSubject" size=60 value=""></td></tr>
155 % while (my $CF = $TxnCFs->Next()) {
157 <TD ALIGN=RIGHT><% $CF->Name %>:</TD>
158 <TD><& /Elements/EditCustomField,
160 NamePrefix => "Object-RT::Transaction--CustomField-"
161 &><em><% $CF->FriendlyType %></em></TD>
164 <tr><td align=right><&|/l&>Attach</&>:</td><td><input name="UpdateAttachment" type="file"></td></tr>
165 <tr><td class=labeltop><&|/l&>Message</&>:</td><td>
166 <& /Elements/MessageBox, Name=>"UpdateContent"&>
170 <& /Elements/TitleBoxEnd &>
173 <& /Elements/TitleBoxStart, title => loc('Edit Links'), color => "#336633"&>
174 <i><&|/l&>Enter tickets or URIs to link tickets to. Separate multiple entries with spaces.</&></i><br>
175 <& /Ticket/Elements/BulkLinks &>
176 <& /Elements/TitleBoxEnd &>
178 <& /Elements/Submit, Label => loc('Update All') &>
184 # Iterate through the ARGS hash and remove anything with a null value.
185 map ($ARGS{$_} =~ /^$/ && (delete $ARGS{$_}), keys %ARGS);
187 my ($bgcolor, @results);
188 my @cols = qw(id Status Priority Subject QueueObj->Name OwnerObj->Name RequestorAddresses DueAsString );
191 my $Tickets = RT::Tickets->new($session{'CurrentUser'});
192 $Tickets->FromSQL($ARGS{'Query'});
194 Abort(loc("No search to operate on.")) unless ($Tickets);
200 while (my $Ticket = $Tickets->Next) {
201 my $cfq = $Ticket->QueueObj;
202 my $cfqid = $cfq->Id;
203 my $cfqn = $cfq->Name;
204 unless ( exists $cfqs{$cfqid} ) {
207 my $cfs = $cfq->TicketCustomFields;
208 while (my $cf = $cfs->Next) {
209 $allcfs{$cf->Id} = $cf;
210 $cfqnames{$cf->Id} = $cfqn;
215 my $do_comment_reply=0;
216 # Prepare for ticket updates
217 $ARGS{'UpdateContent'} =~ s/\r\n/\n/g;
218 chomp ($ARGS{'UpdateContent'}) ;
220 if ($ARGS{'UpdateContent'} &&
221 $ARGS{'UpdateContent'} ne '' &&
222 $ARGS{'UpdateContent'} ne "-- \n" .
223 $session{'CurrentUser'}->UserObj->Signature) {
227 #Iterate through each ticket we've been handed
231 $Tickets->RedoSearch();
232 while (my $Ticket = $Tickets->Next) {
233 $queues{$Ticket->QueueObj->Id}++;
234 $RT::Logger->debug( "Checking Ticket ".$Ticket->Id ."\n");
235 next unless ($ARGS{"UpdateTicket".$Ticket->Id});
236 $RT::Logger->debug ("Matched\n");
238 if ($do_comment_reply) {
239 ProcessUpdateMessage(TicketObj => $Ticket, ARGSRef => \%ARGS, Actions => \@updateresults);
243 my @basicresults = ProcessTicketBasics(TicketObj => $Ticket, ARGSRef => \%ARGS);
244 my @dateresults = ProcessTicketDates(TicketObj => $Ticket, ARGSRef => \%ARGS);
246 my @watchresults = ProcessTicketWatchers(TicketObj => $Ticket, ARGSRef => \%ARGS);
250 $ARGS{'id'} = $Ticket;
251 $ARGS{$Ticket->Id.'-MergeInto'} = $ARGS{'Ticket-MergeInto'};
252 $ARGS{$Ticket->Id.'-DependsOn'} = $ARGS{'Ticket-DependsOn'};
253 $ARGS{'DependsOn-'.$Ticket->Id} = $ARGS{'DependsOn-Ticket'};
254 $ARGS{$Ticket->Id.'-MemberOf'} = $ARGS{'Ticket-MemberOf'};
255 $ARGS{'MemberOf-'.$Ticket->Id} = $ARGS{'MemberOf-Ticket'};
256 $ARGS{$Ticket->Id.'-RefersTo'} = $ARGS{'Ticket-RefersTo'};
257 $ARGS{'RefersTo-'.$Ticket->Id} = $ARGS{'RefersTo-Ticket'};
258 @linkresults = ProcessTicketLinks( TicketObj => $Ticket, ARGSRef => \%ARGS);
260 delete $ARGS{$Ticket->Id.'-MergeInto'};
261 delete $ARGS{$Ticket->Id.'-DependsOn'};
262 delete $ARGS{'DependsOn-'.$Ticket->Id};
263 delete $ARGS{$Ticket->Id.'-MemberOf'};
264 delete $ARGS{'MemberOf-'.$Ticket->Id};
265 delete $ARGS{$Ticket->Id.'-RefersTo'};
266 delete $ARGS{'RefersTo-'.$Ticket->Id};
267 my @tempresults = (@watchresults, @basicresults, @dateresults,
268 @updateresults, @linkresults);
269 @tempresults = map { loc("Ticket [_1]: [_2]",$Ticket->Id,$_) } @tempresults;
271 @results = (@results, @tempresults);
274 my $TxnCFs = RT::CustomFields->new($session{CurrentUser});
275 $TxnCFs->LimitToLookupType("RT::Queue-RT::Ticket-RT::Transaction");
276 $TxnCFs->LimitToGlobalOrObjectId(sort keys %queues);