diff --git a/app/controllers/timeclock.js b/app/controllers/timeclock.js index f287b7b..08a422f 100644 --- a/app/controllers/timeclock.js +++ b/app/controllers/timeclock.js @@ -8,6 +8,8 @@ var TimeClockSpan = mongoose.model('TimeClockSpan'); var TimeClockException = mongoose.model('TimeClockException'); var TimeSheet = mongoose.model('TimeSheet'); var Workorder = mongoose.model('Workorder'); +var Device = mongoose.model('Device'); +var DeviceType = mongoose.model('DeviceType'); var email = require('../util/email'); var config = require('../../config/config')['prod']; @@ -109,9 +111,31 @@ function findUserWorkorder(id, user) { }; return Workorder - .findOne(query) + .findOne({ + _id: id, + techs: user.id, + deleted: false + }) .populate('client', 'name identifier contacts address') - .exec(); + .then(workorder => { + var ids = _(workorder.devices) + .reject(_.isUndefined) + .uniq(id => id.toString()) + .value(); + + return Device + .find({ + _id: { + $in: ids + } + }) + .populate('deviceType') + .select('biomedId deviceType serialNumber') + .then(devices => { + workorder.devices = devices; + return workorder; + }); + }) } function filterSpans(spans, filter) { @@ -614,6 +638,8 @@ module.exports = function () { //TODO: Check to make sure user has a valid timesheet. + var today = moment(); + hasTechApprovedPreviousWeek(req.user.id, today) .then(approved => { diff --git a/app/model/testRun.js b/app/model/testRun.js index a083cea..c972d4b 100644 --- a/app/model/testRun.js +++ b/app/model/testRun.js @@ -7,7 +7,7 @@ var testRunSchema = new Schema({ fields: [{}], date: Date, result: Boolean, - comment: String, + comments: String, deleted: { type: Boolean, default: false } }); diff --git a/app/templates/partsRequest.html.tmpl b/app/templates/partsRequest.html.tmpl index 6b29596..3a74a56 100644 --- a/app/templates/partsRequest.html.tmpl +++ b/app/templates/partsRequest.html.tmpl @@ -78,6 +78,9 @@ <% } %> <% if (biomedId) { %> + +

Workorder

+ Atlantic Biomedical ID <%- biomedId %> diff --git a/app/templates/partsRequest.text.tmpl b/app/templates/partsRequest.text.tmpl index ca59bc1..e0e5bba 100644 --- a/app/templates/partsRequest.text.tmpl +++ b/app/templates/partsRequest.text.tmpl @@ -18,6 +18,9 @@ Phone Number: <% } %> <% if (biomedId) { %> + + +Workorder Atlantic Biomedical ID: <%- biomedId %>