|
@@ -19,13 +19,13 @@ module.exports.createContactEntry = async (req, res) => {
|
|
stage_id = 1;
|
|
stage_id = 1;
|
|
}
|
|
}
|
|
|
|
|
|
- const querycount= "select COUNT(*) as count from contact_master where first_name='" + req.body.first_name + "' and last_name='" + req.body.last_name + "' and mobile_number ='" + req.body.mobile_no + "'";
|
|
|
|
- console.log("querycount",querycount);
|
|
|
|
|
|
+ const querycount = "select COUNT(*) as count from contact_master where first_name='" + req.body.first_name + "' and last_name='" + req.body.last_name + "' and mobile_number ='" + req.body.mobile_no + "'";
|
|
|
|
+ console.log("querycount", querycount);
|
|
const querycountresult = await db.executequery(querycount);
|
|
const querycountresult = await db.executequery(querycount);
|
|
|
|
|
|
console.log("querycountresult", querycountresult);
|
|
console.log("querycountresult", querycountresult);
|
|
-
|
|
|
|
- console.log("querycountresult1",querycountresult[0].count);
|
|
|
|
|
|
+
|
|
|
|
+ console.log("querycountresult1", querycountresult[0].count);
|
|
|
|
|
|
if (querycountresult[0].count > 0) {
|
|
if (querycountresult[0].count > 0) {
|
|
console.log("duplicate entry present");
|
|
console.log("duplicate entry present");
|
|
@@ -48,7 +48,7 @@ module.exports.createContactEntry = async (req, res) => {
|
|
console.log("new contact details")
|
|
console.log("new contact details")
|
|
const query = "INSERT INTO contact_master(first_name,last_name,mobile_number,email_id,designation,department,function_area,created_by,created_on,customer_id,stage_id,mob_no)" +
|
|
const query = "INSERT INTO contact_master(first_name,last_name,mobile_number,email_id,designation,department,function_area,created_by,created_on,customer_id,stage_id,mob_no)" +
|
|
"VALUES(?,?,?,?,?,?,?,?,?,?,?,?)";
|
|
"VALUES(?,?,?,?,?,?,?,?,?,?,?,?)";
|
|
- const values = [req.body.first_name, req.body.last_name, req.body.mobile_no, req.body.email_id, req.body.designation, req.body.department, req.body.function, req.body.created_by, createdate, req.body.contact_for, stage_id,req.body.mob_no]
|
|
|
|
|
|
+ const values = [req.body.first_name, req.body.last_name, req.body.mobile_no, req.body.email_id, req.body.designation, req.body.department, req.body.function, req.body.created_by, createdate, req.body.contact_for, stage_id, req.body.mob_no]
|
|
const res1 = await db.executevaluesquery(query, values);
|
|
const res1 = await db.executevaluesquery(query, values);
|
|
|
|
|
|
logger.info('log to file', res);
|
|
logger.info('log to file', res);
|
|
@@ -123,7 +123,7 @@ module.exports.getdvrDetails = async (req, res) => {
|
|
const validationResp = await validation.getdvrDetailscheck(req);
|
|
const validationResp = await validation.getdvrDetailscheck(req);
|
|
if (validationResp.status) {
|
|
if (validationResp.status) {
|
|
try {
|
|
try {
|
|
- const query = "SELECT d.dvr_id,d.date_of_visit,d.customer_name,d.contact_name,d.physical_meeting,d.message,s.stage_desc,d.stage_id,d.created_on,d.nextstep FROM dvr_report d JOIN stage_master s ON d.stage_id=s.stage_id WHERE d.dvr_id = '" + req.query.dvrid + "' and d.delete_id = 0";
|
|
|
|
|
|
+ const query = "SELECT d.dvr_id,d.date_of_visit,d.customer_name,d.contact_name,d.physical_meeting,d.message,s.stage_desc,d.stage_id,d.created_on,d.nextstep,d.second_contact,d.objective,d.est_Date,d.estvalue,d.func,d.person FROM dvr_report d JOIN stage_master s ON d.stage_id=s.stage_id WHERE d.dvr_id = '" + req.query.dvrid + "' and d.delete_id = 0";
|
|
console.log("query", query)
|
|
console.log("query", query)
|
|
const queryresult = await db.executequery(query);
|
|
const queryresult = await db.executequery(query);
|
|
if (queryresult.length > 0) {
|
|
if (queryresult.length > 0) {
|
|
@@ -141,7 +141,14 @@ module.exports.getdvrDetails = async (req, res) => {
|
|
stage_desc: queryresult[0].stage_desc,
|
|
stage_desc: queryresult[0].stage_desc,
|
|
stage_id: queryresult[0].stage_id,
|
|
stage_id: queryresult[0].stage_id,
|
|
created_on: queryresult[0].created_on,
|
|
created_on: queryresult[0].created_on,
|
|
- nextstep:queryresult[0].nextstep
|
|
|
|
|
|
+ nextstep: queryresult[0].nextstep,
|
|
|
|
+ second_contact:queryresult[0].second_contact,
|
|
|
|
+ objective:queryresult[0].objective,
|
|
|
|
+ est_Date:queryresult[0].est_Date,
|
|
|
|
+ deal:queryresult[0].estvalue,
|
|
|
|
+ func:queryresult[0].func,
|
|
|
|
+ person:queryresult[0].person
|
|
|
|
+
|
|
}
|
|
}
|
|
],
|
|
],
|
|
errors: ""
|
|
errors: ""
|
|
@@ -180,6 +187,9 @@ module.exports.getselectionData = async (req, res) => {
|
|
var customerData = [];
|
|
var customerData = [];
|
|
var contactData = [];
|
|
var contactData = [];
|
|
var stageData = [];
|
|
var stageData = [];
|
|
|
|
+ var personData = [];
|
|
|
|
+ var funcDetails = [];
|
|
|
|
+
|
|
|
|
|
|
const query = "SELECT customer_id,customer_name FROM customer_master";
|
|
const query = "SELECT customer_id,customer_name FROM customer_master";
|
|
const queryresult = await db.executequery(query);
|
|
const queryresult = await db.executequery(query);
|
|
@@ -209,6 +219,24 @@ module.exports.getselectionData = async (req, res) => {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ const query3 = "SELECT person_id,person_name FROM person_details";
|
|
|
|
+ const queryresult3 = await db.executequery(query3);
|
|
|
|
+
|
|
|
|
+ if (queryresult3.length > 0) {
|
|
|
|
+ for (var i = 0; i < queryresult3.length; i++) {
|
|
|
|
+ personData.push(queryresult3[i])
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const query4 = "SELECT func_id,func_name FROM function_details";
|
|
|
|
+ const queryresult4 = await db.executequery(query4);
|
|
|
|
+
|
|
|
|
+ if (queryresult4.length > 0) {
|
|
|
|
+ for (var i = 0; i < queryresult4.length; i++) {
|
|
|
|
+ funcDetails.push(queryresult4[i])
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
res.send({
|
|
res.send({
|
|
status: true,
|
|
status: true,
|
|
@@ -218,6 +246,12 @@ module.exports.getselectionData = async (req, res) => {
|
|
contactData: contactData
|
|
contactData: contactData
|
|
}, {
|
|
}, {
|
|
stageData: stageData
|
|
stageData: stageData
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ personData:personData
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ funcDetails: funcDetails
|
|
}
|
|
}
|
|
],
|
|
],
|
|
error: ""
|
|
error: ""
|
|
@@ -313,38 +347,38 @@ module.exports.getdashboarddetails = async (req, res) => {
|
|
|
|
|
|
if (sale_person != undefined && customer == undefined && searchfilter == 'undefineddate' && sale_person != 'all') {
|
|
if (sale_person != undefined && customer == undefined && searchfilter == 'undefineddate' && sale_person != 'all') {
|
|
console.log("only for sale_person");
|
|
console.log("only for sale_person");
|
|
- querydvr = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep from dvr_report where sale_person like '%" + sale_person + "%' and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc";
|
|
|
|
|
|
+ querydvr = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep,second_contact,objective,est_Date,estvalue,func,person,stage_id from dvr_report where sale_person like '%" + sale_person + "%' and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc";
|
|
countquery = "call SP_CountDashboard_admin ('" + firstdate + "','" + seconddate + "','" + emai_id + "','" + '' + "','" + '' + "')";
|
|
countquery = "call SP_CountDashboard_admin ('" + firstdate + "','" + seconddate + "','" + emai_id + "','" + '' + "','" + '' + "')";
|
|
|
|
|
|
} else if (sale_person == undefined && customer != undefined && searchfilter == 'undefineddate' && sale_person != 'all' && customer != 'all') {
|
|
} else if (sale_person == undefined && customer != undefined && searchfilter == 'undefineddate' && sale_person != 'all' && customer != 'all') {
|
|
console.log("only for customer");
|
|
console.log("only for customer");
|
|
- querydvr = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep from dvr_report where customer_name like '%" + customer + "%' and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc";
|
|
|
|
|
|
+ querydvr = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep,second_contact,objective,est_Date,estvalue,func,person,stage_id from dvr_report where customer_name like '%" + customer + "%' and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc";
|
|
countquery = "call SP_CountDashboard_admin ('" + firstdate + "','" + seconddate + "','" + '' + "','" + customer + "','" + customer_id + "')";
|
|
countquery = "call SP_CountDashboard_admin ('" + firstdate + "','" + seconddate + "','" + '' + "','" + customer + "','" + customer_id + "')";
|
|
|
|
|
|
} else if (sale_person != undefined && customer != undefined && customer_id != undefined && sale_person != 'all') {
|
|
} else if (sale_person != undefined && customer != undefined && customer_id != undefined && sale_person != 'all') {
|
|
console.log("for sales_person and Customer");
|
|
console.log("for sales_person and Customer");
|
|
- querydvr = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep from dvr_report where customer_name like '%" + customer + "%' and sale_person like '%" + sale_person + "%' and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc";
|
|
|
|
|
|
+ querydvr = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep,second_contact,objective,est_Date,estvalue,func,person,stage_id from dvr_report where customer_name like '%" + customer + "%' and sale_person like '%" + sale_person + "%' and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc";
|
|
countquery = "call SP_CountDashboard_admin ('" + firstdate + "','" + seconddate + "','" + emai_id + "','" + customer + "','" + customer_id + "')";
|
|
countquery = "call SP_CountDashboard_admin ('" + firstdate + "','" + seconddate + "','" + emai_id + "','" + customer + "','" + customer_id + "')";
|
|
|
|
|
|
} else if (sale_person != 'all' && firstdate != undefined && seconddate != undefined && sale_person != undefined) {
|
|
} else if (sale_person != 'all' && firstdate != undefined && seconddate != undefined && sale_person != undefined) {
|
|
console.log("date and sale_person");
|
|
console.log("date and sale_person");
|
|
- querydvr = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep from dvr_report where date_of_visit between'" + firstdate + "' and '" + seconddate + "' and sale_person like '%" + sale_person + "%' and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc";
|
|
|
|
|
|
+ querydvr = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep,second_contact,objective,est_Date,estvalue,func,person,stage_id from dvr_report where date_of_visit between'" + firstdate + "' and '" + seconddate + "' and sale_person like '%" + sale_person + "%' and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc";
|
|
countquery = "call SP_CountDashboard_admin ('" + firstdate + "','" + seconddate + "','" + emai_id + "','" + '' + "','" + '' + "')";
|
|
countquery = "call SP_CountDashboard_admin ('" + firstdate + "','" + seconddate + "','" + emai_id + "','" + '' + "','" + '' + "')";
|
|
|
|
|
|
|
|
|
|
} else if (customer != undefined && firstdate != undefined && seconddate != undefined && sale_person == undefined) {
|
|
} else if (customer != undefined && firstdate != undefined && seconddate != undefined && sale_person == undefined) {
|
|
console.log("for date and customer");
|
|
console.log("for date and customer");
|
|
- querydvr = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep from dvr_report where date_of_visit between'" + firstdate + "' and '" + seconddate + "' and customer_name like '%" + customer + "%' and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc";
|
|
|
|
|
|
+ querydvr = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep,second_contact,objective,est_Date,estvalue,func,person,stage_id from dvr_report where date_of_visit between'" + firstdate + "' and '" + seconddate + "' and customer_name like '%" + customer + "%' and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc";
|
|
countquery = "call SP_CountDashboard_admin ('" + firstdate + "','" + seconddate + "','" + '' + "','" + customer + "','" + customer_id + "')";
|
|
countquery = "call SP_CountDashboard_admin ('" + firstdate + "','" + seconddate + "','" + '' + "','" + customer + "','" + customer_id + "')";
|
|
|
|
|
|
} else if (customer != undefined && firstdate != undefined && seconddate != undefined && sale_person != undefined) {
|
|
} else if (customer != undefined && firstdate != undefined && seconddate != undefined && sale_person != undefined) {
|
|
console.log("all filters");
|
|
console.log("all filters");
|
|
- querydvr = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep from dvr_report where date_of_visit between'" + firstdate + "' and '" + seconddate + "' and customer_name like '%" + customer + "%' and sale_person like '%" + sale_person + "%' and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc";
|
|
|
|
|
|
+ querydvr = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep,second_contact,objective,est_Date,estvalue,func,person,stage_id from dvr_report where date_of_visit between'" + firstdate + "' and '" + seconddate + "' and customer_name like '%" + customer + "%' and sale_person like '%" + sale_person + "%' and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc";
|
|
countquery = "call SP_CountDashboard_admin ('" + firstdate + "','" + seconddate + "','" + emai_id + "','" + customer + "','" + customer_id + "')";
|
|
countquery = "call SP_CountDashboard_admin ('" + firstdate + "','" + seconddate + "','" + emai_id + "','" + customer + "','" + customer_id + "')";
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
console.log("only for date");
|
|
console.log("only for date");
|
|
- querydvr = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep from dvr_report where date_of_visit between'" + firstdate + "' and '" + seconddate + "' and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc";
|
|
|
|
|
|
+ querydvr = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep,second_contact,objective,est_Date,estvalue,func,person,stage_id from dvr_report where date_of_visit between'" + firstdate + "' and '" + seconddate + "' and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc";
|
|
countquery = "call SP_CountDashboard_admin ('" + firstdate + "','" + seconddate + "','" + '' + "','" + '' + "','" + '' + "')";
|
|
countquery = "call SP_CountDashboard_admin ('" + firstdate + "','" + seconddate + "','" + '' + "','" + '' + "','" + '' + "')";
|
|
|
|
|
|
}
|
|
}
|
|
@@ -460,10 +494,10 @@ module.exports.getdashboarddetails = async (req, res) => {
|
|
const currentDate = await getcurrentDate();
|
|
const currentDate = await getcurrentDate();
|
|
console.log(lastweek)
|
|
console.log(lastweek)
|
|
if (sale_person == undefined) {
|
|
if (sale_person == undefined) {
|
|
- querydvr = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep from dvr_report where date_of_visit between'" + lastweek + "' and '" + currentDate + "' and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc";
|
|
|
|
|
|
+ querydvr = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep,second_contact,objective,est_Date,estvalue,func,person,stage_id from dvr_report where date_of_visit between'" + lastweek + "' and '" + currentDate + "' and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc";
|
|
|
|
|
|
} else {
|
|
} else {
|
|
- querydvr = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep from dvr_report where date_of_visit between'" + lastweek + "' and '" + currentDate + "' and contact_name like '%" + sale_person + "%' and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc";
|
|
|
|
|
|
+ querydvr = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep,second_contact,objective,est_Date,estvalue,func,person,stage_id from dvr_report where date_of_visit between'" + lastweek + "' and '" + currentDate + "' and contact_name like '%" + sale_person + "%' and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc";
|
|
}
|
|
}
|
|
|
|
|
|
const countquery = "call SP_CountDashboard ('" + lastweek + "','" + currentDate + "','" + '' + "')";
|
|
const countquery = "call SP_CountDashboard ('" + lastweek + "','" + currentDate + "','" + '' + "')";
|
|
@@ -522,10 +556,10 @@ module.exports.getdashboarddetails = async (req, res) => {
|
|
const currentDate = await getcurrentDate();
|
|
const currentDate = await getcurrentDate();
|
|
|
|
|
|
if (sale_person == undefined) {
|
|
if (sale_person == undefined) {
|
|
- querydvr = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep from dvr_report where date_of_visit between'" + lastyeardate + "' and '" + currentDate + "' and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc";
|
|
|
|
|
|
+ querydvr = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep,second_contact,objective,est_Date,estvalue,func,person,stage_id from dvr_report where date_of_visit between'" + lastyeardate + "' and '" + currentDate + "' and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc";
|
|
|
|
|
|
} else {
|
|
} else {
|
|
- querydvr = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep from dvr_report where date_of_visit between'" + lastyeardate + "' and '" + currentDate + "' and contact_name like '%" + sale_person + "%' and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc ";
|
|
|
|
|
|
+ querydvr = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep,second_contact,objective,est_Date,estvalue,func,person,stage_id from dvr_report where date_of_visit between'" + lastyeardate + "' and '" + currentDate + "' and contact_name like '%" + sale_person + "%' and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc ";
|
|
}
|
|
}
|
|
|
|
|
|
console.log("lastyeardate", lastyeardate, " ", currentDate);
|
|
console.log("lastyeardate", lastyeardate, " ", currentDate);
|
|
@@ -601,11 +635,11 @@ module.exports.getdashboarddetails = async (req, res) => {
|
|
console.log("lastmonthDate", lastmonthDate, "currentDate", currentDate);
|
|
console.log("lastmonthDate", lastmonthDate, "currentDate", currentDate);
|
|
|
|
|
|
if (sale_person == undefined) {
|
|
if (sale_person == undefined) {
|
|
- querydvr = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep from dvr_report where date_of_visit between'" + lastmonthDate + "' and '" + currentDate + "' and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc";
|
|
|
|
|
|
+ querydvr = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep,second_contact,objective,est_Date,estvalue,func,person,stage_id from dvr_report where date_of_visit between'" + lastmonthDate + "' and '" + currentDate + "' and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc";
|
|
|
|
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- querydvr = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep from dvr_report where date_of_visit between'" + lastmonthDate + "' and '" + currentDate + "' and contact_name like '%" + sale_person + "%' and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc";
|
|
|
|
|
|
+ querydvr = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep,second_contact,objective,est_Date,estvalue,func,person,stage_id from dvr_report where date_of_visit between'" + lastmonthDate + "' and '" + currentDate + "' and contact_name like '%" + sale_person + "%' and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc";
|
|
}
|
|
}
|
|
|
|
|
|
const countquery = "call SP_CountDashboard ('" + lastmonthDate + "' , '" + currentDate + "','" + '' + "')";
|
|
const countquery = "call SP_CountDashboard ('" + lastmonthDate + "' , '" + currentDate + "','" + '' + "')";
|
|
@@ -667,10 +701,11 @@ module.exports.getdashboarddetails = async (req, res) => {
|
|
const currentDate = await getcurrentDate();
|
|
const currentDate = await getcurrentDate();
|
|
console.log("lastmonthDate ", lastmonthDate, " currentDate", currentDate)
|
|
console.log("lastmonthDate ", lastmonthDate, " currentDate", currentDate)
|
|
if (sale_person == undefined) {
|
|
if (sale_person == undefined) {
|
|
- querydvr = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep from dvr_report where date_of_visit between'" + lastmonthDate + "' and '" + currentDate + "' and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc";
|
|
|
|
|
|
+ querydvr = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep,second_contact,objective,est_Date,estvalue,func,person,stage_id from dvr_report where date_of_visit between'" + lastmonthDate + "' and '" + currentDate + "' and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc";
|
|
|
|
|
|
} else {
|
|
} else {
|
|
- querydvr = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep from dvr_report where date_of_visit between'" + lastmonthDate + "' and '" + currentDate + "' and contact_name like '%" + sale_person + "%' and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc ";
|
|
|
|
|
|
+ console.log("by default value82829293839398")
|
|
|
|
+ querydvr = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep,second_contact,objective,est_Date,estvalue,func,person,stage_id from dvr_report where date_of_visit between'" + lastmonthDate + "' and '" + currentDate + "' and contact_name like '%" + sale_person + "%' and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc ";
|
|
}
|
|
}
|
|
const countquery = "call SP_CountDashboard ('" + lastmonthDate + "' , '" + currentDate + "' ,'" + '' + "')";
|
|
const countquery = "call SP_CountDashboard ('" + lastmonthDate + "' , '" + currentDate + "' ,'" + '' + "')";
|
|
|
|
|
|
@@ -777,7 +812,7 @@ module.exports.getdashboarddetails = async (req, res) => {
|
|
|
|
|
|
if (getcustomer_name) {
|
|
if (getcustomer_name) {
|
|
for (var i = 0; i < getcustomer_name.length; i++) {
|
|
for (var i = 0; i < getcustomer_name.length; i++) {
|
|
- const query = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep from dvr_report where date_of_visit between'" + firstdate + "' and '" + seconddate + "' and customer_name in ('" + getcustomer_name[i] + "') and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc";
|
|
|
|
|
|
+ const query = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep,second_contact,objective,est_Date,estvalue,func,person,stage_id from dvr_report where date_of_visit between'" + firstdate + "' and '" + seconddate + "' and customer_name in ('" + getcustomer_name[i] + "') and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc";
|
|
dvrlist[i] = await db.executequery(query);
|
|
dvrlist[i] = await db.executequery(query);
|
|
|
|
|
|
}
|
|
}
|
|
@@ -913,7 +948,7 @@ module.exports.getdashboarddetails = async (req, res) => {
|
|
|
|
|
|
if (getcustomer_name) {
|
|
if (getcustomer_name) {
|
|
for (var i = 0; i < getcustomer_name.length; i++) {
|
|
for (var i = 0; i < getcustomer_name.length; i++) {
|
|
- const query = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep from dvr_report where date_of_visit between'" + lastweek + "' and '" + currentDate + "' and customer_name in ('" + getcustomer_name[i] + "') and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc";
|
|
|
|
|
|
+ const query = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep,second_contact,objective,est_Date,estvalue,func,person,stage_id from dvr_report where date_of_visit between'" + lastweek + "' and '" + currentDate + "' and customer_name in ('" + getcustomer_name[i] + "') and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc";
|
|
dvrlist[i] = await db.executequery(query);
|
|
dvrlist[i] = await db.executequery(query);
|
|
|
|
|
|
}
|
|
}
|
|
@@ -1050,7 +1085,7 @@ module.exports.getdashboarddetails = async (req, res) => {
|
|
|
|
|
|
if (getcustomer_name) {
|
|
if (getcustomer_name) {
|
|
for (var i = 0; i < getcustomer_name.length; i++) {
|
|
for (var i = 0; i < getcustomer_name.length; i++) {
|
|
- const query = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep from dvr_report where date_of_visit between'" + lastyeardate + "' and '" + currentDate + "' and customer_name in ('" + getcustomer_name[i] + "') and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc";
|
|
|
|
|
|
+ const query = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep,second_contact,objective,est_Date,estvalue,func,person,stage_id from dvr_report where date_of_visit between'" + lastyeardate + "' and '" + currentDate + "' and customer_name in ('" + getcustomer_name[i] + "') and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc";
|
|
dvrlist[i] = await db.executequery(query);
|
|
dvrlist[i] = await db.executequery(query);
|
|
|
|
|
|
}
|
|
}
|
|
@@ -1189,7 +1224,7 @@ module.exports.getdashboarddetails = async (req, res) => {
|
|
|
|
|
|
if (getcustomer_name) {
|
|
if (getcustomer_name) {
|
|
for (var i = 0; i < getcustomer_name.length; i++) {
|
|
for (var i = 0; i < getcustomer_name.length; i++) {
|
|
- const query = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep from dvr_report where date_of_visit between'" + lastmonthDate + "' and '" + currentDate + "' and customer_name in ('" + getcustomer_name[i] + "') and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc";
|
|
|
|
|
|
+ const query = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep,second_contact,objective,est_Date,estvalue,func,person,stage_id from dvr_report where date_of_visit between'" + lastmonthDate + "' and '" + currentDate + "' and customer_name in ('" + getcustomer_name[i] + "') and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc";
|
|
dvrlist[i] = await db.executequery(query);
|
|
dvrlist[i] = await db.executequery(query);
|
|
|
|
|
|
}
|
|
}
|
|
@@ -1332,7 +1367,7 @@ module.exports.getdashboarddetails = async (req, res) => {
|
|
|
|
|
|
if (getcustomer_name) {
|
|
if (getcustomer_name) {
|
|
for (var i = 0; i < getcustomer_name.length; i++) {
|
|
for (var i = 0; i < getcustomer_name.length; i++) {
|
|
- const query = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep from dvr_report where date_of_visit between'" + lastmonthDate + "' and '" + currentDate + "' and customer_name in ('" + getcustomer_name[i] + "') and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc";
|
|
|
|
|
|
+ const query = "select dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person,nextstep,second_contact,objective,est_Date,estvalue,func,person,stage_id from dvr_report where date_of_visit between'" + lastmonthDate + "' and '" + currentDate + "' and customer_name in ('" + getcustomer_name[i] + "') and delete_id=0 order by DATE_FORMAT(date_of_visit, '%Y%m%d') desc";
|
|
dvrlist[i] = await db.executequery(query);
|
|
dvrlist[i] = await db.executequery(query);
|
|
|
|
|
|
}
|
|
}
|
|
@@ -1432,10 +1467,10 @@ module.exports.createDvrEntry = async (req, res) => {
|
|
console.log(" req.body.login_id", req.body.created_by);
|
|
console.log(" req.body.login_id", req.body.created_by);
|
|
const date_of_visit = new Date(req.body.visit_date);
|
|
const date_of_visit = new Date(req.body.visit_date);
|
|
//const date_of_visit=req.body.visit_date;
|
|
//const date_of_visit=req.body.visit_date;
|
|
-
|
|
|
|
- const query = "INSERT INTO dvr_report(date_of_visit,customer_name,contact_name,physical_meeting,message,created_by,created_on,stage_id,login_id,sale_person,delete_id,nextstep,second_contact)" +
|
|
|
|
- "VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
|
|
|
- const values = [date_of_visit, req.body.customer_name, req.body.contact_name, req.body.physical_metting, req.body.message, req.body.created_by, createdate, req.body.stage_id, req.body.created_by, req.body.sale_person, 0,req.body.nextstep,req.body.second_contact]
|
|
|
|
|
|
+ console.log("estvalue:::::::::::::::::::::::::::::::::::::::::::", req.body)
|
|
|
|
+ const query = "INSERT INTO dvr_report(date_of_visit,customer_name,contact_name,physical_meeting,message,created_by,created_on,stage_id,login_id,sale_person,delete_id,nextstep,second_contact,objective,est_Date,estvalue,func,person)" +
|
|
|
|
+ "VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
|
|
|
+ const values = [date_of_visit, req.body.customer_name, req.body.contact_name, req.body.physical_metting, req.body.message, req.body.created_by, createdate, req.body.stage_id, req.body.created_by, req.body.sale_person, 0, req.body.nextstep, req.body.second_contact, req.body.objective, req.body.estDate, req.body.deal,req.body.func,req.body.person]
|
|
|
|
|
|
// console.log("query",query);
|
|
// console.log("query",query);
|
|
//console.log("values",values);
|
|
//console.log("values",values);
|
|
@@ -1502,7 +1537,7 @@ module.exports.updatedvrDetails = async (req, res) => {
|
|
|
|
|
|
if (validationResp.status) {
|
|
if (validationResp.status) {
|
|
try {
|
|
try {
|
|
- const query = "UPDATE dvr_report SET date_of_visit = '" + req.body.visit_date + "' ,customer_name= '" + req.body.customer_name + "',contact_name= '" + req.body.contact_name + "',message= '" + req.body.message + "' ,physical_meeting= '" + req.body.physical_metting + "' ,updated_by= '" + req.body.updated_by + "', updated_on= '" + updatedDate + "', stage_id= '" + req.body.stage_id + "' , nextstep= '" + req.body.nextstep + "' where dvr_id= '" + req.body.dvr_id + "'";
|
|
|
|
|
|
+ const query = "UPDATE dvr_report SET date_of_visit = '" + req.body.visit_date + "' ,customer_name= '" + req.body.customer_name + "',contact_name= '" + req.body.contact_name + "',message= '" + req.body.message + "' ,physical_meeting= '" + req.body.physical_metting + "' ,updated_by= '" + req.body.updated_by + "', updated_on= '" + updatedDate + "', stage_id= '" + req.body.stage_id + "' , nextstep= '" + req.body.nextstep + "', second_contact= '" + req.body.second_contact + "', objective= '" + req.body.objective + "', estDate= '" + req.body.estDate + "', deal= '" + req.body.deal + "',func= '" + req.body.func + "',person= '" + req.body.person + "' where dvr_id= '" + req.body.dvr_id + "'";
|
|
console.log("query", query);
|
|
console.log("query", query);
|
|
const queryresult = await db.executequery(query);
|
|
const queryresult = await db.executequery(query);
|
|
console.log("queryresult", queryresult);
|
|
console.log("queryresult", queryresult);
|
|
@@ -1678,7 +1713,7 @@ module.exports.getlastestdvr = async (req, res) => {
|
|
|
|
|
|
if (person_role == 'admin') {
|
|
if (person_role == 'admin') {
|
|
//admin show all data
|
|
//admin show all data
|
|
- const query = "SELECT d.dvr_id,d.date_of_visit,d.customer_name,d.contact_name,d.physical_meeting,d.message,s.stage_desc,d.stage_id,d.nextstep,d.second_contact FROM dvr_report d JOIN stage_master s ON d.stage_id=s.stage_id where d.created_on between '" + startdate + "' and '" + enddate + "' and d.delete_id=0 order by d.date_of_visit desc";
|
|
|
|
|
|
+ const query = "SELECT d.dvr_id,d.date_of_visit,d.customer_name,d.contact_name,d.physical_meeting,d.message,s.stage_desc,d.stage_id,d.nextstep,d.second_contact,d.objective,d.est_Date,d.estvalue,d.func,d.person FROM dvr_report d JOIN stage_master s ON d.stage_id=s.stage_id where d.created_on between '" + startdate + "' and '" + enddate + "' and d.delete_id=0 order by d.date_of_visit desc";
|
|
const queryresult = await db.executequery(query);
|
|
const queryresult = await db.executequery(query);
|
|
console.log("query", query);
|
|
console.log("query", query);
|
|
|
|
|
|
@@ -1715,7 +1750,7 @@ module.exports.getlastestdvr = async (req, res) => {
|
|
} else {
|
|
} else {
|
|
// other users
|
|
// other users
|
|
console.log("other users");
|
|
console.log("other users");
|
|
- const query = "SELECT d.dvr_id,d.date_of_visit,d.customer_name,d.contact_name,d.physical_meeting,d.message,s.stage_desc,d.stage_id.d.nextstep,d.second_contact FROM dvr_report d JOIN stage_master s ON d.stage_id=s.stage_id where d.login_id='" + login_id + "' and d.created_on between '" + startdate + "' and '" + enddate + "' and d.delete_id=0 order by d.date_of_visit desc";
|
|
|
|
|
|
+ const query = "SELECT d.dvr_id,d.date_of_visit,d.customer_name,d.contact_name,d.physical_meeting,d.message,s.stage_desc,d.stage_id,d.nextstep,d.second_contact,d.objective,d.est_Date,d.estvalue,d.func,d.person FROM dvr_report d JOIN stage_master s ON d.stage_id=s.stage_id where d.login_id='" + login_id + "' and d.created_on between '" + startdate + "' and '" + enddate + "' and d.delete_id=0 order by d.date_of_visit desc";
|
|
const queryresult = await db.executequery(query);
|
|
const queryresult = await db.executequery(query);
|
|
console.log("query", query);
|
|
console.log("query", query);
|
|
|
|
|
|
@@ -1724,7 +1759,7 @@ module.exports.getlastestdvr = async (req, res) => {
|
|
insertedRecord.push(queryresult[i])
|
|
insertedRecord.push(queryresult[i])
|
|
}
|
|
}
|
|
|
|
|
|
- //console.log("res1", res1);
|
|
|
|
|
|
+ console.log("queryresult", queryresult);
|
|
if (queryresult.length > 0) {
|
|
if (queryresult.length > 0) {
|
|
res.send({
|
|
res.send({
|
|
status: true,
|
|
status: true,
|
|
@@ -2459,7 +2494,7 @@ module.exports.deletedvrEntry = async (req, res) => {
|
|
// module.exports.mappingCustomerDetails = async (req, res) => {
|
|
// module.exports.mappingCustomerDetails = async (req, res) => {
|
|
// // Validate the request
|
|
// // Validate the request
|
|
// const validationResp = await validation.mappingCustomerDetailsCheck(req);
|
|
// const validationResp = await validation.mappingCustomerDetailsCheck(req);
|
|
-
|
|
|
|
|
|
+
|
|
// if (validationResp.status) {
|
|
// if (validationResp.status) {
|
|
// try {
|
|
// try {
|
|
// // Extract salesperson's name
|
|
// // Extract salesperson's name
|
|
@@ -2505,9 +2540,9 @@ module.exports.deletedvrEntry = async (req, res) => {
|
|
|
|
|
|
module.exports.mappingCustomerDetails = async (req, res) => {
|
|
module.exports.mappingCustomerDetails = async (req, res) => {
|
|
// Validate the request
|
|
// Validate the request
|
|
- console.log("sale_",req.query.sale_person)
|
|
|
|
|
|
+ console.log("sale_", req.query.sale_person)
|
|
const validationResp = await validation.mappingCustomerDetailsCheck(req);
|
|
const validationResp = await validation.mappingCustomerDetailsCheck(req);
|
|
-
|
|
|
|
|
|
+
|
|
if (validationResp.status) {
|
|
if (validationResp.status) {
|
|
try {
|
|
try {
|
|
const sale_person = req.query.sale_person;
|
|
const sale_person = req.query.sale_person;
|
|
@@ -2568,6 +2603,56 @@ module.exports.mappingCustomerDetails = async (req, res) => {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+module.exports.mappingFuncIDToPersonNames = async (req, res) => {
|
|
|
|
+ // Validate the request
|
|
|
|
+ console.log("func_id_", req.query.func_id);
|
|
|
|
+ const validationResp = await validation.mappingFuncIDToPersonNamesCheck(req);
|
|
|
|
+
|
|
|
|
+ if (validationResp.status) {
|
|
|
|
+ try {
|
|
|
|
+ const func_id = req.query.func_id;
|
|
|
|
+
|
|
|
|
+ // SQL query to get all persons mapped to the given func_id
|
|
|
|
+ const queryFunctionPersonMapping = `
|
|
|
|
+ SELECT f.func_id, p.person_name
|
|
|
|
+ FROM dvr_local.function_person_mapping fp
|
|
|
|
+ JOIN dvr_local.function_details f ON f.func_id = fp.func_id
|
|
|
|
+ JOIN dvr_local.person_details p ON p.person_id = fp.person_id
|
|
|
|
+ WHERE fp.func_id = '${func_id}'`;
|
|
|
|
+
|
|
|
|
+ console.log("queryFunctionPersonMapping", queryFunctionPersonMapping);
|
|
|
|
+
|
|
|
|
+ // Use parameterized query to avoid SQL injection
|
|
|
|
+ const queryResult = await db.executequery(queryFunctionPersonMapping, [func_id]);
|
|
|
|
+ console.log("Function-person mapping query result:", queryResult);
|
|
|
|
+
|
|
|
|
+ if (queryResult.length > 0) {
|
|
|
|
+ res.send({
|
|
|
|
+ status: true,
|
|
|
|
+ data: queryResult,
|
|
|
|
+ error: null
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ res.send({
|
|
|
|
+ status: false,
|
|
|
|
+ data: [],
|
|
|
|
+ errors: "No persons are mapped to the specified function ID."
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ } catch (err) {
|
|
|
|
+ console.error("Error occurred:", err);
|
|
|
|
+ res.send({
|
|
|
|
+ status: false,
|
|
|
|
+ data: [],
|
|
|
|
+ errors: "An error occurred while fetching the person details for the specified function ID."
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ res.send(validationResp);
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
function getLastWeeksDate() {
|
|
function getLastWeeksDate() {
|
|
const now = new Date();
|
|
const now = new Date();
|