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' => (scalar(@locales) + 3),
10 'agent_null_right' => ['View global templates','Edit global templates'],
12 'header' => [ 'Name', '', map ('', @locales), '' ],
13 'fields' => [ 'msgname', @locales, $disable_link_label ],
14 'links' => [ $link, @locale_links, '' ],
15 'link_onclicks' => [ '', map('', @locale_links), $disable_link ],
16 'cell_style' => [ '', '', map ($locale_style, @locales), $locale_style ],
21 my $curuser = $FS::CurrentUser::CurrentUser;
24 unless $curuser->access_right([ 'View templates', 'View global templates',
25 'Edit templates', 'Edit global templates', ]);
28 if ( $curuser->access_right(['Edit templates', 'Edit global templates']) ) {
29 push @menubar, 'Add a new template' => $p.'edit/msg_template.html';
32 my $link = [ "${p}edit/msg_template.html?msgnum=", 'msgnum' ];
34 my $locale_style = 'font-size:0.8em; padding:3px';
36 my (@locales, @locale_links);
37 foreach my $l ( FS::Locales->locales ) {
39 exists ( $_[0]->content_locales->{$l} )
40 ? +{ FS::Locales->locale_info($l) }->{'label'}
43 push @locale_links, sub {
44 my $content = $_[0]->content_locales->{$l} or return '';
45 [ "${p}edit/msg_template.html?locale=$l;msgnum=", 'msgnum' ];
49 my $disable_link = sub {
51 include('/elements/popup_link_onclick.html',
52 action => $p.'misc/disable-msg_template.cgi?msgnum=' .
54 ($template->disabled ? ';enable=1' : ''),
55 actionlabel => 'Disable lemplate',
59 my $disable_link_label = sub {
61 $template->disabled ? '(enable)' : '(disable)' ;