import of rt 3.0.4
[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 </form>
53 <%init>
54 my (@actions);
55
56 my $Scrips = RT::Scrips->new($session{'CurrentUser'});
57
58
59 my $QueueObj = RT::Queue->new($session{'CurrentUser'});
60 if ($id)  {
61         $QueueObj->Load($id);                        
62 }
63
64 if ($QueueObj->id) {                         
65         $Scrips->LimitToQueue($id);
66 }                                            
67 else {                                       
68         $Scrips->LimitToGlobal();
69 }                                           
70
71
72
73
74 # {{{ deal with modifying and deleting existing scrips
75 foreach my $key (keys %ARGS) {
76   # {{{ if we're trying to delete the scrip
77   if ($key =~ /^DeleteScrip-(\d+)/) {
78     my $id = $1;
79     my $scrip = new RT::Scrip($session{'CurrentUser'});
80     $scrip->Load($id);
81     my ($retval, $msg) = $scrip->Delete;
82     if ($retval) {
83       push @actions, loc("Scrip deleted");
84     }
85     else {
86       push @actions, $msg;
87     }
88   }
89   # }}}
90 }
91 # }}}
92 </%init>
93
94 <%ARGS>
95 $id => undef
96 $title => undef
97 </%ARGS>