Skip to content

Commit

Permalink
new route last
Browse files Browse the repository at this point in the history
  • Loading branch information
Sharjeel007305 committed May 24, 2022
1 parent 383de0c commit cc7dc11
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 2 deletions.
66 changes: 66 additions & 0 deletions backend/controllers/attendance_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
})
}
11 changes: 9 additions & 2 deletions backend/routes/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)

Expand Down

0 comments on commit cc7dc11

Please sign in to comment.