This commit is contained in:
Dobie Wollert
2015-12-28 03:35:59 -08:00
parent a83a046933
commit f097af33f5
4 changed files with 35 additions and 3 deletions

View File

@ -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 => {

View File

@ -7,7 +7,7 @@ var testRunSchema = new Schema({
fields: [{}],
date: Date,
result: Boolean,
comment: String,
comments: String,
deleted: { type: Boolean, default: false }
});

View File

@ -78,6 +78,9 @@
</tr>
<% } %>
<% if (biomedId) { %>
<tr style="margin-top: 24px;">
<td colspan="2"><h4>Workorder</h4></td>
</tr>
<tr>
<td>Atlantic Biomedical ID</td>
<td><%- biomedId %></td>

View File

@ -18,6 +18,9 @@ Phone Number:
<% } %>
<% if (biomedId) { %>
Workorder
Atlantic Biomedical ID:
<%- biomedId %>