0% found this document useful (0 votes)
15K views42 pages

1.1 Problem Statement: Laundry Management System

The document provides an introduction to a laundry management system. It discusses the problems with the current manual system, including inefficient tracking of orders and long wait times for customers. It then outlines the hardware and software requirements for the new system, including using SQL, PHP, HTML, CSS, jQuery and XAMPP. Finally, it discusses designing the system using entity relationship diagrams to show relationships between database tables.
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)
15K views42 pages

1.1 Problem Statement: Laundry Management System

The document provides an introduction to a laundry management system. It discusses the problems with the current manual system, including inefficient tracking of orders and long wait times for customers. It then outlines the hardware and software requirements for the new system, including using SQL, PHP, HTML, CSS, jQuery and XAMPP. Finally, it discusses designing the system using entity relationship diagrams to show relationships between database tables.
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/ 42

Laundry Management System

Chapter 1

INTRODUCTION

A database management system (DBMS) refers to the technology for creating and managing
databases. DBMS is a software tool to organize (create, retrieve, update and manage) data in a
database. The main aim of a DBMS is to supply a way to store up and retrieve database
information that is both convenient and efficient. By data, we mean known facts that can be
recorded and that have embedded meaning. Normally people use software such as DBASE IV or
V, Microsoft ACCESS, or EXCEL to store data in the form of a database. Database systems are
meant to handle a large collection of information. Management of data involves both defining
structures for the storage of information and providing mechanisms that can do the manipulation
that stored information. Moreover, the database system must ensure the safety of the information
stored, despite system crashes or attempts at unauthorized access.

1.1 Problem Statement

Presently the laundry shop utilizes a manual framework to record their client’s order information
and other information required for their business i.e today’s laundry business relies more on
manual labor, particularly for manual tagging/labeling and cataloging. Every time the customer
comes to the shop to their clothes for laundry, the staffs’ have to record their information. For
example their name, house address, mobile phone number using the traditional documenting
system. Another issue with the traditional documenting system is, it is hard to track or trace the
specific order. The application of a traditional system generates an extra workload for the
employees of the laundry shop to record, store and retrieve the customer and staff information.
Non-automated records of the customers are not sorted in proper order and it will take a longer
time for the staff to manage these records due to the mixing up of the data in the file. And also the
customers were required to wait for a longer time in front of the shop even during the peak time of
the business. This exhibits the inefficiency of the information system and it will lower the
productivity of the laundry business shop.

1.2 SQL (Structured Query Language)


1
Dept of CS&E, MITE, Moodbidri
Laundry Management System

SQL is used to communicate with databases and it is the standard language for relational database
management systems. SQL statements are used to perform tasks such as creating, reading,
updating, and deleting relational databases and tables. Most of the RDBMS like MySQL, Oracle,
MS Access, Informix, and SQL Server use SQL as their standard database language.

1.3 PHP (Hypertext Pre-processor)

PHP is a widely-used open-source interpreted, object-oriented, scripting language that is


especially suited for web development and can be embedded into HTML. It is used to design
dynamic web applications with MySQL databases. It handles dynamic content, database as well as
session tracking for the website. From a performance standpoint, PHP script is executed much
faster than those scripts which are written in other languages such as ASP and JSP. PHP uses its
own memory, so the server workload and loading time is automatically reduced, which results in
faster processing speed and better performance.

1.4 HTML(Hypertext Markup Language)

HTML is the code that is used to structure the webpage and its contents. HTML is a mark-up
language that helps in creating websites that can be seen in a web browser on a desktop or mobile.
For example, content could be structured within the paragraphs, a list of the bullet points, or using
images or tables. The motive of the web browser is to pursue the HTML document files and
construct those files into perceptible web pages. The elements of the HTML document files build
up websites and it permits images and objects to be implemented and also can be used to create the
forms that can be interactive.

1.5 CSS (Cascading Style Sheet)

Cascading Style Sheet is a stylesheet language used to describe the presentation of a document
written in HTML or XML. CSS describes how the element should be rendered on the screen. CSS
is among the core languages of the open web and is standardized across web browsers according
to W3C specifications. It is used mainly to separate the document text material from document
2
Dept of CS&E, MITE, Moodbidri
Laundry Management System

styling. This upgrades the document text material accessibility, also it gives the overall control and
flexibility in the description of styling characteristics to be able to allow multiple pages to share
their characteristics among themselves and lessen the entanglement and recurrence in the
structural text material.

1.6 JQuery

JQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document
traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use
API that works across a multitude of browsers. JQuery requires much less code, has a wide range
of plugins all over the internet, and is easy to implement for web developers. It works in all
browsers, makes web pages more interactive, simple, and user-friendly.

1.7 XAMPP

XAMPP is a public opensource, cross-platform web server solution stack package developed by
Apache Friends, consisting mainly of Apache HTTP Server, MariaDB database, and interpreters for
the script written in PHP language. It is an uncomplicated, non-heavy weighted Apache distribution
that allows the software builders to build a localized web server for trial and deployment purposes.

3
Dept of CS&E, MITE, Moodbidri
Laundry Management System

