From cc7dc111625f912a5f3ef1f4bf4ced52ce0be9e8 Mon Sep 17 00:00:00 2001 From: sharjeel khan Date: Tue, 24 May 2022 15:12:21 +0500 Subject: [PATCH] new route last --- backend/controllers/attendance_controller.js | 66 ++++++++++++++++++++ backend/routes/routes.js | 11 +++- 2 files changed, 75 insertions(+), 2 deletions(-) diff --git a/backend/controllers/attendance_controller.js b/backend/controllers/attendance_controller.js index a51e1cc..75a12c8 100644 --- a/backend/controllers/attendance_controller.js +++ b/backend/controllers/attendance_controller.js @@ -785,3 +785,69 @@ module.exports.GetReportDailyAtt = async (req, res) => { }) } +module.exports.GetLastReport = async (req, res) => { + const aggr = [ + { + '$match': { + 'UserID': '6283352fb6cd615101a88806', + '$and': [ + { + '$and': [ + { + 'Date.Day': { + '$gte': startDate.getDate() + } + }, { + 'Date.Day': { + '$lte': endDate.getDate() + } + } + ] + }, { + '$and': [ + { + 'Date.Month': { + '$gte': startDate.getMonth() + } + }, { + 'Date.Month': { + '$lte': endDate.getMonth() + } + } + ] + }, { + '$and': [ + { + 'Date.Year': { + '$gte': startDate.getFullYear() + } + }, { + 'Date.Year': { + '$lte': endDate.getFullYear() + } + } + ] + } + ] + } + }, { + '$addFields': { + 'TotalHours': { + '$sum': '$HOUR' + }, + 'WorkingHours': { + '$sum': '$WorkingHours' + } + } + } + ] + await attendance_repo.aggregate(GetLastReport) + + .then(lastReport => { + console.log(lastReport) + res.send({ Status: true, data: lastReport }) + }) + .catch(error => { + res.send({ Status: false, message: error.message }) + }) +} \ No newline at end of file diff --git a/backend/routes/routes.js b/backend/routes/routes.js index 3263f30..f6e1369 100644 --- a/backend/routes/routes.js +++ b/backend/routes/routes.js @@ -6,15 +6,22 @@ let email_controller = require('../controllers/email_controller'); let titlesDictionary =require('../utils/routes_dictionary'); let auth = require('../services/auth'); - +// Login In // routes.post('/login', controller.login); +//EditUser // routes.post('/user/:id',auth.authMiddleware, controller.editUser); +// Register // routes.post('/register',auth.authMiddleware,controller.register); +// ChangePassword // routes.post('/ChangePassword',auth.authMiddleware,controller.ChangePassword) +// Create & Update MailSetup // routes.post('/UpdateMailSetup',auth.authMiddleware,email_controller.UpdateMailSetup) routes.post('/CreateMailSetup',auth.authMiddleware,email_controller.CreateMailSetup) +routes.get('/GetMailSetup',auth.authMiddleware,email_controller.GetMailSetup) +// Forget & Reset Password // routes.post('/ForgotPassword',controller.ForgotPassword ) routes.post('/ResetPassword',controller.ResetPassword) +// Report // routes.post('/attendance_transaction',auth.authMiddleware,attendance_controller.attendance) routes.post('/getreportattendance',auth.authMiddleware,attendance_controller.report) routes.post('/holiday',auth.authMiddleware,attendance_controller.holiday) @@ -23,11 +30,11 @@ routes.post('/getUsershowLeave',auth.authMiddleware,attendance_controller.getUse routes.post('/getlisPendLeave',auth.authMiddleware,attendance_controller.getlisPendLeave) routes.post('/postExcelReport',auth.authMiddleware,attendance_controller.postExcelReport) routes.post('/GetReportDailyAtt',auth.authMiddleware,attendance_controller.GetReportDailyAtt) -routes.get('/GetMailSetup',auth.authMiddleware,email_controller.GetMailSetup) routes.get('/users', controller.getUsers); routes.get('/gettodayattendance',auth.authMiddleware,attendance_controller.gettodayattendance) routes.get('/getreportholiday',auth.authMiddleware,attendance_controller.getreportholiday) routes.get ('/getalltitles', auth.authMiddleware,titlesDictionary.getAllTitles) +routes.get ('/GetLastReport', auth.authMiddleware,attendance_controller.GetLastReport) routes.put('/rejectedLeave/:id',auth.authMiddleware,attendance_controller.rejectedLeave) routes.put('/approvalLeave/:id',auth.authMiddleware,attendance_controller.approvedLeave)