' + row.cid + '
',
+ row.subscribers,
+ htmlescape(striptags(row.description) || ''),
+ '' + _('Edit') + '' ]
+ )
+ });
+ });
+});
+
+
router.post('/ajax/:id', (req, res) => {
lists.get(req.params.id, (err, list) => {
if (err || !list) {
@@ -733,4 +748,27 @@ router.get('/subscription/:id/import/:importId/failed', (req, res) => {
});
});
+router.post('/quicklist/ajax', (req, res) => {
+ lists.filterQuicklist(req.body, (err, data, total, filteredTotal) => {
+ if (err) {
+ return res.json({
+ error: err.message || err,
+ data: []
+ });
+ }
+
+ res.json({
+ draw: req.body.draw,
+ recordsTotal: total,
+ recordsFiltered: filteredTotal,
+ data: data.map((row, i) => ({
+ "0": (Number(req.body.start) || 0) + 1 + i,
+ "1": ' ' + htmlescape(row.name || '') + '',
+ "2": row.subscribers,
+ "DT_RowId": row.id
+ }))
+ });
+ });
+});
+
module.exports = router;
diff --git a/routes/report-templates.js b/routes/report-templates.js
new file mode 100644
index 00000000..7fdc4fbc
--- /dev/null
+++ b/routes/report-templates.js
@@ -0,0 +1,307 @@
+'use strict';
+
+const express = require('express');
+const passport = require('../lib/passport');
+const router = new express.Router();
+const _ = require('../lib/translate')._;
+const reportTemplates = require('../lib/models/report-templates');
+const tools = require('../lib/tools');
+const util = require('util');
+const htmlescape = require('escape-html');
+const striptags = require('striptags');
+
+const allowedMimeTypes = {
+ 'text/html': 'HTML',
+ 'text/csv': 'CSV'
+};
+
+router.all('/*', (req, res, next) => {
+ if (!req.user) {
+ req.flash('danger', _('Need to be logged in to access restricted content'));
+ return res.redirect('/users/login?next=' + encodeURIComponent(req.originalUrl));
+ }
+ res.setSelectedMenu('reports');
+ next();
+});
+
+router.get('/', (req, res) => {
+ res.render('report-templates/report-templates', {
+ title: _('Report Templates')
+ });
+});
+
+router.post('/ajax', (req, res) => {
+ reportTemplates.filter(req.body, (err, data, total, filteredTotal) => {
+ if (err) {
+ return res.json({
+ error: err.message || err,
+ data: []
+ });
+ }
+
+ res.json({
+ draw: req.body.draw,
+ recordsTotal: total,
+ recordsFiltered: filteredTotal,
+ data: data.map((row, i) => [
+ (Number(req.body.start) || 0) + 1 + i,
+ htmlescape(row.name || ''),
+ htmlescape(striptags(row.description) || ''),
+ '' + row.created.toISOString() + '',
+ ' ' + _('Edit') + '']
+ )
+ });
+ });
+});
+
+router.get('/create', passport.csrfProtection, (req, res) => {
+ const data = req.query;
+ const wizard = req.query['type'] || '';
+
+ if (wizard == 'subscribers-all') {
+ if (!('description' in data)) data.description = 'Generates a campaign report listing all subscribers along with their statistics.';
+
+ if (!('mimeType' in data)) data.mimeType = 'text/html';
+
+ if (!('userFields' in data)) data.userFields =
+ '[\n' +
+ ' {\n' +
+ ' "id": "campaign",\n' +
+ ' "name": "Campaign",\n' +
+ ' "type": "campaign",\n' +
+ ' "minOccurences": 1,\n' +
+ ' "maxOccurences": 1\n' +
+ ' }\n' +
+ ']';
+
+ if (!('js' in data)) data.js =
+ 'campaigns.results(inputs.campaign, ["*"], "", (err, results) => {\n' +
+ ' if (err) {\n' +
+ ' return callback(err);\n' +
+ ' }\n' +
+ '\n' +
+ ' const data = {\n' +
+ ' results: results\n' +
+ ' };\n' +
+ '\n' +
+ ' return callback(null, data);\n' +
+ '});';
+
+ if (!('hbs' in data)) data.hbs =
+ '\n' + + ' {{#translate}}Email{{/translate}}\n' + + ' | \n' + + '\n' + + ' {{#translate}}Tracker Count{{/translate}}\n' + + ' | \n' + + ' \n' + + ' {{#if results}}\n' + + ' \n' + + ' {{#each results}}\n' + + '
---|---|
\n' + + ' {{email}}\n' + + ' | \n' + + '\n' + + ' {{tracker_count}}\n' + + ' | \n' + + '
\n' + + ' {{#translate}}Country{{/translate}}\n' + + ' | \n' + + '\n' + + ' {{#translate}}Opened{{/translate}}\n' + + ' | \n' + + '\n' + + ' {{#translate}}All{{/translate}}\n' + + ' | \n' + + '\n' + + ' {{#translate}}Percentage{{/translate}}\n' + + ' | \n' + + ' \n' + + ' {{#if results}}\n' + + ' \n' + + ' {{#each results}}\n' + + '
---|---|---|---|
\n' + + ' {{custom_country}}\n' + + ' | \n' + + '\n' + + ' {{count_opened}}\n' + + ' | \n' + + '\n' + + ' {{count_all}}\n' + + ' | \n' + + '\n' + + ' {{percentage}}%\n' + + ' | \n' + + '
+ | # | @@ -38,7 +38,7 @@ | {{#translate}}Created{{/translate}} | -+ | diff --git a/views/campaigns/edit-rss.hbs b/views/campaigns/edit-rss.hbs index d9080534..3c13c859 100644 --- a/views/campaigns/edit-rss.hbs +++ b/views/campaigns/edit-rss.hbs @@ -71,8 +71,6 @@ - {{> merge_tag_reference}} - |
---|