Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
6 views48 pages

Database Systems Report

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)
6 views48 pages

Database Systems Report

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/ 48

lOMoARcPSD|24562605

Database Systems report

Information Science and Engineering (NITTE (Deemed to be University))

Scan to open on Studocu

Studocu is not sponsored or endorsed by any college or university


Downloaded by Vaishnavi Kandekar ([email protected])
lOMoARcPSD|24562605

ELECTRICITY BILL MANAGEMENT


SYSTEM
DATABASE PROJECT REPORT

SUBMITTED BY

Insert name

As part of the course Database Systems - CS52

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Insert institution name

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

TABLE OF CONTENTS

SI. No. TITLE Page No

1. Abstract 1

2. Introduction 2

3. Background, Motivation and Scope 4

4. Methodology 7

5. Requirements 9

6. E-R Diagram 12

7. Relational Database Design 14

8. Database Normalization 17

9. Data Directory 18

10. Graphical User Interface 22

11. Source Code 27

12. Conclusion 44

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

ABSTRACT

The Electricity Bill Management System represents an innovative solution aimed at revolutionizing
the traditional approach to managing utility billing processes. This project presents a comprehensive
analysis and design of a database-driven system tailored to streamline and enhance the efficiency of
electricity billing operations for both customers and administrators. The system aims to cover key
aspects of an electricity billing system through fundamental database concepts. These include
facilitating user registration, secure authentication and also reminding customers regarding due bills
via an intuitive interface. Additionally, it involves designing a structured database schema capable of
storing essential billing data such as customer information, meter readings, and bill amounts. The
system also focuses on a straightforward bill generation process, whether through predefined rates or
manual inputs. Further, it aims to incorporate basic payment tracking functionalities for record-
keeping purposes. The focus of this project is to introduce fundamental concepts of database design,
implementation, and management in the context of an electricity billing system.

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

INTRODUCTION

'Electricity Bill Management System’ is a one-step solution for streamlined and hassle-free online
electricity bill payments. The Electricity Billing System is an automated system that is developed
using PHP, JavaScript, Bootstrap, CSS, and MySQL database. This Electricity Billing System has
two sections: the client section and the admin section. The admin plays a vital role in all of the
management of the Electricity Billing System and this web application is tailored to redefine the
experience in managing and settling electricity bills seamlessly.

Paying bills such as electricity bills can take a lot of time. Most especially when people need to fall
in a long line in order to pay their bill. Hence, it’s an advantage to have an automated Electricity
Billing System, it’s not just very helpful but it will also lessen the stress of many people because
they don’t have to be there at the outlet just to pay the bill. All they have to do is just go to the
website register for a client’s account then they can have access into the system. As they logged in as
a client , the client now has the ability to view their bill for the month then, they can also send a
complaint regarding their bill. While in the admin section, they have the ability to issue a billing
statement to the client and make a response whenever there are complaints, is meticulously designed
to offer an intuitive and user-friendly interface.

Client Section:
Upon initiation, clients are ushered into an intuitive portal, providing an effortless avenue to peruse
monthly bills and submit queries. Beyond being a mere transactional platform, it serves as a secure
online gateway, simplifying the payment process with a user-friendly dashboard. This platform not
only redefines bill payments but transforms them into a streamlined and secure experience.

Admin Section:
The administrative facet of the system empowers administrators to issue billing statements and
promptly address client concerns. Through meticulous design and functionality, the admin interface
becomes an integral component in ensuring the overall efficiency of the Electricity Billing System.

Key Features:
2

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

1.User Authentication System: Elevating user experience, a robust authentication system prioritizes
data confidentiality and security, guaranteeing a secure online environment.

2. Comprehensive Dashboard: Clients are greeted with a visually appealing and responsive
dashboard, ensuring a seamless experience for bill reviews and secure transactions.

3.Smart Features: Integration of intelligent features, including detailed bill history and personalized
notifications, enhances user engagement and promotes proactive bill management.

4. Database Efficiency: Anchored in a well-structured database schema, the system establishes


efficient relationships between users, bills, and transactions, ensuring meticulous record-keeping and
streamlined data retrieval.

The "Electricity Bill Management System" stands as a testament to the evolution of automated
billing solutions. Beyond a mere platform for financial transactions, it embodies a commitment to
user-centric design, data security, and streamlined management. This innovation, complemented by
comprehensive documentation and unwavering customer support, heralds a new era in electricity bill
management, promising a future marked by efficiency, convenience, and security.

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

BACKGROUND, MOTIVATION AND SCOPE

Background :
The management and payment of electricity bills constitute a fundamental aspect of modern living.
In today's fast-paced world, traditional methods of bill payment are becoming increasingly
inconvenient and time-consuming. Moreover, with the surge in digital transactions and the need for
efficient utility management, there's a pressing need for a streamlined and user-friendly solution for
handling electricity bills. The emergence of digital technologies has opened doors for innovative
solutions to simplify the process of managing utility payments. Recognizing these challenges and
opportunities, the development of an "Electricity Bill Management System" becomes pivotal in
addressing the shortcomings of traditional bill payment methods.
The primary goal behind the creation of the Electricity Bill Management System is to
alleviate the complexities and inefficiencies associated with conventional bill payment processes.
These challenges include long queues at payment centers, manual handling of bills, potential errors
in data entry, and a lack of real-time information for consumers.

Motivation :

The development of the Electricity Bill Management System stemmed from a confluence of
challenges faced by both consumers and utility service providers in the realm of electricity bill
management. These challenges, coupled with the potential for technological innovation, served as
the impetus for creating a robust and user-centric solution.

1. Challenges in Traditional Bill Management

Conventional methods of managing electricity bills often involve cumbersome processes, such as
physically visiting payment centres , waiting in queues, and handling paper-based bills. These
methods not only consume valuable time but also lack transparency and real-time insights into
billing details and consumption patterns.

2. Rising Demand for Digital Solutions

With the rapid digital transformation across various industries, the utility sector faces increasing
4

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

pressure to adopt modern, user-friendly platforms. The proliferation of online transactions and the
need for remote accessibility have underscored the necessity for an efficient and secure digital
solution for managing electricity bills.

3. Empowering Users with Control and Convenience

Understanding the importance of empowering users with control over their utility expenses, the
motivation behind this system is to offer a centralized platform that simplifies bill management. The
system aims to provide consumers with real-time access to their billing information, enabling them
to make informed decisions and manage payments seamlessly from the comfort of their homes or
offices.

4. Addressing Security and Accessibility Concerns

Additionally, security concerns regarding financial transactions and the accessibility needs of diverse
user groups were key motivators in developing a system that not only prioritizes data security but
also ensures an intuitive and inclusive user experience for all.

Scope :

The scope section of an "Electricity Bill Management System" report outlines the boundaries,
functionalities, and limitations of the system. It defines what the system encompasses and what
aspects it does not cover.

1. User Registration and Authentication: The system includes provisions for users to register
accounts securely and authenticate their identities to access the platform.

2. Bill Viewing and Payment: Users can view detailed billing information, including
consumption history, due dates, and payment options. The system facilitates secure online
payments for electricity bills.

3. Notification and Alert System: An integrated notification system alerts users about
upcoming bill due dates, payment confirmations, and other relevant updates.

4. Secure Database Management: The system maintains a robust database structure to manage

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

