mirror of
https://github.com/atlanticbiomedical/biomedjs.git
synced 2025-07-02 00:47:26 -04:00
latest digs
This commit is contained in:
@ -137,4 +137,4 @@ exports.destroy = function(req, res, next) {
|
||||
return res.json(client);
|
||||
})
|
||||
});
|
||||
};
|
||||
};
|
||||
|
@ -14,8 +14,7 @@ module.exports = function(config) {
|
||||
|
||||
return {
|
||||
send: function(req, res) {
|
||||
console.log(req.body);
|
||||
|
||||
console.log(req);
|
||||
var userId = req.body.user;
|
||||
if (!userId) {
|
||||
return res.json(404, null);
|
||||
@ -25,8 +24,10 @@ module.exports = function(config) {
|
||||
User.findById(userId, function(err, user) {
|
||||
if (err) return res.json(500, err);
|
||||
|
||||
var sender = req.user;
|
||||
|
||||
server.send({
|
||||
text: generateMessage(user, req.body),
|
||||
text: generateMessage(sender, user, req.body),
|
||||
from: config.email.user,
|
||||
to: generateToLine(user),
|
||||
subject: 'Message from portal'
|
||||
@ -47,8 +48,9 @@ function generateToLine(user) {
|
||||
return user.name.first + " " + user.name.last + " <" + user.email + ">";
|
||||
}
|
||||
|
||||
function generateMessage(user, message) {
|
||||
function generateMessage(sender, user, message) {
|
||||
var template =
|
||||
"From: %(sender)s\n" +
|
||||
"Message For: %(user)s\n" +
|
||||
"\n" +
|
||||
"Name: %(name)s\n" +
|
||||
@ -60,6 +62,7 @@ function generateMessage(user, message) {
|
||||
"%(notes)s\n";
|
||||
|
||||
var resources = {
|
||||
sender: sender.name.first + " " + sender.name.last,
|
||||
user: user.name.first + " " + user.name.last,
|
||||
name: message.name || '',
|
||||
company: message.company || '',
|
||||
|
@ -47,9 +47,12 @@ module.exports = function(calendar) {
|
||||
},
|
||||
|
||||
create: function(req, res, next) {
|
||||
console.log(req.body);
|
||||
var date = new Date();
|
||||
|
||||
var workorder = new Workorder({
|
||||
client: req.body.client,
|
||||
createdOn: new Date(),
|
||||
createdOn: date,
|
||||
createdBy: req.user,
|
||||
reason: req.body.reason,
|
||||
maintenanceType: req.body.maintenanceType || "",
|
||||
@ -105,7 +108,9 @@ module.exports = function(calendar) {
|
||||
end: workorder.scheduling.end,
|
||||
attendees: generateAttendees(techs)
|
||||
}, function(err, result) {
|
||||
workorder.calendarId = result.id;
|
||||
if (result) {
|
||||
workorder.calendarId = result.id;
|
||||
}
|
||||
callback(err);
|
||||
});
|
||||
},
|
||||
@ -119,7 +124,18 @@ module.exports = function(calendar) {
|
||||
|
||||
Client.findByIdAndUpdate(req.body.client, { $push: { 'workorders': result.id } },
|
||||
function(err, ignored) { callback(err, result) });
|
||||
}
|
||||
},
|
||||
function(result, callback) {
|
||||
console.log("Update Client - Pms");
|
||||
if (workorder.maintenanceType) {
|
||||
console.log("Is PM");
|
||||
var key = 'pms.' + date.getFullYear() + '-' + date.getMonth() + '.' + workorder.maintenanceType;
|
||||
var cmd = { $inc: {} };
|
||||
cmd.$inc[key] = 1;
|
||||
console.log(cmd);
|
||||
Client.findByIdAndUpdate(req.body.client, cmd, function(err, ignored) { callback(err, result) });
|
||||
}
|
||||
},
|
||||
],
|
||||
function(err, result) {
|
||||
if (!err) {
|
||||
@ -145,11 +161,13 @@ module.exports = function(calendar) {
|
||||
workorder = result;
|
||||
|
||||
workorder.reason = req.body.reason;
|
||||
maintenanceType: req.body.maintenanceType || "";
|
||||
workorder.maintenanceType = req.body.maintenanceType || "";
|
||||
workorder.remarks = req.body.remarks;
|
||||
workorder.scheduling = req.body.scheduling;
|
||||
workorder.status = req.body.status;
|
||||
workorder.techs = req.body.techs.map(function(t) { return t._id; });
|
||||
workorder.techs = req.body.techs
|
||||
.filter(function(e) { return e; })
|
||||
.map(function(t) { return t._id; });
|
||||
|
||||
callback(err);
|
||||
});
|
||||
@ -214,11 +232,17 @@ module.exports = function(calendar) {
|
||||
return workorder.save(function(err) {
|
||||
if (!err) {
|
||||
console.log("deleted");
|
||||
calendar.deleteEvent(workorder.calendarId, function(err) {
|
||||
if (!err) {
|
||||
console.log("Calendar event removed.");
|
||||
}
|
||||
|
||||
return res.json(workorder);
|
||||
});
|
||||
} else {
|
||||
console.log("error");
|
||||
return res.json(workorder);
|
||||
}
|
||||
|
||||
return res.json(workorder);
|
||||
})
|
||||
});
|
||||
}
|
||||
@ -231,7 +255,15 @@ function generateSummary(client) {
|
||||
}
|
||||
|
||||
function generateLocation(client) {
|
||||
return sprintf("%(street1)s %(street2)s %(city)s, %(state)s. %(zip)s", client.address);
|
||||
var data = {
|
||||
street1: client.address.street1 || '',
|
||||
street2: client.address.street2 || '',
|
||||
city: client.address.city || '',
|
||||
state: client.address.state || '',
|
||||
zip: client.address.zip || ''
|
||||
};
|
||||
|
||||
return sprintf("%(street1)s %(street2)s %(city)s, %(state)s. %(zip)s", data);
|
||||
}
|
||||
|
||||
function generateDescription(client, workorder) {
|
||||
|
@ -18,8 +18,9 @@ var clientSchema = new Schema({
|
||||
email: String
|
||||
}],
|
||||
frequencies: {},
|
||||
pms: {},
|
||||
workorders: [{ type: ObjectId, ref: 'Workorder' }],
|
||||
deleted: { type: Boolean, default: false }
|
||||
});
|
||||
|
||||
module.exports = mongoose.model('Client', clientSchema);
|
||||
module.exports = mongoose.model('Client', clientSchema);
|
||||
|
@ -8,6 +8,7 @@ var workorderSchema = new Schema({
|
||||
createdOn: Date,
|
||||
createdBy: { type: ObjectId, ref: 'User' },
|
||||
reason: String,
|
||||
maintenanceType: String,
|
||||
remarks: String,
|
||||
status: String,
|
||||
scheduling: {
|
||||
@ -24,4 +25,4 @@ var workorderSchema = new Schema({
|
||||
deleted: { type: Boolean, default: false }
|
||||
});
|
||||
|
||||
module.exports = mongoose.model('Workorder', workorderSchema);
|
||||
module.exports = mongoose.model('Workorder', workorderSchema);
|
||||
|
@ -26,9 +26,20 @@ html(lang="en", ng-app="tags", ng-controller="tags.PageCtrl")
|
||||
.navbar-inner
|
||||
ul.nav
|
||||
li
|
||||
a(href='http://www.atlanticbiomedical.com')
|
||||
i.icon-wrench
|
||||
| Contact Us
|
||||
a(href='#')
|
||||
| Contact:
|
||||
li
|
||||
a(href='tel://1-800-550-8310')
|
||||
i.icon-user
|
||||
| Call
|
||||
li
|
||||
a(href='mailto:service@atlanticbiomedical.com')
|
||||
i.icon-envelope
|
||||
| Email
|
||||
li
|
||||
a(href='http://atlb.co/feature.html')
|
||||
i.icon-list-alt
|
||||
| History
|
||||
.container-fluid
|
||||
h1(ng-show='tag') Device Tag
|
||||
h1(ng-hide='tag') Create Tag
|
||||
@ -46,7 +57,7 @@ html(lang="en", ng-app="tags", ng-controller="tags.PageCtrl")
|
||||
dd {{tag.clientDeviceId}}
|
||||
dt Device
|
||||
dd {{tag.device}}
|
||||
dt Make
|
||||
dt Manufacturer
|
||||
dd {{tag.make}}
|
||||
dt Model
|
||||
dd {{tag.model}}
|
||||
@ -56,12 +67,14 @@ html(lang="en", ng-app="tags", ng-controller="tags.PageCtrl")
|
||||
dd {{tag.purchaseDate}}
|
||||
dt Warranty Expiration
|
||||
dd {{tag.deviceWarrantyExpiration}}
|
||||
dt Test
|
||||
dt PM Test
|
||||
dd {{tag.test}}
|
||||
dt Room #
|
||||
dd {{tag.roomNumber}}
|
||||
dt PO Number
|
||||
dd {{tag.poNumber}}
|
||||
dt Move To
|
||||
dd {{tag.MoveTo}}
|
||||
|
||||
a.btn.btn-primary(href='/auth', ng-show='tag')
|
||||
| Edit Tag
|
||||
@ -87,7 +100,7 @@ html(lang="en", ng-app="tags", ng-controller="tags.PageCtrl")
|
||||
.controls
|
||||
input.text(ng-model='tag.device')
|
||||
.control-group
|
||||
label.control-label Make
|
||||
label.control-label Manufacturer
|
||||
.controls
|
||||
input.text(ng-model='tag.make')
|
||||
.control-group
|
||||
@ -108,7 +121,7 @@ html(lang="en", ng-app="tags", ng-controller="tags.PageCtrl")
|
||||
input.text(type='date', ng-model='tag.deviceWarrantyExpiration')
|
||||
|
||||
.control-group
|
||||
label.control-label Test
|
||||
label.control-label PM Test
|
||||
.controls
|
||||
input.text(ng-model='tag.test')
|
||||
.control-group
|
||||
@ -120,6 +133,11 @@ html(lang="en", ng-app="tags", ng-controller="tags.PageCtrl")
|
||||
label.control-label PO Number
|
||||
.controls
|
||||
input.text(ng-model='tag.poNumber')
|
||||
|
||||
.control-group
|
||||
label.control-label Move To
|
||||
.controls
|
||||
input.text(ng-model='tag.MoveTo')
|
||||
|
||||
.control-group
|
||||
button.btn.btn-primary(ng-click='save()') Save
|
||||
|
Reference in New Issue
Block a user