summaryrefslogtreecommitdiff
path: root/httemplate/browse
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2015-08-29 21:27:20 -0700
committerMark Wells <mark@freeside.biz>2015-08-29 21:27:20 -0700
commit9fd03716b831bd00a725a63edbe19cfe6b88aea0 (patch)
treea6854452a54eb2867004a25a154ac13ed320980d /httemplate/browse
parentd622148c3ad8e98aef7ae1ca163e28483e023609 (diff)
#21564: user interface for REST client
Diffstat (limited to 'httemplate/browse')
-rw-r--r--httemplate/browse/msg_template/email.html (renamed from httemplate/browse/msg_template.html)29
-rw-r--r--httemplate/browse/msg_template/http.html68
2 files changed, 87 insertions, 10 deletions
diff --git a/httemplate/browse/msg_template.html b/httemplate/browse/msg_template/email.html
index 1646bc169..d0ef4e3e9 100644
--- a/httemplate/browse/msg_template.html
+++ b/httemplate/browse/msg_template/email.html
@@ -1,9 +1,9 @@
-<% include( 'elements/browse.html',
+<& /browse/elements/browse.html,
'title' => 'Message templates',
'name_singular' => 'template',
'menubar' => \@menubar,
- 'query' => { 'table' => 'msg_template', },
- 'count_query' => 'SELECT COUNT(*) FROM msg_template',
+ 'query' => $query,
+ 'count_query' => $count_query,
'disableable' => 1,
'disabled_statuspos' => (scalar(@locales) + 3),
'agent_virt' => 1,
@@ -14,8 +14,7 @@
'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;
@@ -26,11 +25,21 @@ die "access denied"
my @menubar = ();
if ( $curuser->access_right(['Edit templates', 'Edit global templates']) ) {
- push @menubar, 'Add a new template' => $p.'edit/msg_template.html';
+ push @menubar, 'Add a new template' => $fsurl.'edit/msg_template/email.html';
}
-push @menubar, 'View template images' => $p.'browse/template_image.html';
+push @menubar, 'Template images' => $fsurl.'browse/template_image.html';
-my $link = [ "${p}edit/msg_template.html?msgnum=", 'msgnum' ];
+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';
@@ -43,14 +52,14 @@ foreach my $l ( FS::Locales->locales ) {
};
push @locale_links, sub {
my $content = $_[0]->content_locales->{$l} or return '';
- [ "${p}edit/msg_template.html?locale=$l;msgnum=", 'msgnum' ];
+ [ $fsurl."edit/msg_template/email.html?locale=$l;msgnum=", 'msgnum' ];
};
}
my $disable_link = sub {
my $template = shift;
include('/elements/popup_link_onclick.html',
- action => $p.'misc/disable-msg_template.cgi?msgnum=' .
+ action => $fsurl.'misc/disable-msg_template.cgi?msgnum=' .
$template->msgnum .
($template->disabled ? ';enable=1' : ''),
actionlabel => 'Disable template',
diff --git a/httemplate/browse/msg_template/http.html b/httemplate/browse/msg_template/http.html
new file mode 100644
index 000000000..888fda441
--- /dev/null
+++ b/httemplate/browse/msg_template/http.html
@@ -0,0 +1,68 @@
+<& /browse/elements/browse.html,
+ 'title' => 'External message interfaces',
+ 'name_singular' => 'interface', # what else do we call them?
+ 'menubar' => \@menubar,
+ 'query' => $query,
+ 'count_query' => $count_query,
+ 'disableable' => 1,
+ 'disabled_statuspos' => 4,
+ 'agent_virt' => 1,
+ 'agent_null_right' => ['View global templates','Edit global templates'],
+ 'agent_pos' => 1,
+ 'header' => [ 'Name',
+ # 'Agent',
+ 'Prepare',
+ 'Send',
+ '' ],
+ 'fields' => [ 'msgname',
+ 'prepare_url',
+ 'send_url',
+ $disable_link_label
+ ],
+ 'links' => [ $link, ],
+ 'link_onclicks' => [ '', '', '', $disable_link ],
+ 'cell_style' => [ '', '', $url_style, $url_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 interface' => $fsurl.'edit/msg_template/http.html';
+}
+push @menubar, 'Email templates' => $fsurl.'browse/msg_template/email.html';
+push @menubar, 'Template images' => $fsurl.'browse/template_image.html';
+
+my $query = {
+ 'table' => 'msg_template',
+ 'select' => '*',
+ 'hashref' => { 'msgclass' => 'http' },
+};
+
+my $count_query = "SELECT COUNT(*) FROM msg_template WHERE msgclass = 'http'";
+
+my $link = [ $fsurl.'edit/msg_template/http.html?msgnum=', 'msgnum' ];
+
+my $url_style = 'font-size:0.8em; padding:3px'; # also for (disable) label
+
+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>