user profiles, billing details, transaction records, and other pertinent data securely.

5. User-Friendly Interface: The platform boasts an intuitive and responsive user interface,
ensuring ease of navigation and accessibility across various devices.

6. Security Measures: Stringent security protocols are implemented to safeguard user data and
financial transactions, including encryption, secure authentication, and protection against
common web vulnerabilities.

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

METHODOLOGY

The development of the " Electricity Bill Management System" involves a systematic approach that
combines elements of software engineering, database design, and web development. The following
methodology outlines the key steps taken to design, implement, and test the system:

1. Requirements Analysis:
○ Users should receive timely notifications about bill due dates, payment confirmations,
and any service-related updates.

○ Users should be able to register securely and authenticate themselves to access the
platform.

2. System Design:
○ Developed a high-level system architecture, outlining the main components and their
interactions.
○ Designed the database schema, identifying entities, relationships, and attributes.
○ Created wireframes and mockups for the user interface, ensuring a user-friendly
design.

3. Technology Stack Selection:


○ Chose HTML, CSS and javascript as the web application framework due to its
robustness and built-in features.
○ Selected a SQL database to store and retrieve data efficiently, considering factors
such as data integrity and scalability.

4. Implementation:
○ This Electricity Billing System has two sections: the client section and the admin
section. The admin plays a vital role in all of the management of the Electricity
Billing System.
○ Ensuring responsive design using Bootstrap and CSS and maintaining data integrity
using a MySQL database.
7

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

○ Implementing these features involves coding in PHP Billing Information Display,


User Authentication and Authorization and Dynamic Content Generation.
○ Created database models and implemented CRUD (Create, Read, Update, Delete)
operations.

5. Use of triggers:
○ Installed triggers to remind customers if the billing is due 5 days prior to the last date.
○ Shows a popup about the time left and country.

6. User Interface Development:


○ Utilized CSS and Bootstrap for a responsive and visually appealing user interface.
○ Ensured consistency in design elements and user experience throughout the
application.

7. Security Implementation:
○ Implemented input validation to prevent SQL injection and other security
vulnerabilities.
○ Used PHP to ensure user validation and authentication.

8. Documentation:
○ Created comprehensive documentation, including a project overview, database
schema documentation, and a guide for setting up and running the application.
○ Documented the codebase to facilitate future maintenance and development.

9. Scalability Considerations:
○ Designed the system with scalability in mind, considering potential areas for
optimization and expansion.
○ Evaluated the system's performance under different load conditions.

This methodology ensures a structured and systematic approach to the development of the Online
Electricity Bill Management System, covering various aspects from requirements analysis to
scalability considerations. It emphasizes the use of best practices and established frameworks to
create a robust and maintainable solution.

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

REQUIREMENTS

The requirements for the " Electricity Bill Management System" were elicited through collaborative
discussions with stakeholders and careful consideration of the desired functionalities. The following
outlines the key functional and non-functional requirements that guided the development process:

Functional Requirements:

1. User Authentication and Authorization:


○ Users should be able to register an account with the system.
○ Registered users must be able to log in securely.
○ User roles should include regular users, auction creators, and administrators.
○ Authorization mechanisms should control access to different features based on user
roles.

2. Bill Management:
○ Users can view and download their electricity bills.

○ The system reminds the users to pay the bills with triggers and pop-up notifications.

○ Admins can generate bills, enter transaction details, and update bill statuses.

○ System validates and securely stores bill information.

3. Filing complaints:

o Users is able to file complaints and the website shows a list of all complaints.
o It also shows the list of resolved and unresolved complaints to the user.
o Admins can view, address, and update the status of user complaints whether it’s
pending or processing.
9

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

4. Managing user list:


○ The system must add the new users who registered ,store their credentials so that they
can login again.
○ This can be done by CRUD operations on the SQL database system.

5. Home page:
○ Display welcome content.
○ Display About the Company Content
○ Track/Display Client's Connection Data and Billing History
○ Notifications should be sent to users when their bills are due.

6. User Interface:
○ The user interface should be intuitive, responsive, and consistent across all pages.
○ Users should be able to navigate seamlessly between different features, such as
viewing bills, dashboard, bills, and filing complaints.

Non-Functional Requirements:

1. Database Schema:
○ The database is designed to efficiently store and retrieve data related to users, bills,
and other entities.
○ Foreign keys and indexes are utilized for optimal performance.

2. Security:
○ The system implements secure user authentication and authorization mechanisms.
○ Input validation is applied to prevent common security vulnerabilities such as SQL
injection and Cross-Site Scripting (XSS).

3. Scalability:
○ The system should be designed with scalability in mind, allowing for potential
expansion and increased user load.
○ Performance should be evaluated under varying conditions to identify and address
scalability challenges.

10

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

4. Documentation:
○ Comprehensive documentation should be provided, including an overview of the
project, database schema documentation, and a guide for setting up and running the
application.
○ Code documentation should be thorough to facilitate future maintenance and
development.

5. Testing:
○ The system should undergo rigorous testing, including unit tests for individual
components and integration tests to validate interactions between different modules.

11

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

E R DIAGRAM

An ER (Entity-Relationship) diagram visually represents a database's structure, depicting entities


(objects or concepts), their attributes, and relationships between entities. Entities are shown as
rectangles, attributes as ellipses, and relationships as diamonds. Cardinality defines how entities are
related, and primary keys uniquely identify records ER diagrams aid in visualizing and designing
database structures.

For the electricity bill management system,


Entities: Admin, bill, User, Complaints, Transaction
Relations: Generates, Pays, Transact, Views, Issues
Primary keys: admin_id, bill_id, user_id, transaction_id, complaint_id

CARDINALITY

 The relationship between admin and bill can be represented by one-to-many Cardinality. An
admin can generate n number of bills for the user.
 The relationship between user and bill can be represented by one-to-many Cardinality. A
single user can get multiple bills for the current month and previous months stored in the
database.
 The relationship between user and transaction can be represented by one to many Cardinality.
A user can pay n number of bills.
 The relationship between user and complaints can be represented by one-to-many
Cardinality. A single user can file multiple complaints which will be stored in the database
for the admin to view and respond to it later.
 The relationship between admin and complaint can be represented by one-to-many

Cardinality. A single admin can view n number of complaints and respond to the user.
12

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

Fig 1: E R Diagram for Electricity Bill Management System Database

13

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

RELATIONAL DATABASE DESIGN

A relational database is a structured collection of data organized into tables. Each table contains
rows representing individual records and columns defining attributes. Primary keys uniquely identify
records, and foreign keys establish relationships between tables. Data is queried using SQL, and
features include normalization for efficiency, ACID properties for reliability, and integrity
constraints. Examples of relational database systems are MySQL, PostgreSQL, SQL Server, Oracle,
and SQLite.

Fig 2: RDBMS Diagram for Electricity Bill Management System

14

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

ENTITIES AND ATTRIBUTES with data types and constraints:

1. USER Table:
 user_id: INT (Primary Key, Auto-Increment)
 user_name: VARCHAR(255)
 user_email: VARCHAR(255)
 user_password: VARCHAR(255)
 user_address: VARCHAR(255) (COMPOSITE ATTRIBUTE)
 street: VARCHAR(255)
 house_no: VARCHAR(10)
 city: VARCHAR(100)

