0% found this document useful (0 votes)
21 views

EMS Project

Ems project

Uploaded by

d36796248
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

EMS Project

Ems project

Uploaded by

d36796248
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

Submitted by

-Kasak Anand
Enrolment Number: 133395

Under the guidance of


Dr. Dipti Mathur with QUALIFICATION
DESIGNATION

In partial fulfilment of the requirements


for the award of the degree of
BACHELOR OF COMPUTER APPLICATIONS
DEPARTMENT OF DATA SCIENCE AND COMPUTER ENGINEERING

NIMS INSTITUTE OF ENGINEERING AND TECHNOLOGY


NIMS UNIVERSITY, NH-11C, DELHI - JAIPUR HIGHWAY, SHOBHA
NAGAR,
JAIPUR, RAJASTHAN 303121
April 2024
CERTIFICATE

This is to certify that the project work entitled “EMPLOYEE MANAGEMENT SYSTEM” is a
Bonafide record of work done by KASAK ANAND(133395) submitted in partial fulfilment of
the requirement for the award of the degree of BACHELOR OF COMPUTER APPLICATIONS
of NIMS INSTITUTE OF ENGINEERING AND TECHNOLOGY, NIMS UNIVERSITY under
my supervision.

Date: Signature of the Guide

Place:

Counter Signed by

______________________ ____________________

Department Coordinator HOD

External Viva-voice Conducted on ________________

INTERNAL EXAMINER: _______________________

EXTERNAL EXAMINER: _______________________


DECLARATION

I, KASAK ANAND with Enrolment Number - 133395 do hereby declare that this project
entitled “EMPLOYEE MANAGEMENT SYSTEM” submitted to DATA SCIENCE AND
COMPUTER ENGINEERING DEPARTEMENT in partial fulfilment of the requirement for
the award of the degree BACHELOR OF COMPUTER APPLICATIONS, is a record of
original work done by me during the period of study at NIMS INSTITUTE OF
ENGINEERING AND TECHNOLOGY under the guidance of DR. DIPTI MATHUR,
QUALIFICATION AND DESIGNATION.

Date:

Place:

Signature of the Candidate:


CONTENT

Acknowledgement

1. INTRODUCTION

1.1 Introduction of the Project

1.2 Overview of project

1.3 Objective of project

1.4 Methodology

2. ANALYSIS AND DESIGN

2.1 Functional Requirements

2.2 Non-Functional Requirements:

2.3 Architecture

2.4 Flow chart

3. OVERVIEW OF THE PROGRAMMING LANGUAGE USED

4. IMPLEMENTATION

4.1 Module Descriptions

4.2 Implementation Details

4.3 Creating Functions

4.4 The Main Function

4.5 Code that makes Perform Actions

4.6 Automation to

5. SOURCE CODE

6. OUTPUT GENERATION

7. CONCLUSION

8. BIBLIOGRAPHY
INTRODUCTION

1.1 Introduction of the Project


The Employee Management System (EMS) project aims to address the evolving needs of
modern organizations in efficiently managing their human resources. In today's dynamic
business landscape, organizations face various challenges in HR management, including
disparate systems, manual processes, compliance issues, and the need for real-time data insights.
The EMS project seeks to overcome these challenges by providing a comprehensive, integrated
platform that centralizes all HR functions into one cohesive system.

1.2 Overview of the Project


The Employee Management System is designed to streamline and automate key HR processes,
including recruitment, onboarding, time and attendance tracking, performance management,
training and development, compensation and benefits management, employee self-service,
analytics, and compliance. By consolidating these functions into a single platform, organizations
can eliminate redundant tasks, improve data accuracy, enhance employee engagement, and drive
strategic decision-making.

The project encompasses the development of both front-end and back-end components, including
user interfaces for HR professionals, managers, and employees, as well as databases, APIs, and
integration modules to support seamless interaction with existing systems and applications. The
EMS project leverages modern technologies such as cloud computing, mobile accessibility,
artificial intelligence, and data analytics to deliver a scalable, secure, and user-friendly solution.