Chapter 2

ANALYSIS AND REQUIREMENT SPECIFICATION

2.1 Functional Requirements


These are statements of services the system should provide, how the system should react to
particular inputs and how the system should behave in particular situations. In some cases, the
functional requirements may also explicitly state what the system should not do. The functional
requirements for a system describe what the system should do. These requirements depend on the
type of software being developed, the expected users of the software and the general approach
taken by the organization when writing requirements. When expressed as user requirements, the
requirements are usually described in an abstract way. However, functional system requirements
describe the system function in detail, its inputs and outputs, exceptions, and so on. Functional
requirements for a software system may be expressed in a number of ways. The functional
requirements are broadly classified into 2 categories, they are:
Hardware Requirements

Software Requirements

Hardware requirements

● Processor : Intel i3/i5,1.8GHz machine or above


● Main memory : 4GB RAM or more.
● Hard disk drive : 1TB

Software requirements

● Operating System : Windows 7 and higher


● Front end : HTML
● Back end : NodeJS
● Software : Visual Studio Code

4
Dept of CS&E, MITE, Moodbidri
Laundry Management System

2.1 Non-Functional Requirements


Non-functional requirements are requirements that are not directly concerned with the specific
functions delivered by the system. They may relate to emergent system properties such as
reliability, response time, and store occupancy. Alternatively, they may define constraints on the
system such as the capabilities of I/O devices and the data representations used in system
interfaces. The plan for implementing functional requirements is detailed in the system design.
The plan for implementing non-functional requirements is detailed in the system architecture.
Non-functional requirements are often called qualities of a system. Other terms for non-functional
requirements are "constraints", "quality attributes", "quality goals", "quality of service
requirements" and "non-behavioral requirements". Qualities, that are non-functional requirements,
can be divided into two main categories: Execution qualities, such as security and usability, which
are observable at run time.

5
Dept of CS&E, MITE, Moodbidri
Laundry Management System

Chapter 3
SYSTEM DESIGN

3.1 ER Diagram
An ER diagram shows the relationship among entity sets. In terms of DBMS, an entity is a table or
attribute of a table in the database, so by showing relationships among tables and their attributes,
ER diagram shows the complete logical structure of a database.

6
Dept of CS&E, MITE, Moodbidri
Laundry Management System

3.2 Schema Diagram

A schema diagram is a diagram which contains entities and the attributes that will define that
schema. A schema diagram only shows us the database design. It does not show the actual data of
the database. Schema can be a single table or it can have more than one table which is related.
.

7
Dept of CS&E, MITE, Moodbidri
Laundry Management System

3.3 Block Diagram


A block diagram is a diagram of a system in which the principal parts or functions are represented
by blocks connected by lines that show the relationships of the blocks.

8
Dept of CS&E, MITE, Moodbidri
Laundry Management System

3.4 Flow Chart


A Flowchart is a graphically representation of the process, algorithm or the step-by-step solution
of the problem.

9
Dept of CS&E, MITE, Moodbidri
Laundry Management System

10
Dept of CS&E, MITE, Moodbidri
Laundry Management System

Chapter 4

IMPLEMENTATION

PHP: Hypertext Pre-processor (or simply PHP) is a server-side scripting language designed for
web development, and also used as a general-purpose programming language. PHP code may be
embedded into HTML code, or it can be used in combination with various web template systems,
web content management systems, and web frameworks. PHP code is usually processed by a PHP
interpreter implemented as a module in the web server or as a Common Gateway Interface (CGI)
executable. The web server combines the results of the interpreted and executed PHP code, which
may be any type of data, including images, with the generated web page. PHP code may also be
executed with a command-line interface (CLI) and can be used to implement standalone graphical
applications.
This project uses HTML as front-end tool. Hypertext Mark-up Language (HTML) is the standard
mark-up language for creating web pages and web applications. With Cascading Style Sheets
(CSS) and JavaScript, it forms a triad of cornerstone technologies for the world wide web. Web
browser receive HTML documents from a web server or from local storage and render the
documents into multimedia web pages.HTML describes the structure of a web page semantically
and originally included cues for the appearance of the document.HTML elements are the building
blocks of HTML pages. With HTML constructs, images and other objects such as interactive
forms may be embedded into the rendered page.HTML provides a means to create structured
documents by structural semantics for text such as headings, paragraphs, lists, links, quotes and
other items.HTML elements are delineated by tags, written using angle brackets. Browsers do not
display the HTML tags, but use them to interrupt the content of the page.

4.1 Code Snippet:

