import rt 3.4.6
[freeside.git] / rt / html / Search / Bulk.html
index 9ecac49..f9eef26 100644 (file)
@@ -1,8 +1,14 @@
-%# BEGIN LICENSE BLOCK
+%# BEGIN BPS TAGGED BLOCK {{{
 %# 
-%# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
+%# COPYRIGHT:
+%#  
+%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC 
+%#                                          <jesse@bestpractical.com>
 %# 
-%# (Except where explictly superceded by other copyright notices)
+%# (Except where explicitly superseded by other copyright notices)
+%# 
+%# 
+%# LICENSE:
 %# 
 %# This work is made available to you under the terms of Version 2 of
 %# the GNU General Public License. A copy of that license should have
 %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 %# General Public License for more details.
 %# 
-%# Unless otherwise specified, all modifications, corrections or
-%# extensions to this work which alter its source code become the
-%# property of Best Practical Solutions, LLC when submitted for
-%# inclusion in the work.
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+%# 
+%# 
+%# CONTRIBUTION SUBMISSION POLICY:
 %# 
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
 %# 
-%# END LICENSE BLOCK
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%# 
+%# END BPS TAGGED BLOCK }}}
 <& /Elements/Header, Title => loc("Bulk ticket update") &>
 <& /Elements/Tabs, Title => loc("Bulk ticket update") &>
 
 <& /Elements/ListActions, actions => \@results &>
-
-<FORM METHOD=POST>
+<FORM METHOD="POST" ACTION="<%$RT::WebPath%>/Search/Bulk.html" >
+<input type="hidden" name="Query" value="<%$ARGS{'Query'}%>">
 <TABLE WIDTH=100% border=0 cellpadding=3 CELLSPACING=0>
 <TR>
 <TH><&|/l&>Update</&></TH>
 
 my $i;
 