1.3 Objective of the Project


The primary objective of the Employee Management System project is to empower organizations
to optimize their HR operations and maximize the potential of their workforce. Specifically, the
project aims to:

 Streamline administrative tasks: By automating routine HR processes such as payroll


processing, leave management, and performance evaluations, the EMS project aims to
reduce the administrative burden on HR professionals and managers, allowing them to
focus on strategic initiatives and employee development.

 Improve decision-making: By providing real-time access to accurate HR data and


analytics, the EMS project aims to enable data-driven decision-making across all levels
of the organization. Managers can track key metrics such as employee performance,
turnover rates, and training outcomes to identify trends, spot opportunities, and address
challenges proactively.
 Enhance employee experience: By offering self-service capabilities, personalized
communication channels, and user-friendly interfaces, the EMS project aims to enhance
the overall employee experience and foster a culture of transparency, collaboration, and
continuous feedback within the organization.

 Ensure compliance: By incorporating robust security features, data encryption, access


controls, and audit trails, the EMS project aims to ensure compliance with regulatory
requirements such as GDPR, HIPAA, and labor laws, protecting sensitive employee
information and mitigating risks associated with data breaches or legal liabilities.

1.4 Methodology
The development of the Employee Management System follows a structured methodology based
on industry best practices and agile principles. The methodology encompasses the following
phases:

1. Requirements gathering: The project team collaborates with stakeholders, including HR


professionals, managers, and IT experts, to define the functional and non-functional
requirements of the EMS. This involves conducting interviews, workshops, surveys, and
analysis of existing processes and systems.

2. System design: Based on the gathered requirements, the project team designs the
architecture, user interfaces, database schema, and integration points of the EMS. This
phase involves creating wireframes, mockups, data models, and technical specifications
to guide the development process.

3. Implementation: The development team builds the front-end and back-end components of
the EMS according to the design specifications. This involves coding, testing, and
integrating various modules and functionalities, as well as incorporating feedback from
stakeholders to ensure alignment with user needs and business goals.

4. Testing: The EMS undergoes rigorous testing to validate its functionality, performance,
security, and usability. This includes unit testing, integration testing, system testing, and
user acceptance testing to identify and fix any defects or issues before deployment.

5. Deployment: Once testing is complete, the EMS is deployed to production environments


following established deployment procedures and protocols. This may involve migration
of data, configuration of settings, and training of end users to ensure a smooth transition
from legacy systems to the new platform.

6. Maintenance and support: After deployment, the EMS undergoes ongoing maintenance,
monitoring, and support to address any issues, updates, or enhancements. This includes
providing technical assistance to users, monitoring system performance, and
implementing patches or upgrades as needed to ensure the reliability, security, and
scalability of the platform.
ANALYSIS AND DESIGN

2.1 Functional Requirements


The Employee Management System (EMS) encompasses a wide range of functional
requirements to support the diverse needs of HR professionals, managers, and employees. These
functional requirements include:

- User authentication and authorization: Users should be able to securely log in to the system
using their credentials and access only the features and data relevant to their roles and
permissions.

- Employee profiles: The system should allow HR professionals to create and maintain detailed
profiles for each employee, including personal information, contact details, employment history,
skills, and performance records.

- Recruitment and on-boarding: The system should support the recruitment process by
allowing HR professionals to post job vacancies, receive applications, schedule interviews, and
make hiring decisions. Additionally, the system should facilitate the onboarding process by
guiding new hires through necessary paperwork, orientation materials, and training modules.

- Time and attendance tracking: The system should enable employees to clock in and out,
request time off, view their work schedules, and track their attendance records. Managers should
be able to review and approve time-off requests, monitor employee attendance, and generate
attendance reports.

- Performance management: The system should facilitate goal setting, performance evaluations,
feedback collection, and performance improvement plans. Managers should be able to conduct
performance reviews, provide feedback to employees, set performance goals, and track progress
over time.

