Database Systems Report
Database Systems Report
SUBMITTED BY
Insert name
TABLE OF CONTENTS
1. Abstract 1
2. Introduction 2
4. Methodology 7
5. Requirements 9
6. E-R Diagram 12
8. Database Normalization 17
9. Data Directory 18
12. Conclusion 44
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.
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
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.
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.
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.
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.
With the rapid digital transformation across various industries, the utility sector faces increasing
4
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.
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.
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
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.
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.
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
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.
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.
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:
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.
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
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
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
E R DIAGRAM
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
13
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.
14
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
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
- 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
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
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.
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
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:
|User
|.bill.php
|.complaint.php
19
|.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
|.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
The graphical user interface for Electricity Bill Management system is easy to understand and use
22
23
24
25
26
SOURCE CODE
ebillsystem.sql
DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `unitstoamount` (IN `units` INT(14), OUT `result` INT(14)) BEGIN
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$$
DELIMITER ;
27
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');
28
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');
29
Admin.php
<?php
// require_once("config.php");
$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
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;
$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
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
$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_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");
?>
<div class="container-fluid">
34
<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 -->
<?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
?>
<div class="container-fluid">
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<?php include("paging2.php"); ?>
</div>
</div>
</div>
</div>
<?php
require_once("footer.php");
37
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);
$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
$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 */
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
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
$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'];
}
}
42
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
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
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