diff --git a/app/controllers/workorders.js b/app/controllers/workorders.js index 8d34815..7e94f44 100644 --- a/app/controllers/workorders.js +++ b/app/controllers/workorders.js @@ -52,6 +52,7 @@ module.exports = function(calendar) { createdOn: new Date(), createdBy: req.user, reason: req.body.reason, + maintenanceType: req.body.maintenanceType || "", remarks: req.body.remarks || "", status: req.body.status, scheduling: req.body.scheduling, @@ -144,6 +145,7 @@ module.exports = function(calendar) { workorder = result; workorder.reason = req.body.reason; + maintenanceType: req.body.maintenanceType || ""; workorder.remarks = req.body.remarks; workorder.scheduling = req.body.scheduling; workorder.status = req.body.status; diff --git a/app/model/pms.js b/app/model/pms.js new file mode 100644 index 0000000..6d077d6 --- /dev/null +++ b/app/model/pms.js @@ -0,0 +1,7 @@ +var mongoose = require('mongoose'), + Schema = mongoose.Schema, + ObjectId = Schema.ObjectId; + +var pmSchema = new Schema({}) + +var Pm = module.exports = mongoose.model('Pm', pmSchema); diff --git a/logs/crash.log b/logs/crash.log new file mode 100755 index 0000000..e69de29 diff --git a/mapreduce.js b/mapreduce.js new file mode 100644 index 0000000..d8b8b0c --- /dev/null +++ b/mapreduce.js @@ -0,0 +1,94 @@ + + + +var mongoose = require('mongoose'); +mongoose.connect('mongodb://localhost/biomed_prod'); + + +var map_clients = function() { + + var result = {}; + + for (var type in this.frequencies) { + if (this.frequencies[type][month]) { + result[type] = 0; + } + } + + if (Object.keys(result).length > 0) { + emit(this._id, result); + } +} + +var reduce_clients = function(key, values) { + return values; +} + +var map_workorders = function() { + if ( + this.scheduling.start >= start && + this.scheduling.start <= end && + this.reason == "Preventive Maintenance") { + + var type = this.maintenanceType || 'legacy'; + var result = {}; + result[type] = 1; + + emit(this.client, result); + } +} + +var reduce_workorders = function(key, values) { + + var result = { } + + values.forEach(function (entry) { + for (i in entry) { + if (i in result) { + result[i] += entry[i]; + } else { + result[i] = entry[i]; + } + } + }); + + return result; +} + + +var today = new Date(); +var year = today.getYear() + 1900; +var month = today.getMonth(); +var start = new Date(year, month, 0); +var end = new Date(year, month + 1, 0); + +console.log(start); +console.log(end); + +var scope = { month: month, start: start, end: end } + +var clients_command = { + mapreduce: "clients", + map: map_clients.toString(), + reduce: reduce_clients.toString(), + scope: scope, + out: { replace: 'pms' } +} + +var workorders_command = { + mapreduce: "workorders", + map: map_workorders.toString(), + reduce: reduce_workorders.toString(), + scope: scope, + out: { reduce: 'pms' } +} + +mongoose.connection.db.executeDbCommand(clients_command, function(err, dbres) { + if (err) throw err; + + mongoose.connection.db.executeDbCommand(workorders_command, function(err, dbres) { + if (err) throw err; + + process.exit(); + }); +}); diff --git a/public/js/app.js b/public/js/app.js index d00049e..62bdb99 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -5,7 +5,7 @@ angular.module('biomed', ['biomed.filters', 'biomed.services', 'biomed.directive $rootScope.TECH_GROUPS = { all: 'All', biomed: 'Biomed', - ice: 'Ice', + ice: 'ICE', sales: 'Sales', other: 'Others' }; diff --git a/public/js/controllers.js b/public/js/controllers.js index c67ec11..aecee7b 100644 --- a/public/js/controllers.js +++ b/public/js/controllers.js @@ -300,16 +300,24 @@ biomed.WorkorderAddCtrl = function($scope, $location, Workorders, Schedule, Clie var search = $location.search(); - if (search.clientId) { + if (search.workorderType == 'pm') { $scope.model.client = search.clientId; - } + $scope.model.reason = "Preventive Maintenance"; + $scope.model.maintenanceType = search.type; - if (search.reason) { - $scope.model.reason = search.reason; - } + $scope.workorderType = 'pm'; + } else { + if (search.clientId) { + $scope.model.client = search.clientId; + } - if (search.remarks) { - $scope.model.remarks = search.remarks; + if (search.reason) { + $scope.model.reason = search.reason; + } + + if (search.remarks) { + $scope.model.remarks = search.remarks; + } } updateAllUsers(); diff --git a/public/partials/clients/edit.html b/public/partials/clients/edit.html index 6c31385..6654c89 100644 --- a/public/partials/clients/edit.html +++ b/public/partials/clients/edit.html @@ -239,7 +239,7 @@ There is no information to display. - Preventive Maintenance ({{pm}})
+ Preventive Maintenance ({{pm}})
This Month PM Due @@ -285,4 +285,4 @@ - \ No newline at end of file + diff --git a/public/partials/schedule/pms.html b/public/partials/schedule/pms.html index fc42e24..197bc99 100644 --- a/public/partials/schedule/pms.html +++ b/public/partials/schedule/pms.html @@ -43,7 +43,7 @@ There is no information to display. - {{pm.client.name}} ({{pm.client.identifier | uppercase}})
+ {{pm.client.name}} ({{pm.client.identifier | uppercase}})
{{pm.reason}} {{pm.client.contacts[0].name}} {{pm.lient.contacts[0].phone}} @@ -51,4 +51,4 @@ - \ No newline at end of file + diff --git a/public/partials/workorders/add.html b/public/partials/workorders/add.html index 04656fc..c1a1dbf 100644 --- a/public/partials/workorders/add.html +++ b/public/partials/workorders/add.html @@ -29,7 +29,7 @@
- @@ -45,6 +45,25 @@
+
+ +
+ +
+
diff --git a/public/partials/workorders/edit.html b/public/partials/workorders/edit.html index 596f81c..d9cf27c 100644 --- a/public/partials/workorders/edit.html +++ b/public/partials/workorders/edit.html @@ -40,6 +40,7 @@
+ {{master.reason}}
{{master.remarks}}
Edit
@@ -63,6 +64,26 @@
+
+ +
+ +
+
+
diff --git a/start.sh b/start.sh new file mode 100755 index 0000000..9a2b56b --- /dev/null +++ b/start.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +while true; +do + NODE_ENV='prod' node/bin/node server.js +done diff --git a/start2.sh b/start2.sh new file mode 100755 index 0000000..617decd --- /dev/null +++ b/start2.sh @@ -0,0 +1,9 @@ +#!/bin/sh +TIMESTAMP=$(date +"%m.%d.%Y at %H:%M:%S") +while true; +do + NODE_ENV='prod' node/bin/node server.js >> logs/portal.log + echo "-------------------------------Shutdown / Crash-------------------------------" >> logs/portal.log + echo "Server was reset on $TIMESTAMP" >> logs/crash.log + notify_by_pushover -u aJmPD4KigO0vLwim76n3WqWKwbKA3k -a YxspDLz3WinbPmwBThuZXCME9QmkDb -s 'falling' -t "Portal Reset" -m "Biomed portal was reset on $TIMESTAMP . See the log file for more details" +done