- Training and development: The system should support the planning, delivery, and tracking of
employee training programs, including online courses, workshops, certifications, and skill
assessments. Employees should be able to enroll in training programs, complete training modules,
and view their training history and progress.

- Compensation and benefits management: The system should handle employee compensation,
benefits packages, bonuses, and incentives. HR professionals should be able to manage payroll
processing, salary adjustments, benefit enrollments, and compensation-related documents.

- Employee self-service: The system should empower employees with self-service capabilities
to update their personal information, submit time-off requests, view their pay stubs, access
company policies and procedures, and communicate with HR.

- Analytics and reporting: The system should provide HR professionals and managers with
access to real-time analytics and reports on various HR metrics, such as employee turnover,
performance trends, training effectiveness, and workforce demographics.

2.2 Non-Functional Requirements:


In addition to functional requirements, the Employee Management System must meet various
non-functional requirements to ensure its effectiveness, reliability, security, and usability. These
non-functional requirements include:

- Performance: The system should be able to handle a large volume of users and data without
experiencing slowdowns or performance issues. Response times for common tasks should be
within acceptable limits, even during peak usage periods.

- Scalability: The system should be scalable to accommodate growth in the number of users,
employees, and data volumes over time. It should be able to scale horizontally by adding more
servers or instances to distribute the workload effectively.

- Security: The system should implement robust security measures to protect sensitive employee
data from unauthorized access, manipulation, or disclosure. This includes encryption of data in
transit and at rest, secure user authentication, role-based access control, and audit trails for
tracking user activities.
- Reliability: The system should be highly available and reliable, with minimal downtime or
disruptions. It should include redundancy, failover mechanisms, and disaster recovery plans to
ensure continuity of operations in the event of hardware failures, software bugs, or other issues.

- Usability: The system should be intuitive and easy to use, with a user-friendly interface that
requires minimal training for users to navigate and perform common tasks. It should adhere to
accessibility standards and best practices to accommodate users with disabilities or special needs.

- Compliance: The system should comply with relevant regulatory requirements, industry
standards, and internal policies governing data privacy, security, and confidentiality. This
includes compliance with laws such as GDPR, HIPAA, SOX, and labor regulations governing
working hours, overtime, and leave entitlements.

2.3 Architecture
The Employee Management System follows a modular and scalable architecture, comprising
several layers and components:

- Presentation layer: The user interface layer provides interfaces for HR professionals,
managers, and employees to interact with the system through web browsers, mobile devices, or
desktop applications. This layer includes screens, forms, dashboards, and reports tailored to
different user roles and permissions.

- Application layer: The application logic layer contains business logic, workflows, and rules
governing the behavior of the system. It handles user requests, processes data, orchestrates
interactions between different modules, and enforces security policies and access controls.

- Data access layer: The data access layer provides access to the underlying data stored in
databases, files, or external systems. It includes components for querying, retrieving, updating,
and deleting data, as well as caching mechanisms for optimizing performance.

- Integration layer: The integration layer enables communication and data exchange between
the EMS and other external systems, such as payroll systems, time tracking software, learning
management systems, and third-party APIs. It supports data synchronization, batch processing,
and real-time integration using standard protocols and interfaces.
- Infrastructure layer: The infrastructure layer consists of servers, networks, storage, and other
hardware and software components that support the operation of the EMS. It includes
deployment environments, hosting platforms, monitoring tools, and security mechanisms to
ensure the reliability, scalability, and security of the system.

2.4 Flow chart

Employee Management System

Employee List Mark Attendance Notes Employees Summary Report

Employee
Employee Attendance Add or Delete Employee
Data
Delete Notes Employee Attendance Record

Add
Employee
OVERVIEW OF THE PROGRAMMING
LANGUAGE USED
The Employee Management System (EMS) has been developed using a combination of
technologies to ensure flexibility, scalability, and performance. The primary programming
languages and frameworks used in the development process include React Native, Expo, and the
MERN stack.

1. React Native: React Native is a popular open-source framework developed by Facebook


