summaryrefslogtreecommitdiff
path: root/rt/webrt/Admin/Global/Template.html
blob: 856d2ee8f52292c50909480067303cfe0d155494 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<& /Admin/Elements/Header, title => "Modify template ".$TemplateObj->id&>
<& /Admin/Elements/SystemTabs &>
<& /Elements/ListActions, actions => \@results &>

<& /Elements/TitleBoxStart, title => $title &>

<FORM METHOD=POST ACTION="Template.html">
%if ($create ) {
<INPUT TYPE=HIDDEN NAME=template VALUE="new">
% } else {
<INPUT TYPE=HIDDEN NAME=template VALUE="<%$TemplateObj->Id%>">
% }

%# hang onto the queue id
<INPUT TYPE=HIDDEN name="Queue" value="<%$Queue%>">


Name: <input name="Name" VALUE="<%$TemplateObj->Name%>" SIZE=20><BR>
Description: <input name="Description" VALUE="<%$TemplateObj->Description%>" SIZE=80><BR>

<TEXTAREA NAME=Content ROWS=25 COLS=80 WRAP=SOFT>
<%$TemplateObj->Content%></TEXTAREA>

<& /Elements/TitleBoxEnd&>
<&/Elements/Submit&>
</FORM>



<%INIT>

my $TemplateObj = new RT::Template($session{'CurrentUser'});
my  ($title, @results);

if ($create) {
  $title = "Create a template";
}

else {
  if ($template eq 'new') {
      my ($val, $msg) =  $TemplateObj->Create(Queue => $Queue, Name => $Name);
      Abort("Could not create template: $msg") unless ($val);
     push @results, $msg;
     $title = 'Created template ' . $TemplateObj->Name(); 
    }
    else {
       $TemplateObj->Load($template) || Abort('No Template');
      $title = 'Editing template ' . $TemplateObj->Name(); 
    }
  
    
}
if ($TemplateObj->Id()) {
  my @attribs = qw( Description Content Queue Name);
  my @aresults = UpdateRecordObject( AttributesRef => \@attribs, 
				     Object => $TemplateObj, 
				     ARGSRef => \%ARGS);
  push @results, @aresults;
}
</%INIT>
<%ARGS>
$Queue => undef
$template => undef
$create => undef
$Name => undef
</%ARGS>