import of rt 3.0.9
[freeside.git] / rt / html / Admin / Elements / EditScrips
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/ListActions, actions => \@actions &>
25
26 <form action="Scrips.html" method="post">
27 <input type="hidden" name="id" value="<%$id%>">
28
29 <P><&|/l&>Current Scrips</&>:</P>
30 % if ($Scrips->Count == 0 ) {
31 <P><i><&|/l&>(No scrips)</&></i></P>
32 % } else {
33 <TABLE>
34 <P><i><&|/l&>(Check box to delete)</&></i></P>
35
36 %   while (my $scrip = $Scrips->Next ) {
37 <TR>
38 <TD>
39 <input type="checkbox" name="DeleteScrip-<%$scrip->Id%>">
40 </TD>
41 <TD>
42 <a href="Scrip.html?id=<%$scrip->Id%>&Queue=<%$id%>"><% $scrip->Description || "<i>(".loc('no value').")</i>" |n %></a><br>
43 <small><&|/l, loc($scrip->ConditionObj->Name), loc($scrip->ActionObj->Name), loc($scrip->TemplateObj->Name) &>[_1] [_2] with template [_3]</&></small>
44 </TD>
45 </TR>
46 %   }
47
48 </TABLE>
49
50 % }
51 <& /Elements/Submit, 
52         Caption => loc("Delete selected scrips"), 
53         Label => loc("Delete") &>
54 </form>
55 <%init>
56 my (@actions);
57
58 my $Scrips = RT::Scrips->new($session{'CurrentUser'});
59
60
61 my $QueueObj = RT::Queue->new($session{'CurrentUser'});
62 if ($id)  {
63         $QueueObj->Load($id);                        
64 }
65
66 if ($QueueObj->id) {                         
67         $Scrips->LimitToQueue($id);
68 }                                            
69 else {                                       
70         $Scrips->LimitToGlobal();
71 }                                           
72
73
74
75
76 # {{{ deal with modifying and deleting existing scrips
77 foreach my $key (keys %ARGS) {
78   # {{{ if we're trying to delete the scrip
79   if ($key =~ /^DeleteScrip-(\d+)/) {
80     my $id = $1;
81     my $scrip = new RT::Scrip($session{'CurrentUser'});
82     $scrip->Load($id);
83     my ($retval, $msg) = $scrip->Delete;
84     if ($retval) {
85       push @actions, loc("Scrip deleted");
86     }
87     else {
88       push @actions, $msg;
89     }
90   }
91   # }}}
92 }
93 # }}}
94 </%init>
95
96 <%ARGS>
97 $id => undef
98 $title => undef
99 </%ARGS>