diff --git a/app/controllers/clients.js b/app/controllers/clients.js index 4b47d64..c41e8a1 100644 --- a/app/controllers/clients.js +++ b/app/controllers/clients.js @@ -6,7 +6,7 @@ var mongoose = require('mongoose'), var log = require('log4node'); -var frequencies = ["Medical Device","Sterilizer - TT","Vaporizer","Ice Maker","Anesthesia","Waste Management System","Imaging","Medical Gas Systems","RAE","ERT","N2O Trace Gas","Sterilizer - F","Quarterly","Semi","Annual","legacy","DLLR", "Isolation Panel", "Battery Backup"]; +var frequencies = ["Medical Device","Sterilizer - TT","Vaporizer","Ice Maker","Anesthesia","Waste Management System","Imaging","Medical Gas Systems","RAE","ERT","N2O Trace Gas","Sterilizer - F","Quarterly","Semi","Annual","legacy","DLLR", "Isolation Panel", "Battery Backup", "Sterilizer - Cleaning"]; exports.index = function(req, res) { log.info("clients.index"); diff --git a/app/controllers/messages.js b/app/controllers/messages.js index bbe14dc..0569cc8 100644 --- a/app/controllers/messages.js +++ b/app/controllers/messages.js @@ -14,13 +14,11 @@ module.exports = function(config) { return { send: function(req, res) { - console.log(req); var userId = req.body.user; if (!userId) { return res.json(404, null); } - console.log("Sending message"); User.findById(userId, function(err, user) { if (err) return res.json(500, err); diff --git a/app/controllers/posts.js b/app/controllers/posts.js index 479b970..7452397 100644 --- a/app/controllers/posts.js +++ b/app/controllers/posts.js @@ -43,7 +43,6 @@ function renderHtml(input) { try { return markdown.toHTML(input); } catch (err) { - console.log('Failed to render html', err); return input; } } else { @@ -108,8 +107,6 @@ exports.create = function(req, res, next) { exports.update = function(req, res, next) { var id = req.param('post_id'); - console.log('updating post'); - return Post.findById(id, function(err, post) { post.title = req.body.title; post.preview = req.body.preview; diff --git a/app/controllers/workorders.js b/app/controllers/workorders.js index c3e3231..66c627b 100644 --- a/app/controllers/workorders.js +++ b/app/controllers/workorders.js @@ -139,9 +139,6 @@ module.exports = function(config, calendar) { var subject = 'Workorder created: ' + workorder.biomedId; - console.log('-------------------------'); - console.log(to); - async.waterfall([ function(cb) { if (to && to.length > 0) { @@ -151,7 +148,6 @@ module.exports = function(config, calendar) { to: to, subject: subject }; - console.log(msg); server.send(msg, function(err, message) { cb(err); }); } else { cb(); @@ -165,7 +161,6 @@ module.exports = function(config, calendar) { to: techTo, subject: subject }; - console.log(msg); server.send(msg, function(err, message) { cb(err); }); } else { cb(); @@ -318,7 +313,6 @@ module.exports = function(config, calendar) { to: to, subject: subject }; - console.log(msg); server.send(msg, function(err, message) { cb(err); }); } else { cb(); @@ -332,7 +326,6 @@ module.exports = function(config, calendar) { to: techTo, subject: subject }; - console.log(msg); server.send(msg, function(err, message) { cb(err); }); } else { cb(); diff --git a/public/js/app.js b/public/js/app.js index 3cabfa2..1f358cc 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -44,6 +44,10 @@ angular.module('biomed', ['biomed.filters', 'biomed.services', 'biomed.directive templateUrl: '/partials/schedule/pms.html', controller: "SchedulePmsCtrl" }) + .when('/schedule/pms/report', { + templateUrl: '/partials/schedule/report.html', + controller: "FrequencyReportCtrl" + }) .when('/clients', { templateUrl: '/partials/clients/index.html', controller: "ClientIndexCtrl", diff --git a/public/js/controllers.js b/public/js/controllers.js index 4572b34..20ef6bd 100644 --- a/public/js/controllers.js +++ b/public/js/controllers.js @@ -118,6 +118,59 @@ angular.module('biomed') $scope.$watch('frequency', update); }) +.controller("FrequencyReportCtrl", function($scope, $q, $filter, Clients, Workorders, Pms) { + $scope.loading = true; + + // Setup initial state + $scope.month = moment().month(); + $scope.year = 2015; + $scope.frequency = "Anesthesia"; + + $scope.sort = { + column: 'client.name', + descending: false + }; + + function update() { + $scope.loading = true; + + if ($scope.month == "" && $scope.frequency == "") { + $scope.frequency = "Anesthesia"; + } + + var query = { + year: $scope.year, + month: $scope.month, + frequency: $scope.frequency, + type: 'all' + }; + + $scope.pms = Pms.index(query, function() { + $scope.loading = false; + }); + } + + $scope.selectedCls = function(column) { + return column == $scope.sort.column && 'sort-' + $scope.sort.descending; + } + + $scope.changeSorting = function(column) { + console.log(column); + var sort = $scope.sort; + if (sort.column == column) { + sort.descending = !sort.descending; + } else { + sort.column = column; + sort.descending = false; + } + }; + + $scope.$watch('month', update); + $scope.$watch('year', update); + $scope.$watch('frequency', update); +}) + + .controller("UsersIndexCtrl", function($scope, $filter, $routeParams, $location, Users, LocationBinder) { $scope.loading = true; @@ -814,7 +867,7 @@ angular.module('biomed') } }) -.controller("WorkorderAddCtrl", function($scope, $location, Workorders, Schedule, Clients, Users) { +.controller("WorkorderAddCtrl", function($scope, $location, $filter, Workorders, Schedule, Clients, Users) { $scope.emailsOptions = { 'multiple': true, @@ -864,19 +917,46 @@ angular.module('biomed') } } + if ($scope.model.client) { + Clients.get({ id: $scope.model.client }, function(item) { + $scope.clientPicker = {id: item._id, text: item.name + " (" + item.identifier + ")", data: item}; + }); + } + updateAllUsers(); updateUsers(); $scope.$watch('group', updateUsers); - $scope.$watch('model.client', function() { - $scope.currentClient = Clients.get({ id: $scope.model.client }); + $scope.$watch('clientPicker', function() { + if ($scope.clientPicker) { + var client = $scope.clientPicker.data; + $scope.model.client = client._id; + $scope.currentClient = client; + } else { + $scope.model.client = null; + $scope.currentClient = null; + } }); Clients.index(function(result) { $scope.clients = result; }); + $scope.clientOpts = { + containerCssClass: 'input-xxlarge', + placeholder: 'Choose a Client', + minimumInputLength: 2, + query: function(query) { + var data = $filter('filter')($scope.clients, query.term); + var results = []; + data.forEach(function(item) { + results.push({id: item._id, text: item.name + " (" + item.identifier + ")", data: item}); + }); + query.callback({ results: results }); + } + }; + function convertToDate(date, time) { return moment(moment(date).format('YYYY-MM-DD') + 'T' + time).toDate(); } diff --git a/public/partials/schedule/index.html b/public/partials/schedule/index.html index c108aaf..58b589c 100644 --- a/public/partials/schedule/index.html +++ b/public/partials/schedule/index.html @@ -1,5 +1,5 @@
Client Name | +Contact | +Phone | +
---|---|---|
{{pm.name}} ({{pm.identifier | uppercase}}) | +{{pm.contacts[0].name}} | +{{pm.contacts[0].phone}} | +