1 <% include( 'elements/browse.html',
2 'title' => 'Message templates',
3 'name_singular' => 'template',
4 'menubar' => \@menubar,
5 'query' => { 'table' => 'msg_template', },
6 'count_query' => 'SELECT COUNT(*) FROM msg_template',
8 'disabled_statuspos' => 2,
10 'agent_null_right' => ['View global templates','Edit global templates'],
12 'header' => [ 'Name', '', map '', @locales ],
13 'fields' => [ 'msgname', @locales ],
14 'links' => [ $link, @locale_links ],
15 'cell_style' => [ '', '', map $locale_style, @locales ],
20 my $curuser = $FS::CurrentUser::CurrentUser;
23 unless $curuser->access_right([ 'View templates', 'View global templates',
24 'Edit templates', 'Edit global templates', ]);
27 if ( $curuser->access_right(['Edit templates', 'Edit global templates']) ) {
28 push @menubar, 'Add a new template' => $p.'edit/msg_template.html';
31 my $link = [ "${p}edit/msg_template.html?msgnum=", 'msgnum' ];
33 my $locale_style = 'font-size:0.8em; padding:3px; background-color:';
35 my (@locales, @locale_links);
36 foreach my $l ( FS::Locales->locales ) {
38 exists ( $_[0]->content_locales->{$l} )
39 ? +{ FS::Locales->locale_info($l) }->{'name'}
42 push @locale_links, sub {
43 my $content = $_[0]->content_locales->{$l} or return '';
44 [ "${p}edit/msg_template.html?locale=$l;msgnum=", 'msgnum' ];