Source Code database_connection.php invoice.php prepare(" SELECT * FROM tbl_order ORDER BY order_id DESC "); $statement->execute(); $all_result = $statement->fetchAll(); $total_rows = $statement->rowCount(); if(isset($_POST["create_invoice"])) { $order_total_before_tax = 0; $order_total_tax1 = 0; $order_total_tax2 = 0; $order_total_tax3 = 0; $order_total_tax = 0; $order_total_after_tax = 0; $statement = $connect->prepare(" INSERT INTO tbl_order (order_no, order_date, order_receiver_name, order_receiver_address, order_total_before_tax, order_total_tax1, order_total_tax2, order_total_tax3, order_total_tax, order_total_after_tax, order_datetime) VALUES (:order_no, :order_date, :order_receiver_name, :order_receiver_address, :order_total_before_tax, :order_total_tax1, :order_total_tax2, :order_total_tax3, :order_total_tax, :order_total_after_tax, :order_datetime) "); $statement->execute( array( ':order_no' => trim($_POST["order_no"]), ':order_date' => trim($_POST["order_date"]), ':order_receiver_name' => trim($_POST["order_receiver_name"]), ':order_receiver_address' => trim($_POST["order_receiver_address"]), ':order_total_before_tax' => $order_total_before_tax, ':order_total_tax1' => $order_total_tax1, ':order_total_tax2' => $order_total_tax2, ':order_total_tax3' => $order_total_tax3, ':order_total_tax' => $order_total_tax, ':order_total_after_tax' => $order_total_after_tax, ':order_datetime' => date("Y-m-d") ) ); $statement = $connect->query("SELECT LAST_INSERT_ID()"); $order_id = $statement->fetchColumn(); for($count=0; $count<$_POST["total_item"]; $count++) { $order_total_before_tax = $order_total_before_tax + floatval(trim($_POST["order_item_actual_amount"][$count])); $order_total_tax1 = $order_total_tax1 + floatval(trim($_POST["order_item_tax1_amount"][$count])); $order_total_tax2 = $order_total_tax2 + floatval(trim($_POST["order_item_tax2_amount"][$count])); $order_total_tax3 = $order_total_tax3 + floatval(trim($_POST["order_item_tax3_amount"][$count])); $order_total_after_tax = $order_total_after_tax + floatval(trim($_POST["order_item_final_amount"][$count])); $statement = $connect->prepare(" INSERT INTO tbl_order_item (order_id, item_name, order_item_quantity, order_item_price, order_item_actual_amount, order_item_tax1_rate, order_item_tax1_amount, order_item_tax2_rate, order_item_tax2_amount, order_item_tax3_rate, order_item_tax3_amount, order_item_final_amount) VALUES (:order_id, :item_name, :order_item_quantity, :order_item_price, :order_item_actual_amount, :order_item_tax1_rate, :order_item_tax1_amount, :order_item_tax2_rate, :order_item_tax2_amount, :order_item_tax3_rate, :order_item_tax3_amount, :order_item_final_amount) "); $statement->execute( array( ':order_id' => $order_id, ':item_name' => trim($_POST["item_name"][$count]), ':order_item_quantity' => trim($_POST["order_item_quantity"][$count]), ':order_item_price' => trim($_POST["order_item_price"][$count]), ':order_item_actual_amount' => trim($_POST["order_item_actual_amount"][$count]), ':order_item_tax1_rate' => trim($_POST["order_item_tax1_rate"][$count]), ':order_item_tax1_amount' => trim($_POST["order_item_tax1_amount"][$count]), ':order_item_tax2_rate' => trim($_POST["order_item_tax2_rate"][$count]), ':order_item_tax2_amount' => trim($_POST["order_item_tax2_amount"][$count]), ':order_item_tax3_rate' => trim($_POST["order_item_tax3_rate"][$count]), ':order_item_tax3_amount' => trim($_POST["order_item_tax3_amount"][$count]), ':order_item_final_amount' => trim($_POST["order_item_final_amount"][$count]) ) ); } $order_total_tax = $order_total_tax1 + $order_total_tax2 + $order_total_tax3; $statement = $connect->prepare(" UPDATE tbl_order SET order_total_before_tax = :order_total_before_tax, order_total_tax1 = :order_total_tax1, order_total_tax2 = :order_total_tax2, order_total_tax3 = :order_total_tax3, order_total_tax = :order_total_tax, order_total_after_tax = :order_total_after_tax WHERE order_id = :order_id "); $statement->execute( array( ':order_total_before_tax' => $order_total_before_tax, ':order_total_tax1' => $order_total_tax1, ':order_total_tax2' => $order_total_tax2, ':order_total_tax3' => $order_total_tax3, ':order_total_tax' => $order_total_tax, ':order_total_after_tax' => $order_total_after_tax, ':order_id' => $order_id ) ); header("location:invoice.php"); } if(isset($_POST["update_invoice"])) { $order_total_before_tax = 0; $order_total_tax1 = 0; $order_total_tax2 = 0; $order_total_tax3 = 0; $order_total_tax = 0; $order_total_after_tax = 0; $order_id = $_POST["order_id"]; $statement = $connect->prepare(" DELETE FROM tbl_order_item WHERE order_id = :order_id "); $statement->execute( array( ':order_id' => $order_id ) ); for($count=0; $count<$_POST["total_item"]; $count++) { $order_total_before_tax = $order_total_before_tax + floatval(trim($_POST["order_item_actual_amount"][$count])); $order_total_tax1 = $order_total_tax1 + floatval(trim($_POST["order_item_tax1_amount"][$count])); $order_total_tax2 = $order_total_tax2 + floatval(trim($_POST["order_item_tax2_amount"][$count])); $order_total_tax3 = $order_total_tax3 + floatval(trim($_POST["order_item_tax3_amount"][$count])); $order_total_after_tax = $order_total_after_tax + floatval(trim($_POST["order_item_final_amount"][$count])); $statement = $connect->prepare(" INSERT INTO tbl_order_item (order_id, item_name, order_item_quantity, order_item_price, order_item_actual_amount, order_item_tax1_rate, order_item_tax1_amount, order_item_tax2_rate, order_item_tax2_amount, order_item_tax3_rate, order_item_tax3_amount, order_item_final_amount) VALUES (:order_id, :item_name, :order_item_quantity, :order_item_price, :order_item_actual_amount, :order_item_tax1_rate, :order_item_tax1_amount, :order_item_tax2_rate, :order_item_tax2_amount, :order_item_tax3_rate, :order_item_tax3_amount, :order_item_final_amount) "); $statement->execute( array( ':order_id' => $order_id, ':item_name' => trim($_POST["item_name"][$count]), ':order_item_quantity' => trim($_POST["order_item_quantity"][$count]), ':order_item_price' => trim($_POST["order_item_price"][$count]), ':order_item_actual_amount' => trim($_POST["order_item_actual_amount"][$count]), ':order_item_tax1_rate' => trim($_POST["order_item_tax1_rate"][$count]), ':order_item_tax1_amount' => trim($_POST["order_item_tax1_amount"][$count]), ':order_item_tax2_rate' => trim($_POST["order_item_tax2_rate"][$count]), ':order_item_tax2_amount' => trim($_POST["order_item_tax2_amount"][$count]), ':order_item_tax3_rate' => trim($_POST["order_item_tax3_rate"][$count]), ':order_item_tax3_amount' => trim($_POST["order_item_tax3_amount"][$count]), ':order_item_final_amount' => trim($_POST["order_item_final_amount"][$count]) ) ); $result = $statement->fetchAll(); } $order_total_tax = $order_total_tax1 + $order_total_tax2 + $order_total_tax3; $statement = $connect->prepare(" UPDATE tbl_order SET order_no = :order_no, order_date = :order_date, order_receiver_name = :order_receiver_name, order_receiver_address = :order_receiver_address, order_total_before_tax = :order_total_before_tax, order_total_tax1 = :order_total_tax1, order_total_tax2 = :order_total_tax2, order_total_tax3 = :order_total_tax3, order_total_tax = :order_total_tax, order_total_after_tax = :order_total_after_tax WHERE order_id = :order_id "); $statement->execute( array( ':order_no' => trim($_POST["order_no"]), ':order_date' => trim($_POST["order_date"]), ':order_receiver_name' => trim($_POST["order_receiver_name"]), ':order_receiver_address' => trim($_POST["order_receiver_address"]), ':order_total_before_tax' => $order_total_before_tax, ':order_total_tax1' => $order_total_tax1, ':order_total_tax2' => $order_total_tax2, ':order_total_tax3' => $order_total_tax3, ':order_total_tax' => $order_total_tax, ':order_total_after_tax' => $order_total_after_tax, ':order_id' => $order_id ) ); $result = $statement->fetchAll(); header("location:invoice.php"); } if(isset($_GET["delete"]) && isset($_GET["id"])) { $statement = $connect->prepare("DELETE FROM tbl_order WHERE order_id = :id"); $statement->execute( array( ':id' => $_GET["id"] ) ); $statement = $connect->prepare( "DELETE FROM tbl_order_item WHERE order_id = :id"); $statement->execute( array( ':id' => $_GET["id"] ) ); header("location:invoice.php"); } ?>

