summaryrefslogtreecommitdiff
path: root/httemplate/browse/msg_template.html
blob: 8a6ccf741b2a110fc8b4ca24f737540b2abb04e1 (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
<% include( 'elements/browse.html',
              'title'         => 'Message templates',
              'name_singular' => 'template',
              'menubar'     => [ 'Add a new template' =>
                                   $p.'edit/msg_template.html',
                               ],
              'query'       => { 'table' => 'msg_template', },
              'count_query' => 'SELECT COUNT(*) FROM msg_template',
              'disableable' => 1,
              'disabled_statuspos' => 2,
              'agent_virt'         => 1,
              'agent_null_right'   => ['Edit global templates','Configuration'],
              'agent_pos'          => 1,
              'header' => [ 'Name', '', ('' x scalar @locales) ],
              'fields' => [ 'msgname', @locales ],
              'links'  => [ $link, @locale_links ],
              'cell_style' => 
                          [ '', '', ($locale_style) x (scalar @locales) ],
          )
%>
<%init>

die "access denied"
  unless $FS::CurrentUser::CurrentUser->access_right('Edit templates')
  ||     $FS::CurrentUser::CurrentUser->access_right('Edit global templates')
  ||     $FS::CurrentUser::CurrentUser->access_right('Configuration');

my $link = [ "${p}edit/msg_template.html?msgnum=", 'msgnum' ];

my $locale_style = 'font-size:0.8em; padding:3px; background-color:';

my (@locales, @locale_links);
foreach my $l ( FS::Locales->locales ) {
  push @locales, sub {
    exists ( $_[0]->content_locales->{$l} )
    ? +{ FS::Locales->locale_info($l) }->{'name'} 
    : '';
  };
  push @locale_links, sub {
    my $content = $_[0]->content_locales->{$l} or return '';
    [ "${p}edit/msg_template.html?locale=$l;msgnum=", 'msgnum' ];
  };
}
    

</%init>