From 64e4a5f661e13ab0ec7b798e1d6b661d88107527 Mon Sep 17 00:00:00 2001
From: suseendhiran17 <58357088+suseendhiran17@users.noreply.github.com>
Date: Thu, 13 Jul 2023 10:36:39 +0530
Subject: [PATCH 1/9] susee
---
app/models/GeneralSection.js | 1 +
app/models/OfficerDetails.js | 1 +
server.js | 2 ++
3 files changed, 4 insertions(+)
diff --git a/app/models/GeneralSection.js b/app/models/GeneralSection.js
index f108c97..c6b1b0d 100644
--- a/app/models/GeneralSection.js
+++ b/app/models/GeneralSection.js
@@ -16,6 +16,7 @@ module.exports = (sequelize, DataTypes) => {
product: { type: DataTypes.STRING },
case_no: { type: DataTypes.STRING },
losid: { type: DataTypes.STRING },
+ sales_pd_type : { type: DataTypes.INTEGER },
application_id: { type: DataTypes.STRING },
main_loan_applicant: { type: DataTypes.STRING },
company_name: { type: DataTypes.STRING },
diff --git a/app/models/OfficerDetails.js b/app/models/OfficerDetails.js
index f16c1f7..a9eab37 100644
--- a/app/models/OfficerDetails.js
+++ b/app/models/OfficerDetails.js
@@ -11,6 +11,7 @@ module.exports = (sequelize, DataTypes) => {
designation: { type: DataTypes.STRING },
date: { type: DataTypes.STRING },
officer_id :{ type: DataTypes.INTEGER },
+ employee_id :{ type: DataTypes.STRING },
email : { type: DataTypes.STRING },
mobile_no :{ type: DataTypes.INTEGER },
officer_full_name : { type: DataTypes.STRING },
diff --git a/server.js b/server.js
index 71704fe..37a3656 100644
--- a/server.js
+++ b/server.js
@@ -62,3 +62,5 @@ app.listen({ port: PORT_NUMBER }, async () => {
//await sequelize.authenticate()
})
+
+
From ec8ed852106717861d425d8d9430e6b906cdace3 Mon Sep 17 00:00:00 2001
From: suseendhiran17 <58357088+suseendhiran17@users.noreply.github.com>
Date: Fri, 14 Jul 2023 10:42:51 +0530
Subject: [PATCH 2/9] susee
---
app/controllers/salespd.controller.js | 19 ++++++++++++++++++-
app/routes/routes.js | 2 +-
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/app/controllers/salespd.controller.js b/app/controllers/salespd.controller.js
index 6430f28..9a30d44 100644
--- a/app/controllers/salespd.controller.js
+++ b/app/controllers/salespd.controller.js
@@ -1141,4 +1141,21 @@ const storage = new Storage({ keyFilename : path.join(__dirname, "../../googleCl
res.send({'status':404,message: err.message || "Some error occurred while retrieving data." ,'data': "No data" });
} //end of try catch
-};
\ No newline at end of file
+};
+
+exports.test = async (req, res) => {
+ const storage = new Storage({ keyFilename : path.join(__dirname, "../../googleCloud.json") });
+ bucketName = 'pd-giene-data';
+ const bucket = storage.bucket(bucketName);
+
+ try {
+ const [files] = await bucket.getFiles();
+
+ const fileNames = files.map((file) => file.name);
+ console.log('File names:', fileNames);
+ res.send({'data':fileNames})
+ } catch (error) {
+ console.error('Error retrieving file names:', error);
+ }
+ }
+
\ No newline at end of file
diff --git a/app/routes/routes.js b/app/routes/routes.js
index 2435d4d..f9141e6 100644
--- a/app/routes/routes.js
+++ b/app/routes/routes.js
@@ -19,7 +19,7 @@ module.exports = app => {
* description: success
*/
router.get("/demo", Mycontroller.Welcome);
-
+router.get("/test", SalesPdController.test);
// landing page api
/**
* @swagger
From 9ebf3e760af73f527836e22300cb41a4f908c852 Mon Sep 17 00:00:00 2001
From: suseendhiran17 <58357088+suseendhiran17@users.noreply.github.com>
Date: Wed, 19 Jul 2023 16:04:13 +0530
Subject: [PATCH 3/9] susee:log
---
app/controllers/salespd.controller.js | 118 +++++++++
app/routes/routes.js | 6 +
app/views/module.ejs | 337 ++++++++++++++++++++++++++
package-lock.json | 88 ++++++-
package.json | 7 +-
server.js | 4 +
6 files changed, 552 insertions(+), 8 deletions(-)
create mode 100644 app/views/module.ejs
diff --git a/app/controllers/salespd.controller.js b/app/controllers/salespd.controller.js
index 9a30d44..54cdcf2 100644
--- a/app/controllers/salespd.controller.js
+++ b/app/controllers/salespd.controller.js
@@ -1158,4 +1158,122 @@ exports.test = async (req, res) => {
console.error('Error retrieving file names:', error);
}
}
+
+
+
+exports.readLogFileName = async (req , res) =>
+{
+ try
+ {
+ folderName = req;
+ const logFilePath = 'storage/log';
+
+ const fileNames = fs.readdirSync(logFilePath);
+ // Remove the first element (0th index)
+ const [, ...data] = fileNames;
+ return data;
+
+ }
+ catch(err)
+ {
+ res.status(500).send({'status':404,
+ message: err.message || "Some error occurred while inserting statements." ,'data': "No data"
+ });
+ } //end of try catch
+};
+
+
+exports.readLogFile = async (req , res) =>
+{
+ try
+ {
+ folderName = req.body.folder;
+ fileName = req.body.file;
+ const logFilePath = 'storage/log/'+fileName;
+
+ fs.readFile(logFilePath, 'utf8', (err, data) => {
+ if (err) {
+ console.error(err);
+ res.status(500).send({'status':404,'message': err.message || "Error reading log file." ,'data': "No data"});
+ }
+ res.send({'status':200 , message:"Success." ,'data': data});
+ });
+
+ }
+ catch(err)
+ {
+ res.status(500).send({'status':404,
+ message: err.message || "Some error occurred while inserting statements." ,'data': "No data"
+ });
+ } //end of try catch
+};
+
+
+exports.viewLandingPage = async (req , res) =>
+{
+ try
+ {
+ moduleName = [ { "module":"SALES PD","folder":"smc_cet_salespd_backend"} ];
+ img = []
+ for(const [index,val] of moduleName.entries())
+ {
+ fileName = await this.readLogFileName(val.folder);
+ for (let i = 0; i < fileName.length; i++)
+ {
+ filePath = 'storage/log/'+fileName[i];
+ const logData = fs.readFileSync(filePath);
+ // Convert the file content to Base64
+ const base64Data = logData.toString('base64');
+ // Create Base64 URL from Base64 data
+ const base64Url = `data:application/octet-stream;base64,${encodeURIComponent(base64Data)}`;
+ img.push(base64Url)
+ }
+ moduleName[index] = await Object.assign(val,{'file':fileName , 'img':img});
+ };
+ res.render( 'module' , { 'data' : moduleName } ,function (err, html ) {
+ res.send(html)
+ })
+
+ }
+ catch(err)
+ {
+ res.status(500).send({'status':404,
+ message: err.message || "Some error occurred while inserting statements." ,'data': "No data"
+ });
+ } //end of try catch
+};
+
+
+exports.deleteLogFile = async (req , res) =>
+{
+ try
+ {
+ folderName = req.body.folder;
+ fileName = req.body.file;
+
+ // folderName = 'smc_cet_creditpd_backend';
+ // fileName = 'msg.log.2023-07-10';
+ const logFilePath = 'storage/log/'+fileName;
+ fs.unlink(logFilePath, (err) => {
+ if (err) {
+ console.error(`Error deleting file: ${err}`);
+ return;
+ }
+
+ console.log('File deleted successfully.');
+ res.send({'status':200 , message:"Success." ,'data': 'No data'});
+ });
+
+ }
+ catch(err)
+ {
+ res.status(500).send({'status':404,
+ message: err.message || "Some error occurred while inserting statements." ,'data': "No data"
+ });
+ } //end of try catch
+};
+
+
+
+
\ No newline at end of file
diff --git a/app/routes/routes.js b/app/routes/routes.js
index f9141e6..f7caee5 100644
--- a/app/routes/routes.js
+++ b/app/routes/routes.js
@@ -408,7 +408,13 @@ router.get("/PropertyInformationList", SalesPdController.PropertyInformationList
+router.get("/getfilename", SalesPdController.readLogFileName);
+router.post("/readlogs", SalesPdController.readLogFile);
+
+router.get("/view", SalesPdController.viewLandingPage);
+
+router.post("/deletelog", SalesPdController.deleteLogFile);
diff --git a/app/views/module.ejs b/app/views/module.ejs
new file mode 100644
index 0000000..0c2c6f4
--- /dev/null
+++ b/app/views/module.ejs
@@ -0,0 +1,337 @@
+
+
+
+
+
+
+
+
+
+
+
+ <% for (let i = 0; i < data.length; i++) { %>
+
+
+
+
+ LOGS
+
+
+
+ <%= data[i].file.length %>
+
+
+
+ <% for (let j = 0; j < data[i].file.length; j++) { %>
+
+ <% } %>
+
+
+
+
+ <% } %>
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/package-lock.json b/package-lock.json
index 7d9e6bd..e1e9d4e 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -724,7 +724,6 @@
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
- "dev": true,
"requires": {
"color-convert": "^2.0.1"
}
@@ -1102,7 +1101,6 @@
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
- "dev": true,
"requires": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
@@ -1111,14 +1109,12 @@
"has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
- "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
- "dev": true
+ "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ=="
},
"supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
- "dev": true,
"requires": {
"has-flag": "^4.0.0"
}
@@ -1210,7 +1206,6 @@
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
- "dev": true,
"requires": {
"color-name": "~1.1.4"
}
@@ -1538,6 +1533,14 @@
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
"integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
},
+ "ejs": {
+ "version": "3.1.9",
+ "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.9.tgz",
+ "integrity": "sha512-rC+QVNMJWv+MtPgkt0y+0rVEIdbtxVADApW9JXrUVlzHetgcyczP/E7DJmWJ4fJCZF2cPcBk0laWO9ZHMG3DmQ==",
+ "requires": {
+ "jake": "^10.8.5"
+ }
+ },
"emoji-regex": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
@@ -1739,6 +1742,32 @@
"moment": "^2.29.1"
}
},
+ "filelist": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.4.tgz",
+ "integrity": "sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q==",
+ "requires": {
+ "minimatch": "^5.0.1"
+ },
+ "dependencies": {
+ "brace-expansion": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
+ "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
+ "requires": {
+ "balanced-match": "^1.0.0"
+ }
+ },
+ "minimatch": {
+ "version": "5.1.6",
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz",
+ "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==",
+ "requires": {
+ "brace-expansion": "^2.0.1"
+ }
+ }
+ }
+ },
"fill-range": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
@@ -1812,6 +1841,11 @@
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
"integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac="
},
+ "fs": {
+ "version": "0.0.1-security",
+ "resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz",
+ "integrity": "sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w=="
+ },
"fs-constants": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz",
@@ -2342,6 +2376,24 @@
"resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz",
"integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo="
},
+ "jake": {
+ "version": "10.8.7",
+ "resolved": "https://registry.npmjs.org/jake/-/jake-10.8.7.tgz",
+ "integrity": "sha512-ZDi3aP+fG/LchyBzUM804VjddnwfSfsdeYkwt8NcbKRvo4rFkjhs456iLFn3k2ZUWvNe4i48WACDbza8fhq2+w==",
+ "requires": {
+ "async": "^3.2.3",
+ "chalk": "^4.0.2",
+ "filelist": "^1.0.4",
+ "minimatch": "^3.1.2"
+ },
+ "dependencies": {
+ "async": {
+ "version": "3.2.4",
+ "resolved": "https://registry.npmjs.org/async/-/async-3.2.4.tgz",
+ "integrity": "sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ=="
+ }
+ }
+ },
"js-yaml": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
@@ -3003,6 +3055,15 @@
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
"integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ=="
},
+ "path": {
+ "version": "0.12.7",
+ "resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz",
+ "integrity": "sha512-aXXC6s+1w7otVF9UletFkFcDsJeO7lSZBPUQhtb5O0xJe8LtYhj/GxldoL09bBj9+ZmE2hNoHqQSFMN5fikh4Q==",
+ "requires": {
+ "process": "^0.11.1",
+ "util": "^0.10.3"
+ }
+ },
"path-is-absolute": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
@@ -3960,6 +4021,21 @@
"prepend-http": "^2.0.0"
}
},
+ "util": {
+ "version": "0.10.4",
+ "resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz",
+ "integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==",
+ "requires": {
+ "inherits": "2.0.3"
+ },
+ "dependencies": {
+ "inherits": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
+ "integrity": "sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw=="
+ }
+ }
+ },
"util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
diff --git a/package.json b/package.json
index 85f99a9..801498d 100644
--- a/package.json
+++ b/package.json
@@ -9,21 +9,24 @@
"author": "",
"license": "ISC",
"dependencies": {
+ "@google-cloud/storage": "^6.9.3",
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"dotenv": "^10.0.0",
+ "ejs": "^3.1.9",
"express": "^4.17.1",
+ "fs": "0.0.1-security",
"lodash": "^4.17.21",
"log4js": "^6.3.0",
"mssql": "^7.2.0",
"multer": "^1.4.4",
+ "path": "^0.12.7",
"request": "^2.88.2",
"sequelize": "^6.6.5",
"swagger-jsdoc": "^6.1.0",
"swagger-ui-express": "^4.1.6",
"winston": "^3.3.3",
- "winston-daily-rotate-file": "^4.5.5",
- "@google-cloud/storage": "^6.9.3"
+ "winston-daily-rotate-file": "^4.5.5"
},
"devDependencies": {
"nodemon": "^2.0.12"
diff --git a/server.js b/server.js
index 37a3656..7e03da7 100644
--- a/server.js
+++ b/server.js
@@ -2,6 +2,7 @@ require('dotenv').config();
const express = require('express')
const app = express()
const bodyParser = require('body-parser');
+const path = require('path');
//it is used to clear cache
app.use(function(req, res, next) {
@@ -14,6 +15,9 @@ app.use(function(req, res, next) {
const {logMsg} = require('./app/services/logger.js');
+app.set('views', path.join(__dirname, 'app\\views'));
+app.set('view engine', 'ejs');
+
const swaggerJsdoc = require('swagger-jsdoc');
const swaggerUi = require('swagger-ui-express');
From 6c685a5175a69201965adfd3c31bd5ce6a5e64dd Mon Sep 17 00:00:00 2001
From: suseendhiran17 <58357088+suseendhiran17@users.noreply.github.com>
Date: Wed, 19 Jul 2023 16:38:18 +0530
Subject: [PATCH 4/9] susee:log
---
app/views/module.ejs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/app/views/module.ejs b/app/views/module.ejs
index 0c2c6f4..8f72c19 100644
--- a/app/views/module.ejs
+++ b/app/views/module.ejs
@@ -219,7 +219,7 @@
<%= data[i].file[j] %>
- Download link
+ Download link
<% } %>
@@ -324,12 +324,12 @@ $(".delete").click(function(){
});
});
-function downloadImage(data)
+function downloadImage(data,fileName)
{
const base64Image = data; // Replace this with your actual Base64 image data
const downloadLink = document.createElement('a');
downloadLink.href = base64Image;
- downloadLink.download = 'log.txt'; // Replace with the desired file name and extension
+ downloadLink.download = fileName; // Replace with the desired file name and extension
downloadLink.click();
}
From c7d57e138ca4bc6db593bfbe6fc03f441784f266 Mon Sep 17 00:00:00 2001
From: suseendhiran17 <58357088+suseendhiran17@users.noreply.github.com>
Date: Wed, 19 Jul 2023 16:49:33 +0530
Subject: [PATCH 5/9] susee:log
---
app/views/module.ejs | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/app/views/module.ejs b/app/views/module.ejs
index 8f72c19..e62293c 100644
--- a/app/views/module.ejs
+++ b/app/views/module.ejs
@@ -4,6 +4,7 @@
+
@@ -219,7 +224,7 @@
<%= data[i].file[j] %>
- Download link
+
<% } %>
From 5c428261640ad5c8274d49455cbacbff372a4d77 Mon Sep 17 00:00:00 2001
From: suseendhiran17 <58357088+suseendhiran17@users.noreply.github.com>
Date: Wed, 19 Jul 2023 18:05:15 +0530
Subject: [PATCH 6/9] susee:log
---
app/views/module.ejs | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/app/views/module.ejs b/app/views/module.ejs
index e62293c..a1f9ca5 100644
--- a/app/views/module.ejs
+++ b/app/views/module.ejs
@@ -297,12 +297,13 @@ $(document).ready(function () {
$(".fileName").click(function(){
data = $(this).attr('id').split("|");
+ var getUrl = window.location;
+ path_name = getUrl.pathname.slice(0,-4)+'readlogs';
$.ajax({
type: "post",
- url: "/api/readlogs",
+ url: path_name,
data: {'file' : data[0] , 'folder' : data[1]},
success: function(response) {
- console.log(response);
$('.modal-title').html(data[0]);
$('.modal-body').html(response.data);
$('#myModal').modal('show');
@@ -315,9 +316,12 @@ $(".fileName").click(function(){
$(".delete").click(function(){
data = $(this).attr('id').split("|");
+ var getUrl = window.location;
+ path_name = getUrl.pathname.slice(0,-4)+'deletelog';
+alert(path_name)
$.ajax({
type: "post",
- url: "/api/deletelog",
+ url: path_name,
data: {'file' : data[0] , 'folder' : data[1]},
success: function(response) {
console.log(response);
From 3f11e692212f1683217aab6fa4ad20afb350ccb8 Mon Sep 17 00:00:00 2001
From: suseendhiran17 <58357088+suseendhiran17@users.noreply.github.com>
Date: Mon, 24 Jul 2023 11:24:48 +0530
Subject: [PATCH 7/9] susee
---
app/controllers/salespd.controller.js | 29 +++++++++++++++++++++++++--
app/controllers/test.controller.js | 3 +++
app/models/GeneralSection.js | 2 +-
3 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/app/controllers/salespd.controller.js b/app/controllers/salespd.controller.js
index 54cdcf2..22c92c9 100644
--- a/app/controllers/salespd.controller.js
+++ b/app/controllers/salespd.controller.js
@@ -42,7 +42,7 @@ exports.PullSalesPdData = async (req, res) =>
if(values.pincode == 'Others') { pincode = values.pincode_others; }else { pincode = values.pincode; }
if(values.person_met_contact_no == "") { delete values.person_met_contact_no; }
- Object.assign(values, { ref_no: req.body.pdid , product :req.body.product , case_no :req.body.caseno , completed_date : new Date(req.body.completed_date) , pincode : pincode , sales_pd_type:req.body.sales_pd_type});
+ Object.assign(values, { ref_no: req.body.pdid , product :req.body.product , case_no :req.body.caseno , completed_date : new Date(req.body.completed_date) , pincode : pincode , sales_pd_type:req.body.sales_pd_type,employee_id : req.body.employee_id});
await GeneralSection.create( values )
.then((successData)=>{logMsg.info("GeneralSection insert success ,PdId= "+successData.dataValues.pd_id);})
.catch((err)=>{ logMsg.info("GeneralSection insert failed ,PdId(ref_no)= "+req.body.pdid+ " ERR =" + err); });
@@ -96,7 +96,7 @@ exports.PullSalesPdData = async (req, res) =>
if (keys == 'section1') {
if(values.pincode == 'Others') { pincode = values.pincode_others; }else { pincode = values.pincode; }
if(values.person_met_contact_no == "") { delete values.person_met_contact_no; }
- Object.assign(values, { ref_no: req.body.pdid , product :req.body.product , case_no :req.body.caseno ,completed_date : new Date(req.body.completed_date) , pincode : pincode});
+ Object.assign(values, { ref_no: req.body.pdid , product :req.body.product , case_no :req.body.caseno ,completed_date : new Date(req.body.completed_date) , pincode : pincode, sales_pd_type:req.body.sales_pd_type,employee_id : req.body.employee_id});
await GeneralSection.create( values )
.then((successData)=>{logMsg.info("GeneralSection insert success ,PdId= "+successData.dataValues.pd_id);})
.catch((err)=>{ logMsg.info("GeneralSection insert failed ,PdId(ref_no)= "+req.body.pdid+ " ERR =" + err); });
@@ -1272,6 +1272,31 @@ exports.deleteLogFile = async (req , res) =>
});
} //end of try catch
};
+
+
+exports.callSineedgeApi = (req, res) =>
+{
+ try
+ {
+ request('http://www.google.com', function (error, response, body) {
+ res = this.PullSalesPdData(body);
+ if(res.status == 200){
+ res.send({'status':200 , message:"Success." ,'data': Msg});
+ }
+ else{
+ res.send({'status':404 , message:"Failed." ,'data': "No data"});
+ }
+ });
+
+ } catch(err) {
+ res.status(500).send({'status':404,
+ message: err.message || "Some error occurred while inserting statements." ,'data': "No data"
+ }); } //end of try catch
+
+};
+
+
+
diff --git a/app/controllers/test.controller.js b/app/controllers/test.controller.js
index fe4afb0..518a868 100644
--- a/app/controllers/test.controller.js
+++ b/app/controllers/test.controller.js
@@ -70,3 +70,6 @@ exports.SalesPd = async (req, res) =>
}
}
+
+
+
diff --git a/app/models/GeneralSection.js b/app/models/GeneralSection.js
index c6b1b0d..8594130 100644
--- a/app/models/GeneralSection.js
+++ b/app/models/GeneralSection.js
@@ -38,7 +38,7 @@ module.exports = (sequelize, DataTypes) => {
createdby: { type: DataTypes.INTEGER },
updatedby: { type: DataTypes.INTEGER },
completed_date : {type : DataTypes.DATE},
- sales_pd_type : { type: DataTypes.INTEGER }
+ employee_id : { type: DataTypes.STRING }
},
{
From 1b5706db82fed02d485583056d47d6513982e7f0 Mon Sep 17 00:00:00 2001
From: suseendhiran17 <58357088+suseendhiran17@users.noreply.github.com>
Date: Fri, 28 Jul 2023 15:12:27 +0530
Subject: [PATCH 8/9] susee
---
app/controllers/salespd.controller.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/salespd.controller.js b/app/controllers/salespd.controller.js
index 22c92c9..67ac60f 100644
--- a/app/controllers/salespd.controller.js
+++ b/app/controllers/salespd.controller.js
@@ -134,7 +134,7 @@ exports.PullSalesPdData = async (req, res) =>
pre_year_sales = 0;
pre_year_net_profit = 0;
pre_year_net_pro_loss_per = 0;
- for (let i = 0; i < 4; i++)
+ for (let i = 0; i < values.length; i++)
{
if(values[i])
{
From ba854db2c3e0e36a62eee9cb10f9ab6d2dfe27b6 Mon Sep 17 00:00:00 2001
From: suseendhiran17 <58357088+suseendhiran17@users.noreply.github.com>
Date: Fri, 4 Aug 2023 15:36:27 +0530
Subject: [PATCH 9/9] susee:pull data
---
app/controllers/salespd.controller.js | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/app/controllers/salespd.controller.js b/app/controllers/salespd.controller.js
index 67ac60f..63f4314 100644
--- a/app/controllers/salespd.controller.js
+++ b/app/controllers/salespd.controller.js
@@ -134,7 +134,8 @@ exports.PullSalesPdData = async (req, res) =>
pre_year_sales = 0;
pre_year_net_profit = 0;
pre_year_net_pro_loss_per = 0;
- for (let i = 0; i < values.length; i++)
+ con = Object.keys(values).filter(key => !isNaN(parseInt(key))).length;
+ for (let i = 0; i < con; i++)
{
if(values[i])
{