Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
shahbaz-rao committed Apr 28, 2022
2 parents c0d418d + 45b3d95 commit b2ddee6
Show file tree
Hide file tree
Showing 17 changed files with 517 additions and 71 deletions.
6 changes: 3 additions & 3 deletions backend/build/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"files": {
"main.css": "/static/css/main.e6c13ad2.css",
"main.js": "/static/js/main.b9c189ae.js",
"main.js": "/static/js/main.d833e689.js",
"static/js/787.16cf1214.chunk.js": "/static/js/787.16cf1214.chunk.js",
"index.html": "/index.html",
"main.e6c13ad2.css.map": "/static/css/main.e6c13ad2.css.map",
"main.b9c189ae.js.map": "/static/js/main.b9c189ae.js.map",
"main.d833e689.js.map": "/static/js/main.d833e689.js.map",
"787.16cf1214.chunk.js.map": "/static/js/787.16cf1214.chunk.js.map"
},
"entrypoints": [
"static/css/main.e6c13ad2.css",
"static/js/main.b9c189ae.js"
"static/js/main.d833e689.js"
]
}
2 changes: 1 addition & 1 deletion backend/build/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>React App</title><script defer="defer" src="/static/js/main.b9c189ae.js"></script><link href="/static/css/main.e6c13ad2.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>React App</title><script defer="defer" src="/static/js/main.d833e689.js"></script><link href="/static/css/main.e6c13ad2.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
1 change: 0 additions & 1 deletion backend/build/static/js/main.b9c189ae.js.map

This file was deleted.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions backend/build/static/js/main.d833e689.js.map

Large diffs are not rendered by default.

