Skip to content

Commit

Permalink
fix(reports): invalid date string
Browse files Browse the repository at this point in the history
  • Loading branch information
polonel committed Feb 1, 2019
1 parent 07dc50b commit 0914d91
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
9 changes: 4 additions & 5 deletions src/controllers/api/v1/reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,14 @@
*/

var _ = require('lodash')

var async = require('async')

var ticketSchema = require('../../../models/ticket')

var groupSchema = require('../../../models/group')

var csv = require('csv')

var moment = require('moment')

var settingsSchema = require('../../../models/setting')

var apiReports = {
generate: {}
}
Expand Down Expand Up @@ -60,6 +57,8 @@ var apiReports = {
*/
apiReports.generate.ticketsByGroup = function (req, res) {
var postData = req.body
if (!postData || !postData.startDate || !postData.endDate)
return res.status(400).json({ success: false, error: 'Invalid Post Data' })

ticketSchema.getTicketsWithObject(
postData.groups,
Expand Down
7 changes: 5 additions & 2 deletions src/public/js/angularjs/controllers/reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ define(['angular', 'underscore', 'jquery', 'moment', 'modules/helpers', 'formval
form.serializeArray().map(function (x) {
data[x.name] = x.value
})
var startDate = moment(data['filterDate_Start'])
var endDate = moment(data['filterDate_End'])

// Standardize the Dates
var startDate = moment(data['filterDate_Start'], helpers.getShortDateFormat()).format('MM-DD-YYYY')
var endDate = moment(data['filterDate_End'], helpers.getShortDateFormat()).format('MM-DD-YYYY')

var groups = []

Expand All @@ -130,6 +132,7 @@ define(['angular', 'underscore', 'jquery', 'moment', 'modules/helpers', 'formval
},
function errorCallback (response) {
$log.log(response.statusText)
$log.error(response)
}
)
.then(function () {
Expand Down

0 comments on commit 0914d91

Please sign in to comment.