Switch to side-by-side view

--- a/controllers/mysql.js
+++ b/controllers/mysql.js
@@ -62,10 +62,10 @@
 	});
 }
 
-module.exports.insertNotification= function(body, callback){
+module.exports.insertNotification= function(data, callback){
 	date = new Date().toISOString().slice(0, 19).replace('T', ' ');
-	strSubject = body.subject.replace(/\s/g, '');
-	var sqlQuery = "INSERT INTO notificationlist ( emailTo, subject, date, token) VALUES ('"+body.emailTo+"','"+strSubject+"', '"+date+"', '"+body.token+"')";
+	strSubject = data.subject + " = " + data.subjectValue;
+	var sqlQuery = "INSERT INTO notificationlist ( emailTo, subject, date, token) VALUES ('"+data.emailTo+"','"+strSubject+"', '"+date+"', '"+data.token+"')";
 	con.query(sqlQuery, function (err, result) {
 		if (err){
 			callback(false,err);
@@ -83,7 +83,7 @@
 			callback(false,err);
 		}
 		else{
-			var sqlQuery = "INSERT INTO ruleslist ( description, parameters, parameter, conditionValue, controlValue, notificationType, token) VALUES ('"+body.description+"','"+body.parameters+"','"+body.parameter+"','"+body.conditionValue+"','"+body.controlValue+"',"+body.notificationType+",'"+res[0].token+"')";
+			var sqlQuery = "INSERT INTO ruleslist ( description, parameter, conditionValue, controlValue, notificationType, totalNotifications, totalNotificationsApplyByRules, totalValue, averageValue, percentageNotificationsApplyByRules, token) VALUES ('"+body.description+"','"+body.parameter+"','"+body.conditionValue+"','"+body.controlValue+"',"+body.notificationType+", 0, 0, 0, '0', '0','"+res[0].token+"')";
 			con.query(sqlQuery, function (err, result) {
 				if (err){ 
 					callback(false,err);
@@ -221,7 +221,6 @@
 						callback(false,err);
 					}
 					else{
-
 						var sqlRules = "DELETE FROM ruleslist where token = '"+res[0].token+"'";
 						con.query(sqlRules, function (err, rows) {
 							if (err) {
@@ -264,6 +263,21 @@
 }
 
 /*
+Updates Values for Statistics
+*/
+module.exports.updateValues = function(totalNotifications, totalNotificationsApplyByRules, totalValue, averageValue, percentageNotificationsApplyByRules, rulesID){
+	var sqlQuery = "UPDATE ruleslist SET totalNotifications = '"+totalNotifications+"',totalNotificationsApplyByRules = '"+totalNotificationsApplyByRules+"',totalValue = '"+totalValue+"',averageValue = '"+averageValue+"',percentageNotificationsApplyByRules = '"+percentageNotificationsApplyByRules+"'where rulesID = '"+rulesID+"'";
+	con.query(sqlQuery, function (err, ruleslist) {
+		if (err) {
+			console.log("Deu Erro!!");
+		}
+		else{
+			console.log("Actualizado");
+		}
+	});
+}
+
+/*
 module.exports.insertConfiguration= function(sql){
 	con.query(sql, function (err, result) {
 		if (err) throw err;