2. BILL Table:
 bill_id: INT (Primary Key, Auto-Increment)
 user_id: INT (Foreign Key referencing USER table)
 transaction_id: INT (Foreign Key referencing TRANSACTION table)
 units: DECIMAL(10, 2)
 amount: DECIMAL(10, 2)
 bill_date: DATE
 status: VARCHAR(50)
 duedate: DATE

3. COMPLAINTS Table:
 complaint_id: INT (Primary Key, Auto-Increment)
 complaint: TEXT
 complaint_status: VARCHAR(50)
 user_id: INT (Foreign Key referencing USER table)
 admin_id: INT (Foreign Key referencing ADMIN table)

15

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

4.ADMIN Table:
 admin_id: INT (Primary Key, Auto-Increment)
 admin_name: VARCHAR(255)
 admin_email: VARCHAR(255)
 admin_password: VARCHAR(255)
 permissions: VARCHAR(255)
 user_id: INT (Foreign Key referencing USER table)
 complaint_id: INT (Foreign Key referencing COMPLAINTS table)

5.TRANSACTION Table:
 transaction_id: INT (Primary Key, Auto-Increment)
 payable: DECIMAL(10, 2)
 date: DATE

Foreign keys (FK) link tables based on Relationships:

- USER and BILL are connected through the user_id foreign key.
- USER and COMPLAINTS are connected through the user_id foreign key.
- USER and ADMIN are connected through the user_id foreign key.
-ADMIN and BILL are connected through the bill_id foreign key.
-USER and BILL are connected through the bill_id foreign key.
- ADMIN and COMPLAINTS are connected through the complaint_id foreign key.
- ADMIN and TRANSACTION are connected through the transaction_id foreign key.
- BILL and TRANSACTION are connected through the transaction_id foreign key.

DATA NORMALISATION
16

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

1. User Information (User Side):


- Normalized user details such as name, email, and contact number.
- Ensure consistent formatting for addresses and other personal information.

2. Client Information (Client Side):


- Normalize client details, such as company name, contact information, and billing address.
- Standardize industry-specific data, if applicable.

3. Signup Page:
- Standardize username, email, and password formats.
- Ensure unique identifiers for each user to prevent duplication.

4. Dashboard:
- Normalize display formats for bills (e.g., currency, date, units).
- Standardize units for usage metrics (e.g., kilowatt-hours).

5. Bills Section:
- Normalize billing data structure, ensuring consistency in fields like amount, due date, and
payment status.
- Use a consistent date format across bills.

6. Complaints Section:
- Normalize complaint data, including user-submitted details and timestamps.
- Categorize and standardize complaint types for analysis.

7. File Complaints:
- Ensure normalized fields for complaint submission, such as category, description, and priority
level.

DATA DIRECTORY
17

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

In database systems and management, a data directory serves as a pivotal repository, housing crucial
metadata and control information essential for the efficient functioning and organization of the
database system.

The repository encompasses several key components:

1. Metadata Storage: The data directory is a reservoir for metadata, encapsulating vital information
about the database's structural elements ranging from tables and indexes to views and various other
database objects. This metadata is fundamental for the Database Management System (DBMS) to
comprehend the organization of data and execute interactions effectively.

2. Control Files: Integral to database systems, control files find their place within the data directory,
storing configuration settings and parameters. These files play a pivotal role in managing transaction
logs, determining data file locations, and overseeing various system-related configurations.

3. Database Configuration: The data directory hosts files containing configuration information for
the entire database system. This encompasses a spectrum of details, including user specifics, access
permissions, and other global settings crucial for the system's seamless operation.

4. Logging and Recovery Information: In certain database systems, the data directory extends its
utility to include logs and information indispensable for recovery in the event of system failures.
This strategic inclusion ensures the preservation of data consistency and durability, safeguarding
against potential disruptions.

5. Security Information: The data directory serves as a repository for database security information,
encompassing critical data such as user credentials and access control lists. This centralized storage
mechanism is instrumental in managing and enforcing robust security policies, ensuring the integrity
of the database system.

The data directory emerges as a comprehensive hub within the database ecosystem, encapsulating
18

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

essential elements that range from foundational structural insights to configuration specifics, security
parameters, and mechanisms for system resilience. Its meticulous organization and storage of these
components contribute significantly to the overall efficiency and reliability of the database system.
The data directory is as follows:

|Electricity Bill Management System


|Admin
|.bill.php
|.billamtcount.php
|.complaint.php
|.dash_defaulting_users.php
|.extra.php
|.footer.php
|.generate_bill.php
|. generate_bill_table.php
|. head_html.php
|. index.php
|. js.php
|.logout.php
|.nav.php
|.paging1.php
|.paging2.php
|.pendingcount.php
|.process_complaint.php
|.sidebar.php
|.users.php

|User
|.bill.php
|.complaint.php

19

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

|.change_password.php
|.extra.php
|.footer.php
|.sub_complaint.php
|. head_html.php
|. index.php
|. js.php
|.logout.php
|.nav.php
|.paging1.php
|.paging2.php
|.transact_bill.php
|.transaction.php
|.sidebar.php
|.users.php

|Assets
|.CSS
|.bootstrap.css
|.dash_admin.css
|.dash_user.css
|.font-awesome.css
|.font-awesome.min.css
|.main.css
|.fonts
|. glyphicons-halflings-regular.eot
|. glyphicons-halflings-regular.svg
|. glyphicons-halflings-regular.woff
|. glyphicons-halflings-regular.ttf
|.img
|.ser01.png

20

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

|.ser02.png
|.ser03.png
|.js
|.bootstrap.min.js
|.custom.js
|.jquery-1.11.0.js
|Database file
|.ebillsystem.sql
|Include
|.admin.php
|.config.php
|.session.php
|.user.php

GRAPHICAL USER INTERFACE


21

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

The graphical user interface for Electricity Bill Management system is easy to understand and use

both for admins and customers.

Fig 1: Sign up and login page for customers

Fig 2:Bills Reflected on the client side

22

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

Fig 3: Option for customers to pay the bill

Fig 4: Pop up alert for due bills

23

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

Fig 5: Status updates to processed after bill has been paid

Fig 6: Clients can log complaints

24

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

Fig 7: Admin can process the complaints

Fig 8:Statistics/overview in user dashboard and updates

25

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

Fig 9:Admin dashboard stats also updated.

Fig 10:Bill generated by admin

26

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

SOURCE CODE
ebillsystem.sql

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";


SET time_zone = "+00:00";

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;


/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `unitstoamount` (IN `units` INT(14), OUT `result` INT(14)) BEGIN

DECLARE a INT(14) DEFAULT 0;


DECLARE b INT(14) DEFAULT 0;
DECLARE c INT(14) DEFAULT 0;

SELECT twohundred FROM unitsRate INTO a ;


SELECT fivehundred FROM unitsRate INTO b ;
SELECT thousand FROM unitsRate INTO c ;

IF units<200
then
SELECT a*units INTO result;

ELSEIF units<500
then
SELECT (a*200)+(b*(units-200)) INTO result;
ELSEIF units > 500
then
SELECT (a*200)+(b*(300))+(c*(units-500)) INTO result;
END IF;

END$$

CREATE DEFINER=`root`@`localhost` FUNCTION `curdate1` () RETURNS INT(11) BEGIN


