summaryrefslogtreecommitdiff
path: root/httemplate/browse/msg_template/http.html
blob: 888fda441433854bb31410cb05400d4591dd3320 (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
67
68
<& /browse/elements/browse.html,
              'title'         => 'External message interfaces',
              'name_singular' => 'interface', # what else do we call them?
              'menubar'       => \@menubar,
              'query'         => $query,
              'count_query'   => $count_query,
              'disableable'   => 1,
              'disabled_statuspos' => 4,
              'agent_virt'         => 1,
              'agent_null_right'   => ['View global templates','Edit global templates'],
              'agent_pos'          => 1,
              'header'      => [ 'Name',
                                 # 'Agent',
                                 'Prepare',
                                 'Send',
                                 '' ],
              'fields'      => [ 'msgname',
                                 'prepare_url',
                                 'send_url',
                                 $disable_link_label
                               ],
              'links'       => [ $link, ],
              'link_onclicks' => [ '', '', '',  $disable_link ],
              'cell_style'  => [ '', '', $url_style, $url_style ],
&>
<%init>

my $curuser = $FS::CurrentUser::CurrentUser;

die "access denied"
  unless $curuser->access_right([ 'View templates', 'View global templates',
                                  'Edit templates', 'Edit global templates', ]);

my @menubar = ();
if ( $curuser->access_right(['Edit templates', 'Edit global templates']) ) {
  push @menubar, 'Add a new interface' => $fsurl.'edit/msg_template/http.html';
}
push @menubar, 'Email templates' => $fsurl.'browse/msg_template/email.html';
push @menubar, 'Template images' => $fsurl.'browse/template_image.html';

my $query = {
  'table'   => 'msg_template',
  'select'  => '*',
  'hashref' => { 'msgclass' => 'http' },
};

my $count_query = "SELECT COUNT(*) FROM msg_template WHERE msgclass = 'http'";

my $link = [ $fsurl.'edit/msg_template/http.html?msgnum=', 'msgnum' ];

my $url_style = 'font-size:0.8em; padding:3px'; # also for (disable) label

my $disable_link = sub {
  my $template = shift;
  include('/elements/popup_link_onclick.html',
    action      => $fsurl.'misc/disable-msg_template.cgi?msgnum=' .
                     $template->msgnum .
                     ($template->disabled ? ';enable=1' : ''),
    actionlabel => 'Disable template',
  );
};

my $disable_link_label = sub {
  my $template = shift;
  $template->disabled ? '(enable)' : '(disable)' ;
};

</%init>