This commit was generated by cvs2svn to compensate for changes in r2523,
[freeside.git] / rt / webrt / Admin / Global / Scrips.html
1 <& /Admin/Elements/Header, Title => 'Edit scrips' &>
2 <& /Admin/Elements/SystemTabs &>
3
4 <& /Elements/ListActions, actions => \@actions &>
5
6 <& /Elements/TitleBoxStart, title => "Modify global scrips" &>
7   
8   <FORM METHOD=POST ACTION="Scrips.html">
9
10 % if ($Scrips->Count > 0 ) {
11 <TABLE>
12 <TR>
13 <TD>Delete
14 </TD>
15 <TD>
16 </TR>
17
18 %   while (my $scrip = $Scrips->Next ) {
19 <TR>
20 <TD>
21 <INPUT TYPE="CHECKBOX" NAME="DeleteScrip-<%$scrip->Id%>">
22 </TD>
23 <TD>
24 <% $scrip->ConditionObj->Name %> 
25 <% $scrip->ActionObj->Name %> 
26 with template <% $scrip->TemplateObj->Name %>
27 </TD>
28 </TR>
29 %   }
30
31 </TABLE>
32
33 % }
34 Add a scrip which will apply to all queues:
35 <ul>
36 <li>Condition: <& /Admin/Elements/SelectScripCondition, Name => 'NewScripCondition' &>
37           Action: <& /Admin/Elements/SelectScripAction, Name => 'NewScripAction' &>
38           Template: <& /Admin/Elements/SelectTemplate, Name => 'NewScripTemplate' &>
39
40 </ul>
41
42 <& /Elements/TitleBoxEnd &>
43 <& /Elements/Submit &>
44 </FORM>
45 <%init>
46 my (@actions, $description);
47
48 my $Scrips = new RT::Scrips ($session{'CurrentUser'});
49 $Scrips->LimitToGlobal();
50
51
52
53
54 if ($NewScripAction and $NewScripCondition) {
55     my $NewScrip = new RT::Scrip($session{'CurrentUser'});
56     
57     my ($retval, $msg) = $NewScrip->Create ( ScripAction => $NewScripAction,
58                                      ScripCondition => $NewScripCondition,
59                                      Stage => 'TransactionCreate',
60                                      Queue => 0,
61                                      Template => $NewScripTemplate);
62     if (defined $retval) {
63         push @actions, $msg;
64     }
65     else {
66         push @actions, $msg;
67     }
68 }
69
70 # {{{ deal with modifying and deleting existing scrips
71 my ($key );
72 foreach $key (keys %ARGS) {
73   # {{{ if we're trying to delete the scrip
74   if ($key =~ /^DeleteScrip-(\d+)/) {
75     my $id = $1;
76     my $scrip = new RT::Scrip($session{'CurrentUser'});
77     $scrip->Load($id);
78     my ($retval, $msg) = $scrip->Delete;
79     if ($retval) {
80       push @actions, "Scrip deleted";
81     }
82     else {
83       push @actions, $msg;
84     }
85   }
86   # }}}
87 }
88 # }}}
89 </%init>
90
91 <%ARGS>
92 $NewScripCondition => undef
93 $NewScripAction => undef
94 $NewScripTemplate => undef
95 </%ARGS>