-
-      
-$session{'tickets'}->RedoSearch();
-while (my $Ticket = $session{'tickets'}->Next) {
+$Tickets->RedoSearch();
+while (my $Ticket = $Tickets->Next) {
  $i++;
  if ($i % 2) {
      $bgcolor = "#dddddd";
@@ -55,8 +75,7 @@ while (my $Ticket = $session{'tickets'}->Next) {
  }
       </%PERL>
 <TR bgcolor="<%$bgcolor%>">
-<TD><input type=checkbox name="UpdateTicket<%$Ticket->Id%>" CHECKED></TD>
-%# The ticket view is controlled by config.pm, WebOptions
+<TD><input type=checkbox name="UpdateTicket<%$Ticket->Id%>" value="1" CHECKED></TD>
 %foreach my $col (@cols) {
 <TD>
 % if ($col eq 'id') {
@@ -129,19 +148,30 @@ while (my $Ticket = $session{'tickets'}->Next) {
 <tr><td align=right><&|/l&>Update Type</&>:</td>
 <td><select name="UpdateType">
   <option value="private" ><&|/l&>Comments (not sent to requestors)</&></option>
-<option value="response" ><&|/l&>Response to requestors</&></option>
+<option value="response" ><&|/l&>Reply to requestors</&></option>
 </select> 
 </td></tr>
 <tr><td align=right><&|/l&>Subject</&>:</td><td> <input name="UpdateSubject" size=60 value=""></td></tr>
+% while (my $CF = $TxnCFs->Next()) {
+<TR>
+<TD ALIGN=RIGHT><% $CF->Name %>:</TD>
+<TD><& /Elements/EditCustomField, 
+    CustomField => $CF, 
+    NamePrefix => "Object-RT::Transaction--CustomField-"
+    &><em><% $CF->FriendlyType %></em></TD>
+</TD></TR>
+% } # end if while
  <tr><td align=right><&|/l&>Attach</&>:</td><td><input name="UpdateAttachment" type="file"></td></tr>
  <tr><td class=labeltop><&|/l&>Message</&>:</td><td>
  <& /Elements/MessageBox, Name=>"UpdateContent"&>
  </td></tr>
  </table>
+
 <& /Elements/TitleBoxEnd &>
 
-<& /Elements/TitleBoxStart, title => loc('Edit Relationships'), color => "#336633"&>
-<i><&|/l&>Enter tickets or URIs to link tickets to. Seperate multiple entries with spaces.</&></i><br>
+
+<& /Elements/TitleBoxStart, title => loc('Edit Links'), color => "#336633"&>
+<i><&|/l&>Enter tickets or URIs to link tickets to. Separate multiple entries with spaces.</&></i><br>
 <& /Ticket/Elements/BulkLinks &>
 <& /Elements/TitleBoxEnd &>
 
@@ -157,8 +187,30 @@ map ($ARGS{$_} =~ /^$/ && (delete $ARGS{$_}), keys %ARGS);
 my ($bgcolor, @results);
 my @cols = qw(id Status Priority Subject QueueObj->Name OwnerObj->Name RequestorAddresses DueAsString );
 
-Abort(loc("No search to operate on.")) unless ($session{'tickets'});
 
+my $Tickets = RT::Tickets->new($session{'CurrentUser'});
+$Tickets->FromSQL($ARGS{'Query'});
+
+Abort(loc("No search to operate on.")) unless ($Tickets);
+
+my %allcfs;
+my %cfqnames;
+my %cfqs;
+my $count = 0;
+while (my $Ticket = $Tickets->Next) {
+    my $cfq = $Ticket->QueueObj;
+    my $cfqid = $cfq->Id;
+    my $cfqn = $cfq->Name;
+    unless ( exists $cfqs{$cfqid} ) {
+       $cfqs{$cfqid} = 1;
+       $count++;
+       my $cfs = $cfq->TicketCustomFields;
+       while (my $cf = $cfs->Next) {
+           $allcfs{$cf->Id} = $cf;
+           $cfqnames{$cf->Id} = $cfqn;
+       }
+    }
+}
 
 my $do_comment_reply=0;
 # Prepare for ticket updates
@@ -174,9 +226,11 @@ if ($ARGS{'UpdateContent'} &&
 
 #Iterate through each ticket we've been handed
 my @linkresults;
+my %queues;
 
-$session{'tickets'}->RedoSearch();
-while (my $Ticket = $session{'tickets'}->Next) {
+$Tickets->RedoSearch();
+while (my $Ticket = $Tickets->Next) {
+    $queues{$Ticket->QueueObj->Id}++;
     $RT::Logger->debug( "Checking Ticket ".$Ticket->Id ."\n");
     next unless ($ARGS{"UpdateTicket".$Ticket->Id});
     $RT::Logger->debug ("Matched\n");
@@ -191,6 +245,7 @@ while (my $Ticket = $session{'tickets'}->Next) {
     #Update the watchers
     my @watchresults = ProcessTicketWatchers(TicketObj => $Ticket, ARGSRef => \%ARGS);    
 
+
     #Update the links
     $ARGS{'id'} = $Ticket;
     $ARGS{$Ticket->Id.'-MergeInto'} = $ARGS{'Ticket-MergeInto'};
@@ -209,11 +264,15 @@ while (my $Ticket = $session{'tickets'}->Next) {
     delete $ARGS{'MemberOf-'.$Ticket->Id};
     delete $ARGS{$Ticket->Id.'-RefersTo'};
     delete $ARGS{'RefersTo-'.$Ticket->Id};
-    
-    my @tempresults = (@watchresults, @basicresults, @dateresults, @updateresults, @linkresults);
+    my @tempresults = (@watchresults, @basicresults, @dateresults,
+    @updateresults, @linkresults);
     @tempresults = map { loc("Ticket [_1]: [_2]",$Ticket->Id,$_) } @tempresults;
 
     @results = (@results, @tempresults);
 }
 
+my $TxnCFs = RT::CustomFields->new($session{CurrentUser});
+$TxnCFs->LimitToLookupType("RT::Queue-RT::Ticket-RT::Transaction");
+$TxnCFs->LimitToGlobalOrObjectId(sort keys %queues);
+
 </%INIT>