Invoice Management System Using PHP & MySQL

in this post, We will explain how to create your own invoice system with PHP & MySQL.It’s also called Billing Management Systems, we’ll create invoice, list all invoices and print invoice.

I am extending my previous tutorials. I’ll add an invoice management system.

What’s Invoice Management Systems

Because the majority of transactions are now done online, invoice or billing management systems are increasingly popular. Every vendor and buyer now requires an invoicing system to manage online billing.

in this article, we’ll cover following functionalities:

  • Create a new Invoice
  • Edit a Invoice
  • Listing invoice
  • Print Invoice

Create Billing Management Systems

Let’s create a PHP project to develop invoice and billing system using PHP and MySQL.I am extending previous tutorial Create Admin Login and Logout Page.

The above post will have normal login as well as admin, I am just using the above source code and functionality.

This article will walk you through the process of creating a full invoice system, including how to create and edit invoices, as well as how to print invoices and convert them to PDF format. We will also make the source code available for download.

Database changes

I’ll update login table, I have added new mobile column into the ‘login’ table:

mobile varchar(255) DEFAULT NULL,
I have created two tables for order and order_details:

The files & folders structure for invoice management:

folder-structure-invoice

We’ll create an invoice module in the admin folder.

Let’s create the above blank files:

admin/ajax_admin.php : This file contains admin ajax logic.
invoice/action.php : It contains all actions method that will fetach invloices,create,edit and delete method.
invoice/create.php : The HTML UI for add a invoice.
invoice/edit.php : The HTML UI for editing a invoice.
invoice/index.php : The HTML UI for listing all invoices.
invoice/print.php : The HTML UI to display invoice details and print.

Create Invoice Form

Open create.php file and added below HTML code into this file.I have included all files that need to use to create a new invoice.

PHP method To Create a new invoice

Let’s add the below code into the action.php file:

sidebar-invoice

Listing all invoices

Let’s create a listing of all invoices into the index.php file, also create methods to get data from database. The getInvoiceList() to get list logged in user’s invoices list.

We have also added action methods to edit, print and delete invoices.

Action method to get All invoices

Let’s add the below methods into the action.php file:

listing-invoice

Edit an Invoice

Let’s create a edit UI and php method to update existing invoice. open edit.php file and added below code:

PHP method To Update an invoice

Let’s add the below code into the action.php file:

Delete an Invoice

Let’s create a delete invoice functionality using jquery ajax, the user will click the delete icon from the listing, the confirmation box will display, once the user confirms the action, the invoice ll delete from the database.

PHP method To Delete an invoice

Let’s add the below code into the ajax_admin.php file:

Action method to delete Invoice

Let’s create two methods into action.php, that’ll delete order and its details from mysql database table:

Print and Download an Invoice

Let’s create a print and download invoice functionality, I am using PHP library Dompdf to create PDF from HTML.

In the print.php file, we will add functionality to create invoice PDFs so that users may print or download invoices. We’ll use the invoice methods getInvoice() and getInvoiceItems() to get invoice details from database tables.

Added below code into the print.php file:

print-invoice

2 thoughts on “Invoice Management System Using PHP & MySQL

  1. Thank you for this nice work.
    Question: What do you need to do if you want to display a logo at the top right or left side of the the printed invoice?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.