import rt 3.0.12
[freeside.git] / rt / html / Admin / Global / Template.html
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 <& /Admin/Elements/Header, Title => loc("Modify template [_1]", $TemplateObj->id)  &>
25 <& /Admin/Elements/SystemTabs, 
26     current_tab => 'Admin/Global/Templates.html', 
27     current_subtab => $current_subtab, 
28     subtabs => $subtabs, 
29     Title => loc("Modify template [_1]", $TemplateObj->id) &>
30 <& /Elements/ListActions, actions => \@results &>
31
32
33 <FORM METHOD=POST ACTION="Template.html">
34 %if ($Create ) {
35 <INPUT TYPE=HIDDEN NAME="Template" VALUE="new">
36 % } else {
37 <INPUT TYPE=HIDDEN NAME="Template" VALUE="<%$TemplateObj->Id%>">
38 % }
39
40 %# hang onto the queue id
41 <INPUT TYPE=HIDDEN name="Queue" value="<%$Queue%>">
42
43 <& /Admin/Elements/ModifyTemplate, Name => $TemplateObj->Name, Description => $TemplateObj->Description, Content => $TemplateObj->Content &>
44
45 <& /Elements/Submit, Label => loc('Save Changes'), Reset => 1 &>
46 </FORM>
47
48
49
50 <%INIT>
51
52 my $TemplateObj = new RT::Template($session{'CurrentUser'});
53 my  ($title, @results, $current_subtab);
54
55 my $subtabs = {
56                  A => { title => loc('Select template'),
57                         path => "Admin/Global/Templates.html"
58                            },
59                  B => { title => loc('New template'),
60                         path => "Admin/Global/Template.html?Create=1&Queue=0",
61                         separator => 1,
62                            }
63               };
64
65
66 if ($Create) {
67   $current_subtab = "Admin/Global/Template.html?Create=1&Queue=0";
68   $title = loc("Create a template");
69 }
70
71 else {
72   if ($Template eq 'new') {
73       my ($val, $msg) =  $TemplateObj->Create(Queue => $Queue, Name => $Name);
74       Abort(loc("Could not create template: [_1]", $msg)) unless ($val);
75      push @results, $msg;
76     }
77     else {
78        $TemplateObj->Load($Template) || Abort(loc('No Template'));
79     }
80       $title = loc('Modify template [_1]', loc($TemplateObj->Name())); 
81   
82     
83 }
84 if ($TemplateObj->Id()) {
85   my @attribs = qw( Description Content Queue Name);
86   my @aresults = UpdateRecordObject( AttributesRef => \@attribs, 
87                                      Object => $TemplateObj, 
88                                      ARGSRef => \%ARGS);
89   $current_subtab = "Admin/Global/Template.html?Queue=0&Template=".$TemplateObj->Id();
90   $subtabs->{"C"} = { title => loc('Template #[_1]', $TemplateObj->Id()),
91                         path => "Admin/Global/Template.html?Queue=0&Template=".$TemplateObj->Id(),
92                         };
93   push @results, @aresults;
94 }
95 </%INIT>
96 <%ARGS>
97 $Queue => undef
98 $Template => undef
99 $Create => undef
100 $Name => undef
101 </%ARGS>