<?php
$conn= new mysqli('localhost','root','','laundry_db')or die("Could not connect to
mysql".mysqli_error($con));
?>
Figure 4.1.1 Code Snippet of Connection Module
The above code snippet in Figure 4.1.1 is used for connecting purpose. This is used to connect back end and

11
Dept of CS&E, MITE, Moodbidri
Laundry Management System

front end. If the connection fails then a message occurs saying could not connect to mysql.

function login()
{
extract($_POST);
$qry = $this->db->query("SELECT * FROM users where username = '". $username . "'
and password = '" . md5($password) . "' ");
if ($qry->num_rows > 0) {
foreach ($qry->fetch_array() as $key => $value) {
if ($key != 'passwors' && !is_numeric($key))
$_SESSION['login_' . $key] = $value;
}
return 1;
} else {
return 3;
}
}

Gjh

function logout()
{
session_destroy();
foreach ($_SESSION as $key => $value) {
unset($_SESSION[$key]);
}
header("location:login.php");
}

Ghj
function save_user()
{
extract($_POST);
$data = "name='$name'";
$data .= ",username='$username'";
$data .= ",password='".md5($password)."'";
$data .= ", type = '$type' ";
if (empty($name) || empty($username) || empty($password)) {
return 0;
}
if (empty($id)) {
$qry = $this->db->query("SELECT * FROM users where $username='".$username."'");

12
Dept of CS&E, MITE, Moodbidri
Laundry Management System

if ($qry!=false && $qry->num_rows>0) {


return 2;
}
else {
$temp=$this->db->query("INSERT INTO users set " .$data);
if($temp)
return 1;
}
}
else {
$qry = $this->db->query("SELECT * FROM users where $username='".$username."'");
if ($qry!=false && $qry->num_rows>=1) {
return 2;
}
else {
$temp=$this->db->query("UPDATE users set ".$data." where id = ".$id);
if($temp)
return 1;
}
}
return 2;
}

Yf
function delete_user(){
extract($_POST);
if ($id == $_SESSION['login_id']) {
return 2;
} else {
$delete = $this->db->query("DELETE FROM users where id = " .$id);
}
if ($delete)
return 1;
}

Hhj
function save_category(){
extract($_POST);
$data = " name = '$name' ";
$data .= ", price = '$price' ";
if (empty($id)) {
$save = $this->db->query("INSERT INTO laundry_categories set " . $data);
return 1;
} else {
$save = $this->db->query("UPDATE laundry_categories set " . $data . " where
13
Dept of CS&E, MITE, Moodbidri
Laundry Management System

id=" . $id);
return 2;
}
}
Cdc

function delete_category(){
extract($_POST);
$delete = $this->db->query("DELETE FROM laundry_categories where id = " .$id);
if ($delete)
return 1;
else
return 2;
}

function save_supply(){
extract($_POST);
$data = " name = '$name' ";
if (empty($id)) {
$save = $this->db->query("INSERT INTO supply_list set " . $data);
} else {
$save = $this->db->query("UPDATE supply_list set " . $data . " where id=" .
$id);
}
if ($save)
return 1;
}

D
function delete_supply(){
extract($_POST);
$delete = $this->db->query("DELETE FROM supply_list where id = " . $id);
if ($delete)
return 1;
}

Ughjg

14
Dept of CS&E, MITE, Moodbidri
Laundry Management System

function save_laundry(){
extract($_POST);
$data = " customer_name = '$customer_name' ";
if (isset($status))
$data .= ", status = '$status' ";
if (empty($id)) {
$queue = $this->db->query("SELECT `queue` FROM laundry_list where status != 3
order by id desc limit 1");
$queue = $queue->num_rows > 0 ? $queue->fetch_array()['queue'] + 1 : 1;
$data .= ", queue = '$queue' ";
$data .= ", total_amount = '$tamount' ";
$data .= ", remarks = '$remarks' ";
$save = $this->db->query("INSERT INTO laundry_list set ".$data);
if ($save) {
$id = $this->db->insert_id;
foreach ($weight as $key => $value) {
$items = " laundry_id = '$id' ";
$items .= ", laundry_category_id = '$laundry_category_id[$key]' ";
$items .= ", weight = '$weight[$key]' ";
$items .= ", unit_price = '$unit_price[$key]' ";
$items .= ", amount = '$amount[$key]' ";
$save2 = $this->db->query("INSERT INTO laundry_items set ".$items);
}
return 1;
}
} else {
// $data .= ", queue = '$queue' ";
$data .= ", total_amount = '$tamount' ";
$data .= ", remarks = '$remarks' ";
$save = $this->db->query("UPDATE laundry_list set ".$data." where id=".$id);
if ($save) {
// $this->db->query("DELETE FROM laundry_items where id not in
(".implode(',', $item_id).") ");
$this->db->query("DELETE FROM laundry_items where id in(".implode(',',
$item_id).")");
foreach ($weight as $key => $value) {
$items = " laundry_id = '$id' ";
$items .= ", laundry_category_id = '$laundry_category_id[$key]' ";
$items .= ", weight = '$weight[$key]' ";
$items .= ", unit_price = '$unit_price[$key]' ";
$items .= ", amount = '$amount[$key]' ";
if (empty($item_id[$key]))
$save2 = $this->db->query("INSERT INTO laundry_items set "
.$items);
else
$save2 = $this->db->query("UPDATE laundry_items set " .$items. "
where id=" .$item_id[$key]);
}
return 1;

15
Dept of CS&E, MITE, Moodbidri
Laundry Management System

}
}
}

Fgf
function delete_laundry(){
extract($_POST);
$delete = $this->db->query("DELETE FROM laundry_list where id = " . $id);
if ($delete)
return 1;
}
Ugh

function save_inv(){
extract($_POST);
$invqry = $this->db->query("SELECT * FROM inventory where id = '" . $id . "' ");
$avl = $invqry->fetch_assoc();
$act_qty = $avl['qty'];
$data = " supply_id = '$supply_id' ";
$act_avl = 0;
if ($stock_type == 2) {
if ($avl['available'] < $qty)
return $qty;
else
$act_avl = $avl['available'] - $qty;
}
if ($stock_type == 1) {
$act_avl = $avl['available'] + $qty;
$act_qty += $qty;
}
if ($act_avl <= 0) {
$act_avl = 0;
$stock_type = 2;
} else {
$stock_type = 1;
}
$data .= ", qty = '$act_qty' ";
$data .= ", available = '$act_avl' ";
$data .= ", stock_type = '$stock_type' ";
if (empty($id)) {
$save = $this->db->query("INSERT INTO inventory set " . $data);
} else {
$save = $this->db->query("UPDATE inventory set " . $data . " where id=" . $id);
}
if ($save)
return 1;
}
16
Dept of CS&E, MITE, Moodbidri
Laundry Management System

Cjbdc

function delete_inv(){
extract($_POST);
$delete = $this->db->query("DELETE FROM inventory where id = " . $id);
if ($delete)
return 1;
}
s

17
Dept of CS&E, MITE, Moodbidri
Laundry Management System

router.post('/employerLogin', authAPI, async (req, res) => {


const {
email,
password
} = req.body
connection.query('select * from Employer where email = ?', [email], async (err,
result, fields) => {
if (err) {
console.log(err)
res.sendStatus(500)
} else {
if (result.length>0) {
constisMatch = awaitbcrypt.compare(password, result[0].password)
if (isMatch) {
if (result[0].verified === 0) {
verifyEmail = 'https://jobsearching.sathvikks.com/verify/'
+ awaitgenerateJWT({
email,
"db":"Employer",
"time":newDate()
})
sendWelcomeMail(email, result[0].name, verifyEmail)
returnres.status(406).send({
error:"The account is not verified. Please verify the
account."
})
}
req.session.user = {
"id":result[0].id,
"name":result[0].name,
"email":result[0].email,
"type":"Employer",
"companyId":result[0].companyId
}
res.cookie('user', awaitgenerateJWT(req.session.user), {
maxAge:86400000
})
req.session.loggedIn = true
res.sendStatus(202)
} else {
res.status(406).send({
error:"Email does not match with the password or the email
is not registered"
})
}
} else {
res.status(406).send({
error:"Email does not match with the password or the email is
not registered"
})
}
}
})

})

18
Dept of CS&E, MITE, Moodbidri
Laundry Management System

res.status(406).send({
error:"Email does not match with the password or the email is
not registered"
})
}
}
})

})

