This commit was generated by cvs2svn to compensate for changes in r3883,
[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 => $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, Label => loc('Create'), Reset => 1 &>
45 </FORM>
46
47
48 <%INIT>
49
50 my $QueueObj = new RT::Queue($session{'CurrentUser'});
51 $QueueObj->Load($Queue);
52
53 my $TemplateObj = new RT::Template($session{'CurrentUser'});
54 my  ($title, @results, $current_subtab);
55
56 my $subtabs = {
57                  A => { title => loc('Select template'),
58                         path => "Admin/Queues/Templates.html?id=$Queue"
59                            },
60                  B => { title => loc('New template'),
61                         path => "Admin/Queues/Template.html?Create=1&Queue=$Queue",
62                         separator => 1,
63                            }
64               };
65
66 if ($Create) {
67   $title = loc("Create a template");
68   $current_subtab = "Admin/Queues/Template.html?create=1&Queue=".$Queue;
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   $Queue = $TemplateObj->Queue;
86
87   my @attribs = qw( Description Content Queue Name);
88   my @aresults = UpdateRecordObject( AttributesRef => \@attribs, 
89                                      Object => $TemplateObj, 
90                                      ARGSRef => \%ARGS);
91   $current_subtab = "Admin/Queues/Template.html?Queue=$Queue&Template=".$TemplateObj->Id();
92   $subtabs->{"C"} = { title => loc('Template #[_1]', $TemplateObj->Id()),
93                         path => "Admin/Queues/Template.html?Queue=$Queue&Template=".$TemplateObj->Id(),
94                         };
95   push @results, @aresults;
96 }
97
98 </%INIT>
99 <%ARGS>
100 $Queue => undef
101 $Template => undef
102 $Create => undef
103 $Name => undef
104 </%ARGS>