DECLARE x INT;
SET x = DAYOFMONTH(CURDATE());
IF (x=1)
THEN
RETURN 1;
ELSE
RETURN 0;
END IF;
END$$

DELIMITER ;

CREATE TABLE `admin` (


`id` int(14) NOT NULL,
`name` varchar(40) NOT NULL,
`email` varchar(40) NOT NULL,
`pass` varchar(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO `admin` (`id`, `name`, `email`, `pass`) VALUES

27

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

(1, 'Administrator One', '[email protected]', 'Password@123'),


(2, 'Administrator Two', '[email protected]', 'admin2');

CREATE TABLE `bill` (


`id` int(14) NOT NULL,
`aid` int(14) NOT NULL,
`uid` int(14) NOT NULL,
`units` int(10) NOT NULL,
`amount` decimal(10,2) NOT NULL,
`status` varchar(10) NOT NULL,
`bdate` date NOT NULL,
`ddate` date NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO `bill` (`id`, `aid`, `uid`, `units`, `amount`, `status`, `bdate`, `ddate`) VALUES
(17, 1, 8, 210, '450.00', 'PROCESSED', '2021-07-06', '2021-08-05'),
(18, 1, 1, 61, '122.00', 'PROCESSED', '2021-07-10', '2021-08-09'),
(19, 1, 2, 78, '156.00', 'PENDING', '2021-07-10', '2021-08-09'),
(20, 1, 3, 70, '140.00', 'PROCESSED', '2021-07-10', '2021-08-09'),
(21, 1, 4, 98, '196.00', 'PENDING', '2021-07-10', '2021-08-09'),
(22, 1, 9, 55, '110.00', 'PROCESSED', '2021-07-10', '2021-08-09'),
(23, 1, 11, 89, '178.00', 'PROCESSED', '2021-07-10', '2021-08-09'),
(24, 1, 7, 103, '206.00', 'PENDING', '2021-07-10', '2021-08-09');

CREATE TABLE `complaint` (


`id` int(14) NOT NULL,
`uid` int(14) NOT NULL,
`aid` int(14) NOT NULL,
`complaint` varchar(140) NOT NULL,
`status` varchar(40) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO `complaint` (`id`, `uid`, `aid`, `complaint`, `status`) VALUES


(1, 1, 1, 'Transaction Not Processed', 'PROCESSED'),
(2, 1, 1, 'Transaction Not Processed', 'PROCESSED'),
(3, 2, 1, 'Previous Complaint Not Processed', 'PROCESSED'),
(4, 2, 1, 'Transaction Not Processed', 'PROCESSED'),
(5, 2, 2, 'Transaction Not Processed', 'PROCESSED'),
(6, 1, 1, 'Bill Not Correct', 'PROCESSED'),
(7, 3, 1, 'Bill Not Correct', 'PROCESSED'),
(8, 3, 2, 'Transaction Not Processed', 'PROCESSED'),
(9, 4, 2, 'Transaction Not Processed', 'PROCESSED'),
(10, 4, 1, 'Bill Not Correct', 'PROCESSED'),
(11, 5, 2, 'Bill Generated Late', 'PROCESSED'),
(12, 1, 2, 'Bill Generated Late', 'NOT PROCESSED'),
(13, 11, 1, 'Bill Generated Late', 'PROCESSED');
CREATE TABLE `transaction` (
`id` int(14) NOT NULL,
`bid` int(14) NOT NULL,
`payable` decimal(10,2) NOT NULL,
`pdate` date DEFAULT NULL,
`status` varchar(10) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO `transaction` (`id`, `bid`, `payable`, `pdate`, `status`) VALUES


(17, 17, '450.00', '2021-07-06', 'PROCESSED'),
(18, 18, '122.00', '2021-07-10', 'PROCESSED'),
(19, 19, '156.00', NULL, 'PENDING'),
(20, 20, '140.00', '2021-07-10', 'PROCESSED'),
(21, 21, '196.00', NULL, 'PENDING'),
(22, 22, '110.00', '2021-07-10', 'PROCESSED'),

28

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

(23, 23, '178.00', '2021-07-10', 'PROCESSED'),


(24, 24, '206.00', NULL, 'PENDING');

CREATE TABLE `unitsrate` (


`sno` int(1) DEFAULT NULL,
`twohundred` int(14) NOT NULL,
`fivehundred` int(14) NOT NULL,
`thousand` int(14) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO `unitsrate` (`sno`, `twohundred`, `fivehundred`, `thousand`) VALUES


(1, 2, 5, 10);

CREATE TABLE `user` (


`id` int(14) NOT NULL,
`name` varchar(40) NOT NULL,
`email` varchar(40) NOT NULL,
`phone` varchar(255) NOT NULL,
`pass` varchar(20) NOT NULL,
`address` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO `user` (`id`, `name`, `email`, `phone`, `pass`, `address`) VALUES
(1, 'Frederick J Baker\n', '[email protected]', '7450002145', 'password', '1488 Franklin Street'),
(2, 'Antonio Dominguez', '[email protected]', '7854547855', 'password', '3961 Sycamore Lake Road'),
(3, 'Etta H Abner', '[email protected]', '7012569980', 'password', '3255 Ocello Street'),
(4, 'Jeffrey Wegman', '[email protected]', '7012458888', 'password', '2962 Pine Tree Lane'),
(5, 'Benjamin Sanderson', '[email protected]', '7012565800', 'password', '4830 Bell Street'),
(6, 'Eric Webb', '[email protected]', '7896541000', 'password', '3485 Stewart Street'),
(7, 'Jonathan Lasalle', '[email protected]', '70145850025', 'password', '3850 Olen Thomas Drive'),
(8, 'Liam Moore', '[email protected]', '7012545555', 'password', '744 Ralph Street'),
(9, 'Will Williams', '[email protected]', '7696969855', 'password', '7855 Allace Avenue'),
(10, 'Christine Moore', '[email protected]', '7896500010', 'password', '1458 Bleckstreet'),
(11, 'Timothy Diaz', '[email protected]', '7412580020', 'password', '4840 Oakdale Avenue');

ALTER TABLE `admin`


ADD PRIMARY KEY (`id`);
ALTER TABLE `bill`
ADD PRIMARY KEY (`id`),
ADD KEY `aid` (`aid`),
ADD KEY `uid` (`uid`);

ALTER TABLE `complaint`


ADD PRIMARY KEY (`id`),
ADD KEY `aid` (`aid`),
ADD KEY `uid` (`uid`);
ALTER TABLE `transaction`
ADD PRIMARY KEY (`id`),
ADD KEY `bid` (`bid`);
ALTER TABLE `user`
ADD PRIMARY KEY (`id`);

ALTER TABLE `admin`


MODIFY `id` int(14) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
ALTER TABLE `bill`
MODIFY `id` int(14) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=25;
ALTER TABLE `complaint`
MODIFY `id` int(14) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=14;
ALTER TABLE `transaction`
MODIFY `id` int(14) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=25;
ALTER TABLE `user`

29

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

MODIFY `id` int(14) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12;


ALTER TABLE `bill`
ADD CONSTRAINT `bill_ibfk_1` FOREIGN KEY (`aid`) REFERENCES `admin` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `bill_ibfk_2` FOREIGN KEY (`uid`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `complaint`
ADD CONSTRAINT `complaint_ibfk_1` FOREIGN KEY (`aid`) REFERENCES `admin` (`id`) ON DELETE CASCADE ON UPDATE
CASCADE,
ADD CONSTRAINT `complaint_ibfk_2` FOREIGN KEY (`uid`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `transaction`
ADD CONSTRAINT `transaction_ibfk_1` FOREIGN KEY (`bid`) REFERENCES `bill` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;


/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

Admin.php
<?php
// require_once("config.php");

function retrieve_bills_generated($id,$offset, $rowsperpage) {


global $con;
$query = "SELECT user.name AS user, bill.bdate AS bdate , bill.units AS units , bill.amount AS amount , bill.id as bid ";
$query .= ", bill.ddate AS ddate, bill.status AS status ";
$query .= " FROM user , bill ";
$query .= " WHERE user.id=bill.uid AND aid={$id} ";
$query .= " ORDER BY bill.id DESC ";
$query .= "LIMIT {$offset}, {$rowsperpage} ";

$result = mysqli_query($con,$query);
if($result === FALSE) {
die(mysql_error()); // TODO: better error handling
}
return $result;
}

function retrieve_bill_data($offset, $rowsperpage){


global $con;
$query = "SELECT curdate() AS bdate , adddate( curdate(),INTERVAL 30 DAY ) AS ddate , user.id AS uid , user.name AS uname FROM user
";
$query .= " LIMIT {$offset}, {$rowsperpage} ";
// echo $query;
$result = mysqli_query($con,$query);
if($result === FALSE) {
die(mysql_error()); // TODO: better error handling
}
return $result;
}

function retrieve_complaints_history($id,$offset,$rowsperpage)
{
global $con;
$query = "SELECT complaint.id AS id , complaint.complaint AS complaint , complaint.status AS status , user.name AS uname ";
$query .= "FROM user , complaint ";
$query .= "WHERE complaint.uid=user.id AND status='NOT PROCESSED' ";
$query .= "ORDER BY complaint.id desc ";
$query .= "LIMIT {$offset}, {$rowsperpage} ";

$result = mysqli_query($con,$query);
if($result === FALSE) {
die(mysql_error()); // TODO: better error handling
}

return $result;

30

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

function retrieve_users_detail($id,$offset, $rowsperpage)


{
global $con;
$query = "SELECT * FROM user ";
$query .= " LIMIT {$offset}, {$rowsperpage} ";
$result = mysqli_query($con,$query);
if($result === FALSE) {
die(mysql_error()); // TODO: better error handling
}
return $result;
}

function retrieve_admin_stats($id)
{
global $con;
$query1 = " SELECT count(id) AS unprocessed_bills FROM bill WHERE status = 'PENDING' AND aid = {$id} ";
$query2 = " SELECT count(id) AS generated_bills FROM bill WHERE aid = {$id} " ;
$query3 = " SELECT count(id) AS unprocessed_complaints from complaint where status='NOT PROCESSED' ";
// echo $query;

$result1 = mysqli_query($con,$query1);
if($result1 === FALSE) {
echo "FAILED1";
die(mysql_error()); // TODO: better error handling
}

$result2 = mysqli_query($con,$query2);
if($result2 === FALSE) {
echo "FAILED2";
die(mysql_error()); // TODO: better error handling
}

$result3 = mysqli_query($con,$query3);
if($result3 === FALSE) {
echo "FAILED3";
die(mysql_error()); // TODO: better error handling
}

return array($result1,$result2,$result3);
}

function retrieve_users_defaulting($id){
global $con;

//TODO : adjust for transaction .payable for delayed action!!!!!!!


//query for late
$query1 = "SELECT COUNT(*) FROM bill , transaction ";
$query1 .= "WHERE curdate() > bill.ddate AND curdate() < adddate(bill.ddate , INTERVAL 25 DAY ) ";
$query1 .= "AND bill.aid={$id} AND bill.status='PENDING' ";
$query1 .= "AND bill.amount = transaction.payable AND bill.id=transaction.bid ";

//query for defaulting


//remove user and all relating data
$query2 = "SELECT COUNT(*) FROM bill ";
$query2 .= "WHERE curdate() > adddate(bill.ddate , INTERVAL 25 DAY ) ";
$query2 .= "AND bill.aid={$id} AND bill.status='PENDING' ";

$result1 = mysqli_query($con,$query1);
if (!$result1)
{
die('1Error: ' . mysqli_error($con));
}

$result2 = mysqli_query($con,$query2);
if (!$result2)
{
die('2Error: ' . mysqli_error($con));
}
31

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

return array($result1,$result2,);
}

function insert_into_transaction($id,$amount){
global $con;
$query = "INSERT INTO transaction (bid,payable,pdate,status) ";
$query .= "VALUES ({$id}, {$amount} , NULL , 'PENDING' )";
// echo $query3;
if (!mysqli_query($con,$query))
{
die('Error: ' . mysqli_error($con));
}

?>

Config.php

<?php
$host='localhost'; # MySQL Host
$mysql_user="root";# MySql Username
$mysql_pwd=""; # MySql Password
$dbms="ebillsystem"; # Database

$con = mysqli_connect($host,$mysql_user,$mysql_pwd,$dbms);
if (!$con) die('Could not connect: ' . mysql_error());
mysqli_select_db($con,$dbms) or die("cannot select DB" . mysql_error());
?>

Session.php

<?php
require_once("config.php");
session_start();
$logged = false;
//checking if anyone(admin/email)is logged in or not
if(isset($_SESSION['logged']))
{
if ($_SESSION['logged'] == true)
{
$logged = true ;
$email = $_SESSION['email'];
}
}
else
$logged=false;

if($logged != true)
{
$email = "";
if (isset($_POST['email']) && isset($_POST['pass']))
{
$email=$_POST['email'];
$password=$_POST['pass'];
// some prereq-safeguards for the purpose of DB searching ->
$email = stripslashes($email);
$email = mysqli_real_escape_string($con,$email);
$password = stripslashes($password);
$password = mysqli_real_escape_string($con,$password);

//DB HAS 2 TABLES ADMIN AND USER BOTH HAVING THEIR OWN ATTRIBUTES
//EMAIL AND PASSWORD
// user
$sql = "SELECT * FROM user WHERE email='$email' AND pass='$password' ";
$result = mysqli_query($con,$sql);
$count = mysqli_num_rows($result);
if ($count == 1) {

32

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

$row=mysqli_fetch_array($result,MYSQLI_ASSOC);
$_SESSION['user'] = $row['name'];
$_SESSION['logged']=true;
$_SESSION['uid']=$row['id'];
$_SESSION['email'] = $email;
$_SESSION['account']="user";
header("Location:user/index.php");
}
// admin
$sql = "SELECT * FROM admin WHERE email='$email' AND pass='$password' ";
$result = mysqli_query($con,$sql);
$count = mysqli_num_rows($result);
if ($count == 1) {
$row=mysqli_fetch_array($result,MYSQLI_ASSOC);
$_SESSION['logged']=true;
$_SESSION['email'] = $email;
$_SESSION['aid']=$row['id'];
$_SESSION['account']="admin";
header("Location:admin/index.php");
}

}
}
?>

User.php

<?php
// require_once("config.php");

function retrieve_complaints ($id,$offset, $rowsperpage) {


global $con;
$query = "SELECT * FROM complaint where uid={$id} ";
$query .= "ORDER BY id DESC ";
$query .= "LIMIT {$offset}, {$rowsperpage}";
$result1 = mysqli_query($con,$query);
return $result1;
}

function retrieve_bills_history($id,$offset, $rowsperpage) {


global $con;
$query = "SELECT * FROM bill where uid={$id} ";
$query .= "ORDER BY bdate DESC ";
$query .= "LIMIT {$offset}, {$rowsperpage} ";
$result = mysqli_query($con,$query);
return $result;
}

function retrieve_bills_due($id,$offset, $rowsperpage) {


global $con;
$query = "SELECT bill.bdate AS bdate, bill.units AS units, bill.ddate AS ddate, transaction.payable AS payable, ";
$query .= " bill.amount AS amount ,transaction.payable-bill.amount AS dues , bill.id AS id ";
$query .= "FROM bill , transaction ";
$query .= "WHERE transaction.bid=bill.id AND bill.uid={$id} AND bill.status='PENDING' ";
$query .= "ORDER BY bill.ddate desc ";
$query .= "LIMIT {$offset}, {$rowsperpage} ";
$result = mysqli_query($con,$query);
return $result;
}
function retrieve_transaction_history($id,$offset, $rowsperpage) {
global $con;
$query = "SELECT transaction.id AS id , bill.bdate AS bdate, transaction.pdate AS pdate, transaction.payable AS payable, ";
$query .= " bill.amount AS amount ,transaction.payable-bill.amount AS dues ";
$query .= "FROM bill , transaction ";
$query .= "WHERE transaction.bid=bill.id AND bill.uid={$id} ";
$query .= "ORDER BY bill.ddate desc ";
$query .= "LIMIT {$offset}, {$rowsperpage} ";
$result = mysqli_query($con,$query);
return $result;
33

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

function retrieve_user_details($id) {
global $con;
$query = "SELECT * FROM user ";
$result = mysqli_query($con, $query);

if (!$result)
{
die('Error: ' . mysqli_error($con));
}
return $result;
}

function retrieve_user_stats($id)
{
global $con;
$query1 = " SELECT count(id) AS unprocessed_bills FROM bill WHERE status = 'PENDING' AND uid = {$id} ";
$query2 = " SELECT count(id) AS payed_bills FROM bill WHERE uid = {$id} AND status='PROCESSED'" ;
$query3 = " SELECT count(id) AS unprocessed_complaints from complaint where status='NOT PROCESSED' AND uid = {$id} ";
// echo $query;

$result1 = mysqli_query($con,$query1);
if($result1 === FALSE) {
echo "FAILED1";
die(mysql_error()); // TODO: better error handling
}

$result2 = mysqli_query($con,$query2);
if($result2 === FALSE) {
echo "FAILED2";
die(mysql_error()); // TODO: better error handling
}

$result3 = mysqli_query($con,$query3);
if($result3 === FALSE) {
echo "FAILED3";
die(mysql_error()); // TODO: better error handling
}

return array($result1,$result2,$result3);
}

?>

Bill.php

<?php
require_once('head_html.php');
require_once('../Includes/config.php');
require_once('../Includes/session.php');
require_once('../Includes/admin.php');
if ($logged==false) {
header("Location:../index.php");
}
?>

<body>

<div id="wrapper">

<?php
require_once("nav.php");
require_once("sidebar.php");
?>

<!-- Page Content -->


<div id="page-content-wrapper">

<div class="container-fluid">
34

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

<!-- Page Heading -->


<div class="row">
<div class="col-lg-12">
<h1 class="page-header">
Bills
</h1>

<!-- Pills Tabbed GENERATED | GENERATE -->


<ul class="nav nav-pills nav-justified">
<li class="active"><a href="#generated" data-toggle="pill">Bills History</a>
</li>
<li class=""><a href="#generate" data-toggle="pill">Generate New Bill</a>
</li>
</ul>

<!-- Tab panes -->


<div class="tab-content">
<div class="tab-pane fade in active" id="generated">
<!-- <h4>{User} Bills(ALL UP TO DATE) goes here{Table form}</h4> -->
<!-- DB RETRIEVAL search db where id is his and status is processed -->

<div class="table-responsive">
<table class="table table-hover table-striped table-bordered table-condensed">
<thead>
<tr>
<th>Bill No.</th>
<th>Customer</th>
<th>Date</th>
<th>UNITS Consumed</th>
<th>Amount</th>
<th>Due Date</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<?php
$id=$_SESSION['aid'];
$query1 = "SELECT COUNT(user.name) FROM user,bill WHERE user.id=bill.uid AND aid={$id}";
$result1 = mysqli_query($con,$query1);
$row1 = mysqli_fetch_row($result1);
$numrows = $row1[0];
include("paging1.php");
$result = retrieve_bills_generated($_SESSION['aid'],$offset, $rowsperpage);
while($row = mysqli_fetch_assoc($result)){
?>
<tr>
<td><?php echo 'BN_'.$row['bid']?></td>
<td height="50"><?php echo $row['user'] ?></td>
<td><?php echo $row['bdate'] ?></td>
<td><?php echo $row['units'] ?></td>
<td><?php echo '$'.$row['amount'] ?></td>
<td><?php echo $row['ddate'] ?></td>
<td><?php if($row['status'] == 'PENDING') { echo'<span class="badge" style="background: red;">'.
$row["status"].'</span>'; } else { echo'<span class="badge" style="background: green;">'.$row["status"].'</span>';} ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
<?php include("paging2.php"); ?>
</div>
<!-- .table-responsive -->
</div>
<!-- .tab-genereated -->

<div class="tab-pane fade" id="generate">


<!-- <h4>{User} due bill info goes here and each linked to a transaction form </h4> -->
<!-- create a clickable list of USERS leading to a modal form to fill up units -->
35

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

<?php
$sql = "SELECT curdate1()";
$result = mysqli_query($con,$sql);
if($result === FALSE) {
echo "FAILED";
die(mysql_error());
}
$row = mysqli_fetch_row($result);
// echo $row[0];
if ($row[0] == 1) {
include("generate_bill_table.php") ;
}
else
{
//echo "<div class=\"text-danger text-center\" style=\"padding-top:100px; font-size: 30px;\">";
//echo " <b><u>BILL TO BE GENERATED ONLY ON THE FIRST OF THE MONTH</u></b>";
//echo " </div>" ;

include("generate_bill_table.php") ;
}

?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

<?php
require_once("footer.php");
require_once("js.php");
?>
</body>
</html>

billamtcount.php

<?php

include('../Includes/config.php');

$result = mysqli_query($con, 'SELECT SUM(payable) AS value_sum FROM transaction WHERE status = "PROCESSED"');
$row = mysqli_fetch_assoc($result);
echo '$'.$sum = $row['value_sum'];

?>

Complaint.php

<?php
require_once('head_html.php');
require_once('../Includes/config.php');
require_once('../Includes/session.php');
require_once('../Includes/admin.php');
if ($logged==false) {
header("Location:../index.php");
}
?>
<body>

<div id="wrapper">

<?php
require_once("nav.php");
require_once("sidebar.php");
36

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

?>

<!-- Page Content -->


<div id="page-content-wrapper">

<div class="container-fluid">

<!-- Page Heading -->


<div class="row">
<div class="col-lg-12">
<h1 class="page-header">
Complaints
</h1>
<ol class="breadcrumb">
<li>Complaint</li>
<li class="active">Not Processed</li>
</ol>
</div>

<div class="table-responsive" style="padding-top: 0">


<table class="table table-hover table-striped table-bordered table-condensed">
<thead>
<tr>
<th>Complaint No.</th>
<th>User</th>
<th>Complaint</th>
<th>Status</th>
<th>Process</th>
</tr>
</thead>
<tbody>
<?php
$id=$_SESSION['aid'];
$query1 = "SELECT COUNT(complaint.id) FROM user , complaint ";
$query1.= " WHERE complaint.uid=user.id AND status='NOT PROCESSED' AND complaint.aid={$id}";
$result1 = mysqli_query($con,$query1);
$row1 = mysqli_fetch_row($result1);
$numrows = $row1[0];
include("paging1.php");
$result = retrieve_complaints_history($_SESSION['aid'],$offset, $rowsperpage);
while($row = mysqli_fetch_assoc($result)){
?>
<tr>
<td><?php echo 'CA-'.$row['id'] ?></td>
<td height="50"><?php echo $row['uname'] ?></td>
<td><?php echo $row['complaint'] ?></td>
<td><?php echo $row['status'] ?></td>
<td width="70">
<form action="process_complaint.php" method="post">
<input type="hidden" name="cid" value=<?php echo $row['id'] ?> >
<button type="submit" name="complaint_process" class="btn btn-success form-control">PROCESS COMPLAINT
</button>
</form>

</td>
</tr>
<?php
}
?>
</tbody>
</table>
<?php include("paging2.php"); ?>
</div>
</div>
</div>
</div>

<?php
require_once("footer.php");

37

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

require_once("js.php");
?>
</body>
</html>

Footer.php
<!-- FOOTER -->
<!-- <a href="#menu-toggle" class="btn btn-primary toggler" id="menu-toggle" style="z-index:1000;position:absolute;left:30px;bottom:0px"><i
class="icon-circle-arrow-left"></i>Toggle DASH</a> -->
<footer class="text-center">
<div class="footer-below">
<div class="container">
Created by <a href="">BILLING </a> SYSTEM
</div>
</div>
</footer>

Generate_bill.php

<?php
require_once('../Includes/config.php');
require_once('../Includes/session.php');
require_once('../Includes/admin.php');

$aid = $_SESSION['aid'];
//set dafaulted variables

$query = "SELECT curdate() AS bdate , adddate( curdate(),INTERVAL 30 DAY ) AS ddate , user.id AS uid , user.name AS uname FROM user ";
$result = mysqli_query($con,$query);
$row = mysqli_fetch_assoc($result);

$bdate = $row['bdate'];
$ddate = $row['ddate'];

// if (isset($_POST['bdate'])) {
// $bdate = $_POST['bdate'];
// }
// if (isset($_POST['ddate'])) {
// $ddate = $_POST['ddate']; }
if (isset($_POST['uid'])) {
$uid = $_POST['uid'];
}if (isset($_POST['units'])) {
$units = $_POST['units'];
}if (isset($_POST['uname'])) {
$uname = $_POST['uname'];
}

if (isset($_POST['generate_bill'])) {
if(isset($_POST["units"]) && !empty($_POST["units"]))
{
// CONVERTING UNITS TO AMOUNT
$query1 = "call unitstoamount({$units} , @x)";
$result1 = mysqli_query($con,$query1);

// INSERTING VALUES INTO BILL


$query = " INSERT INTO bill (aid , uid , units , amount , status , bdate , ddate )";
$query .= " VALUES ( {$aid} , {$uid} , {$units} , @x , 'PENDING' , '{$bdate}' , '{$ddate}' )";
$result2 = mysqli_query($con,$query);
if (!mysqli_query($con,$query1))
{
die('Error: ' . mysqli_error($con));
}

// INSERTING VALUES INTO TRANSACTION

$query2 = "SELECT id , amount FROM bill WHERE aid={$aid} AND uid={$uid} AND units={$units} ";
$query2 .= "AND status='PENDING' AND bdate='{$bdate}' AND ddate='{$ddate}' ";
38

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

$result3 =mysqli_query($con,$query2);
if (!mysqli_query($con,$query2))
{
die('Error: ' . mysqli_error($con));
}
$row = mysqli_fetch_row($result3);

$bid = $row[0];$amount=$row[1];
insert_into_transaction($bid,$amount);

}
}
header("Location:bill.php");
?>

Process_complaint.php
<?php
require_once('../Includes/config.php');
$cid=$_POST['cid'];
echo "$cid";
if (isset($_POST["complaint_process"])) {
if(isset($_POST["cid"])) {
$query = "UPDATE complaint SET status='PROCESSED' WHERE id={$cid}";
// echo $query;
$result = mysqli_query($con,$query);
if($result === FALSE) {
die(mysql_error()); // TODO: better error handling
}
}
}
header("Location:complaint.php");
?>
Main.css
/*
* Project Name:(ELECTRICITY BILL MANAGEMENT SYSTEM)
*/

body {
background-color: #f2f2f2;
font-family: 'Raleway', sans-serif;
font-weight: 300;
font-size: 16px;
color: #555;
-webkit-font-smoothing: antialiased;
-webkit-overflow-scrolling: touch;
}
/* Titles */

h1, h2, h3, h4, h5, h6 ,a{


font-family: Lato,Arial, Helvetica, sans-serif;
font-weight: 300;
color: #333;
}
h1 {
font-size: 40px;
padding-bottom: 10px;
}
h3 {
color: #95a5a6;
font-weight: 400;
}
39

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

h4 {
color: #95a5a6;
font-weight: 400;
font-size: 20px;
}
/* Paragraph & Typographic */
p{
line-height: 28px;
margin-bottom: 25px;
font-size: 16px;
}
.centered {
text-align: center;
}

a{
color: #0e175b;
word-wrap: break-word;
-webkit-transition: color 0.1s ease-in, background 0.1s ease-in;
-moz-transition: color 0.1s ease-in, background 0.1s ease-in;
-ms-transition: color 0.1s ease-in, background 0.1s ease-in;
-o-transition: color 0.1s ease-in, background 0.1s ease-in;
transition: color 0.1s ease-in, background 0.1s ease-in;
}
a:hover, a:focus {
color: #7b7b7b;
text-decoration: none;
outline: 0;
}
hr {
display: block;
height: 1px;
border: 0;
border-top: 1px solid #ccc;
margin: 1em 0;
padding: 0;
}
.navbar-default {
background-color: rgba(38,46,107,.8);
border-color: transparent;
}
.navbar-header > a:hover {
color:#e9eaf0;
}
.navbar-default .navbar-brand {
color: white;
font-size: 25px;
font-weight: 100;
margin: 0px;
padding-top:20px;
}
.mt {
margin-top: 40px;
margin-bottom: 40px;
}
.form-control {
height: 42px;
font-size: 18px;
width: 280px;
}
i{
margin: 8px;
color: #0e175b;
}
#headerwrap {
background-color: #0e175b;
padding-top: 70px;
padding-bottom: 0px;
background-attachment: relative;
background-position: center center;

40

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

min-height: 650px;
width: 100%;
-webkit-background-size: 100%;
-moz-background-size: 100%;
-o-background-size: 100%;
background-size: 100%;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.darkhearderwrap{
background-color: rgba(0,0,0,.27);
margin-top: -50px;
padding-top: 100px;
padding-bottom: 3.2%;
}
#headerwrap h1 {
margin-top: 60px;
margin-bottom: 15px;
color: white;
font-size: 45px;
font-weight: 300;
letter-spacing: 1px;
text-align: center;
}
#headerwrap p , .checkbox {
color: #d8e5e5;
}
#headerwrap>.container>.row>.col-lg-6:first-child{
padding-top: 100px;
}
Signup.php
<?php
require_once("Includes/session.php");
$nameErr = $phoneErr = $addrErr = $emailErr = $passwordErr = $confpasswordErr = "";
$name = $email = $password = $confpassword = $address = "";
$flag=0;
//CHECK IF A VALID FORM STRING
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
if(isset($_POST["reg_submit"])) {
$email = test_input($_POST['email']);
$password = test_input($_POST["inputPassword"]);
$confpassword = test_input($_POST["confirmPassword"]);
$address = test_input($_POST["address"]);
$email = test_input($_POST['email']);
// NAME VALIDATION
if (empty($_POST["name"])) {
$nameErr = "Name is required";
$flag=1;
echo $nameErr;
} else {
$name = test_input($_POST["name"]);
// check if name only contains letters and whitespace
if (!preg_match("/^[a-zA-Z ]*$/",$name)) {
$nameErr = "Only letters and white space allowed";
$flag=1;
echo $nameErr;
}
}
// EMAIL VALIDATION
if (empty($_POST["email"])) {
$emailErr = "Email is required";
$flag=1;
} else {

41

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

$email = test_input($_POST["email"]);
// check if e-mail address is well-formed
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$emailErr = "Invalid email format";
$flag=1;
echo $emailErr;
}
}
// PASSWORD VALIDATION
if (empty($_POST["inputPassword"]))
{
$passwordErr = "PASSWORD missing";
$flag=1;
}
else
{
$password = $_POST["inputPassword"];
}
// CONFIRM PASSWORD
if (empty($_POST["confirmPassword"]))
{
$confpasswordErr = "missing";
$flag=1;
}
else
{
if($_POST['confirmPassword'] == $password)
{
$confpassword = $_POST["confirmPassword"];
}
else
{
$confpasswordErr = "Not same as password!";
$flag = 1;
}
}
// ADDRESS VALIDATION
if (empty($_POST["address"])) {
$addrErr = "Address is required";
$flag=1;
echo $addrErr;
} else {
$address = test_input($_POST["address"]);
}
}
//CONTACT VALIDATION
if (empty($_POST["contactNo"])) {
$flag=1;
$contactNo = "";
// echo "error here";
} else {
$contactNo = test_input($_POST["contactNo"]);
if(!preg_match("/^d{10}$/", $_POST["contactNo"])){
$phoneErr="10 digit phone no allowed.";
echo $_POST['contactNo'];
}
}

// Only if succeed from the validation thourough put


echo $flag;
if($flag == 0)
{
require_once("Includes/config.php");
$sql = "INSERT INTO user (`name`,`email`,`phone`,`pass`,`address`)
VALUES('$name','$email','$contactNo','$password','$address')";
echo $sql;
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
}

42

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

header("Location:index.php");
}
}
?>
<form action="signup.php" method="post" class="form-horizontal" role="form" onsubmit="return validateForm()">
<center>
<div class="row form-group">
<div class="col-md-12">
<input type="name" class="form-control" name="name" id="name" placeholder="Full Name" required>
<!-- <label><?php echo $nameErr;?></label> -->
</div>
</div>
<div class="form-group">
<div class="col-md-12">
<input type="email" class="form-control" name="email" id="email" placeholder="Email" required>
<!-- <label><?php echo $emailErr;?></label> -->
</div>
</div>
<div class="form-group">
<div class="col-md-12">
<input type="password" class="form-control" name="inputPassword" id="inputPassword" placeholder="Password" required>
<!-- <label><?php echo $passwordErr;?></label> -->
</div>
</div>
<div class="form-group">
<div class="col-md-12">
<input type="password" class="form-control" name="confirmPassword" placeholder="Confirm Password" required>
<!-- <label><?php echo $confpasswordErr;?></label><label><?php echo $confpasswordErr;?></label> -->
</div>
</div>
<div class="form-group">
<div class="col-md-12">
<input type="tel" class="form-control" name="contactNo" placeholder="Contact No." required>
<!-- <label><?php echo $phoneErr;?></label> -->
</div>
</div>
<div class="form-group">
<div class="col-md-12">
<input type="address" class="form-control" name="address" placeholder="Address" required>
<!-- <label><?php echo $addrErr;?></label> -->
</div>
</div>
<div class="form-group">
<div class="col-md-10">
<button name="reg_submit" class="btn btn-primary">Sign Up</button>
</div>
</div>
</center>
</form>
Login.php
<?php
require_once("Includes/config.php");
require_once("Includes/session.php");
/*if(!(isset($_POST['email']&&isset($_POST['pass'])))) {
location('index.php');
}
}
?>
<form action="index.php" class="navbar-form navbar-right" role="form" method="post">
<div class="form-group">
<input type="text" placeholder="Email" name="email" id="email" class="form-control">
</div>
<div class="form-group">
<input type="password" placeholder="Password" name="pass" id="pass" class="form-control">
</div>
<button type="login_submit" class="btn btn-success" onclick=" validateForm();">Sign In</button>
</form>

43

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

CONCLUSION

The electricity bill management project intricately addresses the multifaceted aspects of billing, user
information management, complaint resolution, and transaction tracking within the realm of
electricity consumption. Structured with precision, the database encompasses key tables for users,
administrators, bills, transactions, and complaints, each playing a vital role in the seamless operation
of the system.

The project's functionality overview emphasizes the storage of user details, including name, email,
phone, address, and passwords, ensuring a robust foundation for user-centric interactions.
Administrators are afforded detailed records, enabling effective system management. The inclusion
of bills and transactions tables meticulously captures essential information, such as consumed units,
generated amounts, status, and due dates, providing a comprehensive snapshot of financial
transactions and obligations. Concurrently, the complaints table catalogues user grievances,
complete with status indicators for efficient tracking and resolution. A linchpin in the database
design is the implementation of foreign key constraints, fostering data integrity across tables. The
status column within pivotal tables, including bills, complaints, and transactions, adds a dynamic
layer by signifying the current state of processes such as bill payment, complaint resolution, and
transaction processing.

Anticipating scalability challenges as the user base expands, the project emphasizes the optimization
of database queries and scalability measures. This strategic approach ensures that the system can
adeptly handle increasing demands, maintaining optimal performance levels and user satisfaction.
Documentation and maintenance emerge as cornerstones for the project's longevity. Proper
documentation of the database schema, codebase intricacies, and system functionalities not only
facilitates ongoing maintenance but also lays a robust foundation for future updates and development
initiatives.

44

Downloaded by Vaishnavi Kandekar ([email protected])


lOMoARcPSD|24562605

The significance of testing and validation is underscored, as these processes are imperative for
ensuring the accuracy and reliability of the system's functionalities in handling billing, transactions,
and complaints. In total, the presented database project forms a resilient and scalable foundation for
the online electricity bill management system, poised to evolve with the dynamic landscape of user
needs and technological advancements.

45

Downloaded by Vaishnavi Kandekar ([email protected])

You might also like