1 %# BEGIN BPS TAGGED BLOCK {{{
5 %# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC
6 %# <sales@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., 51 Franklin Street, Fifth Floor, Boston, MA
26 %# 02110-1301 or visit their web page on the internet at
27 %# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
30 %# CONTRIBUTION SUBMISSION POLICY:
32 %# (The following paragraph is not intended to limit the rights granted
33 %# to you to modify and distribute this software under the terms of
34 %# the GNU General Public License and is only of importance to you if
35 %# you choose to contribute your changes and enhancements to the
36 %# community by submitting them to Best Practical Solutions, LLC.)
38 %# By intentionally submitting any modifications, corrections or
39 %# derivatives to this work, or any other work intended for use with
40 %# Request Tracker, to Best Practical Solutions, LLC, you confirm that
41 %# you are the copyright holder for those contributions and you grant
42 %# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
43 %# royalty-free, perpetual, license to use, copy, create derivative
44 %# works based on those contributions, and sublicense and distribute
45 %# those contributions and any derivatives thereof.
47 %# END BPS TAGGED BLOCK }}}
48 <& /Elements/ListActions, actions => \@actions &>
50 <form action="Scrips.html" method="post">
51 <input type="hidden" class="hidden" name="id" value="<% $id %>" />
53 <h2><&|/l&>Scrips</&></h2>
54 <div class="admin-hint"><&|/l&>Scrips normally run after each individual change to a ticket.</&></div>
55 % my $scrips = $find_scrips->(Stage => 'TransactionCreate');
56 <& /Elements/CollectionList, %common_applied_args, Collection => $scrips &>
57 % unless ( $scrips->Count ) {
58 <p><i><&|/l&>(No scrips)</&></i></p>
61 <h2><&|/l&>Batch scrips</&></h2>
62 <div class="admin-hint"><&|/l&>Batch scrips run after a set of related changes to a ticket.</&></div>
63 % $scrips = $find_scrips->(Stage => 'TransactionBatch');
64 <& /Elements/CollectionList, %common_applied_args, Collection => $scrips &>
65 % unless ( $scrips->Count ) {
66 <p><i><&|/l&>(No scrips)</&></i></p>
70 Name => 'RemoveScrips',
71 Caption => loc("Un-apply selected scrips"),
72 Label => loc("Update"),
75 <h2><&|/l&>Not applied scrips</&></h2>
76 % $scrips = $find_scrips->(Added => 0);
77 <& /Elements/CollectionList,
81 Collection => $scrips,
83 DisplayFormat => "__CheckBox.{AddScrip}__, $Format",
85 PassArguments => [ qw(Format Rows Page Order OrderBy id) ],
87 % unless ( $scrips->Count ) {
88 <p><i><&|/l&>(No scrips)</&></i></p>
91 <& SelectStageForAdded &>
95 Caption => loc("Apply selected scrips"),
96 Label => loc("Update"),
105 my $QueueObj = RT::Queue->new($session{'CurrentUser'});
106 $QueueObj->Load( $id );
107 Abort(loc("Couldn't load queue #[_1]", $id)) unless $QueueObj->id;
111 my $find_scrips = sub {
112 my %args = (Added => 1, @_);
113 my $scrips = RT::Scrips->new($session{'CurrentUser'});
114 $scrips->LimitByStage( $args{'Stage'} )
116 my $method = $args{'Added'}? 'LimitToAdded' : 'LimitToNotAdded';
117 $scrips->$method(0, $id);
118 $scrips->ApplySortOrder if $args{'Added'};
119 $scrips->FindAllRows;
123 $Format ||= RT->Config->Get('AdminSearchResultFormat')->{'Scrips'};
124 my $Rows = RT->Config->Get('AdminSearchResultRows')->{'Scrips'} || 50;
125 my $DisplayFormat = $Format;
127 $DisplayFormat = "__RemoveCheckBox__, $DisplayFormat";
129 $DisplayFormat = "__CheckBox.{RemoveScrip}__, $DisplayFormat";
131 $DisplayFormat .= ", __Move.{$id}__";
133 my %common_applied_args = (
136 DisplayFormat => $DisplayFormat,
140 PassArguments => [ qw(Format id) ],
143 if ( $RemoveScrips ) {
144 foreach my $sid ( @RemoveScrip ) {
145 my $scrip = RT::Scrip->new( $session{'CurrentUser'} );
146 $scrip->Load( $sid );
147 next unless $scrip->id;
149 my ($status, $msg) = $scrip->RemoveFromObject( $id );
155 foreach my $sid ( @AddScrip ) {
156 my $scrip = RT::Scrip->new( $session{'CurrentUser'} );
157 $scrip->Load( $sid );
158 next unless $scrip->id;
160 my ($status, $msg) = $scrip->AddToObject( $id, Stage => $Stage );
165 if ( $MoveScripUp ) {
166 my $scrip = RT::ObjectScrip->new( $session{'CurrentUser'} );
167 $scrip->LoadByCols( Scrip => $MoveScripUp, ObjectId => $id );
169 my ($status, $msg) = $scrip->MoveUp;
174 if ( $MoveScripDown ) {
175 my $scrip = RT::ObjectScrip->new( $session{'CurrentUser'} );
176 $scrip->LoadByCols( Scrip => $MoveScripDown, ObjectId => $id );
178 my ($status, $msg) = $scrip->MoveDown;
191 $RemoveScrips => undef
195 $Stage => 'TransactionCreate'
197 $MoveScripUp => undef
198 $MoveScripDown => undef