stevebramley
30-06-2009, 08:35 AM
Vee,
//grab the free pdf app: http://www.fpdf.org/
require('/includes/fpdf153/fpdf.php');
//extend it with your page settings etc
//---------- begin pdf ----------------
class PDF extends FPDF{
var $unique_id = "";
var $company_name = "";
var $abn = "";
var $address1 = "";
var $address2 = "";
var $country = "";
var $email = "";
var $web = "";
var $phone = "";
var $fax = "";
var $bank = "";
var $account_name = "";
var $bsb = "";
var $account_number = "";
var $item = "";
var $description = "";
var $amount = "";
//Page header
function init($row=NULL){
$this->unique_id = str_pad($row->unique_id,5,0,STR_PAD_LEFT);
$this->company_name = $row->company_name;
$this->abn = $row->abn;
$this->address1 = $row->address1;
$this->address2 = $row->address2;
$this->country = $row->state;
$this->email = $row->email;
$this->web = $row->web;
$this->phone = $row->phone;
$this->fax = $row->fax;
$this->bank = $row->bank;
$this->account_name = $row->account_name;
$this->bsb = $row->bsb;
$this->account_number = $row->account_number;
$this->item = $row->item;
$this->description = $row->description;
$this->amount = number_format($row->amount,2);
$this->gst = number_format(($this->amount/11),2);
}
//Page header
function Header(){
//Logo
$this->Image('/images/pdf/logo.jpg',10,8,33);
//Arial bold 15
$this->SetFont('Arial','B',15);
//Move to the right
$this->Cell(140);
//Title
$this->Cell(40,10,'Tax Invoice',0,0,'R');
//Arial normal 10
$this->SetFont('Arial','',10);
//Line break
$this->Ln(20);
//Address
$this->Cell(40,10,$this->company_name,0,0,'L');
//Line break
$this->Ln(5);
//Address
$this->Cell(40,10,$this->address1,0,0,'L');
//Line break
$this->Ln(5);
//Address
$this->Cell(40,10,$this->address2,0,0,'L');
//Move to the right
$this->Cell(60);
$this->SetFont('Arial','',7);
$this->SetFillColor(250,250,250);
//Title
$this->Cell(35,5,'TAX REG No.',1,0,'L','1');
//Title
$this->Cell(25,5,'DATE',1,0,'L','1');
//Title
$this->Cell(35,5,'INVOICE No.',1,0,'L','1');
$this->SetFont('Arial','',10);
//Line break
$this->Ln(5);
//Address
$this->Cell(40,10,$this->country,0,0,'L');
//Move to the right
$this->Cell(60);
//Title
$this->Cell(35,8,$this->abn,1,0,'L','0');
//Title
$this->Cell(25,8,date("d/m/Y"),1,0,'L','0');
//Title
$this->Cell(35,8,$this->unique_id,1,0,'L','0');
//Line break
$this->Ln(10);
//Address
$this->Cell(40,10,"Email: " . $this->email,0,0,'L');
//Line break
$this->Ln(5);
//Address
$this->Cell(40,10,"Web: " . $this->web,0,0,'L');
}
}
//instatiate it and create your pdf page
$pdf=new PDF();
$pdf->init($invoice_row);
$pdf->AddPage();
$pdf->Ln(15);
$pdf->SetFillColor(250,250,250);
$pdf->SetFont('Arial','',6);
$pdf->Cell(80,5,"INVOICE TO",1,0,'L','1');
$pdf->Cell(20,5);
$pdf->Cell(60,9,"TERMS",1,0,'C','1');
$pdf->Cell(35,9,"DUE DATE",1,0,'C','1');
$pdf->Ln(5);
$pdf->SetFont('Arial','',8);
$pdf->Cell(80,5,$name,"LR",0,'L','0');
$pdf->Ln(4);
$pdf->Cell(80,5,$company_name,"LR",0,'L','0');
$pdf->Cell(20,5);
$pdf->Cell(60,5,"Payment Immediate",1,0,'C','0');
$pdf->Cell(35,5,date("d/m/Y"),1,0,'C','0');
$pdf->Ln(5);
$pdf->Cell(80,5,$address1,"LR",0,'L','0');
$pdf->Ln(4);
$pdf->Cell(80,5,$suburb . ", " . $postcode,"LR",0,'L','0');
$pdf->Cell(20,5);
$pdf->SetFont('Arial','',6);
$pdf->Cell(60,9,"PAYMENT METHOD",1,0,'C','0');
$pdf->Cell(35,9,"DIRECT DEPOSIT",1,0,'C','0');
$pdf->SetFont('Arial','',8);
$pdf->Ln(4);
$pdf->Cell(80,5,$state,"LBR",0,'L','0');
if ($_POST['promotion'] != ''){
$pdf->Ln(7);
$pdf->Cell(60,9,"PROMOTION CODE USED: " . $_POST['promotion'],1,0,'L','0');
$pdf->Ln(8);
}else{
$pdf->Ln(15);
}
$pdf->SetFont('Arial','',6);
$pdf->Cell(30,7,"ITEM",1,0,'C','1');
$pdf->Cell(90,7,"DESCRIPTION",1,0,'C','1');
$pdf->Cell(25,7,"TAX",1,0,'C','1');
$pdf->Cell(25,7,"TAX AMT",1,0,'C','1');
$pdf->Cell(25,7,"AMOUNT",1,0,'C','1');
$pdf->SetFont('Arial','',8);
$pdf->Ln(7);
$pdf->Cell(30,5,$pdf->item,"1",0,'L','0');
$pdf->Cell(90,5,$pdf->description,"1",0,'L','0');
$pdf->Cell(25,5,"GST","1",0,'C','0');
$pdf->Cell(25,5,"$" . $pdf->gst,"1",0,'R','0');
$pdf->Cell(25,5,"$" . $pdf->amount,"1",0,'R','0');
$pdf->Ln(5);
$pdf->SetFont('Arial','',6);
$pdf->Cell(90,7,"TAX SUMMARY",1,0,'L','1');
$pdf->Cell(55,7);
$pdf->Cell(25,7,"SUBTOTAL","LTB",0,'L','1');
$pdf->Cell(25,7,"$" . $pdf->amount,"RTB",0,'R','1');
$pdf->Ln(7);
$pdf->SetFont('Arial','',6);
$pdf->Cell(90,7,"$" . $pdf->gst . " GST",1,0,'R','1');
$pdf->Cell(55,7);
$pdf->Cell(25,7,"TAX TOTAL","LTB",0,'L','1');
$pdf->Cell(25,7,"$" . $pdf->gst,"RTB",0,'R','1');
$pdf->Ln(7);
$pdf->SetFont('Arial','',6);
$pdf->Cell(90,7,"Thank you for your business",1,0,'L','1');
$pdf->Cell(55,7);
$pdf->Cell(25,7,"TOTAL","LTB",0,'L','1');
$pdf->Cell(25,7,"$" . $pdf->amount,"RTB",0,'R','1');
$pdf->Ln(15);
$pdf->SetFont('Arial','B',10);
$pdf->Cell(90,7,"Payment Information",0,0,'L','0');
$pdf->Ln(5);
$pdf->Cell(20,5,"So we can track your payment, please use the invoice number",0,0,'L');
$pdf->Ln(4);
$pdf->Cell(20,5,"above and your business name as a reference when paying us",0,0,'L');
$pdf->Ln(5);
$pdf->Cell(90,7,"Direct Deposit to:",0,0,'L','0');
$pdf->Ln(4);
$pdf->Cell(90,7,$pdf->bank,0,0,'L','0');
$pdf->Ln(4);
$pdf->Cell(90,7,"Acc. Name: " .$pdf->account_name,0,0,'L','0');
$pdf->Ln(4);
$pdf->Cell(90,7,"BSB: " .$pdf->bsb,0,0,'L','0');
$pdf->Ln(4);
$pdf->Cell(90,7,"Acc. No: " .$pdf->account_number,0,0,'L','0');
$pdf->Output("somefile.pdf");
vBulletin® v3.8.4, Copyright ©2000-2013, Jelsoft Enterprises Ltd.