for building native mobile applications using JavaScript and React. It allows developers
to write code once and deploy it across multiple platforms, including iOS and Android,
while still providing a native user experience. React Native simplifies the development
process by enabling rapid iteration, hot reloading, and access to a vast ecosystem of third-
party libraries and components.

2. Expo: Expo is a set of tools and services built around React Native that streamlines the
development, testing, and deployment of mobile applications. It provides a unified
development environment, including a command-line interface (CLI), a client app for
testing on physical devices, and a set of pre-built UI components and APIs for common
tasks such as navigation, camera access, and push notifications. Expo accelerates the
development process by abstracting away the complexities of native app development
and providing a fast feedback loop for developers.

3. MERN Stack: The MERN stack is a full-stack JavaScript framework consisting of four
key technologies: MongoDB, Express.js, React, and Node.js. It is well-suited for building
modern web applications with real-time capabilities, scalability, and performance. In the
context of the EMS, the MERN stack is used for the back-end development and data
management aspects of the system:

 MongoDB: MongoDB is a NoSQL database that stores data in flexible, JSON-


like documents. It provides a scalable, high-performance solution for managing
large volumes of structured and unstructured data, making it ideal for storing
employee information, performance metrics, and other HR-related data.

 Express.js: Express.js is a lightweight web application framework for Node.js


that simplifies the development of server-side applications. It provides a robust set
of features for handling HTTP requests, routing, middleware, and error handling,
allowing developers to build scalable and maintainable APIs for the EMS.

 Node.js: Node.js is a server-side JavaScript runtime built on Chrome's V8


JavaScript engine. It enables developers to build fast and scalable network
applications using event-driven, non-blocking I/O model. Node.js powers the
back-end of the EMS, handling business logic, data processing, and integration
with external systems.
 React: React is a JavaScript library for building user interfaces, developed by
Facebook. It enables developers to create interactive, component-based UIs using
a declarative and composable approach. In the context of the EMS, React is used
for building the front-end interfaces for HR professionals, managers, and
employees, providing a responsive and intuitive user experience.

By leveraging React Native, Expo, and the MERN stack, the Employee Management System
delivers a powerful, cross-platform solution for managing HR operations, empowering
organizations to streamline processes, improve productivity, and foster employee engagement.
IMPLEMENTATION
4.1 Module Descriptions

The implementation of the Employee Management System (EMS) involves several modules,
each responsible for specific functionalities within the system. These modules include:

 Employee Management Module: Manages employee data, including profiles, contact


information, employment history, skills, and performance records. Provides CRUD
(Create, Read, Update, Delete) operations for managing employee records.

 Time and Attendance Module: Tracks employee attendance, working hours, leave
requests, and overtime. Allows employees to clock in/out, request time off, view work
schedules, and managers to approve time-off requests and generate attendance reports.

 Performance Management Module: Supports goal setting, performance evaluations,


feedback collection, and performance improvement plans. Enables managers to conduct
performance reviews, provide feedback, set goals, and track progress.

4.2 Implementation Details

The Employee Management System is implemented using React Native for the front-end mobile
application, Node.js and Express.js for the back-end API services, MongoDB for data storage,
and Expo for development and deployment.

Front-end Implementation:
 User interfaces are developed using React Native components, including screens, forms,
navigation elements, and UI widgets.

 Redux is used for state management, allowing components to access and update
application state efficiently.

 React Navigation is used for routing and navigation between screens, enabling users to
navigate through different sections of the application seamlessly.

Back-end Implementation:
 API endpoints are implemented using Express.js, providing RESTful services for client-
server communication.

 Mongoose is used as an ODM (Object Data Modeling) library for MongoDB, simplifying
data access and manipulation operations.

 Authentication is implemented using JSON Web Tokens (JWT), ensuring secure access to
protected resources and preventing unauthorized access.
Data Storage:
 MongoDB is used as the database for storing employee data, performance metrics,
training records, and other HR-related information.

 Collections are designed to store structured JSON documents representing employee


