import rt 3.4.6
[freeside.git] / rt / html / Search / Bulk.html
1 %# BEGIN BPS TAGGED BLOCK {{{
2 %# 
3 %# COPYRIGHT:
4 %#  
5 %# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC 
6 %#                                          <jesse@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., 675 Mass Ave, Cambridge, MA 02139, USA.
26 %# 
27 %# 
28 %# CONTRIBUTION SUBMISSION POLICY:
29 %# 
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.)
35 %# 
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.
44 %# 
45 %# END BPS TAGGED BLOCK }}}
46 <& /Elements/Header, Title => loc("Bulk ticket update") &>
47 <& /Elements/Tabs, Title => loc("Bulk ticket update") &>
48
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>
53 <TR>
54 <TH><&|/l&>Update</&></TH>
55 %foreach my $col (@cols) {
56 % my $colalias = $col;
57 % $colalias =~ s/(Obj\-\>|)(Name|AsString)//;
58
59 <TH><% loc($colalias) %>&nbsp;</TH>
60 %}
61 </TR>
62
63 <%PERL>
64
65 my $i;
66
67 $Tickets->RedoSearch();
68 while (my $Ticket = $Tickets->Next) {
69  $i++;
70  if ($i % 2) {
71      $bgcolor = "#dddddd";
72  }
73  else {
74      $bgcolor = "#ffffff";
75  }
76       </%PERL>
77 <TR bgcolor="<%$bgcolor%>">
78 <TD><input type=checkbox name="UpdateTicket<%$Ticket->Id%>" value="1" CHECKED></TD>
79 %foreach my $col (@cols) {
80 <TD>
81 % if ($col eq 'id') {
82 <A HREF="<% $RT::WebPath%>/Ticket/Display.html?id=<%$Ticket->Id%>"><%$Ticket->Id()%></A>
83 % }
84 %else {
85 <% eval "\$Ticket->$col()" %>&nbsp;
86 %}
87 </TD>
88 %}
89 </TR>
90 %}
91
92
93
94 </TABLE>
95
96 <HR>
97
98
99 <& /Elements/TitleBoxStart, title => loc('Update selected tickets') &>
100 <TABLE>
101 <TR>
102 <TD VALIGN=TOP>
103 <table>
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>
118 </table>
119 </TD>
120 <TD VALIGN=TOP>
121 <table>
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>
140 </table>
141
142 </TD>
143 </TR>
144 </table>
145 <& /Elements/TitleBoxEnd&>
146 <& /Elements/TitleBoxStart, title => loc('Add comments or replies to selected tickets') &>
147 <table>
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>
152 </select> 
153 </td></tr>
154 <tr><td align=right><&|/l&>Subject</&>:</td><td> <input name="UpdateSubject" size=60 value=""></td></tr>
155 % while (my $CF = $TxnCFs->Next()) {
156 <TR>
157 <TD ALIGN=RIGHT><% $CF->Name %>:</TD>
158 <TD><& /Elements/EditCustomField, 
159     CustomField => $CF, 
160     NamePrefix => "Object-RT::Transaction--CustomField-"
161     &><em><% $CF->FriendlyType %></em></TD>
162 </TD></TR>
163 % } # end if while
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"&>
167  </td></tr>
168  </table>
169
170 <& /Elements/TitleBoxEnd &>
171
172
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 &>
177
178 <& /Elements/Submit, Label => loc('Update All') &>
179
180
181 </FORM>
182 <%INIT>
183
184 # Iterate through the ARGS hash and remove anything with a null value.
185 map ($ARGS{$_} =~ /^$/ && (delete $ARGS{$_}), keys %ARGS);
186
187 my ($bgcolor, @results);
188 my @cols = qw(id Status Priority Subject QueueObj->Name OwnerObj->Name RequestorAddresses DueAsString );
189
190
191 my $Tickets = RT::Tickets->new($session{'CurrentUser'});
192 $Tickets->FromSQL($ARGS{'Query'});
193
194 Abort(loc("No search to operate on.")) unless ($Tickets);
195
196 my %allcfs;
197 my %cfqnames;
198 my %cfqs;
199 my $count = 0;
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} ) {
205         $cfqs{$cfqid} = 1;
206         $count++;
207         my $cfs = $cfq->TicketCustomFields;
208         while (my $cf = $cfs->Next) {
209             $allcfs{$cf->Id} = $cf;
210             $cfqnames{$cf->Id} = $cfqn;
211         }
212     }
213 }
214
215 my $do_comment_reply=0;
216 # Prepare for ticket updates
217 $ARGS{'UpdateContent'} =~ s/\r\n/\n/g;
218 chomp ($ARGS{'UpdateContent'}) ;
219
220 if ($ARGS{'UpdateContent'} &&
221     $ARGS{'UpdateContent'} ne '' &&
222     $ARGS{'UpdateContent'} ne  "-- \n" .
223     $session{'CurrentUser'}->UserObj->Signature) {
224             $do_comment_reply=1;
225 }
226
227 #Iterate through each ticket we've been handed
228 my @linkresults;
229 my %queues;
230
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");
237     my @updateresults; 
238     if ($do_comment_reply) {
239        ProcessUpdateMessage(TicketObj => $Ticket, ARGSRef => \%ARGS, Actions => \@updateresults); 
240     }
241
242     #Update the basics.
243     my @basicresults = ProcessTicketBasics(TicketObj => $Ticket, ARGSRef => \%ARGS);
244     my @dateresults = ProcessTicketDates(TicketObj => $Ticket, ARGSRef => \%ARGS);
245     #Update the watchers
246     my @watchresults = ProcessTicketWatchers(TicketObj => $Ticket, ARGSRef => \%ARGS);    
247
248
249     #Update the links
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);
259     delete $ARGS{'id'};
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;
270
271     @results = (@results, @tempresults);
272 }
273
274 my $TxnCFs = RT::CustomFields->new($session{CurrentUser});
275 $TxnCFs->LimitToLookupType("RT::Queue-RT::Ticket-RT::Transaction");
276 $TxnCFs->LimitToGlobalOrObjectId(sort keys %queues);
277
278 </%INIT>