ashwini 1 месяц назад
Родитель
Сommit
3612674120
3 измененных файлов с 67 добавлено и 69 удалено
  1. 34 33
      controllers/dvrReportController.js
  2. 32 35
      controllers/loginController.js
  3. 1 1
      routes/route.js

+ 34 - 33
controllers/dvrReportController.js

@@ -46,9 +46,9 @@ module.exports.createContactEntry = async (req, res) => {
 
             } else {
                 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)" +
-                    "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]
+                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(?,?,?,?,?,?,?,?,?,?,?,?)";
+                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);
 
                 logger.info('log to file', res);
@@ -123,7 +123,7 @@ module.exports.getdvrDetails = async (req, res) => {
     const validationResp = await validation.getdvrDetailscheck(req);
     if (validationResp.status) {
         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 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 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)
             const queryresult = await db.executequery(query);
             if (queryresult.length > 0) {
@@ -140,7 +140,8 @@ module.exports.getdvrDetails = async (req, res) => {
                             physical_metting: queryresult[0].physical_meeting,
                             stage_desc: queryresult[0].stage_desc,
                             stage_id: queryresult[0].stage_id,
-                            created_on: queryresult[0].created_on
+                            created_on: queryresult[0].created_on,
+                            nextstep:queryresult[0].nextstep
                         }
                     ],
                     errors: ""
@@ -312,38 +313,38 @@ module.exports.getdashboarddetails = async (req, res) => {
 
                     if (sale_person != undefined && customer == undefined && searchfilter == 'undefineddate' && sale_person != 'all') {
                         console.log("only for sale_person");
-                        querydvr = "select  dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person 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 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 + "','" + '' + "','" + '' + "')";
 
                     } else if (sale_person == undefined && customer != undefined && searchfilter == 'undefineddate' && sale_person != 'all' && customer != 'all') {
                         console.log("only for customer");
-                        querydvr = "select  dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person 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 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 + "')";
 
                     } else if (sale_person != undefined && customer != undefined && customer_id != undefined && sale_person != 'all') {
                         console.log("for sales_person and Customer");
-                        querydvr = "select  dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person 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 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 + "')";
 
                     } else if (sale_person != 'all' && firstdate != undefined && seconddate != undefined && sale_person != undefined) {
                         console.log("date and sale_person");
-                        querydvr = "select  dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person 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 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 + "','" + '' + "','" + '' + "')";
 
 
                     } else if (customer != undefined && firstdate != undefined && seconddate != undefined && sale_person == undefined) {
                         console.log("for date and customer");
-                        querydvr = "select  dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person 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 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 + "')";
 
                     } else if (customer != undefined && firstdate != undefined && seconddate != undefined && sale_person != undefined) {
                         console.log("all filters");
-                        querydvr = "select  dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person 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 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 + "')";
                     }
                     else {
                         console.log("only for date");
-                        querydvr = "select  dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person 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 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 + "','" + '' + "','" + '' + "','" + '' + "')";
 
                     }
@@ -459,10 +460,10 @@ module.exports.getdashboarddetails = async (req, res) => {
                         const currentDate = await getcurrentDate();
                         console.log(lastweek)
                         if (sale_person == undefined) {
-                            querydvr = "select  dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person 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 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 {
-                            querydvr = "select  dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person 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 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 + "','" + '' + "')";
@@ -521,10 +522,10 @@ module.exports.getdashboarddetails = async (req, res) => {
                         const currentDate = await getcurrentDate();
 
                         if (sale_person == undefined) {
-                            querydvr = "select  dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person 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 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 {
-                            querydvr = "select  dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person 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 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);
@@ -600,11 +601,11 @@ module.exports.getdashboarddetails = async (req, res) => {
                         console.log("lastmonthDate", lastmonthDate, "currentDate", currentDate);
 
                         if (sale_person == undefined) {
-                            querydvr = "select  dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person 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 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 {
-                            querydvr = "select  dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person 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 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 + "','" + '' + "')";
@@ -666,10 +667,10 @@ module.exports.getdashboarddetails = async (req, res) => {
                 const currentDate = await getcurrentDate();
                 console.log("lastmonthDate ", lastmonthDate, "  currentDate", currentDate)
                 if (sale_person == undefined) {
-                    querydvr = "select  dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person 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 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 {
-                    querydvr = "select  dvr_id, date_of_visit,customer_name,contact_name,message,physical_meeting,sale_person 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 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 + "' ,'" + '' + "')";
 
@@ -776,7 +777,7 @@ module.exports.getdashboarddetails = async (req, res) => {
 
                         if (getcustomer_name) {
                             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 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 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);
 
                             }
@@ -912,7 +913,7 @@ module.exports.getdashboarddetails = async (req, res) => {
 
                             if (getcustomer_name) {
                                 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 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 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);
 
                                 }
@@ -1049,7 +1050,7 @@ module.exports.getdashboarddetails = async (req, res) => {
 
                             if (getcustomer_name) {
                                 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 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 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);
 
                                 }
@@ -1188,7 +1189,7 @@ module.exports.getdashboarddetails = async (req, res) => {
 
                             if (getcustomer_name) {
                                 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 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 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);
 
                                 }
@@ -1331,7 +1332,7 @@ module.exports.getdashboarddetails = async (req, res) => {
 
                     if (getcustomer_name) {
                         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 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 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);
 
                         }
@@ -1432,9 +1433,9 @@ module.exports.createDvrEntry = async (req, res) => {
             const date_of_visit = new Date(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)" +
-                "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]
+            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)" +
+                "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]
 
             // console.log("query",query);
             //console.log("values",values);
@@ -1501,7 +1502,7 @@ module.exports.updatedvrDetails = async (req, res) => {
 
     if (validationResp.status) {
         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 + "'  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 + "' where dvr_id= '" + req.body.dvr_id + "'";
             console.log("query", query);
             const queryresult = await db.executequery(query);
             console.log("queryresult", queryresult);
@@ -1594,7 +1595,7 @@ module.exports.updateContactDetails = async (req, res) => {
 
     if (validationResp.status) {
         try {
-            const query = "UPDATE contact_master SET customer_id= '" + req.body.customer_id + "',first_name= '" + req.body.first_name + "',last_name= '" + req.body.last_name + "' ,mobile_number= '" + req.body.mobile_number + "' ,email_id= '" + req.body.email_id + "', designation= '" + req.body.designation + "', department= '" + req.body.department + "', updated_on= '" + updatedDate + "'  where customer_id= '" + req.body.customer_id + "'";
+            const query = "UPDATE contact_master SET customer_id= '" + req.body.customer_id + "',first_name= '" + req.body.first_name + "',last_name= '" + req.body.last_name + "' ,mobile_number= '" + req.body.mobile_number + "' ,email_id= '" + req.body.email_id + "', designation= '" + req.body.designation + "', department= '" + req.body.department + "', updated_on= '" + updatedDate + "' , mob_no= '" + req.body.mob_no + "'  where customer_id= '" + req.body.customer_id + "'";
             console.log("query", query);
             const queryresult = await db.executequery(query);
             console.log("queryresult", queryresult);
@@ -1918,7 +1919,7 @@ module.exports.getCustcontactDetails = async (req, res) => {
             passing_id = queryresult[0].customer_id;
 
 
-            const query_id = "SELECT first_name,last_name,mobile_number,email_id,designation,department,function_area FROM contact_master where customer_id=  '" + passing_id + "' order by first_name";
+            const query_id = "SELECT first_name,last_name,mobile_number,email_id,designation,department,function_area,mob_no,stage_id FROM contact_master where customer_id=  '" + passing_id + "' order by first_name";
             const queryresult_id = await db.executequery(query_id);
             console.log("query", query);
 
@@ -1955,7 +1956,7 @@ module.exports.getCustcontactDetails = async (req, res) => {
 
             if (customer_id == 0) {
                 console.log("getting all contact data");
-                const query = "SELECT first_name,last_name,mobile_number,email_id,designation,department,function_area FROM contact_master order by first_name";
+                const query = "SELECT first_name,last_name,mobile_number,email_id,designation,department,function_area,mob_no,stage_id FROM contact_master order by first_name";
                 const queryresult = await db.executequery(query);
                 console.log("query", query);
 
@@ -1989,7 +1990,7 @@ module.exports.getCustcontactDetails = async (req, res) => {
 
             } else {
                 console.log("getting only specific customer contact data");
-                const query = "SELECT first_name,last_name,mobile_number,email_id,designation,department,function_area FROM contact_master where customer_id=  '" + customer_id + "' order by first_name";
+                const query = "SELECT first_name,last_name,mobile_number,email_id,designation,department,function_area,mob_no,stage_id FROM contact_master where customer_id=  '" + customer_id + "' order by first_name";
                 const queryresult = await db.executequery(query);
                 console.log("query", query);
 

+ 32 - 35
controllers/loginController.js

@@ -125,58 +125,55 @@ module.exports.loginUser = async (req, res) => {
 
 }
 
-module.exports.signupuser = async (req, res) => {
-    const validationResp = await validation.signupCheck(req);
-    const createdate = new Date();
+module.exports.changepassword = async (req, res) => {
+    const validationResp = await validation.logindatacheck(req);
+    const createdate = moment(new Date()).format("YYYY-MM-DD HH:mm");
+
     console.log("Before if condition");
     if (validationResp.status) {
 
         console.log("After if condition")
         try {
-            const query = "select login_id, user_id from user_master where login_id= '" + req.body.login_id + "'";
+            const query = "select login_id, user_id from user_master where login_id= '" + req.body.username + "'";
             const queryresult = await db.executequery(query);
             console.log("queryresult", queryresult);
             if (queryresult.length > 0) {
+                console.log("User present in database allow to change password");
+
+                const query = "update user_master SET updated_on='" + createdate + "', password= '" + req.body.password + "' , updated_by= '" + req.body.username + "' where  login_id='" + req.body.username + "'";
+                const queryresult = await db.executequery(query);
+                console.log("queryresult",queryresult)
                 res.send({
-                    message: "User Already Created.",
-                    SingupStatus: "1",
-                    exception: {
-                        errorid: "",
-                        errormessage: "No Errors"
-                    }
+                    status: true,
+                    data: [
+                        {
+                            status: '0',
+                            message: "Password updated suceesfully."
+                        }
+                    ],
+                    errors: " "
 
                 })
+                
             } else {
-                console.log("create new user");
-                const query1 = "INSERT INTO user_master(login_id,customer_id,password,first_name,last_name,email,mobile_number,created_by,created_on,last_login_date)" +
-                    " VALUES(?,?,?,?,?,?,?,?,?,?)";
-                const values = [req.body.login_id, req.body.customer_id, req.body.password, req.body.first_name, req.body.last_name, req.body.email, req.body.mobile_number, req.body.login_id, createdate, createdate]
-                const res1 = await db.executevaluesquery(query1, values);
-                console.log("res1", res1);
-                if (res1) {
-                    const createdtoken = await createToken.createToken(req.body.login_id);
-
-                    res.send({
-                        message: "User Created Successfully ",
-                        SingupStatus: "0",
+                console.log("User not password in datbase");
+                res.send({
+                    status: false,
+                    data: [{
+                        message: "Invaild User",
+                        loginStatus: "1",
+                        logindata: {
+                            user_id: "",
+                            user_name: "",
+                            last_loginDate: ""
+                        },
                         exception: {
                             errorid: "",
                             errormessage: "No Errors"
-                        },
-                        jwttoken: createdtoken
-
-                    })
-                } else {
-                    res.send({
-                        message: "",
-                        createStatus: "1",
-                        exception: {
-                            errorid: "404",
-                            errormessage: "Bad request"
                         }
-                    })
-                }
+                    }]
 
+                })   
             }
 
 

+ 1 - 1
routes/route.js

@@ -9,7 +9,7 @@ const auth = require("../middlewares/authorize");
 router.use(bodyParser.urlencoded({ extended: true }))
 router.use(bodyParser.json());
 
-router.post("/api/signupuser", loginController.signupuser);
+router.post("/api/changepassword", loginController.changepassword);
 router.post("/api/loginuser", loginController.loginUser);
 router.get("/api/getselectionData",auth,dvrController.getselectionData);