profiles, attendance records, performance evaluations, training programs, and
compensation details.

4.3 Creating Functions

In the Employee Management System, functions are created to perform specific actions and
operations within each module. These functions are organized based on their functionality and
are typically implemented as reusable components to promote code modularity and
maintainability. Examples of functions include:

 createUserProfile(): Creates a new employee profile in the database with the provided
information.

 updateUserProfile(): Updates an existing employee profile with the specified changes.

 submitTimeOffRequest(): Submits a time-off request for the employee, including the


requested dates and reason.

 approveTimeOffRequest(): Approves or rejects a time-off request submitted by an


employee, updating the request status accordingly.

 generateAttendanceReport(): Generates a report summarizing employee attendance


records for a specified time period.

4.4 The Main Function

The main function of the Employee Management System is to provide a centralized platform for
managing all HR-related activities within the organization. This includes:

 Providing real-time access to employee data, performance metrics, training programs,


and compensation details.

 Facilitating communication and collaboration between HR professionals, managers, and


employees.

 Supporting data-driven decision-making through analytics, reports, and insights on key


HR metrics.
The main function is implemented through a combination of front-end interfaces, back-end
services, and data storage mechanisms, ensuring seamless integration and interaction between
different system components.

4.5 Code that makes Perform Actions

The Employee Management System contains code that performs various actions and operations
within the system. This includes event handlers, API endpoints, database queries, and business
logic to handle user interactions, process data, and enforce business rules. Examples of code
snippets that perform actions include:

 Handling form submissions to create or update employee profiles.

 Processing time-off requests and updating attendance records accordingly.

 Calculating performance scores based on evaluation criteria and feedback provided by


managers.

 Retrieving training programs and materials based on employee preferences and skill gaps.

4.6 Automation

Automation is implemented within the Employee Management System to streamline repetitive


tasks, improve efficiency, and reduce manual intervention. This includes:

 Scheduled reports and analytics to provide stakeholders with timely insights into HR
metrics and performance trends.

 Integration with third-party systems and services to automate data synchronization, data
imports, and data exports.

 Workflow automation to route approval requests, trigger notifications, and escalate issues
based on predefined rules and conditions.

By leveraging automation, the Employee Management System enhances productivity, accuracy,


and compliance while freeing up resources to focus on strategic initiatives and value-added
activities.
SOURCE CODE
Below is the source code of home page:
import { StyleSheet, Text, View, ScrollView, Pressable } from "react-native";
import React from "react";
import { LinearGradient } from "expo-linear-gradient";
import {
Feather,
Entypo,
Ionicons,
Octicons,
MaterialCommunityIcons,
} from "@expo/vector-icons";
import { useRouter } from "expo-router";