Code snipper for Employer login

router.post('/employer/addJob', authAPI, async (req, res) => {


const {
name,
categoryName,
description,
salary,
vacancy,
location,
pincode
} = req.body
connection.query('insert into Jobs (name, categoryName, companyId, employerId,
description, salary, vacancy, location, pincode) values (?,?,?,?,?,?,?,?,?)', [name,
categoryName, req.session.user.companyId, req.session.user.id, description, salary,
vacancy, location, pincode], async (err, result, fields) => {
if (err) {
console.log(err);
res.sendStatus(500)
} else {
res.sendStatus(201)
}
})
})

Code snippet for adding jobs

19
Dept of CS&E, MITE, Moodbidri
Laundry Management System

router.delete('/employer/deleteJob', authAPI, async (req, res) => {


const {
jobId
} = req.body
connection.query('delete from Jobs where id=? and employerId = ?', [jobId,
req.session.user.id], async (err, result, fields) => {
if (err) {
console.log(err)
res.sendStatus(500)
} else {
res.sendStatus(200)
}
})
})

C
ode snippet for deleting the jobs

router.patch('/employer/updateJob', authAPI, async (req, res) => {


const {
id,
name,
categoryName,
description,
salary,
vacancy,
location,
pincode
} = req.body
connection.query('update Jobs set name = ?, categoryName = ?, description = ?,
salary = ?, vacancy = ?, location = ?, pincode = ? where id = ? and employerId =?',
[name, categoryName, description, salary, vacancy, location, pincode, id,
req.session.user.id], async (err, result, fields) => {
if (err) {
console.log(err);
res.sendStatus(500)
} else {
res.sendStatus(200)
}
})
})

Code snippet for updating job information

20
Dept of CS&E, MITE, Moodbidri
Laundry Management System

router.get('/employer/getJobs', authAPI, async (req, res) => {


connection.query('select id, name, categoryName, description, salary, vacancy,
location, pincode from Jobs where employerId = ?', [req.session.user.id],
async(err, result, fields) => {
varjobsList = []
if(err) {
console.log(err)
returnres.sendStatus(500)
}
for(varxofresult) {
jobsList.push(x)
}
res.status(200).send(jobsList)
})
})

