import of rt 3.0.4
[freeside.git] / rt / html / Admin / Queues / 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 => $title &>
25 <& /Admin/Elements/QueueTabs, id => $Queue, 
26     QueueObj => $TemplateObj->QueueObj,
27      current_tab => 'Admin/Queues/Templates.html?id='.$Queue,
28      current_subtab => $current_subtab, 
29      subtabs => $subtabs, 
30      Title => $title &>
31 <& /Elements/ListActions, actions => \@results &>
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 <& /Admin/Elements/ModifyTemplate, Name => $TemplateObj->Name, Description =>
43 $TemplateObj->Description, Content => $TemplateObj->Content &> 
44 <& /Elements/Submit, Caption => loc("Be sure to save your changes"), Reset => 1 &>
45 </FORM>
46
47
48 <%INIT>
49
50 my $TemplateObj = new RT::Template($session{'CurrentUser'});
51 my  ($title, @results, $current_subtab);
52
53 my $subtabs = {
54                  A => { title => loc('Select template'),
55                         path => "Admin/Queues/Templates.html?id=$Queue"
56                            },
57                  B => { title => loc('New template'),
58                         path => "Admin/Queues/Template.html?Create=1&Queue=$Queue",
59                         separator => 1,
60                            }
61               };
62
63 if ($Create) {
64   $title = loc("Create a template");
65   $current_subtab = "Admin/Queues/Template.html?create=1&Queue=".$Queue;
66 }
67
68 else {
69   if ($Template eq 'new') {
70       my ($val, $msg) =  $TemplateObj->Create(Queue => $Queue, Name => $Name);
71       Abort(loc("Could not create template: [_1]", $msg)) unless ($val);
72      push @results, $msg;
73     }
74     else {
75        $TemplateObj->Load($Template) || Abort(loc('No Template'));
76     }
77      $title = loc('Modify template [_1]', loc($TemplateObj->Name())); 
78   
79     
80 }
81 if ($TemplateObj->Id()) {
82   $Queue = $TemplateObj->Queue;
83
84   my @attribs = qw( Description Content Queue Name);
85   my @aresults = UpdateRecordObject( AttributesRef => \@attribs, 
86                                      Object => $TemplateObj, 
87                                      ARGSRef => \%ARGS);
88   $current_subtab = "Admin/Queues/Template.html?Queue=$Queue&Template=".$TemplateObj->Id();
89   $subtabs->{"C"} = { title => loc('Template #[_1]', $TemplateObj->Id()),
90                         path => "Admin/Queues/Template.html?Queue=$Queue&Template=".$TemplateObj->Id(),
91                         };
92   push @results, @aresults;
93 }
94
95 </%INIT>
96 <%ARGS>
97 $Queue => undef
98 $Template => undef
99 $Create => undef
100 $Name => undef
101 </%ARGS>