const index = () => {


const router = useRouter()
return (
<ScrollView>
<LinearGradient colors={["#7F7FD5", "#E9E4F0"]} style={{ flex: 1 }}>
<View style={{ padding: 12 }}>
<View
style={{
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between",
}}
>
<Feather name="bar-chart" size={24} color="black" />
<Text style={{ fontSize: 16, fontWeight: "600" }}>
Employee Management System
</Text>
<Entypo name="lock" size={24} color="black" />
</View>

<View
style={{
marginTop: 20,
flexDirection: "row",
alignItems: "center",
gap: 20,
}}
>
<Pressable
onPress={() => router.push("/(home)/employees")}
style={{
backgroundColor: "#D3CCE3",
padding: 12,
borderRadius: 6,
alignItems: "center",
justifyContent: "center",
flex: 1,
}}
>
<View
style={{
width: 50,
height: 50,
borderRadius: 25,
backgroundColor: "white",
alignItems: "center",
justifyContent: "center",
}}
>
<Ionicons name="people-sharp" size={24} color="black" />
</View>
<Text style={{ marginTop: 7, fontWeight: "600" }}>
Employee List
</Text>
</Pressable>
<Pressable
onPress={() => router.push("/(home)/markattendance")}
style={{
backgroundColor: "#D3CCE3",
padding: 12,
borderRadius: 6,
alignItems: "center",
justifyContent: "center",
flex: 1,
}}
>
<View
style={{
width: 50,
height: 50,
borderRadius: 25,
backgroundColor: "white",
alignItems: "center",
justifyContent: "center",
}}
>
<Ionicons name="people-sharp" size={24} color="black" />
</View>
<Text style={{ marginTop: 7, fontWeight: "600" }}>
Mark Attendance
</Text>
</Pressable>
</View>
<View
style={{
marginTop: 20,
backgroundColor: "white",
paddingHorizontal: 10,
paddingVertical: 10,
borderRadius: 7,
}}
>
<Pressable
onPress={() => router.push("/(home)/notes")}
style={{
backgroundColor: "#BE93C5",
borderRadius: 6,
padding: 10,
flexDirection: "row",
alignItems: "center",
marginVertical: 10,
}}
>
<View
style={{
width: 50,
height: 50,
borderRadius: 25,
backgroundColor: "white",
alignItems: "center",
justifyContent: "center",
}}
>
<Ionicons name="newspaper-outline" size={24} color="black" />
</View>
<Text
style={{
marginLeft: 10,
fontSize: 16,
fontWeight: "600",
flex: 1,
}}
>
Notes
</Text>
<View
style={{
width: 35,
height: 35,
borderRadius: 7,
backgroundColor: "white",
alignItems: "center",
justifyContent: "center",
}}
>
<Entypo name="chevron-right" size={24} color="black" />
</View>
</Pressable>
<Pressable
onPress={() => router.push("/(home)/record")}
style={{
backgroundColor: "#BE93C5",
borderRadius: 6,
padding: 10,
flexDirection: "row",
alignItems: "center",
marginVertical: 10,
}}
>
<View
style={{
width: 50,
height: 50,
borderRadius: 25,
backgroundColor: "white",
alignItems: "center",
justifyContent: "center",
}}
>
<Octicons name="report" size={24} color="black" />
</View>
<Text
style={{
marginLeft: 10,
fontSize: 16,
fontWeight: "600",
flex: 1,
}}
>
Employees
</Text>
<View
style={{
width: 35,
height: 35,
borderRadius: 7,
backgroundColor: "white",
alignItems: "center",
justifyContent: "center",
}}
>
<Entypo name="chevron-right" size={24} color="black" />
</View>
</Pressable>
<Pressable
onPress={() => router.push("/(home)/summary")}
style={{
backgroundColor: "#BE93C5",
borderRadius: 6,
padding: 10,
flexDirection: "row",
alignItems: "center",
marginVertical: 10,
}}
>
<View
style={{
width: 50,
height: 50,
borderRadius: 25,
backgroundColor: "white",
alignItems: "center",
justifyContent: "center",
}}
>
<Octicons name="repo-pull" size={24} color="black" />
</View>
<Text
style={{
marginLeft: 10,
fontSize: 16,
fontWeight: "600",
flex: 1,
}}
>
Summary Report
</Text>
<View
style={{
width: 35,
height: 35,
borderRadius: 7,
backgroundColor: "white",
alignItems: "center",
justifyContent: "center",
}}
>
<Entypo name="chevron-right" size={24} color="black" />
</View>
</Pressable>
</View>
<View
style={{
marginTop: 20,
flexDirection: "row",
alignItems: "center",
gap: 12,
}}
>
<View
style={{
backgroundColor: "#f79d00",
borderRadius: 6,
padding: 12,
alignItems: "center",

justifyContent: "center",
flex: 1,
}}
>
<View
style={{
width: 35,
height: 35,
borderRadius: 7,
backgroundColor: "white",
alignItems: "center",
justifyContent: "center",
}}
>
<MaterialCommunityIcons
name="guy-fawkes-mask"
size={24}
color="black"
/>
</View>
<Text style={{ marginTop: 7 }}>Attendance Criteria</Text>
</View>
<View
style={{
backgroundColor: "#ABCABA",
borderRadius: 6,
padding: 12,
alignItems: "center",
justifyContent: "center",
flex: 1,
}}
>
<View
style={{
width: 35,
height: 35,
borderRadius: 7,
backgroundColor: "white",
alignItems: "center",
justifyContent: "center",
}}
>
<Feather name="bar-chart" size={24} color="black" />
</View>
<Text style={{ marginTop: 7 }}>Increased Workflow</Text>
</View>
</View>
<View
style={{
marginTop: 20,
flexDirection: "row",
alignItems: "center",
gap: 12,
}}
>
<View
style={{
backgroundColor: "#D3CCE3",
borderRadius: 6,
padding: 12,
alignItems: "center",

justifyContent: "center",
flex: 1,
}}
>
<View
style={{
width: 35,
height: 35,
borderRadius: 7,
backgroundColor: "white",
alignItems: "center",
justifyContent: "center",
}}
>
<MaterialCommunityIcons
name="guy-fawkes-mask"
size={24}
color="black"
/>
</View>
<Text style={{ marginTop: 7 }}>Cost Savings</Text>
</View>
<View
style={{
backgroundColor: "#bdc3c7",
borderRadius: 6,
padding: 12,
alignItems: "center",
justifyContent: "center",
flex: 1,
}}
>
<View
style={{
width: 35,
height: 35,
borderRadius: 7,
backgroundColor: "white",
alignItems: "center",
justifyContent: "center",
}}
>
<Feather name="bar-chart" size={24} color="black" />
</View>
<Text style={{ marginTop: 7 }}>Employee Performance</Text>
</View>
</View>
</View>
</LinearGradient>
</ScrollView>
);
};

