import rt 3.0.12
[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&>Stage</&>: 
81 </TD>
82 <TD>
83 <& /Admin/Elements/SelectStage, Name => "Scrip-$id-Stage", Default => $scrip->Stage &>
84 </TD>
85 </TR>
86 <TR>
87 <TD ALIGN=RIGHT>
88 <&|/l&>Template</&>: 
89 </TD>
90 <TD>
91 <& /Admin/Elements/SelectTemplate, Name => "Scrip-$id-Template", Default => $scrip->TemplateObj->Id, Queue => $Queue &>
92 </TD>
93 </TR>
94
95 <& /Elements/Submit, Label => loc('Create'), Reset => 1 &>
96 </FORM>
97 <%init>
98 my (@actions);
99
100
101 my $scrip = new RT::Scrip($session{'CurrentUser'});
102
103 if ( $id eq 'new' ) {
104
105     my ( $retval, $msg ) = $scrip->Create(
106             Queue                  => $Queue,
107             ScripAction            => $ARGS{"Scrip-new-ScripAction"},
108             ScripCondition         => $ARGS{"Scrip-new-ScripCondition"},
109             Template               => $ARGS{"Scrip-new-Template"},
110             Description            => $ARGS{"Scrip-new-Description"},
111             CustomPrepareCode      => $ARGS{"Scrip-new-CustomPrepareCode"},
112             CustomCommitCode       => $ARGS{"Scrip-new-CustomCommitCode"},
113             CustomIsApplicableCode => $ARGS{"Scrip-new-CustomIsApplicableCode"},
114     );
115     if ( defined $retval ) {
116         push @actions, $msg;
117         $id = $scrip->id;
118     }
119     else {
120         Abort( $msg);
121     }
122 }
123 elsif ($id) {
124     my ($val,$msg) =$scrip->Load($id);
125     if  ($val) {
126         $id = $scrip->id;
127     } else {
128        Abort ($msg);
129     }
130     my @attribs = qw (
131       Queue
132       ScripAction
133       ScripCondition
134       Template
135       Stage
136       Description
137       CustomPrepareCode
138       CustomCommitCode
139       CustomIsApplicableCode
140     );
141     my @results = UpdateRecordObject( AttributesRef => \@attribs,
142                                       AttributePrefix => 'Scrip-'.$scrip->Id,
143                                       Object        => $scrip,
144                                       ARGSRef       => \%ARGS );
145     push (@actions, @results);
146 }
147
148 elsif ($ARGS{'create'}) {
149     $id = 'new';
150 }
151
152 # }}}
153 </%init>
154
155 <%ARGS>
156 $id => undef
157 $title => undef
158 $Queue => 0
159 </%ARGS>