Code snippet for fetching all the jobs uploaded by the Employer

router.get('/employer/me', authAPI, async (req, res) => {


connection.query('select e.name as ename, email, phone, c.name as cname,
website, details, address from Employer e, Company c where e.id=c.employer_id and
e.id = ?', [req.session.user.id], async(err, result, fields) => {
if(err) {
console.log(err)
returnres.sendStatus(500)
}
res.status(200).send({
"profile":result[0]
})
})
})

Code snippet for getting the Employer profile details

21
Dept of CS&E, MITE, Moodbidri
Laundry Management System

router.delete('/employer/me', authAPI, async (req, res) => {


connection.query('delete from Employer where id=?', [req.session.user.id],
async(err, result, fields) => {
if(err) {
console.log(err)
returnres.sendStatus(500)
}
try {
req.session.loggedIn = false
req.session.user = undefined
res.clearCookie("user");
} catch (e) {
console.log(e)
}
res.sendStatus(200)
})
})

Code snippet for deleting the Employer’s account

router.post('/seekerLogin', authAPI, async (req, res) => {


const {
email,
password
} = req.body
connection.query('select * from Seekers where email = ?', [email], async
(err, result, fields) => {
if (err) {
console.log(err)
res.sendStatus(500)
} else {
if (result.length > 0) {
const isMatch = await bcrypt.compare(password,
result[0].password)
if (isMatch) {
if (result[0].verified === 0) {
verifyEmail =
'https://jobsearching.sathvikks.com/verify/' + await generateJWT({
email,
"db": "Seekers",
"time": new Date()
})
sendWelcomeMail(email, result[0].name, verifyEmail)
return res.status(406).send({
error: "The account is not verified. Please verify
the account."
})
}
req.session.user = {
"id": result[0].id,
"name": result[0].name,
22
Dept of CS&E, MITE, Moodbidri
Laundry Management System

"email": result[0].email,
"type": "Seekers",
"companyId": result[0].companyId
}
res.cookie('user', await generateJWT(req.session.user), {
maxAge: 86400000
})
req.session.loggedIn = true
res.sendStatus(202)
} else {
res.status(406).send({
error: "Email does not match with the password or the
email is not registered"
})
}
} else {
res.status(406).send({
error: "Email does not match with the password or the
email is not registered"
})
}
}
})

})

Code snippet for Seeker login

router.post('/seekerCreate', authAPI, async (req, res) => {


const {
name,
email,
password,
passwordConfirm,
phone,
age,
pincode,
description,
workCategory,
gender
} = req.body;
let verifyEmail
if (name === undefined || email === undefined || password === undefined ||
phone === undefined || age === undefined) {
return res.status(406).send({
error: "The fields cannot be empty"
})
}
if (age <= 0) return res.status(406).send({
error: "Age cannot be less than or equal to 0"
})
if (!val.isEmail(email)) {
return res.status(406).send({
error: "Please enter a valid email address"
23
Dept of CS&E, MITE, Moodbidri
Laundry Management System

})
}
if (password !== passwordConfirm) {
return res.status(406).send({
error: "Passwords do not match"
})
}
const hashPassword = await bcrypt.hash(password, 8)
connection.query('select * from Seekers where email = ?', [email], async
(err, result, fields) => {
if (err) {
console.log(err)
res.sendStatus(500)
} else {
if (result.length > 0) {
return res.status(406).send({
error: "Email already exists"
})
}
connection.beginTransaction((err) => {
if (err) {
console.log(err)
return res.sendStatus(500)
}
connection.query('insert into Seekers (name, email, password,
age, phone, description, pincode, gender) values (?, ?, ?, ?, ?, ?, ?, ?)',
[name, email, hashPassword, age, phone, description, pincode, gender], async
(err, result, fields) => {
if (err) {
res.sendStatus(500)
console.log(err)
return connection.rollback()
} else {
var sql = ''
workCategory.forEach((item) => {
sql += `insert into Seeker_Work_Category
(seeker_id, field) values (${result.insertId}, '${item}');`
})
connection.query(sql, async (err, result, fields) => {
if (err) {
res.sendStatus(500)
console.log(err)
return connection.rollback()
} else {
connection.commit(async (err) => {
if (err) {
res.sendStatus(500)
console.log(err)
return connection.rollback()
}
verifyEmail =
'https://jobsearching.sathvikks.com/verify/' + await generateJWT({
email,
"db": "Seekers",
"time": new Date()
})
sendWelcomeMail(email, name, verifyEmail)
24
Dept of CS&E, MITE, Moodbidri
Laundry Management System

res.sendStatus(201)
})

}
})
}
})
})
}
})

})

Code snippet for Seeker signup

25
Dept of CS&E, MITE, Moodbidri
Laundry Management System

router.get('/seeker/me', authAPI, async (req, res) => {


connection.query('select id, name, email, phone, gender, age, pincode,
description from Seekers where id = ?', [req.session.user.id], async (err,
result, fields) => {
if (err) {
console.log(err)
return res.sendStatus(500)
}
res.status(200).send({
"profile": result[0],
"type": 'Seekers'
})
})
})