export default index;

const styles = StyleSheet.create({});


Below is the backend code:
const express = require("express");
const bodyParser = require("body-parser");
const mongoose = require("mongoose");
const moment = require("moment");

const app = express();


const port = 8000;
const cors = require("cors");
app.use(cors());

app.use(bodyParser.urlencoded({ extended: false }));


app.use(bodyParser.json());

mongoose
.connect("mongodb+srv://<username>:<password>@cluster0.ko9k8jw.mongodb.net/", {
useNewUrlParser: true,
useUnifiedTopology: true,
})
.then(() => {
console.log("Connected to MongoDB");
})
.catch((error) => {
console.log("Error connecting to MongoDB", error);
});

app.listen(port, () => {
console.log("Server is running on port 8000");
});

const Employee = require("./models/employee");


const Attendance = require("./models/attendance");
const Note = require("./models/note");

// Delete an employee by ID
app.delete("/employees/:id", async (req, res) => {
try {
const employeeId = req.params.id;
// Find and delete the employee by ID
await Employee.findByIdAndDelete(employeeId);
res.status(200).json({ message: "Employee deleted successfully" });
} catch (error) {
console.error("Error deleting employee:", error);
res.status(500).json({ message: "Error deleting employee" });
}
});

//endpoint to register a employee


app.post("/addEmployee", async (req, res) => {
try {
const {
employeeName,
employeeId,
designation,
phoneNumber,
dateOfBirth,
joiningDate,
activeEmployee,
salary,
address,
} = req.body;
//create a new Employee
const newEmployee = new Employee({
employeeName,
employeeId,
designation,
phoneNumber,
dateOfBirth,
joiningDate,
activeEmployee,
salary,
address,
});

await newEmployee.save();

res
.status(201)
.json({ message: "Employee saved successfully", employee: newEmployee });
} catch (error) {
console.log("Error creating employee", error);
res.status(500).json({ message: "Failed to add an employee" });
}
});

//endpoint to fetch all the employees


app.get("/employees", async (req, res) => {
try {
const employees = await Employee.find();
res.status(200).json(employees);
} catch (error) {
res.status(500).json({ message: "Failed to retrieve the employees" });
}
});

