Option to ignore old CDRs, RT#81480
[freeside.git] / httemplate / browse / msg_template / http.html
1 <& /browse/elements/browse.html,
2               'title'         => 'External message interfaces',
3               'name_singular' => 'interface', # what else do we call them?
4               'menubar'       => \@menubar,
5               'query'         => $query,
6               'count_query'   => $count_query,
7               'disableable'   => 1,
8               'disabled_statuspos' => 4,
9               'agent_virt'         => 1,
10               'agent_null_right'   => ['View global templates','Edit global templates'],
11               'agent_pos'          => 1,
12               'header'      => [ 'Name',
13                                  # 'Agent',
14                                  'Prepare',
15                                  'Send',
16                                  '' ],
17               'fields'      => [ 'msgname',
18                                  'prepare_url',
19                                  'send_url',
20                                  $disable_link_label
21                                ],
22               'links'       => [ $link, ],
23               'link_onclicks' => [ '', '', '',  $disable_link ],
24               'cell_style'  => [ '', '', $url_style, $url_style ],
25 &>
26 <%init>
27
28 my $curuser = $FS::CurrentUser::CurrentUser;
29
30 die "access denied"
31   unless $curuser->access_right([ 'View templates', 'View global templates',
32                                   'Edit templates', 'Edit global templates', ]);
33
34 my @menubar = ();
35 if ( $curuser->access_right(['Edit templates', 'Edit global templates']) ) {
36   push @menubar, 'Add a new interface' => $fsurl.'edit/msg_template/http.html';
37 }
38 push @menubar, 'Email templates' => $fsurl.'browse/msg_template/email.html';
39 push @menubar, 'Template images' => $fsurl.'browse/template_image.html';
40
41 my $query = {
42   'table'   => 'msg_template',
43   'select'  => '*',
44   'hashref' => { 'msgclass' => 'http' },
45 };
46
47 my $count_query = "SELECT COUNT(*) FROM msg_template WHERE msgclass = 'http'";
48
49 my $link = [ $fsurl.'edit/msg_template/http.html?msgnum=', 'msgnum' ];
50
51 my $url_style = 'font-size:0.8em; padding:3px'; # also for (disable) label
52
53 my $disable_link = sub {
54   my $template = shift;
55   include('/elements/popup_link_onclick.html',
56     action      => $fsurl.'misc/disable-msg_template.cgi?msgnum=' .
57                      $template->msgnum .
58                      ($template->disabled ? ';enable=1' : ''),
59     actionlabel => 'Disable template',
60   );
61 };
62
63 my $disable_link_label = sub {
64   my $template = shift;
65   $template->disabled ? '(enable)' : '(disable)' ;
66 };
67
68 </%init>