Code snippet for fetching Seeker’s profile

router.get('/seeker/company', authAPI, async (req, res) => {


if (req.session.user.companyId === null || req.session.user.companyId ===
undefined) {
return res.sendStatus(406)
}
connection.query('select name from Company where id = ?',
[req.session.user.companyId], async (err, result, fields) => {
if (err) {
console.log(err)
return res.sendStatus(500)
}
res.status(200).send({
"company": result[0].name
})
})
})

Code snippet for fetching Seekers’s company name

26
Dept of CS&E, MITE, Moodbidri
Laundry Management System

router.post('/seeker/company/ratings', authAPI, async (req, res) => {


if (req.session.user.companyId === null || req.session.user.companyId ===
undefined) {
return res.sendStatus(406)
}
const {
stars,
description
} = req.body
connection.query('insert into Reviews (companyId, reviewerId, stars,
description) values (?,?,?,?)', [req.session.user.companyId,
req.session.user.id, stars, description], async (err, result, fields) => {
if (err) {
console.log(err)
return res.sendStatus(500)
}
res.sendStatus(201)
})
})

Code snippet for adding reviews

router.patch('/seeker/company/ratings', authAPI, async (req, res) => {


if (req.session.user.companyId === null || req.session.user.companyId ===
undefined) {
return res.sendStatus(406)
}
const {
stars,
description
} = req.body
connection.query('update Reviews set stars = ?, description = ? where
companyId = ? and reviewerId = ?', [stars, description,
req.session.user.companyId, req.session.user.id], async (err, result, fields)
=> {
if (err) {
console.log(err)
return res.sendStatus(500)
}
res.sendStatus(201)
})
})

Code snippet for updating the reviews

router.get('/seeker/company/getRating', authAPI, async (req, res) => {


if (req.session.user.companyId === null || req.session.user.companyId ===
undefined) {
return res.sendStatus(406)
}

27
Dept of CS&E, MITE, Moodbidri
Laundry Management System

connection.query('select stars, description from Reviews where companyId =


? and reviewerId = ?', [req.session.user.companyId, req.session.user.id],
async (err, result, fields) => {
if (err) {
console.log(err)
return res.sendStatus(500)
}
if (result.length > 0) {
return res.status(200).send(result[0])
}
res.sendStatus(404)
})
})

Code snippet for fetching the reviews

router.delete('/seeker/me', authAPI, async (req, res) => {


connection.query('delete from Seekers where id=?', [req.session.user.id],
async (err, result, fields) => {
if (err) {
console.log(err)
return res.sendStatus(500)
}
try {
req.session.loggedIn = false
req.session.user = undefined
res.clearCookie("user");
} catch (e) {
console.log(e)
}
res.sendStatus(200)
})
})

Code snippet for deleting Seeker’s account

router.post('/jobSearch/name', authAPI, async (req, res) => {


const {
search
} = req.body
connection.query(`select j.id as id, j.name as jname, categoryName, c.name
as cname, description, salary, vacancy, location, pincode from Jobs j, Company
c where j.companyId = c.id and j.name like ?`, [`%${search}%`], async (err,
result, fields) => {
if (err) {
console.log(err)
return res.sendStatus(500)
28
Dept of CS&E, MITE, Moodbidri
Laundry Management System

}
res.status(200).send(result)
})
})

Code snippet for fetching jobs by name

router.post('/jobSearch/pincode', authAPI, async (req, res) => {


const {
search
} = req.body
connection.query(`select j.id as id, j.name as jname, categoryName, c.name
as cname, description, salary, vacancy, location, pincode from Jobs j, Company
c where j.companyId = c.id and pincode like '?___'`, [search], async (err,
result, fields) => {
if (err) {
console.log(err)
return res.sendStatus(500)
}
res.status(200).send(result)
})
})

Code snippet for fetching jobs by pincode

router.post('/jobSearch/company', authAPI, async (req, res) => {


const {
search
} = req.body
connection.query(`select j.id as id, j.name as jname, categoryName, c.name
as cname, description, salary, vacancy, location, pincode from Jobs j, Company
c where j.companyId = c.id and c.name like ?`, [`%${search}%`], async (err,
result, fields) => {
if (err) {
console.log(err)
return res.sendStatus(500)
}
res.status(200).send(result)
})
})

29
Dept of CS&E, MITE, Moodbidri
Laundry Management System

Code snippet for fetching jobs by company name

router.post('/jobSearch/category', authAPI, async (req, res) => {


const {
search
} = req.body
connection.query('select j.id as id, j.name as jname, categoryName, c.name
as cname, description, salary, vacancy, location, pincode from Jobs j, Company
c where j.companyId = c.id and categoryName = ?', [search], async (err,
result, fields) => {
if (err) {
console.log(err)
return res.sendStatus(500)
}
res.status(200).send(result)
})
})

Code snippet for fetching jobs by category

30
Dept of CS&E, MITE, Moodbidri
Laundry Management System

