Added the option to select lists in report.
Added an option to generate a CSV report.
This commit is contained in:
parent
6ba04d7ff4
commit
2056645023
8 changed files with 177 additions and 50 deletions
|
@ -17,6 +17,10 @@ module.exports.filter = (request, parent, callback) => {
|
|||
tableHelpers.filter('lists', ['*'], request, ['#', 'name', 'cid', 'subscribers', 'description'], ['name'], 'name ASC', null, callback);
|
||||
};
|
||||
|
||||
module.exports.filterQuicklist = (request, callback) => {
|
||||
tableHelpers.filter('lists', ['id', 'name', 'subscribers'], request, ['#', 'name', 'subscribers'], ['name'], 'name ASC', null, callback);
|
||||
};
|
||||
|
||||
module.exports.quicklist = callback => {
|
||||
db.getConnection((err, connection) => {
|
||||
if (err) {
|
||||
|
|
|
@ -16,7 +16,7 @@ module.exports.list = (start, limit, callback) => {
|
|||
|
||||
module.exports.filter = (request, callback) => {
|
||||
tableHelpers.filter('reports JOIN report_templates ON reports.report_template = report_templates.id',
|
||||
['reports.id AS id', 'reports.name AS name', 'reports.description AS description', 'reports.report_template AS report_template', 'reports.params AS params', 'reports.created AS created', 'report_templates.name AS report_template_name' ],
|
||||
['reports.id AS id', 'reports.name AS name', 'reports.description AS description', 'reports.report_template AS report_template', 'reports.params AS params', 'reports.created AS created', 'report_templates.name AS report_template_name', 'report_templates.mime_type AS mime_type' ],
|
||||
request, ['#', 'name', 'report_templates.name', 'description', 'created'], ['name'], 'created DESC', null, callback);
|
||||
};
|
||||
|
||||
|
|
|
@ -10,7 +10,19 @@ module.exports.list = (source, fields, orderBy, start, limit, callback) => {
|
|||
return callback(err);
|
||||
}
|
||||
|
||||
connection.query('SELECT SQL_CALC_FOUND_ROWS ' + fields.join(', ') + ' FROM ' + source + ' ORDER BY ' + orderBy + ' DESC LIMIT ? OFFSET ?', [limit, start], (err, rows) => {
|
||||
let limitQuery = '';
|
||||
let limitValues = [];
|
||||
if (limit) {
|
||||
limitQuery = ' LIMIT ?';
|
||||
limitValues.push(limit);
|
||||
|
||||
if (start) {
|
||||
limitQuery += ' OFFSET ?';
|
||||
limitValues.push(start);
|
||||
}
|
||||
}
|
||||
|
||||
connection.query('SELECT SQL_CALC_FOUND_ROWS ' + fields.join(', ') + ' FROM ' + source + ' ORDER BY ' + orderBy + ' DESC' + limitQuery, limitValues, (err, rows) => {
|
||||
if (err) {
|
||||
connection.release();
|
||||
return callback(err);
|
||||
|
@ -56,8 +68,6 @@ module.exports.filter = (source, fields, request, columns, searchFields, default
|
|||
values = values.concat(queryData.values || []);
|
||||
}
|
||||
|
||||
log.info("tableHelpers", query);
|
||||
|
||||
connection.query(query, values, (err, total) => {
|
||||
if (err) {
|
||||
connection.release();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue