RT# 82137 - added processing fee template substitution.
[freeside.git] / httemplate / edit / msg_template / http.html
1 <& /edit/elements/edit.html,
2     'post_url'         => $fsurl.'edit/process/msg_template.html', 
3     'name_singular'    => 'message interface',
4     'table'            => 'msg_template',
5     'viewall_dir'      => 'browse',
6     'agent_virt'       => 1,
7     'agent_null'       => 1,
8     'agent_null_right' => [ 'View global templates', 'Edit global templates' ],
9
10     'fields'           => [], # callback takes care of this
11     'new_callback'     => $edit_callback,
12     'edit_callback'    => $edit_callback,
13     'error_callback'   => $edit_callback,
14     'labels'           => \%labels,
15     'no_submit'        => $no_submit,
16 &>
17 <%init>
18 my $curuser = $FS::CurrentUser::CurrentUser;
19
20 die "access denied"
21   unless $curuser->access_right([ 'View templates', 'View global templates',
22                                   'Edit templates', 'Edit global templates',
23                                ]);
24
25 my %labels = (
26   'msgnum'      => 'Template', # it's still a template number
27   'agentnum'    => 'Agent',
28   'msgname'     => 'Interface name',
29   'prepare_url' => 'Prepare URL',
30   'send_url'    => 'Send URL',
31   'username'    => 'HTTP username',
32   'password'    => 'HTTP password',
33   'content'     => 'Additional POST content',
34 );
35
36 my $no_submit = 0;
37
38 my $edit_callback = sub {
39   my ($cgi, $msg_template, $fields, $opt) = @_;
40   if ( $curuser->access_right('Edit global templates') 
41      || (    $curuser->access_right('Edit templates')
42           && $msg_template
43           && $msg_template->agentnum
44           && $curuser->agentnums_href->{$msg_template->agentnum}
45         )
46   ) {
47     @$fields = (
48         { field => 'msgclass',
49           type  => 'hidden',
50           value => 'http',
51         },
52         { field => 'agentnum',
53           type  => 'select-agent',
54         },
55         { field => 'msgname',   size=>60, required => 1 },
56         { field => 'prepare_url', size=>60, required => 1 },
57         { field => 'send_url',  size=>60, required => 1 },
58         { field => 'username', size=>20 },
59         { field => 'password', size=>20 },
60         { field => 'content', type => 'textarea' },
61     );
62   } else { #readonly
63
64     $no_submit = 1;
65
66     @$fields = (
67         { field => 'agentnum',
68           type  => 'select-agent',
69           fixed => 1,
70         },
71         { field => 'msgname',   type => 'fixed', },
72         { field => 'prepare_url', type => 'fixed', },
73         { field => 'send_url',  type => 'fixed', },
74         { field => 'username',  type => 'fixed', },
75         { field => 'password',  type => 'fixed', },
76         { field => 'content', type => 'fixed' },
77     );
78
79   }
80 };
81
82 </%init>