Professional Documents
Culture Documents
BY
Divya S
A PROJECT REPORT
Submitted to the
August, 2021
i
Certified that the project report titled ONLINE GROCERY PERSONALIZED SHOPPING
CART WITH LOYALTY POINTS is the bonafide work of Ms. Divya.S who carried out the
work under any my supervision.Certified further that to the best of my knowledge the work
reported herein does not form part of any other project report or dissertation on the basis of which
a degree or award was conferred on an earlier occasion on this or any other candidate.
ii
Certificate of Viva-Voce-Examination
This is to certify that Ms. Divya S (Roll No.: 1925MCS0030; Register No.
: 75719100013) has been subjected to Viva-Voce-Examination on ……………………
(Date) at ................................ (Time) at the Study Centre Centre for Distance Education,
Anna University, Chennai 600 025.
Dr. P. Nirmalkumar
Professor – Deputy Director (M.Sc(CS))
Centre for Distance Education,
Anna University, Chennai - 25
Date:
iii
CHAPTER TITLE PAGE
1 INTRODUCTION 1
1.1 AIM OF PROJECT 1
2 SYSTEM ANALYSIS 3
3 SYSTEM SPECIFICATION 9
3.1 HARDWARE REQUIREMENT 9
4 SYSTEM DESIGN 21
4.1 ARCHITECTURE DIAGRAM 22
5 SYSTEM IMPLEMENTATION 34
5.1 LIST OF MODULES 35
5.2 DESCRIPTION OF MODULES 35
iv
6 TESTING 38
7 APPENDICES 47
7.1 SCREENSHOT 47
8 CONCLUSION 91
9 REFERENCES 93
v
ABSTRACT
Due to advancement in technologies and globalization buying and selling of products over other
boundaries had become very easy. Online selling is a best way of reaching the customers
worldwide. To support selling of our grocery product we are developing a web application which
should allow customer throughout the world to register, view products and buy them. It also
provides a payment gateway through which the customer can make their payment and track their
purchase thought our web application. As we have multiple product and models, our system
provides a virtual showroom to our customer so that they can view the product images,
description and details like color, size, type etc. before purchase the product. It also provides the
separate login to administrate the Online process by the sales team. The functionalities include
history, order status update, Login details, view payment details etc. In addition, available service
windows are presented to the customer as a function of customer selected order and service types
and further, the order picking is assigned in accordance with a picker's preference. When ordering
goods, many shopping systems provide a virtual shopping cart for holding items selected for
purchase. Successive items selected for purchase are placed into the virtual shopping cart until a
customer completes their shopping trip. Once the plan to by above certain amount of purchase
they will get the loyalty point. So that can be used in the next order. The system has purchase
space with the extra booster to save money on their next Oder and also we can grab our customer
back.
vi
ACKNOWLEDGEMENT
I have taken efforts in this project. However, it would not have been possible without the
kind support and help of many individuals and organizations. I would like to extend my
sincere thanks to all of them.
I would like to express my gratitude towards my parents & friends for their kind co-operation
and encouragement which help me in completion of this project.
(Ms. Divya.S)
vii
LIST OF TABLES
viii
LIST OF FIGURES
ix
CHAPTER 1
INTRODUCTION
An online grocery system that permits a customer to submit online orders for
items and/or services from a store that serves online customers. The online shopping system
presents an online display of an order and an associated delivery window for items selected by the
customer. The system accepts the customer's submission of a purchase order for the item in
response to a time of submission. In addition, available service windows are presented to the
customer as a function of customer selected order and service types and further, the order picking
is assigned in accordance with a picker's preference. When ordering goods, shopping systems
provide a virtual shopping cart for holding items selected for purchase. Successive items selected
for purchase are placed into the virtual shopping cart until a customer completes their shopping
trip. Virtual shopping carts may be examined at any time, and their contents can be edited or
deleted at the option of the customer. Once the customer decides to submit a purchase order and if
the customer places order above the certain amount they will get the loyalty points which the user
can use it on their next purchase.
Advantages:
Online grocery system helps is in easy purchase of fresh grocery in online
It saves user time instead of going to the shop they will get the products using the
website.
The can compare the price with the others retailers very easily.
Compare the advertising price and actual price
The system allows to select the product and then can order it and they will get it
delivered.
It gives the customer benefits by giving the loyalty points that can be used on their
next purchase.
Disadvantages:
The customers can not touch and fell of the products when they want to Purchase.
Some time delivery time is so much late.
Security of internet banking password and credit card password
1
1.2 Literature Survey:
Online grocery shopping – “Analyzing the paradigm shift in Consumer buying behavior"
The groceries segment of India is one of the major components of the Indian retail market of
which the groceries holds a whopping share of 60% as food is the basic requirement of all
the people irrespective of their class. Online grocery shopping is one of the mega-trends
which involves sale and purchase of groceries over the internet. The concept though
conceived in the west is gaining lot of popularity in the emerging markets of India. Since the
industry is growing at a tremendous pace it has attracted huge investments by venture
capitalists and angel investors. The market has seen lot of emerging players of which Big
Basket leads from the front. These startups have been very successful because they currently
are present in different cities and commanding leading sales. Although online grocery
shopping is yet to catch up with the residents of many cities, yet all these e-commerce
companies have started operating in many metro cities with an aim to change the way people
do their grocery, veggie and staples shopping. Penetration of internet and the rise in the
public's demand for convenience shopping among the population.
Since online grocery stores have potential to grow, retailers basically can use different
strategies to penetrate different markets and market segments. One of the strategies is
providing wide range of product assortments (Ramus, K. and Nielsen, N. A., 2005). Online
store creates the value to their customers by offering customers to search and browse a
specialized assortment or customised products (Anckar, et al., 2002). Online store easily
becomes a specialty store to offer specific products and their target audience classified
based on market segmentation and individual demands (Anckar, et al., 2002) .
Perceived order accessibility involves consumer‟s perception on the easiness to order the
products via online grocer‟s sites (Raijas, A., 2002). In this case, online grocers have to
find ways to solve the navigation problem. As mentioned by Ring, L. J. and Tigert, D. J.
(2001) the reducing number of online shoppers to purchase via online is due to the layout,
design and navigation of the online grocers‟ websites. Online groceries have to equip with
fast, flexible, convenience and easy-to-use-item search system where customers can easily
search what they want to buy (Ogawara. S. et al., 2003).
According to Duffy, G. and Dale, B. G. (2002), order fulfillment is one of the important
key success factors when running online business to end users. Based on the study of
2
understanding shopper‟s expectation on internet retailing, the most important and
significant factor of shopper‟s expectation on online groceries is “time to place an order”
(Wilson-Jeanselme, M. and Reynolds, J., 2006). In other words, online grocers have to
ensure that the speed of the webpage when placing an order via online (Wilson-Jeanselme,
M. and Reynolds, J., 2006).
Besides that, “delivery time” also another important attribute because the increase and
decrease of the sales depends on the duration of delivery (Wilson Jeanselme, M. and
Reynolds, J., 2006). The unique selling point of online busiess is superior delivery system
(Ogawara. S. et al., 2003). So, the delivery should be flexible and fast to fulfill different
kind of customers and increase the operational efficiency (Ogawara. S. et al., 2003).
3
SYSTEM ANALYSIS
4
CHAPTER 2
SYSTEM ANALYSIS
2. ANALYSIS OVERVIEW
System analysis is used in every field where something is developed. It is a
process of identifying our project goals and purposes and to create the systems and
procedures that will achieve them in an efficient way.
The system analysis and designing are two main process before developing
the project because if these two step go wrong then the entire project may go wrong
because wrong design leads us to the wrong product or system development.
2.1 DISADVANTAGE
1. To starting new showroom company need to invest a huge amount
2. offline retail sales limits the number of customer because they are accessible
at that particular geographic region
ADVANTAGES
1. Our market expands from local to global space so the number of customer get
increases
2. Very less cost of implementation when compare to starting a retail showroom
3. Customer Based Recommendation help improve the sales and customer
experience
5
2.3 FEASIBILITY STUDY
Preliminary investigation examine project feasibility, the likelihood the
system will be useful to the organization. The main objective of the feasibility study
is to test the Technical, Operational and Economical feasibility for adding new
modules and debugging old running system. All system is feasible if they are
unlimited resources and infinite time. There are aspects in the feasibility study
portion of the preliminary investigation:
Technical Feasibility
Operation Feasibility
Economical Feasibility
TECHNICAL FEASIBILITY
The technical issue usually raised during the feasibility stage of the
investigation includes the following:
Does the necessary technology exist to do what is suggested?
Do the proposed equipment's have the technical capacity to hold the data
required to use the new system?
Will the proposed system provide adequate response to inquiries, regardless
of the number or location of users?
Can the system be upgraded if developed?
Are there technical guarantees of accuracy, reliability, ease of access and data
security?
Earlier no system existed to cater to the needs of „Secure Infrastructure
Implementation System‟. The current system developed is technically feasible. It is
a browser based user interface for audit workflow. Thus it provides an easy access
to the users. The database‟s purpose is to create, establish and maintain a workflow
among various entities in order to facilitate all concerned users in their various
capacities or roles. Permission to the users would be granted based on the roles
specified. Therefore, it provides the technical guarantee of accuracy, reliability and
security. The software and hard requirements for the development of this project are
not many and are already available or are available as free as open source. The
work for the project is done with the current equipment and existing software
technology. Necessary bandwidth exists for providing a fast feedback to the users
irrespective of the number of users using the system.
OPERATIONAL FEASIBILITY
The analyst considers the extent the proposed system will fulfill his
departments. That is whether the proposed system covers all aspects of the working
6
system and whether it has considerable improvements. We have found that the
proposed “Secure file transaction” will certainly have considerable improvements
over the existing system.
ECONOMIC FEASIBILITY
The proposed system is economically feasible because the cost involved in
purchasing the hardware and the software are within approachable. Working in this
system need not required a highly qualified professional. The operating-
environment costs are marginal. The less time involved also helped in its
economical feasibility.
7
SYSTEM SPECIFICATION
8
CHAPTER 3
SYSTEM SPECIFICATION
3. REQUIREMENT REQUIREMENT
System requirement explains or describes the requirement of developing the
projects. The requirement is divides into two categories, first is hardware
requirements and configuration and second software requirements and
configuration. This is a pre-development process which is needed to be verified
before staring the project because if they doesn‟t match then the project outcomes
may have issues or the development process may be delay and interpreted in
between.
Web Server: PHP will work with virtually all Web Server software,
including Microsoft's Internet Information Server (IIS) but then most often
used is freely available Apache Server. Download Apache for free here −
https://httpd.apache.org/download.cgi
Database:PHP will work with virtually all database software, including
Oracle and Sybase but most commonly used is freely available MySQL
database. Download MySQL for free here −
https://www.mysql.com/downloads/
PHP Parser: In order to process PHP script instructions a parser must be
installed to generate HTML output that can be sent to the Web Browser. This
tutorial will guide you how to install PHP parser on your computer.
11
It can be installed on all operating systems like Linux, Windows, Unix,
FreeBSD, Solaris, Mac OS X etc.
It is a powerful, flexible, HTTP/1.1 compliant web server.
This server is highly configurable and extensible with third party modules.
It provides complete source code and comes with an unrestricted license.
Apache supports some of the capabilities like CGI (Common Gateway
Interface) and SSI (Server Side Includes), URL redirection, loading modules
support, user authentication, proxy caching abilities etc.
The most common operation in SQL is the query, which is performed with
the declarative SELECT statement. SELECT retrieves data from one or more tables,
or expressions. Standard SELECT statements have no persistent effects on the
database. Some non-standard implementations of SELECT can have persistent
effects, such as the SELECT INTO syntax that exists in some databases. Queries
allow the user to describe desired data, leaving the database management system
12
(DBMS) responsible for planning, optimizing, and performing the physical
operations necessary to produce that result as it chooses. A query includes a list of
columns to be included in the final result immediately following the SELECT
keyword. An asterisk ("*") can also be used to specify that the query should return
all columns of the queried tables. SELECT is the most complex statement in SQL,
with optional keywords and clauses that include:
The FROM clause which indicates the table(s) from which data is to be
retrieved. The FROM clause can include optional JOIN sub clauses to specify the
rules for joining tables. The WHERE clause includes a comparison predicate, which
restricts the rows returned by the query. The WHERE clause eliminates all rows
from the result set for which the comparison predicate does not evaluate to True.
The GROUP BY clause is used to project rows having common values
into a smaller set of rows. GROUP BY is often used in conjunction with SQL
aggregation functions or to eliminate duplicate rows from a result set. The WHERE
clause is applied before the GROUP BY clause. The HAVING clause includes a
predicate used to filter rows resulting from the GROUP BY clause. Because it acts
on the results of the GROUP BY clause, aggregation functions can be used in the
HAVING clause predicate.
The ORDER BY clause identifies which columns are used to sort the
resulting data, and in which direction they should be sorted (options are ascending
or descending). Without an ORDER BY clause, the order of rows returned by an
SQL query is undefined. Microsoft SQL Server 2000 automatically tunes many of
the server configuration options, therefore requiring little, if any, tuning by a system
administrator. Although these configuration options can be modified by the system
administrator, it is generally recommended that these options be left at their default
values, allowing SQL Server to automatically tune itself based on run-time
conditions.
An index in SQL Server assists the database engine with locating records,
just like an index in a book helps you locate information quickly. Without indexes,
a query causes SQL Server to search all records in a table (table scan) in order to
13
find matches. A database index contains one or more column values from a table
(called the index key) and pointers to the corresponding table records. When you
perform a query using the index key, the Query Optimizer will likely use an index
to locate the records that match the query.
A B-tree is analogous to an upside-down tree with the root of the tree at the
top, the leaf levels at the bottom, and intermediate levels in between. Each object in
the tree structure is a group of sorted index keys called an index page. A B-tree
facilitates fast and consistent query performance by carefully balancing the width
and depth of the tree as the index grows. Sorting the index on the index key also
improves query performance. All search requests begin at the root of a B-tree and
then move through the tree to the appropriate leaf level. The number of table
records and the size of the index key affect the width and depth of the tree. Index
key size is called the key width. A table that has many records and a large index key
width creates a deep and wide B-tree. The smaller the tree, the more quickly a
search result is returned.
SQL Server Tables
SQL Server stores records relating to each other in a table. Different tables
are created for the various groups of information. Related tables are grouped
together to form a database.
Primary Key
Every table in SQL Server has a field or a combination of fields that uniquely
identifies each record in the table. The Unique identifier is called the Primary Key,
or simply the Key. The primary key provides the means to distinguish one record
from all other in a table. It allows the user and the database system to identify,
locate and refer to one particular record in the database.
Relational Database
Sometimes all the information of interest to a business operation can be
stored in one table. SQL Server makes it very easy to link the data in multiple
tables. Matching an employee to the department in which they work is one
example. This is what makes SQL Server a relational database management
system, or RDBMS. It stores data in two or more tables and enables you to define
relationships between the table and enables you to define relationships between the
tables.
Foreign Key
When a field is one table matches the primary key of another field is referred
to as a foreign key. A foreign key is a field or a group of fields in one table whose
values match those of the primary key of another table.
Referential Integrity
14
Not only does SQL Server allow you to link multiple tables, it also maintains
consistency between them. Ensuring that the data among related tables is correctly
matched is referred to as maintaining referential integrity.
Data Abstraction
A major purpose of a database system is to provide users with an abstract
view of the data. This system hides certain details of how the data is stored and
maintained. Data abstraction is divided into three levels. Physical level: This is the
lowest level of abstraction at which one describes how the data are actually stored.
Conceptual Level: At this level of database abstraction all the attributed and what
data are actually stored is described and entries and relationship among them. View
level: This is the highest level of abstraction at which one describes only part of the
database.
Advantages Of RDBMS
Redundancy can be avoided
Inconsistency can be eliminated
Data can be Shared
Standards can be enforced
Security restrictions can be applied
Integrity can be maintained
Conflicting requirements can be balanced
Data independence can be achieved.
Disadvantages Of DBMS
A significant disadvantage of the DBMS system is cost. In addition to the
cost of purchasing of developing the software, the hardware has to be upgraded to
allow for the extensive programs and the workspace required for their execution
and storage. While centralization reduces duplication, the lack of duplication
requires that the database be adequately backed up so that in case of failure the data
can be recovered.
MySQL Server is a truly portable, distributed, and open DBMS that delivers
unmatched performance, continuous operation and support for every database. SQL
15
Server RDBMS is high performance fault tolerant DBMS which is specially
designed for online transactions processing and for handling large database
application. MySQL SERVER with transactions processing option offers two
features which contribute to very high level of transaction processing throughput,
which are the row level lock manager
16
SYSTEM DESIGN
17
CHAPTER 4
SYSTEM DESIGN
4. SYSTEM DESIGN
System design is process of software development life cycle where the
project is defined in diagrammatic way or picture representation so that the process
and the ideology of the project can be properly understood by the developer
visually.
18
Fig:4.2 System Usecase
USECASE COMPONENTS
Actor and usecase are the main components of the usecase diagram which are used
to explain the access of function for a particular participant in an application
19
The functionalities of the project are represented using an ellipse with a label inside
them which mentions the name of the functionality. The figure 4.2.2 is a how the
usecase will look like.
4.3 ER DIAGRAM
Relation database contains a collection table(entity) and relationship between
table(entity) them self. The Design of database mostly relies on tables and
relationship. For proper understanding of the structure we make use of entity
relationship diagram (in short known as ER diagram).
20
Fig:4.3 ER Diagram
ER COMPONENTS
ER diagram uses the ellipse, diamond, arrows and rectangle to represent the
database structure used in the project. The arrows are many used to represent the
connection or relationship between the other components
Relationships between the entities are represented by diamond-shaped box. All the
entities (rectangles) participating in a relationship, are connected to it by a line. The
21
type of relationship is mentioned at the sides of the diamond shape symbol as show
in the figure
22
Fig: Object Component
The rectangular box is used to represent the objects used in the project and a label
given inside the rectangle to identify the object. The messages flow between the
objects for which a straight line is drawn below the rectangle.
An arrow as shown in the figure Message Flow Component will be used to mention
the message flow between the objects the label below the arrow represent the
message. The point of the arrow represent the direction of the message flow and the
sequence of the arrows used in the diagram represent the sequence of the message
flow.
23
Fig:4.5 Activity Diagram
The initial node is the starting point of an activity represented by an empty circle or
a filled circle as in figure Start and final(end) Symbol. An activity can have more
than one initial node; in this case several flows start at the beginning of an activity.
24
It is also possible that an activity has no initial node, but is initiated by an event
(action: accepting an event).
The activity final node a circle with a dot are show in figure 4.4.1 indicates that an
activity is completed. An activity diagram can have more than one exit in the form
of activity final nodes: If several parallel flows are present within an activity, all
flows are stopped at the time the activity final node is reached.
Cities Table
25
Product
Sales
26
SYSTEM IMPLEMENTATION
27
CHAPTER 5
IMPLEMENTATION
5. SYSTEM IMPLEMENTATION
In this chapter the main implementation of the projects is explained in detail
part by part in the form of modules. The implementation is based on the project
design as already mentioned in the system design chapter. The developer always
need to compare and verify the system design information for developing the
correct and proper implementation of the project.
Register Users
In order to buy products in our E-Commerce website customers need to
register their details online
On successful registration of customer our application create an account for
the users
This account will be accessible on login using the username and password
and in this account customer‟s all transactions will be stored
List Products
This module fetches product details from the database that we stored using
the add product module
Product details like name, category and cost will be shown to the customer
along with their images
28
When product is clicked then the complete details of the product will be
listed to the customers
Cart Management
Cart is a temporary database which is used to store the product desired by the
customers before completion of the sale
When a customer clicks on add to cart the product will be added to this
temporary database
Customer can view them on clicking show my cart option in our ecommerce
website
They can also remove the product which they don't like and update the cart
Place Order
This module is used by the customer to place an order for the list of product
along with the quantity
After review the product in the cart, customer need to click the place order
button which will redirect them to payment process
Once the payment process get completed the order will be place by the
system to the administrator
Shipping Management
After completing the purchase the customer‟s order the undergoes multiple
process which has to be shown to the customers
Our application provides access to administrator to update the status of the
taken order
When administrator update the status the changes are instantly shown to the
customer in their my orders page so that they can track the order
29
SYSTEM TESTING
30
CHAPTER 6
TESTING
31
6.2.2 SYSTEM TESTING
System Testing (ST) is a black box testing technique performed to evaluate
the complete system the system's compliance against specified requirements. In
System testing, the functionalities of the system are tested from an end-to-end
perspective.
System Testing is usually carried out by a team that is independent of the
development team in order to measure the quality of the system unbiased. It
includes both functional and Non-Functional testing.
32
The above diagram explains the different types of testing process carried out during
the system testing process. For a project to success the system testing it has to pass
all the above testing process
34
User acceptance testing is a testing methodology where the clients/end users
involved in testing the product to validate the product against their requirements. It
is performed at client location at developer's site.
For industry such as medicine or aviation industry, contract and regulatory
compliance testing and operational acceptance testing is also carried out as part of
user acceptance testing. UAT is context dependent and the UAT plans are prepared
based on the requirements and NOT mandatory to execute all kinds of user
acceptance tests and even coordinated and contributed by testing team.
The following diagram explains the fitment of user acceptance testing in the
software development life cycle:
The acceptance test cases are executed against the test data or using an acceptance
test script and then the results are compared with the expected ones. Acceptance
criteria are defined on the basis of the following attributes
Functional Correctness and Completeness
Data Integrity
Data Conversion
Usability
Performance
Timeliness
Confidentiality and Availability
Install ability and Upgradability
Scalability
Documentation
36
CHAPTER 7
APPENDICE
7.1 SCREENSHOT
Home
View product
37
Product Category
Product Details
Product Recommendation
38
Registration
Login
39
Login with Validation
Cart
40
Payment
Payment Confirmation
41
Orders
Order Details
Admin
42
Add Category
View Category
43
Add Product
View Product
44
Registered Users
View order
45
User Details
Header
<?php if(isset($_SESSION['email'])){?>
<a href="cart.php">Cart</a>
<a href="my_order.php">My Orders</a>
<a href="logout.php">Logout</a>
46
<?php } else { ?>
<a href="register.php">Register</a>
<a href="login.php">Login</a>
<?php } ?>
</div>
?>
</div>
<?php include_once('footer.php'); ?>
</div>
</div><!-- Container Ends here -->
</body>
</html>
dtat Functions
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "ecommerce_db";
$connection = "mysql:host=$servername;dbname=$dbname";
function add_category($data)
{
$result['status'] ="failed";
$result['message'] ="No Updation";
global $connection;
global $username;
47
global $password;
try
{
$conn = new PDO($connection, $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("insert into pro_category (category_name) values (:catname)");
$stmt->bindParam(':catname', $data["category_name"]);
//$stmt->beginTransaction();
$stmt->execute();
//$last_id = $stmt->lastInsertId();
//$stmt->commit();
$result['status'] = 'success';
$result['message'] ="Category Created Successfully";
}
catch(PDOException $e)
{
//$stmt->rollback();
$result['status'] = 'error';
$result['message'] = $e->getMessage();
}
$conn = null;
return $result;
}
function view_category()
{
global $connection;
global $username;
global $password;
$result['status'] = "failed";
$result['data'] =array();
try
{
$conn = new PDO($connection, $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql ="select * from pro_category";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result['data'] = $stmt->fetchAll(PDO::FETCH_ASSOC);
$result['status']='success';
}
catch(PDOException $e)
{
$result['status'] = "Error: " . $e->getMessage();
}
$conn = null;
return $result ;
}
function option_category()
48
{
global $connection;
global $username;
global $password;
$result =array();
$cat_status = 1;
$options ="";
try
{
$conn = new PDO($connection, $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("select * from pro_category");
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach($result as $key=>$row)
{
$options .="<option
value='".$row['category_name']."'>".$row['category_name']."</option>";
}
}
catch(PDOException $e)
{
$result['status'] = "Error: " . $e->getMessage();
}
$conn = null;
return $options ;
}
function get_category()
{
global $connection;
global $username;
global $password;
$result =array();
$cat_status = 1;
try
{
$conn = new PDO($connection, $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("select * from pro_category");
$stmt->execute();
$result['data'] = $stmt->fetchAll(PDO::FETCH_ASSOC);
$result['status'] = 'success';
}
catch(PDOException $e)
{
$result['status'] = "Error: " . $e->getMessage();
}
$conn = null;
49
return $result ;
}
function view_product()
{
global $connection;
global $username;
global $password;
$result['status'] = "failed";
$result['data'] =array();
try
{
$conn = new PDO($connection, $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql ="select id,pro_name,pro_cat,pro_cost,pro_desc,pro_image,pro_active from
product_table where pro_active=1";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result['data'] = $stmt->fetchAll(PDO::FETCH_ASSOC);
$result['status']='success';
}
catch(PDOException $e)
{
$result['status'] = "Error: " . $e->getMessage();
}
$conn = null;
return $result ;
}
function view_product_cat($cat='indian')
{
global $connection;
global $username;
global $password;
$result['status'] = "failed";
$result['data'] =array();
try
{
$conn = new PDO($connection, $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql ="select id,pro_name,pro_cat,pro_cost,pro_desc,pro_image,pro_active from
product_table where pro_active=1 and pro_cat='".$cat."'";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result['data'] = $stmt->fetchAll(PDO::FETCH_ASSOC);
$result['status']='success';
}
catch(PDOException $e)
{
50
$result['status'] = "Error: " . $e->getMessage();
}
$conn = null;
return $result ;
}
function view_product_id($id='0')
{
global $connection;
global $username;
global $password;
$result['status'] = "failed";
$result['data'] =array();
try
{
$conn = new PDO($connection, $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql ="select * from product_table where pro_active=1 and id=".$id;
$stmt = $conn->prepare($sql);
$stmt->execute();
$result['data'] = $stmt->fetchAll(PDO::FETCH_ASSOC);
$result['status']='success';
}
catch(PDOException $e)
{
$result['status'] = "Error: " . $e->getMessage();
}
$conn = null;
return $result ;
}
function option_product()
{
global $connection;
global $username;
global $password;
$result =array();
$options ="";
try
{
$conn = new PDO($connection, $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("select * from product_table");
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach($result as $key=>$row)
{
$options .="<option value='".$row['id']."'>".$row['pro_name']."</option>";
}
}
catch(PDOException $e)
51
{
$result['status'] = "Error: " . $e->getMessage();
}
$conn = null;
return $options ;
}
function get_product()
{
global $connection;
global $username;
global $password;
$result =array();
$allproduct=array();
try
{
$conn = new PDO($connection, $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("select * from product_table");
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach($result as $key=>$row)
{
$allproduct[$row['id']] = $row['pro_name'];
}
}
catch(PDOException $e)
{
$result['status'] = "Error: " . $e->getMessage();
}
$conn = null;
return $allproduct;
}
function get_users()
{
global $connection;
global $username;
global $password;
$result =array();
$users=array();
try
{
$conn = new PDO($connection, $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("select * from user_table");
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach($result as $key=>$row)
52
{
$users[$row['email_id']] = $row['user_name'].' ('.$row['mobile_number'].'), '.$row['city'] ;
}
}
catch(PDOException $e)
{
$result['status'] = "Error: " . $e->getMessage();
}
$conn = null;
return $users;
}
function view_orders($email='asasd')
{
global $connection;
global $username;
global $password;
$result['status'] = "failed";
$result['data'] =array();
try
{
$conn = new PDO($connection, $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql ="select id,user_id,order_time,pro_count,pro_total, pro_status from order_master where
user_id='".$email."' order by pro_status,id desc";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result['data'] = $stmt->fetchAll(PDO::FETCH_ASSOC);
$result['status']='success';
}
catch(PDOException $e)
{
$result['status'] = "Error: " . $e->getMessage();
}
$conn = null;
return $result ;
}
function orders_status($data)
{
$result['status'] ="failed";
$result['message'] ="No Updation";
global $connection;
global $username;
global $password;
$val = 0;
if($data['status']==0){
$val = 1;
}
53
try
{
$conn = new PDO($connection, $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("update order_master set pro_status=:active where id=:id");
$stmt->bindParam(':id', $data["id"]);
$stmt->bindParam(':active', $data["status"]);
$stmt->execute();
$result['status'] = 'success';
$result['message'] = 'Order Status Changed Succesfully !';
}
catch(PDOException $e)
{
$result['status'] = 'error';
$result['message'] = $e->getMessage();
}
$conn = null;
return $result;
}
function remove_orders($data)
{
$result['status'] ="failed";
$result['message'] ="No Updation";
global $connection;
global $username;
global $password;
try
{
$conn = new PDO($connection, $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("delete from order_master where id=:id");
$stmt->bindParam(':id', $data["id"]);
$stmt->execute();
$result['status'] = 'success';
$result['message'] ="Orders Deleted Successfully";
}
catch(PDOException $e)
{
$result['status'] = 'error';
$result['message'] = $e->getMessage();
}
$conn = null;
return $result;
}
function view_order_details($order_id = 0)
{
global $connection;
54
global $username;
global $password;
$result['status'] = "failed";
$result['data'] =array();
try
{
$conn = new PDO($connection, $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql ="select order_id, user_id, pro_id , pro_count from order_details";
$sql .=" where order_id =? order by id asc";
$stmt = $conn->prepare($sql);
$stmt->execute(array($order_id));
$result['data'] = $stmt->fetchAll(PDO::FETCH_ASSOC);
$result['status']='success';
}
catch(PDOException $e)
{
$result['status'] = "Error: " . $e->getMessage();
}
$conn = null;
return $result ;
}
function add_user($data)
{
$result['status'] ="failed";
$result['message'] = 'Nothing Happended!';
global $connection;
global $username;
global $password;
try
{
$conn = new PDO($connection, $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "insert into user_table";
$sql .="(email_id, user_name, address, city, pincode, mobile_number,password)";
$sql .= " values(:email,:name,:address,:city,:pincode,:mobile,:password)";
$stmt = $conn->prepare($sql);
$stmt->bindParam(':email', $data["email"]);
$stmt->bindParam(':name', $data["username"]);
$stmt->bindParam(':address', $data["address"]);
$stmt->bindParam(':city', $data["city"]);
$stmt->bindParam(':pincode', $data["pincode"]);
$stmt->bindParam(':mobile', $data["mobile"]);
$stmt->bindParam(':password', $data["password"]);
$stmt->execute();
$result['status'] = 'success';
$result['message'] = 'Registeration Successfully!';
}
catch(PDOException $e)
{
55
$result['status'] = "error";
$result['message'] = $e->getMessage();
}
$conn = null;
return $result;
}
function view_users()
{
global $connection;
global $username;
global $password;
$result['status'] = "failed";
$result['data'] =array();
try
{
$conn = new PDO($connection, $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql ="select * from user_table";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result['data'] = $stmt->fetchAll(PDO::FETCH_ASSOC);
$result['status']='success';
}
catch(PDOException $e)
{
$result['status'] = "Error: " . $e->getMessage();
}
$conn = null;
return $result ;
}
function valid_user($data)
{
$result['status'] ="failed";
$result['message'] = 'Nothing Happended!';
global $connection;
global $username;
global $password;
try
{
$conn = new PDO($connection, $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "select * from user_table ";
$sql .="where email_id = :email and password = :password";
$stmt = $conn->prepare($sql);
$stmt->bindParam(':email', $data["email"]);
$stmt->bindParam(':password', $data["password"]);
$stmt->execute();
$result['data'] = $stmt->fetchAll(PDO::FETCH_ASSOC);
if(count($result['data']) > 0 ){
56
$result['status'] = 'success';
$result['message'] = 'Registeration Successfully!';
}
else
{
$result['status'] = 'invalid';
$result['message'] = 'Email / password Incorrect !';
}
}
catch(PDOException $e)
{
$result['status'] = "error";
$result['message'] = $e->getMessage();
}
$conn = null;
return $result;
}
function valid_card($data)
{
$result['status'] ="failed";
$result['message'] = 'Nothing Happended!';
global $connection;
global $username;
global $password;
try
{
$conn = new PDO($connection, $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "select * from card_table ";
$sql .="where card_no = :cardno and expire = :date and spin=:spin";
$stmt = $conn->prepare($sql);
$stmt->bindParam(':cardno', $data["cardno"]);
$stmt->bindParam(':date', $data["date"]);
$stmt->bindParam(':spin', $data["spin"]);
$stmt->execute();
$result['data'] = $stmt->fetchAll(PDO::FETCH_ASSOC);
if(count($result['data']) > 0 ){
$result['status'] = 'success';
$result['message'] = 'Registeration Successfully!';
}
else
{
$result['status'] = 'invalid';
$result['message'] = 'Invalid Card Details !';
}
}
catch(PDOException $e)
{
$result['status'] = "error";
$result['message'] = $e->getMessage();
57
}
$conn = null;
return $result;
}
function view_comment()
{
global $connection;
global $username;
global $password;
$result['status'] = "failed";
$result['data'] =array();
try
{
$conn = new PDO($connection, $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql ="select id, user_id, user_comment from order_master where user_comment='No
Comments'";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result['data'] = $stmt->fetchAll(PDO::FETCH_ASSOC);
$result['status']='success';
}
catch(PDOException $e)
{
$result['status'] = "Error: " . $e->getMessage();
}
$conn = null;
return $result ;
}
function make_order($items,$email)
{
$result['status'] ="failed";
$result['message'] ="No Updation";
global $connection;
global $username;
global $password;
try
{
58
$tot_amt = $tot_amt + ($item['pro_cost']*$item['pro_count']);
}
$conn = new PDO($connection, $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$conn->beginTransaction();
foreach($items as $item)
{
$stmt = $conn->prepare("insert into order_details(order_id,user_id, pro_id, pro_count)
values (:order,:user,:prod,:count)");
$stmt->bindParam(':order', $last_id);
$stmt->bindParam(':user', $email);
$stmt->bindParam(':prod', $item["id"]);
$stmt->bindParam(':count', $item["pro_count"]);
$stmt->execute();
}
$conn->commit();
$result['status'] = 'success';
$result['message'] ="Purchase Made Successfully";
}
catch(PDOException $e)
{
$conn->rollback();
$result['status'] = 'error';
$result['message'] = $e->getMessage();
}
$conn = null;
return $result;
}
function view_recommeded($pro_id='0')
{
global $connection;
global $username;
global $password;
$result['status'] = "failed";
$result['data'] =array();
$order_ids = array();
$prod_weights = array();
$order_and_prod = array();
59
try
{
$conn = new PDO($connection, $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql ="select * from order_details";
$stmt = $conn->prepare($sql);
$stmt->execute();
$orders_data = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach($orders_data as $row)
{
$rprd_id = $row['pro_id'];
$r_order_id = $row['order_id'];
if($pro_id == $rprd_id)
array_push($order_ids, $r_order_id);
if(isset($order_and_prod[$r_order_id]))
array_push($order_and_prod[$r_order_id], $rprd_id);
else
$order_and_prod[$r_order_id]=array($rprd_id);
}
$selected_pro = array();
foreach($order_ids as $order)
{
foreach($order_and_prod[$order] as $pro_list)
{
if($pro_list != $pro_id)
{
if(isset($prod_weights[$pro_list]))
$prod_weights[$pro_list] = $prod_weights[$pro_list] + 1;
else
$prod_weights[$pro_list] = 1;
}
}
arsort($prod_weights);
$final_pro = "";
$count = 0;
foreach($prod_weights as $key=>$val)
{
if($count == 0)
$final_pro = $key;
else if($count<3)
$final_pro .= ",". $key;
$count++;
}
60
$sql ="select id,pro_name,pro_cat,pro_cost,pro_desc,pro_image,pro_active from
product_table where pro_active=1 and id in (". $final_pro.")";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result['data'] = $stmt->fetchAll(PDO::FETCH_ASSOC);
}
catch(PDOException $e)
{
$result['status'] = "Error: " . $e->getMessage();
}
$conn = null;
return $result ;
}
?>
<?php
61
}
}
else
{
$table .="<td>".$data."</td>";
}
}
else{
$table .="<td>".$data."</td>";
}
}
if(isset($actions))
{
foreach($actions as $action)
{
$table .="<td><a class='".$action['class']."'
href='".$action['url']."?id=".$row[$action['id']]."'>".$action['text']."</a></td>";
}
}
$table .="</tr>";
}
$table .="</table>";
return $table;
}
function showMessage($result)
{
if( $result['status'] == 'success')
{
echo "<div class='dCenter'>".$result['message']."</div>";
}
elseif($result['status'] == 'loading'){
echo " ";
}
else
{
echo "<div class='dCenter danger'>".$result['message']."</div>";
}
echo "<script>";
echo "$(document).ready(function(){";
echo "$('form').click(function(){ $('.dCenter').remove(); });";
echo "});";
echo "</script>";
62
$table ="<table class='$css_class' style='$style'>";
$table .="<tr>";
foreach($columns as $col=>$span)
{
if($span > 1){
$table .="<th colspan='$span'>".$col."</th>";
}
else{
$table .="<th>".$col."</th>";
}
}
$table .="</tr>";
foreach( $rows as $row)
{
$table .="<tr>";
foreach($row as $key=>$data)
{
if(count($data_convert)>0)
{
if(array_key_exists($key,$data_convert))
{
if(array_key_exists($data, $data_convert[$key]))
{
$table .="<td>".$data_convert[$key][$data]."</td>";
}
else
{
$table .="<td>".$data."</td>";
}
}
else
{
$table .="<td>".$data."</td>";
}
}
else{
$table .="<td>".$data."</td>";
}
}
if(isset($actions))
{
foreach($actions as $action)
{
$urlParameter="";
$paramCount = count($action['param']);
foreach($action['param'] as $param=>$colname)
{
$paramCount--;
if($paramCount == 0)
{
63
$urlParameter .=$param.'='.$row[$colname]; }
else{
$urlParameter .=$param.'='.$row[$colname].'&';
}
}
$table .="<td><a class='".$action['class']."'
href='".$action['url']."?".$urlParameter."'>".$action['text']."</a></td>";
}
}
$table .="</tr>";
}
$table .="</table>";
return $table;
}
function showMessage2($result,$divclass,$divclass2)
{
if( $result['status'] == 'success')
{
echo "<div class='".$divclass."'>".$result['message']."</div>";
}
elseif($result['status'] == 'loading'){
echo " ";
}
else
{
echo "<div class='".$divclass2."'>".$result['message']."</div>";
}
}
?>
<?php
include_once('header.php');
if(!isset($_SESSION['email']))
header("location:login.php");
?>
<?php
$quantity = 1;
if(isset($_SESSION['cart'][$_GET['pid']]))
$quantity = $_SESSION['cart'][$_GET['pid']];
64
}
else
{
$_SESSION['cart'] = array();
$_SESSION['cart'][$_GET['pid']] = $_GET['pqt'];
}
}
?>
?>
</div>
</div>
<div id="sidebox">
<div class="box">
<div class="bpad10 brdb gray">Item Details</div>
<div class="bpad10 pagegrid gap10">
<?php
if(isset($_GET['pid']))
{
$result = view_product_id($_GET['pid']);
if(count($result['data']) > 0 )
{
$product = $result['data'][0];
$item = "<div class='box gray'>";
$item .= " <div class='itemimg'><img src='".$product['pro_image']."' alt=''
/></div>";
$item .= " <div class='itemdesc'>";
//$item .= " <div class='itemname'>".$product['pro_name']."</div>";
//$item .= " <div class='itemcost'>Rs. ".$product['pro_cost'].".00</div>";
$item .= " <div class='itemcost'>";
$item .= " <form method='GET' >";
$item .= " <input type='hidden' name='pid' value='". $_GET['pid'] ."'>";
$item .= " <div class='grid2 bpad10'>";
$item .= " <div><input style='border-right:none;' type='text' name='pqt'
value='". $quantity ."'></div>";
$item .= " <div><input style='margin-top:0px; padding:8px 10px;'
type='submit' value='Add to Cart'></div>";
65
$item .= " </div>";
$item .= " </form>";
$item .= " </div>";
$item .= " </div>";
$item .= "</div>";
$item .= "<div class='box gray bpad20'>";
$item .= " <h1>". $product['pro_name']. "</h1>";
$item .= " <p style='padding:10px 0px'> Cost: Rs.".$product['pro_cost']."</p>";
$item .= " <p>".$product['pro_desc']."</p>";
$item .= "</div>";
echo $item;
}
}
?>
</div>
</div>
?>
</div>
</div>
</div>
</div>
66
<?php include_once('footer.php'); ?>
View orders
$result =view_orders($_SESSION['email']);
$column = array('#'=>'1','Users'=>'1','Order At'=>'1','Items'=>'1','Amount'=>'1','status'=>'1',
'Action'=>'1');
$view = array('id'=>'id');
$actions[0] = array('url'=>'view_order_details.php','param'=> $view, 'class'=>'editbtn',
'text'=>'Details');
$convetions['user_id'] = get_users();
$convetions['pro_status'] = array();
$convetions['pro_status'][0] = "<span class='dangerft'>New_Order</span>";
$convetions['pro_status'][1] = "<span class='dangerft'>On_Process</span>";
$convetions['pro_status'][2] = "<span class='successft'>Packing</span>";
$convetions['pro_status'][3] = "<span class='successft'>Deliveried</span>";
67
PROJECT CONCLUSION
68
CHAPTER 8
CONCLUSION
69
REFERENCES
70
CHAPTER 9
REFERENCES
71