151 changes: 102 additions & 49 deletions backend/controllers/attendance_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ module.exports.holiday = async (req, res) => {
ActionTakenByLoginID: req.user.Login_ID,
};
let TransactionType;
if(req.body.OtherType) TransactionType = req.body.OtherType
if (req.body.OtherType) TransactionType = req.body.OtherType
else TransactionType = req.body.TransactionType;
const Users = await user_repo.find({
StatusCode: 1,
Expand All @@ -206,7 +206,7 @@ module.exports.holiday = async (req, res) => {
ActionDetails: ActionDetails
};
Docs.push(newDocObj)
var newDate = loop.setDate(loop.getDate() + 1);
var newDate = loop.setDate(loop.getDate() + 1);
loop = new Date(newDate);
}

Expand Down Expand Up @@ -274,7 +274,7 @@ module.exports.getUsershowLeave = async (req, res) => {
const usershow = await attendance_repo.find({
UserID: req.user._id,
TransactionType: 'Leave',
Status: { $in: ['Pending', 'Approved','Rejected'] },
Status: { $in: ['Pending', 'Approved', 'Rejected'] },
'Date.Month': new Date().getMonth()

}, false, false)
Expand All @@ -288,25 +288,26 @@ module.exports.getUsershowLeave = async (req, res) => {

module.exports.getlisPendLeave = async (req, res) => {
const user = await user_repo.find({
_id : req.user._id
},true)
_id: req.user._id
}, true)
const approvedRight = user.RightsTitle.find((right) => {
return right === 'Approved Leave'})
if(approvedRight){
console.log(user)
return right === 'Approved Leave'
})
if (approvedRight) {
console.log(user)
const pendList = await attendance_repo.find({
TransactionType: 'Leave',
Status: 'Pending',
}, false)
.then(list => {
res.send({ Status: true, data: list })
})
.catch(error => {
res.send({ Status: false, message: error.message })
})
.then(list => {
res.send({ Status: true, data: list })
})
.catch(error => {
res.send({ Status: false, message: error.message })
})
}
else{
res.send({ Status: true,message:"Not Authorized" })
else {
res.send({ Status: true, message: "Not Authorized" })
}
}

Expand Down Expand Up @@ -411,23 +412,23 @@ module.exports.postExcelReport = async (req, res) => {
const attendance = await attendance_repo.aggregate(aggr);

// Create a new worksheet
const workbook = new excelJs.Workbook();
const workbook = new excelJs.Workbook();
// New Worksheet
const worksheet = workbook.addWorksheet("Attendance_Sheet");
// Path to downlaod excel
const path = __dirname + "/attendance.csv";
//column for data in excel.key must match data key0
worksheet.columns =[
{ header: "S no.", key: "s_no", width: 10},
{ header: "Name", key: "Name", width: 10},
{ header: "Total Hours", key: "TotalHours", width: 10},
{ header: "Total Working Hours", key: "TotalWorkingHours", width: 10},
{ header: "Leave", key: "Leave", width: 10},
worksheet.columns = [
{ header: "S no.", key: "s_no", width: 10 },
{ header: "Name", key: "Name", width: 10 },
{ header: "Total Hours", key: "TotalHours", width: 10 },
{ header: "Total Working Hours", key: "TotalWorkingHours", width: 10 },
{ header: "Leave", key: "Leave", width: 10 },
];

let counter = 1;

attendance.forEach((attend)=>{
attendance.forEach((attend) => {
attend.s_no = counter;
attend.Name = attend.Details[0].UserName;
attend.TotalHours = attend.TotalHours;
Expand All @@ -437,17 +438,17 @@ module.exports.postExcelReport = async (req, res) => {
counter++;
});
worksheet.getRow(1).eachCell((cell) => {
cell.font = {bold : true };
cell.font = { bold: true };
});

try{
try {
const data = await workbook.csv.writeFile(path)
.then(() =>{
const stream = fs.createReadStream(path)
res.download(path)
});
} catch(err) {
res.send({
.then(() => {
const stream = fs.createReadStream(path)
res.download(path)
});
} catch (err) {
res.send({
Status: "error",
message: "Something went wrong",
})
Expand All @@ -458,25 +459,25 @@ module.exports.postExcelReport = async (req, res) => {
module.exports.getreportholiday = (req, res) => {
const aggr = [
{
'$match': {
'Title': 'Holiday'
}
'$match': {
'Title': 'Holiday'
}
}, {
'$group': {
'_id': {
'Date': {
'Day': '$Date.Day',
'Month': '$Date.Month',
'Year': '$Date.Year'
},
'Title': '$Title'
},
'Details': {
'$first': '$TransactionType'
'$group': {
'_id': {
'Date': {
'Day': '$Date.Day',
'Month': '$Date.Month',
'Year': '$Date.Year'
},
'Title': '$Title'
},
'Details': {
'$first': '$TransactionType'
}
}
}
}
];
];
attendance_repo.aggregate(aggr)
.then(holiday => {
console.log(holiday)
Expand All @@ -486,3 +487,55 @@ module.exports.getreportholiday = (req, res) => {
res.send({ Status: false, message: error.message })
})
}


module.exports.GetReportDailyAtt = async (req, res) => {
const agg = [
{
$match: {
'TakenIn': {
'$gte': new Date(req.body.StartDate),
'$lte': new Date(new Date(req.body.EndDate).setHours(23, 59, 59))
}
}
},
{
'$addFields': {
'HOUR': {
'$divide': [
{
'$subtract': [
'$TakenOut', '$TakenIn'
]
}, 3600000
]
}
}
},
{
'$group': {
'_id': '$UserID',
'Details': {
'$push': '$$ROOT'
},
'TotalHours': {
'$sum': '$HOUR'
},
'WorkingHours': {
'$sum': '$WorkingHours'
},

}
}
]

const reportattend = await attendance_repo.aggregate(agg)

.then(daliyattendance => {
res.send({ Status: true, data: daliyattendance })
})
.catch(error => {
res.send({ Status: false, message: error.message })
})
}

1 change: 1 addition & 0 deletions backend/routes/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ routes.put('/approvalLeave/:id',auth.authMiddleware,attendance_controller.approv
routes.put('/rejectedLeave/:id',auth.authMiddleware,attendance_controller.rejectedLeave)
routes.post('/postExcelReport',auth.authMiddleware,attendance_controller.postExcelReport)
routes.get('/getreportholiday',auth.authMiddleware,attendance_controller.getreportholiday)
routes.get('/GetReportDailyAtt',auth.authMiddleware,attendance_controller.GetReportDailyAtt)
routes.get ('/getalltitles', auth.authMiddleware,titlesDictionary.getAllTitles)


Expand Down
11 changes: 5 additions & 6 deletions frontend/src/App.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { useState } from "react";
import SignIn from "./pages/SignIn";
import Dashboard from "./pages/Dashboard";
import { BrowserRouter } from "react-router-dom";
import { BrowserRouter, Route, Routes } from "react-router-dom";
import ResetPassword from "./pages/ResetPassword";



Expand All @@ -13,11 +14,9 @@ function App() {
return (
<>
<BrowserRouter>

{
loggedin ? <Dashboard setLoggedin={setLoggedin} /> : <SignIn setLoggedin={setLoggedin} />
}

{
loggedin ? <Dashboard setLoggedin={setLoggedin} /> : <SignIn setLoggedin={setLoggedin} />
}
</BrowserRouter>
</>
);
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/components/MainListItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ export const mainListItems = (
icon: <AssessmentIcon />,
path: '/holidayRegistration'
},
{
text: 'Daily Attendence',
icon: <AssessmentIcon />,
path: '/dailyattendence'
},
{
text: 'Change Password',
icon: <LockOutlinedIcon />,
Expand Down
1 change: 0 additions & 1 deletion frontend/src/logo.svg

This file was deleted.

3 changes: 3 additions & 0 deletions frontend/src/pages/AdminReport.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,13 @@ export default function AdminReport() {
)
.catch(err =>{
console.log(err, "err")
handleCloseBackdrop();

})
}
else{
SetMessage({ value: "Please Enter correct date", type: "error" })
handleCloseBackdrop();

}

Expand Down
Loading

0 comments on commit b2ddee6

Please sign in to comment.