app.post("/attendance", async (req, res) => {


try {
const { employeeId, employeeName, date, status } = req.body;

const existingAttendance = await Attendance.findOne({ employeeId, date });

if (existingAttendance) {
existingAttendance.status = status;
await existingAttendance.save();
res.status(200).json(existingAttendance);
} else {
const newAttendance = new Attendance({
employeeId,
employeeName,
date,
status,
});
await newAttendance.save();
res.status(200).json(newAttendance);
}
} catch (error) {
res.status(500).json({ message: "Error submitting attendance" });
}
});

app.get("/attendance", async (req, res) => {


try {
const { date } = req.query;

// Find attendance records for the specified date


const attendanceData = await Attendance.find({ date: date });

res.status(200).json(attendanceData);
} catch (error) {
res.status(500).json({ message: "Error fetching attendance data" });
}
});

app.get("/attendance-report-all-employees", async (req, res) => {


try {
const { month, year } = req.query;

console.log("Query parameters:", month, year);


// Calculate the start and end dates for the selected month and year
const startDate = moment(`${year}-${month}-01`, "YYYY-MM-DD")
.startOf("month")
.toDate();
const endDate = moment(startDate).endOf("month").toDate();

// Aggregate attendance data for all employees and date range


const report = await Attendance.aggregate([
{
$match: {
$expr: {
$and: [
{
$eq: [
{ $month: { $dateFromString: { dateString: "$date" } } },
parseInt(req.query.month),
],
},
{
$eq: [
{ $year: { $dateFromString: { dateString: "$date" } } },
parseInt(req.query.year),
],
},
],
},
},
},
{
$group: {
_id: "$employeeId",
present: {
$sum: {
$cond: { if: { $eq: ["$status", "present"] }, then: 1, else: 0 },
},
},
absent: {
$sum: {
$cond: { if: { $eq: ["$status", "absent"] }, then: 1, else: 0 },
},
},
halfday: {
$sum: {
$cond: { if: { $eq: ["$status", "halfday"] }, then: 1, else: 0 },
},
},
holiday: {
$sum: {
$cond: { if: { $eq: ["$status", "holiday"] }, then: 1, else: 0 },
},
},
},
},
{
$lookup: {
from: "employees", // Name of the employee collection
localField: "_id",
foreignField: "employeeId",
as: "employeeDetails",
},
},
{
$unwind: "$employeeDetails", // Unwind the employeeDetails array
},
{
$project: {
_id: 1,
present: 1,
absent: 1,
halfday: 1,
name: "$employeeDetails.employeeName",
designation:"$employeeDetails.designation",
salary: "$employeeDetails.salary",
employeeId: "$employeeDetails.employeeId",
},
},
]);

res.status(200).json({ report });


} catch (error) {
console.error("Error generating attendance report:", error);
res.status(500).json({ message: "Error generating the report" });
}
});

// GET endpoint to retrieve all notes


app.get('/api/notes', async (req, res) => {
try {
const notes = await Note.find(); // Fetch all notes from the database
res.json(notes); // Return the list of notes as a JSON response
} catch (error) {
console.error('Error fetching notes:', error);
res.status(500).json({ error: 'Internal Server Error' });
}
});

// POST endpoint to add a new note


app.post('/api/notes', async (req, res) => {
try {
const { title, content } = req.body;

// Create a new note instance


const newNote = new Note({
title,
content,
});

// Save the new note to the database


await newNote.save();

// Return the newly created note as a JSON response


res.status(201).json(newNote);
} catch (error) {
console.error('Error adding note:', error);
res.status(500).json({ error: 'Internal Server Error' });
}
});

// DELETE endpoint to delete a note by ID


app.delete('/api/notes/:id', async (req, res) => {
try {
const noteId = req.params.id;

// Find the note by ID and delete it


const deletedNote = await Note.findByIdAndDelete(noteId);

if (!deletedNote) {
return res.status(404).json({ error: 'Note not found' });
}

// Return a success message as a JSON response


res.json({ message: 'Note deleted successfully' });
} catch (error) {
console.error('Error deleting note:', error);
res.status(500).json({ error: 'Internal Server Error' });
}
});

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy