diff options
Diffstat (limited to 'httemplate/browse/msg_template/email.html')
-rw-r--r-- | httemplate/browse/msg_template/email.html | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/httemplate/browse/msg_template/email.html b/httemplate/browse/msg_template/email.html new file mode 100644 index 000000000..d0ef4e3e9 --- /dev/null +++ b/httemplate/browse/msg_template/email.html @@ -0,0 +1,74 @@ +<& /browse/elements/browse.html, + 'title' => 'Message templates', + 'name_singular' => 'template', + 'menubar' => \@menubar, + 'query' => $query, + 'count_query' => $count_query, + 'disableable' => 1, + 'disabled_statuspos' => (scalar(@locales) + 3), + 'agent_virt' => 1, + 'agent_null_right' => ['View global templates','Edit global templates'], + 'agent_pos' => 1, + 'header' => [ 'Name', '', map ('', @locales), '' ], + 'fields' => [ 'msgname', @locales, $disable_link_label ], + 'links' => [ $link, @locale_links, '' ], + 'link_onclicks' => [ '', map('', @locale_links), $disable_link ], + 'cell_style' => [ '', '', map ($locale_style, @locales), $locale_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 template' => $fsurl.'edit/msg_template/email.html'; +} +push @menubar, 'Template images' => $fsurl.'browse/template_image.html'; + +push @menubar, 'External message interfaces' => $fsurl.'browse/msg_template/http.html'; + +my $query = { + 'table' => 'msg_template', + 'select' => '*', + 'hashref' => { 'msgclass' => 'email' }, +}; + +my $count_query = "SELECT COUNT(*) FROM msg_template WHERE msgclass = 'email'"; + +my $link = [ $fsurl.'edit/msg_template/email.html?msgnum=', 'msgnum' ]; + +my $locale_style = 'font-size:0.8em; padding:3px'; + +my (@locales, @locale_links); +foreach my $l ( FS::Locales->locales ) { + push @locales, sub { + exists ( $_[0]->content_locales->{$l} ) + ? +{ FS::Locales->locale_info($l) }->{'label'} + : ''; + }; + push @locale_links, sub { + my $content = $_[0]->content_locales->{$l} or return ''; + [ $fsurl."edit/msg_template/email.html?locale=$l;msgnum=", 'msgnum' ]; + }; +} + +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> |