import of rt 3.0.4
[freeside.git] / rt / html / Admin / Elements / EditScrip
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   
27 <FORM METHOD=POST ACTION="Scrip.html">
28 <input type="hidden" name="id" value="<%$id%>">
29 <input type="hidden" name="Queue" value="<%$Queue%>">
30 <TABLE>
31 <TR>
32 <TD ALIGN=RIGHT>
33 <&|/l&>Description</&>:
34 </TD>
35 <TD>
36 <input Name="Scrip-<%$id%>-Description" value="<%$scrip->Description%>">
37 </TR>
38 <TR>
39 <TD ALIGN=RIGHT>
40 <&|/l&>Condition</&>:
41 </TD>
42 <TD>
43 <& /Admin/Elements/SelectScripCondition, Name => "Scrip-$id-ScripCondition", Default => $scrip->ConditionObj->Id &><BR>
44 </TD>
45 </TR>
46 <TR>
47 <TD ALIGN=RIGHT>
48 <&|/l&>Custom condition</&>:
49 </TD>
50 <TD>
51 <TEXTAREA COLS=80 ROWS=5 NAME="Scrip-<%$id%>-CustomIsApplicableCode"><%$scrip->CustomIsApplicableCode%></TEXTAREA>
52 </TD>
53 </TR>
54 <TR>
55 <TD ALIGN=RIGHT>
56 <&|/l&>Action</&>:
57 </TD>
58 <TD>
59 <& /Admin/Elements/SelectScripAction, Name => "Scrip-$id-ScripAction", Default => $scrip->ActionObj->Id &>
60 </TD>
61 </TR>
62 <TR>
63 <TD ALIGN=RIGHT>
64 <&|/l&>Custom action preparation code</&>:
65 </TD>
66 <TD>
67 <TEXTAREA COLS=80 ROWS=5 NAME="Scrip-<%$id%>-CustomPrepareCode"><%$scrip->CustomPrepareCode%></TEXTAREA>
68 </TD>
69 </TR>
70 <TR>
71 <TD ALIGN=RIGHT>
72 <&|/l&>Custom action cleanup code</&>:
73 </TD>
74 <TD>
75 <TEXTAREA COLS=80 ROWS=5 NAME="Scrip-<%$id%>-CustomCommitCode"><%$scrip->CustomCommitCode%></TEXTAREA>
76 </TD>
77 </TR>
78 <TR>
79 <TD ALIGN=RIGHT>
80 <&|/l&>Template</&>: 
81 </TD>
82 <TD>
83 <& /Admin/Elements/SelectTemplate, Name => "Scrip-$id-Template", Default => $scrip->TemplateObj->Id, Queue => $Queue &>
84 </TD>
85 </TR>
86
87 <& /Elements/Submit, Caption => loc("Be sure to save your changes"), Reset => 1 &>
88 </FORM>
89 <%init>
90 my (@actions);
91
92
93 my $scrip = new RT::Scrip($session{'CurrentUser'});
94
95 if ( $id eq 'new' ) {
96
97     my ( $retval, $msg ) = $scrip->Create(
98             Queue                  => $Queue,
99             ScripAction            => $ARGS{"Scrip-new-ScripAction"},
100             ScripCondition         => $ARGS{"Scrip-new-ScripCondition"},
101             Template               => $ARGS{"Scrip-new-Template"},
102             Description            => $ARGS{"Scrip-new-Description"},
103             CustomPrepareCode      => $ARGS{"Scrip-new-CustomPrepareCode"},
104             CustomCommitCode       => $ARGS{"Scrip-new-CustomCommitCode"},
105             CustomIsApplicableCode => $ARGS{"Scrip-new-CustomIsApplicableCode"},
106     );
107     if ( defined $retval ) {
108         push @actions, $msg;
109     }
110     else {
111         Abort( $msg);
112     }
113 }
114 elsif ($id) {
115     my ($val,$msg) =$scrip->Load($id);
116     if  ($val) {
117         $id = $scrip->id;
118     } else {
119        Abort ($msg);
120     }
121     my @attribs = qw (
122       Queue
123       ScripAction
124       ScripCondition
125       Template
126       Description
127       CustomPrepareCode
128       CustomCommitCode
129       CustomIsApplicableCode
130     );
131     my @results = UpdateRecordObject( AttributesRef => \@attribs,
132                                       AttributePrefix => 'Scrip-'.$scrip->Id,
133                                       Object        => $scrip,
134                                       ARGSRef       => \%ARGS );
135     push (@actions, @results);
136 }
137
138 elsif ($ARGS{'create'}) {
139     $id = 'new';
140 }
141
142 # }}}
143 </%init>
144
145 <%ARGS>
146 $id => undef
147 $title => undef
148 $Queue => 0
149 </%ARGS>