import of rt 3.0.9
[freeside.git] / rt / html / Search / Bulk.html
1 %# BEGIN LICENSE BLOCK
2 %# 
3 %# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
4 %# 
5 %# (Except where explictly superceded by other copyright notices)
6 %# 
7 %# This work is made available to you under the terms of Version 2 of
8 %# the GNU General Public License. A copy of that license should have
9 %# been provided with this software, but in any event can be snarfed
10 %# from www.gnu.org.
11 %# 
12 %# This work is distributed in the hope that it will be useful, but
13 %# WITHOUT ANY WARRANTY; without even the implied warranty of
14 %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 %# General Public License for more details.
16 %# 
17 %# Unless otherwise specified, all modifications, corrections or
18 %# extensions to this work which alter its source code become the
19 %# property of Best Practical Solutions, LLC when submitted for
20 %# inclusion in the work.
21 %# 
22 %# 
23 %# END LICENSE BLOCK
24 <& /Elements/Header, Title => loc("Bulk ticket update") &>
25 <& /Elements/Tabs, Title => loc("Bulk ticket update") &>
26
27 <& /Elements/ListActions, actions => \@results &>
28
29 <FORM METHOD=POST>
30 <TABLE WIDTH=100% border=0 cellpadding=3 CELLSPACING=0>
31 <TR>
32 <TH><&|/l&>Update</&></TH>
33 %foreach my $col (@cols) {
34 % my $colalias = $col;
35 % $colalias =~ s/(Obj\-\>|)(Name|AsString)//;
36
37 <TH><% loc($colalias) %>&nbsp;</TH>
38 %}
39 </TR>
40
41 <%PERL>
42
43 my $i;
44
45
46       
47 $session{'tickets'}->RedoSearch();
48 while (my $Ticket = $session{'tickets'}->Next) {
49  $i++;
50  if ($i % 2) {
51      $bgcolor = "#dddddd";
52  }
53  else {
54      $bgcolor = "#ffffff";
55  }
56       </%PERL>
57 <TR bgcolor="<%$bgcolor%>">
58 <TD><input type=checkbox name="UpdateTicket<%$Ticket->Id%>" CHECKED></TD>
59 %# The ticket view is controlled by config.pm, WebOptions
60 %foreach my $col (@cols) {
61 <TD>
62 % if ($col eq 'id') {
63 <A HREF="<% $RT::WebPath%>/Ticket/Display.html?id=<%$Ticket->Id%>"><%$Ticket->Id()%></A>
64 % }
65 %else {
66 <% eval "\$Ticket->$col()" %>&nbsp;
67 %}
68 </TD>
69 %}
70 </TR>
71 %}
72
73
74
75 </TABLE>
76
77 <HR>
78
79
80 <& /Elements/TitleBoxStart, title => loc('Update selected tickets') &>
81 <TABLE>
82 <TR>
83 <TD VALIGN=TOP>
84 <table>
85 <tr><td class=label> <&|/l&>Make Owner</&>: </td>
86 <td class=value> <& /Elements/SelectOwner, Name => "Owner" &> (<input type=checkbox name="ForceOwnerChange"> <&|/l&>Force change</&>) </td></tr>
87 <tr><td class=label> <&|/l&>Add Requestor</&>: </td>
88 <td class=value> <INPUT Name="AddRequestor" SIZE=20> </td></tr>
89 <tr><td class=label> <&|/l&>Remove Requestor</&>: </td>
90 <td class=value> <INPUT Name="DeleteRequestor" SIZE=20> </td></tr>
91 <tr><td class=label> <&|/l&>Add Cc</&>: </td>
92 <td class=value> <INPUT Name="AddCc" SIZE=20> </td></tr>
93 <tr><td class=label> <&|/l&>Remove Cc</&>: </td>
94 <td class=value> <INPUT Name="DeleteCc" SIZE=20> </td></tr>
95 <tr><td class=label> <&|/l&>Add AdminCc</&>: </td>
96 <td class=value> <INPUT Name="AddAdminCc" SIZE=20> </td></tr>
97 <tr><td class=label> <&|/l&>Remove AdminCc</&>: </td>
98 <td class=value> <INPUT Name="DeleteAdminCc" SIZE=20> </td></tr>
99 </table>
100 </TD>
101 <TD VALIGN=TOP>
102 <table>
103 <tr><td class=label> <&|/l&>Make subject</&>: </td>
104 <td class=value> <INPUT Name="Subject" SIZE=20> </td></tr>
105 <tr><td class=label> <&|/l&>Make priority</&>: </td>
106 <td class=value> <INPUT Name="Priority" SIZE=4> </td></tr>
107 <tr><td class=label> <&|/l&>Make queue</&>: </td>
108 <td class=value> <& /Elements/SelectQueue, Name => "Queue" &> </td></tr>
109 <tr><td class=label> <&|/l&>Make Status</&>: </td>
110 <td class=value> <& /Elements/SelectStatus, Name => "Status" &> </td></tr>
111 <tr><td class=label> <&|/l&>Make date Starts</&>: </td>
112 <td class=value> <& /Elements/SelectDate, Name => "Starts_Date", ShowTime => 0, Default => '' &> </td></tr>
113 <tr><td class=label> <&|/l&>Make date Started</&>: </td>
114 <td class=value> <& /Elements/SelectDate, Name => "Started_Date", ShowTime => 0, Default => '' &> </td></tr>
115 <tr><td class=label> <&|/l&>Make date Told</&>: </td>
116 <td class=value> <& /Elements/SelectDate, Name => "Told_Date", ShowTime => 0, Default => '' &> </td></tr>
117 <tr><td class=label> <&|/l&>Make date Due</&>: </td>
118 <td class=value> <& /Elements/SelectDate, Name => "Due_Date", ShowTime => 0, Default => '' &> </td></tr>
119 <tr><td class=label> <&|/l&>Make date Resolved</&>: </td>
120 <td class=value> <& /Elements/SelectDate, Name => "Resolved_Date", ShowTime => 0, Default => '' &> </td></tr>
121 </table>
122
123 </TD>
124 </TR>
125 </table>
126 <& /Elements/TitleBoxEnd&>
127 <& /Elements/TitleBoxStart, title => loc('Add comments or replies to selected tickets') &>
128 <table>
129 <tr><td align=right><&|/l&>Update Type</&>:</td>
130 <td><select name="UpdateType">
131   <option value="private" ><&|/l&>Comments (not sent to requestors)</&></option>
132 <option value="response" ><&|/l&>Response to requestors</&></option>
133 </select> 
134 </td></tr>
135 <tr><td align=right><&|/l&>Subject</&>:</td><td> <input name="UpdateSubject" size=60 value=""></td></tr>
136  <tr><td align=right><&|/l&>Attach</&>:</td><td><input name="UpdateAttachment" type="file"></td></tr>
137  <tr><td class=labeltop><&|/l&>Message</&>:</td><td>
138  <& /Elements/MessageBox, Name=>"UpdateContent"&>
139  </td></tr>
140  </table>
141 <& /Elements/TitleBoxEnd &>
142
143 <& /Elements/TitleBoxStart, title => loc('Edit Relationships'), color => "#336633"&>
144 <i><&|/l&>Enter tickets or URIs to link tickets to. Seperate multiple entries with spaces.</&></i><br>
145 <& /Ticket/Elements/BulkLinks &>
146 <& /Elements/TitleBoxEnd &>
147
148 <& /Elements/Submit &>
149
150
151 </FORM>
152 <%INIT>
153
154 # Iterate through the ARGS hash and remove anything with a null value.
155 map ($ARGS{$_} =~ /^$/ && (delete $ARGS{$_}), keys %ARGS);
156
157 my ($bgcolor, @results);
158 my @cols = qw(id Status Priority Subject QueueObj->Name OwnerObj->Name RequestorAddresses DueAsString );
159
160 Abort(loc("No search to operate on.")) unless ($session{'tickets'});
161
162
163 my $do_comment_reply=0;
164 # Prepare for ticket updates
165 $ARGS{'UpdateContent'} =~ s/\r\n/\n/g;
166 chomp ($ARGS{'UpdateContent'}) ;
167
168 if ($ARGS{'UpdateContent'} &&
169     $ARGS{'UpdateContent'} ne '' &&
170     $ARGS{'UpdateContent'} ne  "-- \n" .
171     $session{'CurrentUser'}->UserObj->Signature) {
172             $do_comment_reply=1;
173 }
174
175 #Iterate through each ticket we've been handed
176 my @linkresults;
177
178 $session{'tickets'}->RedoSearch();
179 while (my $Ticket = $session{'tickets'}->Next) {
180     $RT::Logger->debug( "Checking Ticket ".$Ticket->Id ."\n");
181     next unless ($ARGS{"UpdateTicket".$Ticket->Id});
182     $RT::Logger->debug ("Matched\n");
183     #Update the basics.
184     my @basicresults = ProcessTicketBasics(TicketObj => $Ticket, ARGSRef => \%ARGS);
185     my @dateresults = ProcessTicketDates(TicketObj => $Ticket, ARGSRef => \%ARGS);
186     #Update the watchers
187     my @watchresults = ProcessTicketWatchers(TicketObj => $Ticket, ARGSRef => \%ARGS);    
188
189     #Update the links
190     $ARGS{'id'} = $Ticket;
191     $ARGS{$Ticket->Id.'-MergeInto'} = $ARGS{'Ticket-MergeInto'};
192     $ARGS{$Ticket->Id.'-DependsOn'} = $ARGS{'Ticket-DependsOn'};
193     $ARGS{'DependsOn-'.$Ticket->Id} = $ARGS{'DependsOn-Ticket'};
194     $ARGS{$Ticket->Id.'-MemberOf'} = $ARGS{'Ticket-MemberOf'};
195     $ARGS{'MemberOf-'.$Ticket->Id} = $ARGS{'MemberOf-Ticket'};
196     $ARGS{$Ticket->Id.'-RefersTo'} = $ARGS{'Ticket-RefersTo'};
197     $ARGS{'RefersTo-'.$Ticket->Id} = $ARGS{'RefersTo-Ticket'};
198     @linkresults = ProcessTicketLinks( TicketObj => $Ticket, ARGSRef => \%ARGS);
199     delete $ARGS{'id'};
200     delete $ARGS{$Ticket->Id.'-MergeInto'};
201     delete $ARGS{$Ticket->Id.'-DependsOn'};
202     delete $ARGS{'DependsOn-'.$Ticket->Id};
203     delete $ARGS{$Ticket->Id.'-MemberOf'};
204     delete $ARGS{'MemberOf-'.$Ticket->Id};
205     delete $ARGS{$Ticket->Id.'-RefersTo'};
206     delete $ARGS{'RefersTo-'.$Ticket->Id};
207     
208     my @updateresults; 
209     if ($do_comment_reply) {
210     ProcessUpdateMessage(TicketObj => $Ticket, ARGSRef => \%ARGS, Actions => \@updateresults); 
211    } 
212    my @tempresults = (@watchresults, @basicresults, @dateresults, @updateresults, @linkresults);
213     @tempresults = map { loc("Ticket [_1]: [_2]",$Ticket->Id,$_) } @tempresults;
214
215     @results = (@results, @tempresults);
216 }
217
218 </%INIT>