router.get('/jobSearch/forYou', authAPI, async (req, res) => {


connection.query('select j.id as id, j.name as jname, categoryName, c.name
as cname, description, salary, vacancy, location, pincode from Jobs j, Company
c where j.companyId = c.id and categoryName in (select field from
Seeker_Work_Category where seeker_id = ?)', [req.session.user.id], async (err,
result, fields) => {
if (err) {
console.log(err)
return res.sendStatus(500)
}
res.status(200).send(result)
})
})

Code snippet for fetching jobs by Seeker’s work category

router.get('/jobSearch/', authAPI, async (req, res) => {


connection.query('select j.id as id, j.name as jname, categoryName, c.name
as cname, description, salary, vacancy, location, pincode from Jobs j, Company
c where j.companyId = c.id', async (err, result, fields) => {
if (err) {
console.log(err)
return res.sendStatus(500)
}
res.status(200).send(result)
})
})

Code snippet for fetching all jobs

router.post('/job/apply', authAPI, async (req, res) => {


const {
jobId
} = req.body
connection.query('insert into JobApplications (seekerId, jobId) values (?,
?)', [req.session.user.id, jobId], async (err, result, fields) => {
if (err) {
if (err.code === 'ER_DUP_ENTRY') {
return res.status(406).send({
error: 'You have already applied for this job'
})
}
console.log(err)
return res.sendStatus(500)
}
connection.query('select email, j.name as name from Employer e, Jobs j
where e.id = j.employerId and j.id = ?', [jobId], async (err, result, fields)
=> {
if (err) {
console.log(err)
return res.sendStatus(500)
}
sendNewJobApplicationMail(result[0].email, req.session.user.name,
result[0].name, 'https://jobsearching.sathvikks.com/requests')
res.sendStatus(201)
})
31
Dept of CS&E, MITE, Moodbidri
Laundry Management System

})
})

Code snippet to apply for the jobs

router.get('/job/applications', authAPI, async (req, res) => {


connection.query('select s.name as sname, s.id as sid, j.name as jname,
j.id as jid, j.companyId as cid, s.description, email, phone, gender, age,
s.pincode from Seekers s, Jobs j, JobApplications ja where ja.seekerId = s.id
and ja.jobId = j.id and j.employerId = ?', [req.session.user.id], async (err,
result, fields) => {
if (err) {
console.log(err)
return res.sendStatus(500)
}
res.status(201).send(result)
})
})

Code snippet for fetching all the job applications

router.post('/job/applications/manage/:mode', authAPI, async (req, res) => {


const {
sname,
jname,
email,
jid,
sid,
cid
} = req.body

connection.beginTransaction((err) => {
if (err) {
console.log(err)
return res.sendStatus(500)
}
connection.query('delete from JobApplications where seekerId = ? and
jobId = ?', [sid, jid], async (err, result, fields) => {
if (err) {
console.log(err)
res.sendStatus(500)
return connection.rollback()
}
if (req.params.mode === ":Accept") {
sendJobApplicationAcceptanceStatusMail(email, sname, jname,
'Accepted')
connection.query('update Seekers set companyId = ? where id =
?', [cid, sid], async (err, result, fields) => {
if (err) {
console.log(err)
res.sendStatus(500)
return connection.rollback()
}
connection.commit((err) => {
if (err) {
res.sendStatus(500)
32
Dept of CS&E, MITE, Moodbidri
Laundry Management System

console.log(err)
return connection.rollback()
}
})
})
} else if (req.params.mode === ":Reject") {
sendJobApplicationAcceptanceStatusMail(email, sname, jname,
'Rejected')
}
res.sendStatus(200)
})

})
})

Code snippet for accepting or rejecting the job application

router.get('/verifyEmail/:id', async (req, res) => {


const toVerify = await verifyJWT(req.params.id)
if (toVerify === undefined) {
res.status(406).send({
error: "Invalid link data recieved"
})
} else {
if (new Date() - new Date(toVerify.time) > 900000) {
return res.status(406).send({
error: "The link has expired"
})
}
const sql1 = `select * from ${toVerify.db} where email =
'${toVerify.email}'`
connection.query(sql1, async (err, result, fields) => {
if (err) {
console.log(err)
res.status(500).send({
error: "Internal Server Error"
})
} else {
if (result.length === 0) {
return res.status(406).send({
error: "Invalid email"
})
}
if (result[0].verified == 1) {
return res.status(406).send({
error: "The account has already been verified"
})
} else {
const sql = `update ${toVerify.db} set verified = 1 where
email = '${toVerify.email}'`
connection.query(sql, async (err, result, fields) => {
if (err) {
console.log(err)
res.status(500).send({
error: "Internal Server Error"
})
} else {
33
Dept of CS&E, MITE, Moodbidri
Laundry Management System

res.sendStatus(202)
}
})
}
}
})
}
})

Code snippet for verifying emails post signup

router.post('/forgotPassword/reset/:id', authAPI, async (req, res) => {


const {
password1,
password2,
email,
db
} = req.body
if (password1 !== password2) {
return res.status(406).send({
error: "The passwords do not match"
})
}
const hashPassword = await bcrypt.hash(password1, 8)
const sql = `update ${db} set password = '${hashPassword}' where email =
'${email}'`
connection.query(sql, async (err, result, fields) => {
if (err) {
console.log(err)
return res.sendStatus(500)
} else {
return res.sendStatus(202)
}
})
})

