I am extending my previous tutorials. I’ll add an invoice management system.
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.
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.
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:
-- -- Table structure for table `orders` -- CREATE TABLE `orders` ( `order_id` int(11) NOT NULL, `user_id` int(11) NOT NULL, `order_date` timestamp NOT NULL DEFAULT current_timestamp(), `order_receiver_name` varchar(250) NOT NULL, `order_receiver_address` text NOT NULL, `order_total_before_tax` decimal(10,2) NOT NULL, `order_total_tax` decimal(10,2) NOT NULL, `order_tax_per` varchar(250) NOT NULL, `order_total_after_tax` double(10,2) NOT NULL, `order_amount_paid` decimal(10,2) NOT NULL, `order_total_amount_due` decimal(10,2) NOT NULL, `note` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `orders` -- INSERT INTO `orders` (`order_id`, `user_id`, `order_date`, `order_receiver_name`, `order_receiver_address`, `order_total_before_tax`, `order_total_tax`, `order_tax_per`, `order_total_after_tax`, `order_amount_paid`, `order_total_amount_due`, `note`) VALUES (684, 1, '2021-11-15 15:33:26', '1', 'test', '157.00', '0.00', '', 157.00, '0.00', '157.00', ''); -- -------------------------------------------------------- -- -- Table structure for table `order_details` -- CREATE TABLE `order_details` ( `order_item_id` int(11) NOT NULL, `order_id` int(11) NOT NULL, `item_code` varchar(250) NOT NULL, `item_name` varchar(250) NOT NULL, `order_item_quantity` decimal(10,2) NOT NULL, `order_item_price` decimal(10,2) NOT NULL, `order_item_final_amount` decimal(10,2) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `order_details` -- INSERT INTO `order_details` (`order_item_id`, `order_id`, `item_code`, `item_name`, `order_item_quantity`, `order_item_price`, `order_item_final_amount`) VALUES (4368, 684, '1', 'test', '1.00', '45.00', '45.00'), (4369, 684, '3', 'test2', '2.00', '56.00', '112.00');
The files & folders structure for invoice management:
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.
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.
if (isset($_GET['logout'])) < session_destroy(); unset($_SESSION['user_info']); header("location: ../../login.php"); >include 'action.php'; $invoice = new Invoice(); if(!empty($_POST['companyName']) && $_POST['companyName']) < $invoice->saveInvoice($_POST); header("Location:index.php"); > ?>Create an Invoice