Create Invoice

To,
RECEIVER (BILL TO)
Reverse Charge

Sr No. Item Name Quantity Price Actual Amt. Tax1 (%) Tax2 (%) Tax3 (%) Total
Rate Amt. Rate Amt. Rate Amt.
1
Total
prepare(" SELECT * FROM tbl_order WHERE order_id = :order_id LIMIT 1 "); $statement->execute( array( ':order_id' => $_GET["id"] ) ); $result = $statement->fetchAll(); foreach($result as $row) { ?>

Edit Invoice

To,
RECEIVER (BILL TO)
Reverse Charge

prepare(" SELECT * FROM tbl_order_item WHERE order_id = :order_id "); $statement->execute( array( ':order_id' => $_GET["id"] ) ); $item_result = $statement->fetchAll(); $m = 0; foreach($item_result as $sub_row) { $m = $m + 1; ?>
Sr No. Item Name Quantity Price Actual Amt. Tax1 (%) Tax2 (%) Tax3 (%) Total
Rate Amt. Rate Amt. Rate Amt.
" /> "/> " /> " readonly /> " /> " /> " /> " /> " /> " /> " />
Total
" />

Invoice System Using Jquery PHP Mysql and Bootstrap


Create

0) { foreach($all_result as $row) { echo ' '; } } ?>
Invoice No. Invoice Date Receiver Name Invoice Total PDF Edit Delete
'.$row["order_no"].' '.$row["order_date"].' '.$row["order_receiver_name"].' '.$row["order_total_after_tax"].' PDF

pdf.php print_invoice.php prepare(" SELECT * FROM tbl_order WHERE order_id = :order_id LIMIT 1 "); $statement->execute( array( ':order_id' => $_GET["id"] ) ); $result = $statement->fetchAll(); foreach($result as $row) { $output .= '
Invoice
To,
RECEIVER (BILL TO)
Name : '.$row["order_receiver_name"].'
Billing Address : '.$row["order_receiver_address"].'
Reverse Charge
Invoice No. : '.$row["order_no"].'
Invoice Date : '.$row["order_date"].'

'; $statement = $connect->prepare( "SELECT * FROM tbl_order_item WHERE order_id = :order_id" ); $statement->execute( array( ':order_id' => $_GET["id"] ) ); $item_result = $statement->fetchAll(); $count = 0; foreach($item_result as $sub_row) { $count++; $output .= ' '; } $output .= ' '; $output .= '
Sr No. Item Name Quantity Price Actual Amt. Tax1 (%) Tax2 (%) Tax3 (%) Total
Rate Amt. Rate Amt. Rate Amt.
'.$count.' '.$sub_row["item_name"].' '.$sub_row["order_item_quantity"].' '.$sub_row["order_item_price"].' '.$sub_row["order_item_actual_amount"].' '.$sub_row["order_item_tax1_rate"].' '.$sub_row["order_item_tax1_amount"].' '.$sub_row["order_item_tax2_rate"].' '.$sub_row["order_item_tax2_amount"].' '.$sub_row["order_item_tax3_rate"].' '.$sub_row["order_item_tax3_amount"].' '.$sub_row["order_item_final_amount"].'
Total '.$row["order_total_after_tax"].'
Total Amt. Before Tax : '.$row["order_total_before_tax"].'
Add : Tax1 : '.$row["order_total_tax1"].'
Add : Tax2 : '.$row["order_total_tax2"].'
Add : Tax3 : '.$row["order_total_tax3"].'
Total Tax Amt. : '.$row["order_total_tax"].'
Total Amt. After Tax : '.$row["order_total_after_tax"].'
'; } $pdf = new Pdf(); $file_name = 'Invoice-'.$row["order_no"].'.pdf'; $pdf->loadHtml($output); $pdf->render(); $pdf->stream($file_name, array("Attachment" => false)); } ?> Database -- -- Database: `testing4` -- -- -------------------------------------------------------- -- -- Table structure for table `tbl_order` -- CREATE TABLE IF NOT EXISTS `tbl_order` ( `order_id` int(11) NOT NULL, `order_no` varchar(50) NOT NULL, `order_date` date NOT NULL, `order_receiver_name` varchar(250) NOT NULL, `order_receiver_address` text NOT NULL, `order_total_before_tax` decimal(10,2) NOT NULL, `order_total_tax1` decimal(10,2) NOT NULL, `order_total_tax2` decimal(10,2) NOT NULL, `order_total_tax3` decimal(10,2) NOT NULL, `order_total_tax` decimal(10,2) NOT NULL, `order_total_after_tax` decimal(10,2) NOT NULL, `order_datetime` datetime NOT NULL ) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=latin1; -- -- Table structure for table `tbl_order_item` -- CREATE TABLE IF NOT EXISTS `tbl_order_item` ( `order_item_id` int(11) NOT NULL, `order_id` int(11) 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_actual_amount` decimal(10,2) NOT NULL, `order_item_tax1_rate` decimal(10,2) NOT NULL, `order_item_tax1_amount` decimal(10,2) NOT NULL, `order_item_tax2_rate` decimal(10,2) NOT NULL, `order_item_tax2_amount` decimal(10,2) NOT NULL, `order_item_tax3_rate` decimal(10,2) NOT NULL, `order_item_tax3_amount` decimal(10,2) NOT NULL, `order_item_final_amount` decimal(10,2) NOT NULL ) ENGINE=InnoDB AUTO_INCREMENT=2008 DEFAULT CHARSET=latin1; -- -- Indexes for table `tbl_order` -- ALTER TABLE `tbl_order` ADD PRIMARY KEY (`order_id`); -- -- Indexes for table `tbl_order_item` -- ALTER TABLE `tbl_order_item` ADD PRIMARY KEY (`order_item_id`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `tbl_order` -- ALTER TABLE `tbl_order` MODIFY `order_id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=1; -- -- AUTO_INCREMENT for table `tbl_order_item` -- ALTER TABLE `tbl_order_item` MODIFY `order_item_id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=1;