Code snippet for password reset

router.get('/getCompanies', authAPI, async (req, res) => {


var companyData = []
var company = {
name: '',
address: '',
stars: '',
details: '',
web: '',
ratingCount: ''
}
connection.query('select c.name, c.address, c.details, c.website, c.id as
companyId from Company c, Employer e where c.employer_id = e.id and e.verified
= 1', async (err, result, fields) => {
if (err) {
console.log(err)
return res.sendStatus(500)
} else {
34
Dept of CS&E, MITE, Moodbidri
Laundry Management System

for (let i = 0; i < result.length; i++) {


company = {
name: result[i].name,
address: result[i].address,
details: result[i].details,
web: result[i].website
}
const query =
util.promisify(connection.query).bind(connection)
var r
try {
r = await query('select count(*) as count, avg(stars) as
avg from Reviews where companyId = ?', [result[i].companyId])
} catch (e) {
console.log(e)
return res.sendStatus(500)
}
company = {
...company,
stars: r[0].avg || 0,
ratingCount: r[0].count
}

companyData.push(company)
}
res.status(200).send(companyData)
}
})
})

Code snippet for fetching the company details

35
Dept of CS&E, MITE, Moodbidri
Laundry Management System

Chapter 5
TESTING

Software testing is the process of used to identify the correctness, security, completeness and
quality of developed computer software. This includes the process of executing the program or
applications with the intent of finding errors. An individual unit, functions or procedures of
developed project is verified and validated and these units are fit for use.
5.1 Testing process
Best testing process is to test each subsystem separately, as we have done in project. Best done
during implementation. Best done after small sub-steps of the implementation rather than large
chunks. Once each lowest level unit has been tested, units are combined with related units and
retested in combination. This proceeds hierarchically bottom-up until the entire system is
tested as a whole. Typical levels of testing:

● Module- package, abstract data type, class

● Sub-system- collection of related modules, cluster of classes, method-message paths

● Acceptance testing- whole system with real data (involve customer, user, etc)

Alpha testing is acceptance testing with a single client (common for bespoke systems).

5.1.1 Unit testing


Unit testing is the process of testing individual software components unit or modules. Since it
needs the detailed knowledge of the internal program design and code this task is done by the
programmer and not by testers.

5.1.2 Integration Testing


Integration testing is another aspect of testing that is generally done in order to uncover errors
associated with the flow of data across interfaces. The unit-tested modules are grouped
together and tested in small segment, which makes it easier to isolate and correct errors. This
approach is continued until we have integrated all modules to form the system as a whole.
After the completion of each module it has been combined with the remaining module to
ensure that the project is working properly as expected.

5.1.3 System Testing


36
Dept of CS&E, MITE, Moodbidri
Laundry Management System

System testing tests a completely integrated system to verify that it meets its requirements.
After the completion of the entire module they are combined together to test whether the entire
project is working properly.

5.2 Test Cases


A Test Case is a software testing document, which consists of events, action, input, output,
expected result and actual result. Technically a test case includes test description, procedure,
expected result and remarks. Test cases should be based primarily on the software
requirements and developed to verify correct functionality and to establish conditions that
reveal potential errors.

Test cases no Test Case Expected results Status

1 Logging into website Email and password Successful


provided correct

2 Logging into website Email incorrect Unsuccessful

3 Logging into website Password Incorrect Unsuccessful

4 Logging into website Any field left empty Unsuccessful

Table 5.1 Test Case for Login


Table 5.1 represents the test case for login module. It shows both successful and unsuccessful
results for the test cases.

Test cases no Test Case Expected results Status

1 Registration for new user All details provided Successful


correctly

2 Registration for new user Any one field is incorrect Unsuccessful

3 Registration for new user Any field left empty Unsuccessful

Table 5.2 Test Case for Signup

Table 5.2 represents the test case for sign up module. It shows both successful and
unsuccessful results for the test cases.

37
Dept of CS&E, MITE, Moodbidri
Laundry Management System

Chapter 6

SNAPSHOT

Home page

Login Page

38
Dept of CS&E, MITE, Moodbidri
Laundry Management System

Seeker signup page

Employer signup page

39
Dept of CS&E, MITE, Moodbidri
Laundry Management System

Seeker Profile page

Employer Profile page


Chapter 7

CONCLUSION

40
Dept of CS&E, MITE, Moodbidri
Laundry Management System

The introduction of an online platform thus makes it easy for the company to advertise their
company to the world, for employers to add the jobs available in their company and accept the
applications from the seekers, for seekers to find their job of interest.

41
Dept of CS&E, MITE, Moodbidri
Laundry Management System

[1] Fundamentals of database system, Ramez elmarsri Shamkanth b 7th edition,2017,


Pearson.

[2] https://www.w3schools.com/
[3] https://www.geeksforgeeks.org/
[4] https://www.npmjs.com/

42
Dept of CS&E, MITE, Moodbidri

You might also like