Please Help me. I am coding PHP using below code but out put is not perfect. i am also attach output picture below.
<?php
require_once 'core.php';
include_once("../fpdf182/fpdf.php");
$pdf = new FPDF();
$pdf->AddPage();
$pdf->setFont("Arial","B",16);
$orderId = $_POST['orderId'];
$sql = "SELECT orders.order_id, orders.order_date, customer.customer_name, customer.customer_mobile, orders.sub_total, orders.vat, orders.total_amount, orders.discount, orders.grand_total, orders.paid, orders.due, orders.payment_place,orders.gstn FROM orders INNER JOIN customer ON customer.customer_id = orders.client_name WHERE orders.order_id = $orderId";
$orderResult = $connect->query($sql);
$orderData = $orderResult->fetch_array();
$orderNo = $orderData[0];
$orderDate = $orderData[1];
$clientName = $orderData[2];
$clientContact = $orderData[3];
$subTotal = $orderData[4];
$vat = $orderData[5];
$totalAmount = $orderData[6];
$discount = $orderData[7];
$grandTotal = $orderData[8];
$paid = $orderData[9];
$due = $orderData[10];
$payment_place = $orderData[11];
$gstn = $orderData[12];
if ($orderDate && $orderNo) {
$pdf->Cell(190,10,"Invoice",0,1,"C");
$pdf->Cell(50,10,"Date",0,0);
$pdf->Cell(50,10,": ".$orderDate,0,1);
$pdf->Cell(50,10,"Customer Name",0,0);
$pdf->Cell(50,10,": ".$clientName,0,1);
$pdf->Cell(50,10,"",0,1);
$pdf->Cell(10,10,"#",1,0,"C");
$pdf->Cell(70,10,"Product Name",1,0,"C");
$pdf->Cell(30,10,"Quantity",1,0,"C");
$pdf->Cell(40,10,"Price",1,0,"C");
$pdf->Cell(40,10,"Total (Tk)",1,1,"C");
$orderItemSql = "SELECT order_item.product_id, order_item.rate, order_item.quantity, order_item.total,
product.product_name FROM order_item
INNER JOIN product ON order_item.product_id = product.product_id
WHERE order_item.order_id = $orderId";
$orderItemResult = $connect->query($orderItemSql);
$row = $orderItemResult->fetch_array();
for ($i=1; $i < count($row[0]) ; $i++) {
$pdf->Cell(10,10, ($i+1) ,1,0,"C");
$pdf->Cell(70,10, $row[4][$i],1,0,"C");
$pdf->Cell(30,10, $row[2][$i],1,0,"C");
$pdf->Cell(40,10, $row[1][$i],1,0,"C");
$pdf->Cell(40,10, ($row[2][$i] * $row[1][$i]) ,1,1,"C");
}
$pdf->Cell(50,10,"",0,1);
$pdf->Cell(50,10,"Sub Total",0,0);
$pdf->Cell(50,10,": ".$subTotal,0,1);
$pdf->Cell(50,10,"Gst Tax",0,0);
$pdf->Cell(50,10,": ".$vat,0,1);
$pdf->Cell(50,10,"Discount",0,0);
$pdf->Cell(50,10,": ".$discount,0,1);
$pdf->Cell(50,10,"Net Total",0,0);
$pdf->Cell(50,10,": ".$grandTotal,0,1);
$pdf->Cell(50,10,"Paid",0,0);
$pdf->Cell(50,10,": ".$paid,0,1);
$pdf->Cell(50,10,"Due Amount",0,0);
$pdf->Cell(50,10,": ".$due,0,1);
$pdf->Cell(50,10,"Payment Type",0,0);
$pdf->Cell(50,10,": ".$payment_place,0,1);
$pdf->Cell(180,10,"Signature",0,0,"R");
$pdf->Output();
}
?>
Output :
So Please Please as early as possible.