diff --git a/app/controllers/clients.js b/app/controllers/clients.js index c9d53f0..ae077f1 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"]; +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"]; exports.index = function(req, res) { log.info("clients.index"); diff --git a/app/controllers/workorders.js b/app/controllers/workorders.js index f40f1ed..4dd52cf 100644 --- a/app/controllers/workorders.js +++ b/app/controllers/workorders.js @@ -75,7 +75,8 @@ module.exports = function(config, calendar) { remarks: req.body.remarks || "", status: req.body.status, scheduling: req.body.scheduling, - techs: req.body.techs + techs: req.body.techs, + alternativeContact: req.body.alternativeContact }); var notify = req.body._notify || ""; @@ -238,6 +239,11 @@ module.exports = function(config, calendar) { workorder.techs = req.body.techs .filter(function(e) { return e; }) .map(function(t) { return t._id; }); + workorder.invoiceNumber = req.body.invoiceNumber; + workorder.invoicedOn = req.body.invoicedOn; + workorder.checkNumber = req.body.checkNumber; + workorder.paidOn = req.body.paidOn; + workorder.alternativeContact = req.body.alternativeContact; callback(err); }); diff --git a/app/model/workorder.js b/app/model/workorder.js index 4b0e5a6..c7b967b 100644 --- a/app/model/workorder.js +++ b/app/model/workorder.js @@ -24,7 +24,12 @@ var workorderSchema = new Schema({ newValues: {}, modifiedBy: { type: ObjectId, ref: 'User' } }], - deleted: { type: Boolean, default: false } + deleted: { type: Boolean, default: false }, + invoiceNumber: String, + invoicedOn: Date, + checkNumber: String, + paidOn: Date, + alternativeContact: String }); module.exports = mongoose.model('Workorder', workorderSchema); diff --git a/app/views/index.jade b/app/views/index.jade index 163f09e..f17dd19 100644 --- a/app/views/index.jade +++ b/app/views/index.jade @@ -41,27 +41,30 @@ html(lang="en", ng-app="biomed", ng-controller="biomed.PageCtrl") ul.nav li(data-match-route='/schedule.*') a(href='/schedule') - i.icon-calendar | Schedule + li + a(href='/schedule/pms') + | PM + li(data-match-route='/client.*') a(href='/clients') - i.icon-briefcase | Clients li(data-match-route='/workorder.*') a(href='/workorders') - i.icon-wrench | Workorders + li(data-match-route='/accounting.*') + a(href='/accounting') + | Accounting + li(data-match-route='/posts.*', ng-show="accountHasPermission('system.admin')") a(href='/posts') - i.icon-wrench | Posts li(data-match-route='/admin.*', ng-show="accountHasPermission('system.admin')") a(href='/admin') - i.icon-wrench | Admin li.day-of-year {{dayOfYear}} diff --git a/public/js/app.js b/public/js/app.js index 09ebca5..b245d19 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -57,6 +57,11 @@ angular.module('biomed', ['biomed.filters', 'biomed.services', 'biomed.directive templateUrl: '/partials/clients/edit.html', controller: biomed.ClientEditCtrl }) + .when('/accounting', { + templateUrl: '/partials/accounting/index.html', + controller: biomed.AccountingIndexCtrl, + reloadOnSearch: false + }) .when('/workorders', { templateUrl: '/partials/workorders/index.html', controller: biomed.WorkorderIndexCtrl, diff --git a/public/js/controllers.js b/public/js/controllers.js index 37b50e3..4b82e74 100644 --- a/public/js/controllers.js +++ b/public/js/controllers.js @@ -75,15 +75,29 @@ biomed.SchedulePmsCtrl = function($scope, Clients) { $scope.pms = []; angular.forEach(allData, function(client) { - angular.forEach(client.frequencies, function(value, key) { + + var reason = []; + + angular.forEach(client.frequencies, function(value, key) { if (value[$scope.month]) { - $scope.pms.push({ - reason: key, - client: client - }); + reason.push(key); + +// $scope.pms.push({ +// reason: key, +// client: client +// }); } }); + + if (reason.length > 0) { + $scope.pms.push({ + reason: reason, + client: client + }); + } }); + + console.log($scope.pms); } $scope.sort = { @@ -654,6 +668,80 @@ biomed.ClientEditCtrl = function($scope, $routeParams, Clients) { } }; +biomed.AccountingIndexCtrl = function($scope, $filter, $routeParams, Workorders, LocationBinder) { + $scope.loading = true; + + var data = {}; + + var defaultEnd = moment().toDate(); + var defaultStart = moment(defaultEnd).subtract('days', 7).toDate(); + + LocationBinder($scope, ['query', 'start', 'end'], { + start: defaultStart, + end: defaultEnd + }); + + fetchData(); + + + var filteredData = []; + var index = 0; + var initialPageSize = 100; + var pageSize = 5; + + $scope.canLoad = true; + + $scope.$watch('query', filter); + + $scope.$watch('start', fetchData); + + $scope.$watch('end', fetchData); + + $scope.sort = { + column: 'scheduling.start', + descending: true + }; + + $scope.addItems = function() { + $scope.workorders = $scope.workorders.concat(filteredData.slice(index, index + pageSize)); + index += pageSize; + $scope.canLoad = index < filteredData.length; + } + + function filter() { + filteredData = $filter('filter')(data, $scope.query); + index = initialPageSize; + $scope.canLoad = true; + $scope.workorders = filteredData.slice(0, initialPageSize); + }; + + $scope.selectedCls = function(column) { + return column == $scope.sort.column && 'sort-' + $scope.sort.descending; + } + + $scope.changeSorting = function(column) { + var sort = $scope.sort; + if (sort.column == column) { + sort.descending = !sort.descending; + } else { + sort.column = column; + sort.descending = false; + } + }; + + function fetchData() { + $scope.loading = true; + + data = Workorders.index({ + start: $scope.start.toJSON(), + end: $scope.end.toJSON() + }, function() { + $scope.loading = false; + filter(); + }); + } +} + biomed.WorkorderIndexCtrl = function($scope, $filter, $routeParams, Workorders, LocationBinder) { $scope.loading = true; diff --git a/public/partials/accounting/index.html b/public/partials/accounting/index.html new file mode 100644 index 0000000..1f92a08 --- /dev/null +++ b/public/partials/accounting/index.html @@ -0,0 +1,59 @@ +
+Workorder | +Client | +Date | +Invoice # | +Invoice Date | +Check # | +Paid Date | +Status | +
---|---|---|---|---|---|---|---|
+ #{{workorder.biomedId}} - {{workorder.reason}} + |
+ {{workorder.client.name}} ({{workorder.client.identifier}}) | +{{workorder.scheduling.start | date}} | +{{workorder.invoiceNumber}} | +{{workorder.invoicedOn | date}} | +{{workorder.checkNumber}} | +{{workorder.paidOn | date}} | +{{workorder.status}} | +
Client Name | -Reason | +Client Name | +Frequency | Contact | Phone |
---|---|---|---|---|---|
{{pm.client.name}} ({{pm.client.identifier | uppercase}}) - | {{pm.reason}} | +
+ {{pm.client.name}} ({{pm.client.identifier | uppercase}}) + + {{reason}}, + + |
{{pm.client.contacts[0].name}} | {{pm.client.contacts[0].phone}} |