In this post we are going to discuss Invoice or Billing Management System by using PHP Script with Jquery. For make Simple Invoice we have use not only PHP JQuery but also we have use Bootstrap Framework and Mysql database also. In this system we will not create Invoice or Billing for one item but here we will make system that will create multiple dynamic item Invoice. This is simple script and this script any one can use for his project or learning purpose like how to developed Invoice System by using Open Source PHP and Jquery with Mysql and Bootstrap. From this post you can gain knowledge to make Simple Billing System in PHP.
This is the time digitization, all type of transaction has been done online, so for here we have make online Invoice system using PHP. By using this script you can make invoice online. In this tutorial you add some other functionality like after making of invoice you can email this invoice to particular person also. In short you can generate digital invoice from this script. After making of invoice you can also convert that invoice into PDF format also. Here we have also discuss how to convert digital invoice into PDF format, so we can also get hard copy of Invoice also. By using this script you can generate invoice by filing simple form in which we have use JQuery for add multiple item.
In this system We can generate new invoice, we can edit or update invoice details, we can delete or remove invoice and lastly we can also generate PDF file from that invoice also and after this we can get print from PDF file also. This way we can generate unlimited invoices from this system. In this system we can add multiple item in single invoice by using Jquery and this form we can also add tax details also and this all calculation has been done by using Jquery. Suppose you want to remove any product from invoice then you can also remove product from Invoice also. In this system all calculation has been done by using JQuery code, so by using this JQuery we can make dynamic product invoice form. And lastly in this system you can also get the details of previously generated invoice also.
This is the time digitization, all type of transaction has been done online, so for here we have make online Invoice system using PHP. By using this script you can make invoice online. In this tutorial you add some other functionality like after making of invoice you can email this invoice to particular person also. In short you can generate digital invoice from this script. After making of invoice you can also convert that invoice into PDF format also. Here we have also discuss how to convert digital invoice into PDF format, so we can also get hard copy of Invoice also. By using this script you can generate invoice by filing simple form in which we have use JQuery for add multiple item.
In this system We can generate new invoice, we can edit or update invoice details, we can delete or remove invoice and lastly we can also generate PDF file from that invoice also and after this we can get print from PDF file also. This way we can generate unlimited invoices from this system. In this system we can add multiple item in single invoice by using Jquery and this form we can also add tax details also and this all calculation has been done by using Jquery. Suppose you want to remove any product from invoice then you can also remove product from Invoice also. In this system all calculation has been done by using JQuery code, so by using this JQuery we can make dynamic product invoice form. And lastly in this system you can also get the details of previously generated invoice also.
Source Code
database_connection.php
<?php
//database_connection.php
$connect = new PDO('mysql:host=localhost;dbname=testing4', 'root', '');
?>
invoice.php
<?php
//invoice.php
include('database_connection.php');
$statement = $connect->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");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="robots" content="noindex, nofollow">
<link rel="stylesheet" href="css/bootstrap.min.css">
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery.dataTables.min.js"></script>
<script src="js/dataTables.bootstrap.min.js"></script>
<link rel="stylesheet" href="css/dataTables.bootstrap.min.css">
<style>
/* Remove the navbar's default margin-bottom and rounded borders */
.navbar {
margin-bottom: 4px;
border-radius: 0;
}
/* Add a gray background color and some padding to the footer */
footer {
background-color: #f2f2f2;
padding: 25px;
}
.carousel-inner img {
width: 100%; /* Set width to 100% */
margin: auto;
min-height:200px;
}
.navbar-brand
{
padding:5px 40px;
}
.navbar-brand:hover
{
background-color:#ffffff;
}
/* Hide the carousel text when the screen is less than 600 pixels wide */
@media (max-width: 600px) {
.carousel-caption {
display: none;
}
}
</style>
</head>
<body>
<style>
.box
{
width: 100%;
max-width: 1390px;
border-radius: 5px;
border:1px solid #ccc;
padding: 15px;
margin: 0 auto;
margin-top:50px;
box-sizing:border-box;
}
</style>
<link rel="stylesheet" href="css/datepicker.css">
<script src="js/bootstrap-datepicker1.js"></script>
<script>
$(document).ready(function(){
$('#order_date').datepicker({
format: "yyyy-mm-dd",
autoclose: true
});
});
</script>
<div class="container-fluid">
<?php
if(isset($_GET["add"]))
{
?>
<form method="post" id="invoice_form">
<div class="table-responsive">
<table class="table table-bordered">
<tr>
<td colspan="2" align="center"><h2 style="margin-top:10.5px">Create Invoice</h2></td>
</tr>
<tr>
<td colspan="2">
<div class="row">
<div class="col-md-8">
To,<br />
<b>RECEIVER (BILL TO)</b><br />
<input type="text" name="order_receiver_name" id="order_receiver_name" class="form-control input-sm" placeholder="Enter Receiver Name" />
<textarea name="order_receiver_address" id="order_receiver_address" class="form-control" placeholder="Enter Billing Address"></textarea>
</div>
<div class="col-md-4">
Reverse Charge<br />
<input type="text" name="order_no" id="order_no" class="form-control input-sm" placeholder="Enter Invoice No." />
<input type="text" name="order_date" id="order_date" class="form-control input-sm" readonly placeholder="Select Invoice Date" />
</div>
</div>
<br />
<table id="invoice-item-table" class="table table-bordered">
<tr>
<th width="7%">Sr No.</th>
<th width="20%">Item Name</th>
<th width="5%">Quantity</th>
<th width="5%">Price</th>
<th width="10%">Actual Amt.</th>
<th width="12.5%" colspan="2">Tax1 (%)</th>
<th width="12.5%" colspan="2">Tax2 (%)</th>
<th width="12.5%" colspan="2">Tax3 (%)</th>
<th width="12.5%" rowspan="2">Total</th>
<th width="3%" rowspan="2"></th>
</tr>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th>Rate</th>
<th>Amt.</th>
<th>Rate</th>
<th>Amt.</th>
<th>Rate</th>
<th>Amt.</th>
</tr>
<tr>
<td><span id="sr_no">1</span></td>
<td><input type="text" name="item_name[]" id="item_name1" class="form-control input-sm" /></td>
<td><input type="text" name="order_item_quantity[]" id="order_item_quantity1" data-srno="1" class="form-control input-sm order_item_quantity" /></td>
<td><input type="text" name="order_item_price[]" id="order_item_price1" data-srno="1" class="form-control input-sm number_only order_item_price" /></td>
<td><input type="text" name="order_item_actual_amount[]" id="order_item_actual_amount1" data-srno="1" class="form-control input-sm order_item_actual_amount" readonly /></td>
<td><input type="text" name="order_item_tax1_rate[]" id="order_item_tax1_rate1" data-srno="1" class="form-control input-sm number_only order_item_tax1_rate" /></td>
<td><input type="text" name="order_item_tax1_amount[]" id="order_item_tax1_amount1" data-srno="1" readonly class="form-control input-sm order_item_tax1_amount" /></td>
<td><input type="text" name="order_item_tax2_rate[]" id="order_item_tax2_rate1" data-srno="1" class="form-control input-sm number_only order_item_tax2_rate" /></td>
<td><input type="text" name="order_item_tax2_amount[]" id="order_item_tax2_amount1" data-srno="1" readonly class="form-control input-sm order_item_tax2_amount" /></td>
<td><input type="text" name="order_item_tax3_rate[]" id="order_item_tax3_rate1" data-srno="1" class="form-control input-sm number_only order_item_tax3_rate" /></td>
<td><input type="text" name="order_item_tax3_amount[]" id="order_item_tax3_amount1" data-srno="1" readonly class="form-control input-sm order_item_tax3_amount" /></td>
<td><input type="text" name="order_item_final_amount[]" id="order_item_final_amount1" data-srno="1" readonly class="form-control input-sm order_item_final_amount" /></td>
<td></td>
</tr>
</table>
<div align="right">
<button type="button" name="add_row" id="add_row" class="btn btn-success btn-xs">+</button>
</div>
</td>
</tr>
<tr>
<td align="right"><b>Total</td>
<td align="right"><b><span id="final_total_amt"></span></b></td>
</tr>
<tr>
<td colspan="2"></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="hidden" name="total_item" id="total_item" value="1" />
<input type="submit" name="create_invoice" id="create_invoice" class="btn btn-info" value="Create" />
</td>
</tr>
</table>
</div>
</form>
<script>
$(document).ready(function(){
var final_total_amt = $('#final_total_amt').text();
var count = 1;
$(document).on('click', '#add_row', function(){
count++;
$('#total_item').val(count);
var html_code = '';
html_code += '<tr id="row_id_'+count+'">';
html_code += '<td><span id="sr_no">'+count+'</span></td>';
html_code += '<td><input type="text" name="item_name[]" id="item_name'+count+'" class="form-control input-sm" /></td>';
html_code += '<td><input type="text" name="order_item_quantity[]" id="order_item_quantity'+count+'" data-srno="'+count+'" class="form-control input-sm number_only order_item_quantity" /></td>';
html_code += '<td><input type="text" name="order_item_price[]" id="order_item_price'+count+'" data-srno="'+count+'" class="form-control input-sm number_only order_item_price" /></td>';
html_code += '<td><input type="text" name="order_item_actual_amount[]" id="order_item_actual_amount'+count+'" data-srno="'+count+'" class="form-control input-sm order_item_actual_amount" readonly /></td>';
html_code += '<td><input type="text" name="order_item_tax1_rate[]" id="order_item_tax1_rate'+count+'" data-srno="'+count+'" class="form-control input-sm number_only order_item_tax1_rate" /></td>';
html_code += '<td><input type="text" name="order_item_tax1_amount[]" id="order_item_tax1_amount'+count+'" data-srno="'+count+'" readonly class="form-control input-sm order_item_tax1_amount" /></td>';
html_code += '<td><input type="text" name="order_item_tax2_rate[]" id="order_item_tax2_rate'+count+'" data-srno="'+count+'" class="form-control input-sm number_only order_item_tax2_rate" /></td>';
html_code += '<td><input type="text" name="order_item_tax2_amount[]" id="order_item_tax2_amount'+count+'" data-srno="'+count+'" readonly class="form-control input-sm order_item_tax2_amount" /></td>';
html_code += '<td><input type="text" name="order_item_tax3_rate[]" id="order_item_tax3_rate'+count+'" data-srno="'+count+'" class="form-control input-sm number_only order_item_tax3_rate" /></td>';
html_code += '<td><input type="text" name="order_item_tax3_amount[]" id="order_item_tax3_amount'+count+'" data-srno="'+count+'" readonly class="form-control input-sm order_item_tax3_amount" /></td>';
html_code += '<td><input type="text" name="order_item_final_amount[]" id="order_item_final_amount'+count+'" data-srno="'+count+'" readonly class="form-control input-sm order_item_final_amount" /></td>';
html_code += '<td><button type="button" name="remove_row" id="'+count+'" class="btn btn-danger btn-xs remove_row">X</button></td>';
html_code += '</tr>';
$('#invoice-item-table').append(html_code);
});
$(document).on('click', '.remove_row', function(){
var row_id = $(this).attr("id");
var total_item_amount = $('#order_item_final_amount'+row_id).val();
var final_amount = $('#final_total_amt').text();
var result_amount = parseFloat(final_amount) - parseFloat(total_item_amount);
$('#final_total_amt').text(result_amount);
$('#row_id_'+row_id).remove();
count--;
$('#total_item').val(count);
});
function cal_final_total(count)
{
var final_item_total = 0;
for(j=1; j<=count; j++)
{
var quantity = 0;
var price = 0;
var actual_amount = 0;
var tax1_rate = 0;
var tax1_amount = 0;
var tax2_rate = 0;
var tax2_amount = 0;
var tax3_rate = 0;
var tax3_amount = 0;
var item_total = 0;
quantity = $('#order_item_quantity'+j).val();
if(quantity > 0)
{
price = $('#order_item_price'+j).val();
if(price > 0)
{
actual_amount = parseFloat(quantity) * parseFloat(price);
$('#order_item_actual_amount'+j).val(actual_amount);
tax1_rate = $('#order_item_tax1_rate'+j).val();
if(tax1_rate > 0)
{
tax1_amount = parseFloat(actual_amount)*parseFloat(tax1_rate)/100;
$('#order_item_tax1_amount'+j).val(tax1_amount);
}
tax2_rate = $('#order_item_tax2_rate'+j).val();
if(tax2_rate > 0)
{
tax2_amount = parseFloat(actual_amount)*parseFloat(tax2_rate)/100;
$('#order_item_tax2_amount'+j).val(tax2_amount);
}
tax3_rate = $('#order_item_tax3_rate'+j).val();
if(tax3_rate > 0)
{
tax3_amount = parseFloat(actual_amount)*parseFloat(tax3_rate)/100;
$('#order_item_tax3_amount'+j).val(tax3_amount);
}
item_total = parseFloat(actual_amount) + parseFloat(tax1_amount) + parseFloat(tax2_amount) + parseFloat(tax3_amount);
final_item_total = parseFloat(final_item_total) + parseFloat(item_total);
$('#order_item_final_amount'+j).val(item_total);
}
}
}
$('#final_total_amt').text(final_item_total);
}
$(document).on('blur', '.order_item_price', function(){
cal_final_total(count);
});
$(document).on('blur', '.order_item_tax1_rate', function(){
cal_final_total(count);
});
$(document).on('blur', '.order_item_tax2_rate', function(){
cal_final_total(count);
});
$(document).on('blur', '.order_item_tax3_rate', function(){
cal_final_total(count);
});
$('#create_invoice').click(function(){
if($.trim($('#order_receiver_name').val()).length == 0)
{
alert("Please Enter Reciever Name");
return false;
}
if($.trim($('#order_no').val()).length == 0)
{
alert("Please Enter Invoice Number");
return false;
}
if($.trim($('#order_date').val()).length == 0)
{
alert("Please Select Invoice Date");
return false;
}
for(var no=1; no<=count; no++)
{
if($.trim($('#item_name'+no).val()).length == 0)
{
alert("Please Enter Item Name");
$('#item_name'+no).focus();
return false;
}
if($.trim($('#order_item_quantity'+no).val()).length == 0)
{
alert("Please Enter Quantity");
$('#order_item_quantity'+no).focus();
return false;
}
if($.trim($('#order_item_price'+no).val()).length == 0)
{
alert("Please Enter Price");
$('#order_item_price'+no).focus();
return false;
}
}
$('#invoice_form').submit();
});
});
</script>
<?php
}
elseif(isset($_GET["update"]) && isset($_GET["id"]))
{
$statement = $connect->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)
{
?>
<script>
$(document).ready(function(){
$('#order_no').val("<?php echo $row["order_no"]; ?>");
$('#order_date').val("<?php echo $row["order_date"]; ?>");
$('#order_receiver_name').val("<?php echo $row["order_receiver_name"]; ?>");
$('#order_receiver_address').val("<?php echo $row["order_receiver_address"]; ?>");
});
</script>
<form method="post" id="invoice_form">
<div class="table-responsive">
<table class="table table-bordered">
<tr>
<td colspan="2" align="center"><h2 style="margin-top:10.5px">Edit Invoice</h2></td>
</tr>
<tr>
<td colspan="2">
<div class="row">
<div class="col-md-8">
To,<br />
<b>RECEIVER (BILL TO)</b><br />
<input type="text" name="order_receiver_name" id="order_receiver_name" class="form-control input-sm" placeholder="Enter Receiver Name" />
<textarea name="order_receiver_address" id="order_receiver_address" class="form-control" placeholder="Enter Billing Address"></textarea>
</div>
<div class="col-md-4">
Reverse Charge<br />
<input type="text" name="order_no" id="order_no" class="form-control input-sm" placeholder="Enter Invoice No." />
<input type="text" name="order_date" id="order_date" class="form-control input-sm" readonly placeholder="Select Invoice Date" />
</div>
</div>
<br />
<table id="invoice-item-table" class="table table-bordered">
<tr>
<th width="7%">Sr No.</th>
<th width="20%">Item Name</th>
<th width="5%">Quantity</th>
<th width="5%">Price</th>
<th width="10%">Actual Amt.</th>
<th width="12.5%" colspan="2">Tax1 (%)</th>
<th width="12.5%" colspan="2">Tax2 (%)</th>
<th width="12.5%" colspan="2">Tax3 (%)</th>
<th width="12.5%" rowspan="2">Total</th>
<th width="3%" rowspan="2"></th>
</tr>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th>Rate</th>
<th>Amt.</th>
<th>Rate</th>
<th>Amt.</th>
<th>Rate</th>
<th>Amt.</th>
</tr>
<?php
$statement = $connect->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;
?>
<tr>
<td><span id="sr_no"><?php echo $m; ?></span></td>
<td><input type="text" name="item_name[]" id="item_name<?php echo $m; ?>" class="form-control input-sm" value="<?php echo $sub_row["item_name"]; ?>" /></td>
<td><input type="text" name="order_item_quantity[]" id="order_item_quantity<?php echo $m; ?>" data-srno="<?php echo $m; ?>" class="form-control input-sm order_item_quantity" value = "<?php echo $sub_row["order_item_quantity"]; ?>"/></td>
<td><input type="text" name="order_item_price[]" id="order_item_price<?php echo $m; ?>" data-srno="<?php echo $m; ?>" class="form-control input-sm number_only order_item_price" value="<?php echo $sub_row["order_item_price"]; ?>" /></td>
<td><input type="text" name="order_item_actual_amount[]" id="order_item_actual_amount<?php echo $m; ?>" data-srno="<?php echo $m; ?>" class="form-control input-sm order_item_actual_amount" value="<?php echo $sub_row["order_item_actual_amount"];?>" readonly /></td>
<td><input type="text" name="order_item_tax1_rate[]" id="order_item_tax1_rate<?php echo $m; ?>" data-srno="<?php echo $m; ?>" class="form-control input-sm number_only order_item_tax1_rate" value="<?php echo $sub_row["order_item_tax1_rate"]; ?>" /></td>
<td><input type="text" name="order_item_tax1_amount[]" id="order_item_tax1_amount<?php echo $m; ?>" data-srno="<?php echo $m; ?>" readonly class="form-control input-sm order_item_tax1_amount" value="<?php echo $sub_row["order_item_tax1_amount"];?>" /></td>
<td><input type="text" name="order_item_tax2_rate[]" id="order_item_tax2_rate<?php echo $m; ?>" data-srno="<?php echo $m; ?>" class="form-control input-sm number_only order_item_tax2_rate" value="<?php echo $sub_row["order_item_tax2_rate"];?>" /></td>
<td><input type="text" name="order_item_tax2_amount[]" id="order_item_tax2_amount<?php echo $m; ?>" data-srno="<?php echo $m; ?>" readonly class="form-control input-sm order_item_tax2_amount" value="<?php echo $sub_row["order_item_tax2_amount"]; ?>" /></td>
<td><input type="text" name="order_item_tax3_rate[]" id="order_item_tax3_rate<?php echo $m; ?>" data-srno="<?php echo $m; ?>" class="form-control input-sm number_only order_item_tax3_rate" value="<?php echo $sub_row["order_item_tax3_rate"]; ?>" /></td>
<td><input type="text" name="order_item_tax3_amount[]" id="order_item_tax3_amount<?php echo $m; ?>" data-srno="<?php echo $m; ?>" readonly class="form-control input-sm order_item_tax3_amount" value="<?php echo $sub_row["order_item_tax3_amount"]; ?>" /></td>
<td><input type="text" name="order_item_final_amount[]" id="order_item_final_amount<?php echo $m; ?>" data-srno="<?php echo $m; ?>" readonly class="form-control input-sm order_item_final_amount" value="<?php echo $sub_row["order_item_final_amount"]; ?>" /></td>
<td></td>
</tr>
<?php
}
?>
</table>
</td>
</tr>
<tr>
<td align="right"><b>Total</td>
<td align="right"><b><span id="final_total_amt"><?php echo $row["order_total_after_tax"]; ?></span></b></td>
</tr>
<tr>
<td colspan="2"></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="hidden" name="total_item" id="total_item" value="<?php echo $m; ?>" />
<input type="hidden" name="order_id" id="order_id" value="<?php echo $row["order_id"]; ?>" />
<input type="submit" name="update_invoice" id="create_invoice" class="btn btn-info" value="Edit" />
</td>
</tr>
</table>
</div>
</form>
<script>
$(document).ready(function(){
var final_total_amt = $('#final_total_amt').text();
var count = "<?php echo $m; ?>";
$(document).on('click', '#add_row', function(){
count++;
$('#total_item').val(count);
var html_code = '';
html_code += '<tr id="row_id_'+count+'">';
html_code += '<td><span id="sr_no">'+count+'</span></td>';
html_code += '<td><input type="text" name="item_name[]" id="item_name'+count+'" class="form-control input-sm" /></td>';
html_code += '<td><input type="text" name="order_item_quantity[]" id="order_item_quantity'+count+'" data-srno="'+count+'" class="form-control input-sm number_only order_item_quantity" /></td>';
html_code += '<td><input type="text" name="order_item_price[]" id="order_item_price'+count+'" data-srno="'+count+'" class="form-control input-sm number_only order_item_price" /></td>';
html_code += '<td><input type="text" name="order_item_actual_amount[]" id="order_item_actual_amount'+count+'" data-srno="'+count+'" class="form-control input-sm order_item_actual_amount" readonly /></td>';
html_code += '<td><input type="text" name="order_item_tax1_rate[]" id="order_item_tax1_rate'+count+'" data-srno="'+count+'" class="form-control input-sm number_only order_item_tax1_rate" /></td>';
html_code += '<td><input type="text" name="order_item_tax1_amount[]" id="order_item_tax1_amount'+count+'" data-srno="'+count+'" readonly class="form-control input-sm order_item_tax1_amount" /></td>';
html_code += '<td><input type="text" name="order_item_tax2_rate[]" id="order_item_tax2_rate'+count+'" data-srno="'+count+'" class="form-control input-sm number_only order_item_tax2_rate" /></td>';
html_code += '<td><input type="text" name="order_item_tax2_amount[]" id="order_item_tax2_amount'+count+'" data-srno="'+count+'" readonly class="form-control input-sm order_item_tax2_amount" /></td>';
html_code += '<td><input type="text" name="order_item_tax3_rate[]" id="order_item_tax3_rate'+count+'" data-srno="'+count+'" class="form-control input-sm number_only order_item_tax3_rate" /></td>';
html_code += '<td><input type="text" name="order_item_tax3_amount[]" id="order_item_tax3_amount'+count+'" data-srno="'+count+'" readonly class="form-control input-sm order_item_tax3_amount" /></td>';
html_code += '<td><input type="text" name="order_item_final_amount[]" id="order_item_final_amount'+count+'" data-srno="'+count+'" readonly class="form-control input-sm order_item_final_amount" /></td>';
html_code += '<td><button type="button" name="remove_row" id="'+count+'" class="btn btn-danger btn-xs remove_row">X</button></td>';
html_code += '</tr>';
$('#invoice-item-table').append(html_code);
});
$(document).on('click', '.remove_row', function(){
var row_id = $(this).attr("id");
var total_item_amount = $('#order_item_final_amount'+row_id).val();
var final_amount = $('#final_total_amt').text();
var result_amount = parseFloat(final_amount) - parseFloat(total_item_amount);
$('#final_total_amt').text(result_amount);
$('#row_id_'+row_id).remove();
count--;
$('#total_item').val(count);
});
function cal_final_total(count)
{
var final_item_total = 0;
for(j=1; j<=count; j++)
{
var quantity = 0;
var price = 0;
var actual_amount = 0;
var tax1_rate = 0;
var tax1_amount = 0;
var tax2_rate = 0;
var tax2_amount = 0;
var tax3_rate = 0;
var tax3_amount = 0;
var item_total = 0;
quantity = $('#order_item_quantity'+j).val();
if(quantity > 0)
{
price = $('#order_item_price'+j).val();
if(price > 0)
{
actual_amount = parseFloat(quantity) * parseFloat(price);
$('#order_item_actual_amount'+j).val(actual_amount);
tax1_rate = $('#order_item_tax1_rate'+j).val();
if(tax1_rate > 0)
{
tax1_amount = parseFloat(actual_amount)*parseFloat(tax1_rate)/100;
$('#order_item_tax1_amount'+j).val(tax1_amount);
}
tax2_rate = $('#order_item_tax2_rate'+j).val();
if(tax2_rate > 0)
{
tax2_amount = parseFloat(actual_amount)*parseFloat(tax2_rate)/100;
$('#order_item_tax2_amount'+j).val(tax2_amount);
}
tax3_rate = $('#order_item_tax3_rate'+j).val();
if(tax3_rate > 0)
{
tax3_amount = parseFloat(actual_amount)*parseFloat(tax3_rate)/100;
$('#order_item_tax3_amount'+j).val(tax3_amount);
}
item_total = parseFloat(actual_amount) + parseFloat(tax1_amount) + parseFloat(tax2_amount) + parseFloat(tax3_amount);
final_item_total = parseFloat(final_item_total) + parseFloat(item_total);
$('#order_item_final_amount'+j).val(item_total);
}
}
}
$('#final_total_amt').text(final_item_total);
}
$(document).on('blur', '.order_item_price', function(){
cal_final_total(count);
});
$(document).on('blur', '.order_item_tax1_rate', function(){
cal_final_total(count);
});
$(document).on('blur', '.order_item_tax2_rate', function(){
cal_final_total(count);
});
$(document).on('blur', '.order_item_tax3_rate', function(){
cal_final_total(count);
});
$('#create_invoice').click(function(){
if($.trim($('#order_receiver_name').val()).length == 0)
{
alert("Please Enter Reciever Name");
return false;
}
if($.trim($('#order_no').val()).length == 0)
{
alert("Please Enter Invoice Number");
return false;
}
if($.trim($('#order_date').val()).length == 0)
{
alert("Please Select Invoice Date");
return false;
}
for(var no=1; no<=count; no++)
{
if($.trim($('#item_name'+no).val()).length == 0)
{
alert("Please Enter Item Name");
$('#item_name'+no).focus();
return false;
}
if($.trim($('#order_item_quantity'+no).val()).length == 0)
{
alert("Please Enter Quantity");
$('#order_item_quantity'+no).focus();
return false;
}
if($.trim($('#order_item_price'+no).val()).length == 0)
{
alert("Please Enter Price");
$('#order_item_price'+no).focus();
return false;
}
}
$('#invoice_form').submit();
});
});
</script>
<?php
}
}
else
{
?>
<h3 align="center">Invoice System Using Jquery PHP Mysql and Bootstrap</h3>
<br />
<div align="right">
<a href="invoice.php?add=1" class="btn btn-info btn-xs">Create</a>
</div>
<br />
<table id="data-table" class="table table-bordered table-striped">
<thead>
<tr>
<th>Invoice No.</th>
<th>Invoice Date</th>
<th>Receiver Name</th>
<th>Invoice Total</th>
<th>PDF</th>
<th>Edit</th>
<th>Delete</th>
</tr>
</thead>
<?php
if($total_rows > 0)
{
foreach($all_result as $row)
{
echo '
<tr>
<td>'.$row["order_no"].'</td>
<td>'.$row["order_date"].'</td>
<td>'.$row["order_receiver_name"].'</td>
<td>'.$row["order_total_after_tax"].'</td>
<td><a href="print_invoice.php?pdf=1&id='.$row["order_id"].'">PDF</a></td>
<td><a href="invoice.php?update=1&id='.$row["order_id"].'"><span class="glyphicon glyphicon-edit"></span></a></td>
<td><a href="#" id="'.$row["order_id"].'" class="delete"><span class="glyphicon glyphicon-remove"></span></a></td>
</tr>
';
}
}
?>
</table>
<?php
}
?>
</div>
<br>
<footer class="container-fluid text-center">
<p>Footer Text</p>
</footer>
</body>
</html>
<script type="text/javascript">
$(document).ready(function(){
var table = $('#data-table').DataTable({
"order":[],
"columnDefs":[
{
"targets":[4, 5, 6],
"orderable":false,
},
],
"pageLength": 25
});
$(document).on('click', '.delete', function(){
var id = $(this).attr("id");
if(confirm("Are you sure you want to remove this?"))
{
window.location.href="invoice.php?delete=1&id="+id;
}
else
{
return false;
}
});
});
</script>
<script>
$(document).ready(function(){
$('.number_only').keypress(function(e){
return isNumbers(e, this);
});
function isNumbers(evt, element)
{
var charCode = (evt.which) ? evt.which : event.keyCode;
if (
(charCode != 46 || $(element).val().indexOf('.') != -1) && // “.” CHECK DOT, AND ONLY ONE.
(charCode < 48 || charCode > 57))
return false;
return true;
}
});
</script>
pdf.php
<?php
//pdf.php;
require_once 'dompdf/autoload.inc.php';
use Dompdf\Dompdf;
class Pdf extends Dompdf{
public function __construct() {
parent::__construct();
}
}
?>
print_invoice.php
<?php
//print_invoice.php
if(isset($_GET["pdf"]) && isset($_GET["id"]))
{
require_once 'pdf.php';
include('database_connection.php');
$output = '';
$statement = $connect->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 .= '
<table width="100%" border="1" cellpadding="5" cellspacing="0">
<tr>
<td colspan="2" align="center" style="font-size:18px"><b>Invoice</b></td>
</tr>
<tr>
<td colspan="2">
<table width="100%" cellpadding="5">
<tr>
<td width="65%">
To,<br />
<b>RECEIVER (BILL TO)</b><br />
Name : '.$row["order_receiver_name"].'<br />
Billing Address : '.$row["order_receiver_address"].'<br />
</td>
<td width="35%">
Reverse Charge<br />
Invoice No. : '.$row["order_no"].'<br />
Invoice Date : '.$row["order_date"].'<br />
</td>
</tr>
</table>
<br />
<table width="100%" border="1" cellpadding="5" cellspacing="0">
<tr>
<th>Sr No.</th>
<th>Item Name</th>
<th>Quantity</th>
<th>Price</th>
<th>Actual Amt.</th>
<th colspan="2">Tax1 (%)</th>
<th colspan="2">Tax2 (%)</th>
<th colspan="2">Tax3 (%)</th>
<th rowspan="2">Total</th>
</tr>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th>Rate</th>
<th>Amt.</th>
<th>Rate</th>
<th>Amt.</th>
<th>Rate</th>
<th>Amt.</th>
</tr>';
$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 .= '
<tr>
<td>'.$count.'</td>
<td>'.$sub_row["item_name"].'</td>
<td>'.$sub_row["order_item_quantity"].'</td>
<td>'.$sub_row["order_item_price"].'</td>
<td>'.$sub_row["order_item_actual_amount"].'</td>
<td>'.$sub_row["order_item_tax1_rate"].'</td>
<td>'.$sub_row["order_item_tax1_amount"].'</td>
<td>'.$sub_row["order_item_tax2_rate"].'</td>
<td>'.$sub_row["order_item_tax2_amount"].'</td>
<td>'.$sub_row["order_item_tax3_rate"].'</td>
<td>'.$sub_row["order_item_tax3_amount"].'</td>
<td>'.$sub_row["order_item_final_amount"].'</td>
</tr>
';
}
$output .= '
<tr>
<td align="right" colspan="11"><b>Total</b></td>
<td align="right"><b>'.$row["order_total_after_tax"].'</b></td>
</tr>
<tr>
<td colspan="11"><b>Total Amt. Before Tax :</b></td>
<td align="right">'.$row["order_total_before_tax"].'</td>
</tr>
<tr>
<td colspan="11">Add : Tax1 :</td>
<td align="right">'.$row["order_total_tax1"].'</td>
</tr>
<tr>
<td colspan="11">Add : Tax2 :</td>
<td align="right">'.$row["order_total_tax2"].'</td>
</tr>
<tr>
<td colspan="11">Add : Tax3 :</td>
<td align="right">'.$row["order_total_tax3"].'</td>
</tr>
<tr>
<td colspan="11"><b>Total Tax Amt. :</b></td>
<td align="right">'.$row["order_total_tax"].'</td>
</tr>
<tr>
<td colspan="11"><b>Total Amt. After Tax :</b></td>
<td align="right">'.$row["order_total_after_tax"].'</td>
</tr>
';
$output .= '
</table>
</td>
</tr>
</table>
';
}
$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;
invoice.php was concatenated with index.php, and i see some other mismatches... thank you.
ReplyDeleteExcellent
ReplyDeleteIt served me too much
ReplyDeleteCongratulations
ReplyDeleteC'est vraiment bien expliqué dans les tuto, c'est très intéressant.
ReplyDeleteyou amaze me at how dedicate so much time to help the rest of us budding developers.cheers
ReplyDeleteThank you!! for this awesome tutorial
ReplyDeletehow ican fix this problem (Failed to load PDF document.)
ReplyDeletethanks
ReplyDeleteworking well , nice
ReplyDeletevery nice
ReplyDeleteHello, Admin
ReplyDeleteI have problem with this script when i create invoice when i check database the only tbl_order is getting filled with details where it is failing to insert contents to tbl_order_item. Please Help!!!!
Regards,
Sudheer
Nice! congratulations simple! thanks for sharing.
ReplyDeletesir,
ReplyDeletePlease Send me... this fully project(zip file)with bootstrap Css
email: animeshmanna1998@yahoo.com
really good tutorial,thanks a lot.
ReplyDeletewe need a link to download this code plz
ReplyDeletethx
PHP Warning: require_once(/dompdf/autoload.inc.php): failed to open stream: No such file or directory in C:\Bitnami\wampstack-5.6.31-0\apps\invoice system\js\pdf.php on line 2 PHP Fatal error: require_once(): Failed opening required '/dompdf/autoload.inc.php' (include_path='.;C:/Bitnami/wampstack-5.6.31-0/php/PEAR') in C:\Bitnami\wampstack-5.6.31-0\apps\invoice system\js\pdf.php on line 2
ReplyDeletePHP Warning: require_once(/dompdf/autoload.inc.php): failed to open stream: No such file or directory in C:\Bitnami\wampstack-5.6.31-0\apps\invoice system\js\pdf.php on line 2 PHP Fatal error: require_once(): Failed opening required '/dompdf/autoload.inc.php' (include_path='.;C:/Bitnami/wampstack-5.6.31-0/php/PEAR') in C:\Bitnami\wampstack-5.6.31-0\apps\invoice system\js\pdf.php on line 2
ReplyDeleteplz help as i am getting this error but unable to get rid of it.Thanks in advance.
ReplyDeletesir pls send zip file,help me
ReplyDeletemy email id is: sandeepev@gmail.com
where file css or js
ReplyDeletecan you please share the CSS and JQuery script
ReplyDeletemy page is very awkward
Dear sir
ReplyDeletevery nice tutorial
autoload.inc.php file code missing..please update here or send me at
karthicbabu.83@gmail.com
thank you
hi
ReplyDeleteautoload.inc.php file and code missing in your tutorial..im waiting for your reply
Please provide dompdf/autoload.inc.php file for this project and also provid css and js file which is important. thank you sir for being sharing this projects
ReplyDeleteHello. Very nice tutorial but i am not getting the desired results as shown in the demo. Can you pls upload the demo's code . Thanks in advance
ReplyDeletethanx
ReplyDeletethis is not working in mobile browser
ReplyDeletei have been try again and again but i can't enter the data. Please if you send me the the complet source code of invoice system then i will be thankfull to you
ReplyDeletemy email address is web.developerbj@gmail.com
Nice Script.
ReplyDeleteCan you provide code for - send created pdf file via email to concerned Receiver.
Great WORK Sir
ReplyDeletecan I GET the file links i.e datastyle and datepicker etc
very nice.
ReplyDeletethanks for the nice tutorial ,i cant find the style sheets and javascript libraly used in this demo ,when i try to include other sources the incoive calculations and the add input fields does not work.Kindly help
ReplyDeleteHello, can you provide "Make Online Invoice System by using PHP Jquery" source file especially dompdf file?
ReplyDeleteHello, the final product for this tutorial, can it be used as PDF with all the functions of sum and adding new rows?
ReplyDeletehi... your code was working perfectly...but converting of pdf format is not working,it shows some error like page not working....and here some pages are missing...i need that page....--->dompdf/autoload.inc.php
ReplyDeletegive the total zip file...thank you..
How to download code for invoice
ReplyDeletewhere is dompdf/autoload.inc.php ? and its related information
ReplyDeleteno response form
ReplyDeletehello there
ReplyDeletei wanna use this for but have some problems...
BEFORE. i dont like boottrap...
i wanna edit created invoice.. cant add new items.. why ?
could you create new template for beginners with only base codes ?
i wann add/update-delete items.. but cant it..
thx
where is dompdf/autoload.inc.php file
ReplyDeleteplz give download fle
ReplyDeleteplease source code download needed
ReplyDeletekindly provide download for the invoice project
ReplyDeleteplease source code download needed
ReplyDeleteHow can i get dompdf file and other folder.
ReplyDeletei want to download this
ReplyDeletethank you
ReplyDeletedompdf/autoload.inc.php code
ReplyDeleteSorry to say but this does not work for me.
ReplyDeleteit is not working.
ReplyDeleteIt's not working.
ReplyDeleteAwesome, Very nice tutorial. It works fine for me. If this code not works for any body, He has/have to download and add the jquery,bootstrap and datatable libraries from internet.
ReplyDeletewhere to get that file?
DeleteSir can you share the code with me of dompdf/autoload.inc.php it would be wery much helpful for me
DeleteIts Jubair from BD
DeleteYes...need to work on it....
COOL, Very nice. Its working fine for me too
DeleteNeed to work on it......with patience..
-Jubair +880 1717069916 (Bangladesh)
its not working for me...the datepicker, add button, total function and tax function still not working for me..can u help me by sending the code at my gmail?
DeleteI am also facing the same issue ... can someone please tell me , is there any file update missing ?
DeleteBootstrap is tool for coder who don't know wahat he is doing.
ReplyDeleteFatal error: Class 'Dompdf\Dompdf' not found in pdf.php file
ReplyDeleteDompdf arabic is not worke
ReplyDeleteits a plugin youi install using composer. google it guys maybe it will help
DeleteSir can you please share the all libraries links used in this code. I downloaded some but that are not fully functional.
ReplyDeletePlease support all developer for this code . please upload download flies
ReplyDeletemine is not loading bootstrap
ReplyDeleteYou Should download Bootstrap manually and unzip the css and js folders in your folder with .php files. Refresh your browser and it works.
Deletekindly share the code of autoload.inc.php
ReplyDeletehow to create a button that prints all the invoices instead of clicking each of the pdf button ?
ReplyDeleteTo get it work correctly:
ReplyDelete1. First download Bootstrap here and extract it to working folder in your Webspace (www or htdocs):
https://github.com/twbs/bootstrap/releases/download/v4.0.0/bootstrap-4.0.0-dist.zip
2. Download stable Dompdf from Github and extract it to your folder:
https://github.com/dompdf/dompdf/releases/download/v0.8.2/dompdf_0-8-2.zip
and at last refresh your browser, tadaa it works.
hii,,
Deletei put bootstrap & DomPDf file its not working
Hooray...! Yeah It's working. Thank You So........... Much!!! 😍😍😍😍
DeleteGetting an error. Failed to load PDF document.
Deleteyap did you find the solution
Deletehow to download
ReplyDeleteits not working
ReplyDeletehow to upload image with this crud?
ReplyDeleteits not work
ReplyDeleteThanks a lot.. it is working.
ReplyDeletecan you please send the zip file
Deleteyeah could you please send the files?
Deletenot working upload to database,datepicker and add row. Any help please!
ReplyDelete< script src= "https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.js" > < / script >
Deleteput this line in invoice.php nearby (line no. 281)
Thanks
not working . kindly update the library
ReplyDeleteWhere are Bootstrap, Jquery, Js files and (dataTables, datepicker) files etc ?
ReplyDeleteHi,
ReplyDeletefirst: how to receive and insert data in a form using typeahead,
type="text" name="item_name[]" id="item_name1" class="form-control input-sm" autocomplete="off" />
jQuery(document).ready(function($){
$('#item_name1').typeahead({
items: 1000,
minLength: 2,
highlight: true,
source: function(query, result)
{
$.ajax({
url:"fetch_mag.php",
method:"POST",
data:{query:query},
dataType:"json",
success:function(data){
result($.map(data, function(item){
return item;
}));
}
})
}
});
});
Thx and how does fetch_mag.php looks like pls
Deletethanks you sir
ReplyDeleteyou code is running for me
very very thanks
Hi i am still facing issue. Can you guide me.
DeleteThank u soo much sir
ReplyDeleteYour code is running
please send download links
ReplyDeleteHallo guys how can i validate if the invoice item already exist in database before inserting for loop with invoice items.
ReplyDeleteFatal error: Uncaught exception 'Dompdf\Exception' with message 'Min/max width is undefined for table rows' in /Applications/XAMPP/xamppfiles/htdocs/NTPC/dompdf/src/FrameReflower/TableRow.php:72 Stack trace: #0 /Applications/XAMPP/xamppfiles/htdocs/NTPC/dompdf/src/FrameDecorator/AbstractFrameDecorator.php(903): Dompdf\FrameReflower\TableRow->get_min_max_width() #1 /Applications/XAMPP/xamppfiles/htdocs/NTPC/dompdf/src/FrameReflower/AbstractFrameReflower.php(268): Dompdf\FrameDecorator\AbstractFrameDecorator->get_min_max_width() #2 /Applications/XAMPP/xamppfiles/htdocs/NTPC/dompdf/src/FrameDecorator/AbstractFrameDecorator.php(903): Dompdf\FrameReflower\AbstractFrameReflower->get_min_max_width() #3 /Applications/XAMPP/xamppfiles/htdocs/NTPC/dompdf/src/FrameReflower/AbstractFrameReflower.php(268): Dompdf\FrameDecorator\AbstractFrameDecorator->get_min_max_width() #4 /Applications/XAMPP/xamppfiles/htdocs/NTPC/dompdf/src/FrameDecorator/AbstractFrameDecorator.php(903): Dompdf\FrameReflower\AbstractFrameReflower->get_min_max_width in /Applications/XAMPP/xamppfiles/htdocs/NTPC/dompdf/src/FrameReflower/TableRow.php on line 72
DeleteVery nice tutorial. Just missing an autocomplete lookup for items from mysql table to populate code and price. Pla add it to complete invoice. Thx for great tutorials
ReplyDeleteFatal error: Class 'Dompdf\Dompdf' not found in C:\xampp\htdocs\pdf\pdf.php on line 6
ReplyDeletei had an one suggestion. i added an one order. if i need to edit i need add extra product on order that option was not available no problem this one have a solution .
ReplyDeleteMy Doubt i when i going to edit a order i mistakenly add one product on order i need to delete using a code . its going to redirect and comes the main page location but total calculate deleted product details also
think sir. work like a charm !
ReplyDeletei inserted your code in my project but some errors occured in my project database values not inserting properly in database also table values are not deleted when clicking on delete button
ReplyDeletehi. its working... but i hv remove some fields and also some changes in insert query... no error... but its bit inserting data into db.... its reading all the values from the controls
ReplyDeletecan i get js files path please?
ReplyDeleteremove row is ot working
ReplyDeletepdf.php
ReplyDeleteWarning: require_once(dompdf/autoload.inc.php): failed to open stream: No such file or directory in C:\xampp\htdocs\inv\index.php on line 925
Fatal error: require_once(): Failed opening required 'dompdf/autoload.inc.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\inv\index.php on line 925
sir pls help me how to solve this error
My code is working , BUT
ReplyDeleteI guess the codes up here is not complete cus, the edit link is not working as it is working in the demo.
It only loads just one item
Anyone experiencing this ?
This is not working, data are not able to be added in database? sir please give me download link for this.
ReplyDeletehii how to use auto complete for this code while enter the item name
ReplyDeleteThis app works fine !!!
ReplyDeleteI´m tray to adapt it into my Construction ERP System...
Congrats from Mexico City !!!
Hi, folks who are struggling to get this working after copying the files from the website above. It won't work as is, there's still some additional steps that need to be done. Below is what I did to get this fully working:
ReplyDelete1. Copy and Paste all the main php files above and put them inside your webserver.
2. The author has provided the dummy mysql file above, this has to be imported into your MySQL server. Google or YouTube how to setup your own MySQL server ( I personally used phpMyAdmin) and then how to import the database file.sql into your MySQL server.
3. The last step (and the one I think most people are getting stuck), is that you need all the right version of the .js and .css files that the author has used. Note: if you simply try to use the latest bootstrap 4.0, it simply won't work :) What I did was to simply locally save the pages from the "Demo page" of this tutorial and then opened .css and .js files to find out the right versions. You can google around those files or you can simply copy these files over into your local project.
4. For the PDF stuff you also need to download more files (Dompdf) the latest version as of today is working still v.0.8.3.
I confirm the above tutorial is working fully. I thank the author for this tutorial as it's clearly not a straightforward solution by any means to come up with an invoicing solution for your e-commerce website.
Happy Coding
send to me source code
ReplyDeleteThanks a lot, Sir. You have save my time a great deal of.
ReplyDeleteGuyz he just gave us a brief basic idea about how to create basic invoice and the important concept in this tutorial is to validate amounts and adding new row with jQuery.. Code works fine if we make few changes.. when clicking edit button data is not populating and there is no functionality to add new row in edit invoice. if you want this code make it run you must have good knowledge in JQuery. if you want clean working code of this tutorial. ask me.
ReplyDeleteVery Nice project. thanks, but if I am deleting the 2nd row, srno of 3rd not changing to srno 2. And then if i add again record, records with duplicate input ids created resulting cal_final_amount is not working on duplicate row. Kindly Help.
ReplyDeletei have error this
ReplyDeleteWarning: require(dompdf/autoload.php): failed to open stream: No such file or directory in C:\xampp\htdocs\demo-dental-lab\pdf.php on line 4
Fatal error: require(): Failed opening required 'dompdf/autoload.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\demo-dental-lab\pdf.php on line 4, how can solve this error sir
Hi Guys is anyone there havig a problem with saving data to MYSQL? could u please help me with that ? i'm almost finish!
ReplyDeletethanks!
HOW TO USE IT FOR ODBC SERVER
ReplyDeleteThanks you so much sir
ReplyDeleteYour code is running very well for me
Hi guys
My file arrangement below
please refer
D:\xampp\htdocs\php-invoice-system
│ database.sql
│ database_connection.php
│ invoice.php
│ pdf.php
│ print_invoice.php
│
├─css
│ │ bootstrap.min.css
│ │ dataTables.bootstrap.min.css
│ └ datepicker.css
│
├─dompdf <- Outer download
│ └ unzip all folders and files
│
├─fonts <- bootstrap zip file(I use ver.3.4.1, ver.4.0.0 not include)
│ │ glyphicons-halflings-regular.eot
│ │ glyphicons-halflings-regular.svg
│ │ glyphicons-halflings-regular.ttf
│ │ glyphicons-halflings-regular.woff
│ └ glyphicons-halflings-regular.woff2
│
└─js
│ bootstrap-datepicker1.js
│ bootstrap.min.js
│ dataTables.bootstrap.min.js
│ jquery.dataTables.min.js
└ jquery.min.js
1) Open Online DEMO Page (invoice.php)
2) Save Complete Page to Desktop tmp folder
3) Choose css and js files from 2)tmp folder and rename to above
Ok, I configured all, my front-end are well. But..
DeleteWhen I call database, show this error:
Fatal error: Call to a member function prepare() on string in C:\wamp64\www\invoice\invoice.php on line 10
See below my configurations:
PHP 5.6.40
Mysql: 5.7.31
Code connection used:
\PDO::ERRMODE_EXCEPTION,
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
\PDO::ATTR_EMULATE_PREPARES => false,
];
$conn = "mysql:host=$host;dbname=$db";
try {
$pdo = new \PDO($conn, $user, $pass, $options);
} catch (\PDOException $e) {
throw new \PDOException($e->getMessage(), (int)$e->getCode());
}
?>
I didnt understand what's happened...
Could You help me?
really helpful sample, thank you so much,
ReplyDeletebut Sir nothing saved into tbl_order_item
kindly advice any solution
when i click on create it display Object not found!
ReplyDeletesir but this not working give us a code in zip file
ReplyDeleteSir / Madam,
ReplyDeleteKindly help order added properly, but Order Items not insert in the Data Table.
Pls do the needful.
Sir how to add default tax rate other than adding by ourself
ReplyDeletedate picking option is not working anyone can help me plz
ReplyDeleteWorks awesome, just add missing stuff. Thanks for the awesome tutorials!
ReplyDeleteshare link download bootstrap please
ReplyDeletecode is not working bro plz send me zip file 7709738352
ReplyDeletedjpawar47@gmail.com
product.php & order.php are not compatible with bootstrap 4:
ReplyDelete"DataTables warning: table id=product_data - Invalid JSON response"
Hey Dude, you have shared a Simple and good stuff where lots of other people are selling shit at unreasonable price
ReplyDeleteThank you for the code
in Edit invoice can not add new row Item or delete row
ReplyDeleteSir can you plz share the all libraries links used in this code. I downloaded some but that are not fully functional.
ReplyDeleteWhy does the admin fail to represent a solution against that Fatal Error?
ReplyDeleteWhy does the admin fail to represent a solution against that fatal error?
ReplyDeleteThanks for great tutorial. My tbl_order_item is empty. I can't find mistake. Please help me!
ReplyDeleteI have a problem with database.
ReplyDeleteQuantity: 1 ; Price: 500
I type tax1 rate 5%, amt.tax1 is 25. But when I edited rate to 0%, amt.tax1 is not change to 0, and when create button, amt.tax1 25 still insert into database 'order_item_tax1_amount' (tbl_order_item) and 'order_total_tax1' (tbl_order)
How to fix? Thank
Hello, I find not a error but not showing any pdf document. and if i run in google chrome then show a error Failed to load PDF document.
ReplyDeleteHi Admin i want help above error. don't know why it is getting. i really need help urgently, want to submit college project.
DeleteHow to add SHIPPING CHARGE in Create invoice page & also that charge is added in Total Amount?(SHIPPING CHARGE column is not incremented when i click + button)
ReplyDeletehttp://localhost/1/2/print_invoice.php?pdf=1&id=1 (Error
ReplyDeleteFailed to load PDF document.)
its not working for me...the datepicker, add button, total function and tax function still not working for me..can u help me by sending the code at my gmail?
ReplyDeletehow to create databse connection im using plz desk server.
ReplyDeleteshould i use xampp for that.
ReplyDeleteinvoice date value was not saving in backend database
ReplyDeleteCan you please share as zip fip file? I cant run completely and cant find the search box source code.
ReplyDeleteThank You Sir
ReplyDeletethere is an error in database table when i import the table structure
ReplyDelete
ReplyDeleteWarning: require_once(dompdf/autoload.inc.php): failed to open stream: No such file or directory in C:\xampp\htdocs\invoce\pdf.php on line 3
Fatal error: require_once(): Failed opening required 'dompdf/autoload.inc.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\invoce\pdf.php on line 3
require_once(): Failed opening required 'dompdf/autoload.inc.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\invoce\pdf.php on line 3
Deleteyour code is not working properly.
ReplyDeleteDid anyone has fully working code please upload
ReplyDeletesource code needed
ReplyDeletesend me the full source code
ReplyDeletesend me the full source code.Please....
ReplyDeletePlease ...
DeletePls send full source with pdf print and potstrap my email. hodib78@gmail.com
ReplyDeleteI want to choose item name from table using dropdown combo instead of input box for item_name and populate order_item_price from table. What will be the code then. please help.
ReplyDeleteNeed Source Code Otherwise useless
ReplyDeleteya correcrt
Deletepodría pasar los scrips y styles?
ReplyDeletejoksan_rodriguez@hotmail.com
Everything running cool. Except this error in dompdf (Parse error: syntax error, unexpected '=' in dompdf\src\Dompdf.php on line 370)
ReplyDeleteThats my error, Can u help me? can u send to my email?
Sir Dompdf file...? where can I get that file?
ReplyDelete