1 %# {{{ BEGIN BPS TAGGED BLOCK
5 %# This software is Copyright (c) 1996-2004 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 &>
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%>" CHECKED></TD>
79 %# The ticket view is controlled by config.pm, WebOptions
80 %foreach my $col (@cols) {
83 <A HREF="<% $RT::WebPath%>/Ticket/Display.html?id=<%$Ticket->Id%>"><%$Ticket->Id()%></A>
86 <% eval "\$Ticket->$col()" %>
100 <& /Elements/TitleBoxStart, title => loc('Update selected tickets') &>
105 <tr><td class=label> <&|/l&>Make Owner</&>: </td>
106 <td class=value> <& /Elements/SelectOwner, Name => "Owner" &> (<input type=checkbox name="ForceOwnerChange"> <&|/l&>Force change</&>) </td></tr>
107 <tr><td class=label> <&|/l&>Add Requestor</&>: </td>
108 <td class=value> <INPUT Name="AddRequestor" SIZE=20> </td></tr>
109 <tr><td class=label> <&|/l&>Remove Requestor</&>: </td>
110 <td class=value> <INPUT Name="DeleteRequestor" SIZE=20> </td></tr>
111 <tr><td class=label> <&|/l&>Add Cc</&>: </td>
112 <td class=value> <INPUT Name="AddCc" SIZE=20> </td></tr>
113 <tr><td class=label> <&|/l&>Remove Cc</&>: </td>
114 <td class=value> <INPUT Name="DeleteCc" SIZE=20> </td></tr>
115 <tr><td class=label> <&|/l&>Add AdminCc</&>: </td>
116 <td class=value> <INPUT Name="AddAdminCc" SIZE=20> </td></tr>
117 <tr><td class=label> <&|/l&>Remove AdminCc</&>: </td>
118 <td class=value> <INPUT Name="DeleteAdminCc" SIZE=20> </td></tr>
123 <tr><td class=label> <&|/l&>Make subject</&>: </td>
124 <td class=value> <INPUT Name="Subject" SIZE=20> </td></tr>
125 <tr><td class=label> <&|/l&>Make priority</&>: </td>
126 <td class=value> <INPUT Name="Priority" SIZE=4> </td></tr>
127 <tr><td class=label> <&|/l&>Make queue</&>: </td>
128 <td class=value> <& /Elements/SelectQueue, Name => "Queue" &> </td></tr>
129 <tr><td class=label> <&|/l&>Make Status</&>: </td>
130 <td class=value> <& /Elements/SelectStatus, Name => "Status" &> </td></tr>
131 <tr><td class=label> <&|/l&>Make date Starts</&>: </td>
132 <td class=value> <& /Elements/SelectDate, Name => "Starts_Date", ShowTime => 0, Default => '' &> </td></tr>
133 <tr><td class=label> <&|/l&>Make date Started</&>: </td>
134 <td class=value> <& /Elements/SelectDate, Name => "Started_Date", ShowTime => 0, Default => '' &> </td></tr>
135 <tr><td class=label> <&|/l&>Make date Told</&>: </td>
136 <td class=value> <& /Elements/SelectDate, Name => "Told_Date", ShowTime => 0, Default => '' &> </td></tr>
137 <tr><td class=label> <&|/l&>Make date Due</&>: </td>
138 <td class=value> <& /Elements/SelectDate, Name => "Due_Date", ShowTime => 0, Default => '' &> </td></tr>
139 <tr><td class=label> <&|/l&>Make date Resolved</&>: </td>
140 <td class=value> <& /Elements/SelectDate, Name => "Resolved_Date", ShowTime => 0, Default => '' &> </td></tr>
146 <& /Elements/TitleBoxEnd&>
147 <& /Elements/TitleBoxStart, title => loc('Add comments or replies to selected tickets') &>
149 <tr><td align=right><&|/l&>Update Type</&>:</td>
150 <td><select name="UpdateType">
151 <option value="private" ><&|/l&>Comments (not sent to requestors)</&></option>
152 <option value="response" ><&|/l&>Reply to requestors</&></option>
155 <tr><td align=right><&|/l&>Subject</&>:</td><td> <input name="UpdateSubject" size=60 value=""></td></tr>
156 <tr><td align=right><&|/l&>Attach</&>:</td><td><input name="UpdateAttachment" type="file"></td></tr>
157 <tr><td class=labeltop><&|/l&>Message</&>:</td><td>
158 <& /Elements/MessageBox, Name=>"UpdateContent"&>
163 % foreach (keys %allcfs) {
165 % my $cf = $allcfs{$_};
167 % if ($cf->Queue == 0) {
168 % $pref = "[Global]";
170 % $pref = "[Queue: " . $cfqnames{$_} . "]";
172 <%$pref%> <b><% $cf->Name %></b><br>
173 <% $cf->FriendlyType %>
176 % if ($cf->Type ne "FreeformMultiple") {
177 <& /Ticket/Elements/EditCustomField, CustomField => $cf &>
180 <textarea cols=15 rows=3 name="<%$cf->Id%>-Values"></textarea>
183 <textarea cols=15 rows=3 name="<%$cf->Id%>-DeleteValues"></textarea>
190 <& /Elements/TitleBoxEnd &>
192 <& /Elements/TitleBoxStart, title => loc('Edit Links'), color => "#336633"&>
193 <i><&|/l&>Enter tickets or URIs to link tickets to. Seperate multiple entries with spaces.</&></i><br>
194 <& /Ticket/Elements/BulkLinks &>
195 <& /Elements/TitleBoxEnd &>
197 <& /Elements/Submit, Label => loc('Update All') &>
203 # Iterate through the ARGS hash and remove anything with a null value.
204 map ($ARGS{$_} =~ /^$/ && (delete $ARGS{$_}), keys %ARGS);
206 my ($bgcolor, @results);
207 my @cols = qw(id Status Priority Subject QueueObj->Name OwnerObj->Name RequestorAddresses DueAsString );
210 my $Tickets = RT::Tickets->new($session{'CurrentUser'});
211 $Tickets->FromSQL($ARGS{'Query'});
213 Abort(loc("No search to operate on.")) unless ($Tickets);
219 while (my $Ticket = $Tickets->Next) {
220 my $cfq = $Ticket->QueueObj;
221 my $cfqid = $cfq->Id;
222 my $cfqn = $cfq->Name;
223 unless ( exists $cfqs{$cfqid} ) {
226 my $cfs = $cfq->CustomFields;
227 while (my $cf = $cfs->Next) {
228 $allcfs{$cf->Id} = $cf;
229 $cfqnames{$cf->Id} = $cfqn;
234 my $do_comment_reply=0;
235 # Prepare for ticket updates
236 $ARGS{'UpdateContent'} =~ s/\r\n/\n/g;
237 chomp ($ARGS{'UpdateContent'}) ;
239 if ($ARGS{'UpdateContent'} &&
240 $ARGS{'UpdateContent'} ne '' &&
241 $ARGS{'UpdateContent'} ne "-- \n" .
242 $session{'CurrentUser'}->UserObj->Signature) {
246 #Iterate through each ticket we've been handed
249 $Tickets->RedoSearch();
250 while (my $Ticket = $Tickets->Next) {
251 $RT::Logger->debug( "Checking Ticket ".$Ticket->Id ."\n");
252 next unless ($ARGS{"UpdateTicket".$Ticket->Id});
253 $RT::Logger->debug ("Matched\n");
255 if ($do_comment_reply) {
256 ProcessUpdateMessage(TicketObj => $Ticket, ARGSRef => \%ARGS, Actions => \@updateresults);
260 my @basicresults = ProcessTicketBasics(TicketObj => $Ticket, ARGSRef => \%ARGS);
261 my @dateresults = ProcessTicketDates(TicketObj => $Ticket, ARGSRef => \%ARGS);
263 my @watchresults = ProcessTicketWatchers(TicketObj => $Ticket, ARGSRef => \%ARGS);
265 #Update custom fields
266 my $pat = "^(\\d+)-(.*)\$";
267 foreach (keys %ARGS) {
268 $ARGS{"Ticket-" . $Ticket->Id . "-CustomField-" . $1 . "-" . $2} = $ARGS{$_} if (/$pat/o);
270 my @cfresults = ProcessTicketCustomFieldUpdates(ARGSRef => \%ARGS);
271 foreach (keys %ARGS) {
272 delete $ARGS{"Ticket-" . $Ticket->Id . "-CustomField-" . $1 . "-" . $2} if (/$pat/o);
277 $ARGS{'id'} = $Ticket;
278 $ARGS{$Ticket->Id.'-MergeInto'} = $ARGS{'Ticket-MergeInto'};
279 $ARGS{$Ticket->Id.'-DependsOn'} = $ARGS{'Ticket-DependsOn'};
280 $ARGS{'DependsOn-'.$Ticket->Id} = $ARGS{'DependsOn-Ticket'};
281 $ARGS{$Ticket->Id.'-MemberOf'} = $ARGS{'Ticket-MemberOf'};
282 $ARGS{'MemberOf-'.$Ticket->Id} = $ARGS{'MemberOf-Ticket'};
283 $ARGS{$Ticket->Id.'-RefersTo'} = $ARGS{'Ticket-RefersTo'};
284 $ARGS{'RefersTo-'.$Ticket->Id} = $ARGS{'RefersTo-Ticket'};
285 @linkresults = ProcessTicketLinks( TicketObj => $Ticket, ARGSRef => \%ARGS);
287 delete $ARGS{$Ticket->Id.'-MergeInto'};
288 delete $ARGS{$Ticket->Id.'-DependsOn'};
289 delete $ARGS{'DependsOn-'.$Ticket->Id};
290 delete $ARGS{$Ticket->Id.'-MemberOf'};
291 delete $ARGS{'MemberOf-'.$Ticket->Id};
292 delete $ARGS{$Ticket->Id.'-RefersTo'};
293 delete $ARGS{'RefersTo-'.$Ticket->Id};
295 my @tempresults = (@watchresults, @basicresults, @dateresults, @updateresults, @linkresults, @cfresults);
296 @tempresults = map { loc("Ticket [_1]: [_2]",$Ticket->Id,$_) } @tempresults;
298 @results = (@results, @tempresults);