Code
<?php
session_start();
define('FPDF_FONTPATH','../../fpdf17/font/');
require('../../inc/connect.php');
require('../../inc/function1.php');
require('../actions/query_user.php');
require('../../fpdf17/fpdf.php');
//checklogin($_SESSION['username']);
$invS = "SELECT
inv.id AS inv_id,
inv.name AS inv_no,
inv.p_id AS project_id,
inv.p_name AS project_name,
inv.date AS inv_date,
inv.po_no AS po_no,
inv.quo_no AS quo_no,
inv.c_id AS c_id,
inv.c_thai AS c_thai,
inv.c_taxid AS tax_id,
inv.c_branch AS c_branch,
inv.co_name AS contact,
inv.project_type AS pj_type,
inv.vat AS vat,
inv.tax AS tax,
inv.inv_term AS credit_term,
inv.curency AS curency,
inv.cur_rate AS cur_rate,
inv.note AS inv_note,
inv.inv_total AS inv_total,
inv.inv_discount AS inv_discount,
inv.inv_sub_total AS inv_sub_total,
inv.inv_vat AS inv_vat,
inv.inv_inc_vat AS inv_inc_vat,
inv.inv_tax AS inv_tax,
inv.inv_paid AS inv_paid,
inv.bahttext AS bahttext,
adr.id AS adr_id,
adr.line1 AS line1,
adr.line2 AS line2,
adr.line3 AS line3,
adr.city AS city,
adr.province AS province,
adr.zipcode AS zipcode,
adr.country AS country,
c.phone1 AS phone1,
c.phone2 AS phone2,
c.fax1 AS fax1,
c.fax2 AS fax2
FROM invoice AS inv
LEFT JOIN invoice_client_company_address AS adr ON inv.id=adr.inv_id
LEFT JOIN client_company AS c ON c.id=inv.c_id
WHERE inv.id='{$_GET['id']}'";
$invQ = mysql_query($invS) or die("INVOICE SQL=".mysql_error());
$invN = mysql_num_rows($invQ);
$invR = mysql_fetch_array($invQ);
$inv_date = date("j M Y",strtotime($invR['inv_date']));
//echo $cid."<br>".$invR['c_thai'];
//ทำการสืบทอดคลาส FPDF ให้เป็นคลาสใหม่
class PDF extends FPDF
{
function Header(){ //Override คำสั่ง (เมธอด) Header
$this->SetFont('Circular','',14);
$this->Image('../../img/Onecool_Ramindra_logo_noname.jpg',5, 5, 50, 0);
$this->Cell(0,6, iconv('UTF-8','TIS-620', 'บริษัท วัน คูล แอนด์ รามอินทรา ซาวด์ สตูดิโอ จำกัด | One Cool & Ramindra Sound Studio Co., Ltd.'),0,1,'R');
$this->Cell(45,0,'',0,0,' ');
$this->Cell(0,0,iconv('UTF-8','TIS-620', ' '),1,1,'R');
$this->SetFont('Circular','',10);
$this->Cell(45,0,'',0,0,' ');
$this->Cell(0,5,iconv('UTF-8','TIS-620', '226 ถนนประดิษฐ์มนูธรรม แขวงพลับพลา เขตวังทองหลาง กรุงเทพฯ 10310 โทร 02-148-1100 แฟกซ์ 02-148-1100'),0,1,'');
$this->Cell(45,0,'',0,0,' ');
$this->Cell(0,2,iconv('UTF-8','TIS-620', '226 Praditmanuthum Road, Phapphla, Wongthonglang, Bangkok 10310 Tel. 662-1481-100 Fax. 662-148-1100'),0,1,'');
$this->Cell(45,0,'',0,0,' ');
$this->Cell(80,5,iconv('UTF-8','TIS-620', 'เลขประจำตัวผู้เสียภาษี / Tax ID : 0 10 555 709 831 2'),0,0,'');
$this->Cell(0,5,iconv('UTF-8','TIS-620','สำนักงานใหญ่'),0,1,'');
$this->SetFont('Circular','B',16);
$this->Cell(0,10,iconv('UTF-8','TIS-620','ใบแจ้งหนี้ / INVOICE'),0,1,'R');
$this->SetFont('Circular','B',12);
$this->Cell(30,0,iconv('UTF-8','TIS-620','Code / รหัสลูกค้า'),0,0,'R');
$this->SetFont('Circular','',12);
$this->Cell(20,0,iconv('UTF-8','TIS-620',''.$invR['c_id']),0,0,'');
$this->SetFont('Circular','B',12);
$this->Cell(30,0,iconv('UTF-8','TIS-620','TAX ID / เลขประจำตัวผู้เสียภาษี'),0,0,'R');
$this->SetFont('Circular','',12);
$this->Cell(0,0,iconv('UTF-8','TIS-620',''.$invR['tax_id']),0,1,'');
//ปัดบรรทัด กำหนดความกว้างของบรรทัด 20หน่วย
//$this->Ln(5);
}
//Override คำสั่ง (เมธอด) Footer
function Footer(){
$this->SetY( -20 ); //นับจากขอบกระดาษด้านล่างขึ้นมา 10 มม.
$this->SetFont('Circular','',12);
$this->Cell(65,5,iconv('UTF-8','TIS-620','_________________________________'),0,0,'C');
$this->Cell(65,5,iconv('UTF-8','TIS-620',''),0,0,'C');
$this->Cell(65,5,iconv('UTF-8','TIS-620','_________________________________'),0,1,'C');
$this->Cell(65,5,iconv('UTF-8','TIS-620','ผู้รับบิล / RECEIVED BY'),0,0,'C');
$this->Cell(65,5,iconv('UTF-8','TIS-620',''),0,0,'C');
$this->Cell(65,5,iconv('UTF-8','TIS-620','ผู้มีอำนาจลงนาม / AUTHORIZED BY'),0,1,'C');
$this->Cell(65,10,iconv('UTF-8','TIS-620','วันที่ / DATE _____/_____/_____'),0,0,'C');
$this->Cell(65,10,iconv('UTF-8','TIS-620',''),0,0,'C');
$this->Cell(65,10,iconv('UTF-8','TIS-620','วันที่ / DATE _____/_____/_____'),0,1,'C');
}
}
//ตั้งค่าหน้ากระดาษ
$pdf=new PDF('P' , 'mm' ,'Letter');
// เพิ่มฟอนต์ภาษาไทยเข้ามา ตัวธรรมดา กำหนด ชื่อ เป็น Circular
$pdf->AddFont('Circular','','Circular.php');
// เพิ่มฟอนต์ภาษาไทยเข้ามา ตัวหนา กำหนด ชื่อ เป็น Circular
$pdf->AddFont('Circular','B','CircularBold.php');
//สร้างหน้าเอกสาร
$pdf->AddPage();
/*
$pdf->SetFont('Circular','B',12);
$pdf->Cell(30,0,iconv('UTF-8','TIS-620','Code / รหัสลูกค้า'),0,0,'R');
$pdf->SetFont('Circular','',12);
$pdf->Cell(20,0,iconv('UTF-8','TIS-620',''.$invR['c_id']),0,0,'');
$pdf->SetFont('Circular','B',12);
$pdf->Cell(30,0,iconv('UTF-8','TIS-620','TAX ID / เลขประจำตัวผู้เสียภาษี'),0,0,'R');
$pdf->SetFont('Circular','',12);
$pdf->Cell(0,0,iconv('UTF-8','TIS-620',''.$invR['tax_id']),0,1,'');*/
$pdf->SetFont('Circular','B',12);
$pdf->Cell(30,10,iconv('UTF-8','TIS-620','Company / บริษัท'),0,0,'R');
$pdf->SetFont('Circular','',12);
$pdf->Cell(100,10,iconv('UTF-8','TIS-620',''.$invR['c_thai']),0,0,'');
$pdf->SetFont('Circular','B',12);
$pdf->Cell(30,10,iconv('UTF-8','TIS-620','No. / เลขที่'),0,0,'R');
$pdf->SetFont('Circular','',12);
$pdf->Cell(35,10,iconv('UTF-8','TIS-620',''.$invR['inv_no']),0,1,'');
$pdf->SetFont('Circular','B',12);
$pdf->Cell(30,0,iconv('UTF-8','TIS-620','Branch / สาขา'),0,0,'R');
$pdf->SetFont('Circular','',12);
$pdf->Cell(100,0,iconv('UTF-8','TIS-620',''.$invR['c_branch']),0,0,'');
$pdf->SetFont('Circular','B',12);
$pdf->Cell(30,0,iconv('UTF-8','TIS-620','Date / วันที่'),0,0,'R');
$pdf->SetFont('Circular','',12);
$pdf->Cell(35,0,iconv('UTF-8','TIS-620',''.$inv_date),0,1,'');
$pdf->SetFont('Circular','B',12);
$pdf->Cell(30,10,iconv('UTF-8','TIS-620','Address / ที่อยู่'),0,0,'R');
$pdf->SetFont('Circular','',12);
$pdf->Cell(100,10,iconv('UTF-8','TIS-620',''.$invR['line1']." ".$invR['line2']),0,1,'');
$pdf->SetFont('Circular','B',12);
$pdf->Cell(30,0,iconv('UTF-8','TIS-620',''),0,0,'R');
$pdf->SetFont('Circular','',12);
$pdf->Cell(100,0,iconv('UTF-8','TIS-620',''.$invR['line3'].", ".$invR['city'].", ".$invR['province']." ".$invR['zipcode']),0,1,'');
$pdf->SetFont('Circular','B',12);
$pdf->Cell(30,10,iconv('UTF-8','TIS-620','Telephone / โทรศัพท์'),0,0,'R');
$pdf->SetFont('Circular','',12);
$pdf->Cell(100,10,iconv('UTF-8','TIS-620',''.$invR['phone1']." ".$invR['phone2']),0,0,'');
$pdf->SetFont('Circular','B',12);
$pdf->Cell(30,10,iconv('UTF-8','TIS-620','Credit / เงื่อนไขการชำระเงิน'),0,0,'R');
$pdf->SetFont('Circular','',12);
$pdf->Cell(15,10,iconv('UTF-8','TIS-620',''.$invR['credit_term']),0,0,'C');
$pdf->Cell(20,10,iconv('UTF-8','TIS-620','Day(s)'),0,1,'L');
$pdf->SetFont('Circular','B',12);
$pdf->Cell(30,0,iconv('UTF-8','TIS-620','FAX / โทรสาร'),0,0,'R');
$pdf->SetFont('Circular','',12);
$pdf->Cell(100,0,iconv('UTF-8','TIS-620',''.$invR['fax1']." ".$invR['fax2']),0,0,'');
$pdf->SetFont('Circular','B',12);
$pdf->Cell(30,0,iconv('UTF-8','TIS-620','Currency / สกุลเงิน'),0,0,'R');
$pdf->SetFont('Circular','',12);
$pdf->Cell(35,0,iconv('UTF-8','TIS-620',''.$invR['curency']),0,1,'ศ');
$pdf->SetFont('Circular','B',12);
$pdf->Cell(30,10,iconv('UTF-8','TIS-620','Subject / ชื่องาน'),0,0,'R');
$pdf->SetFont('Circular','',12);
$pdf->Cell(165,10,iconv('UTF-8','TIS-620',''.$invR['project_name']),0,1,'');
$pdf->SetFont('Circular','B',12);
$pdf->Cell(50,5,iconv('UTF-8','TIS-620','Contact Name / ผู้ติดต่อ'),'TLR',0,'C');
$pdf->Output();
ด้านบนเป็น Code ทั้งหมดนะครับ แต่ ในส่วนที่ไม่ดึงข้อมูลมาคือส่วนนี้นะครับ
Code
$this->SetFont('Circular','B',12);
$this->Cell(30,0,iconv('UTF-8','TIS-620','Code / รหัสลูกค้า'),0,0,'R');
$this->SetFont('Circular','',12);
$this->Cell(20,0,iconv('UTF-8','TIS-620',''.$invR['c_id']),0,0,'');
$this->SetFont('Circular','B',12);
$this->Cell(30,0,iconv('UTF-8','TIS-620','TAX ID / เลขประจำตัวผู้เสียภาษี'),0,0,'R');
$this->SetFont('Circular','',12);
$this->Cell(0,0,iconv('UTF-8','TIS-620',''.$invR['tax_id']),0,1,'');
ไม่แน่ใจว่าผมทำอะไรพลาดตรงไหนครับ แต่ส่วนเนื้อหา ลองดูแล้วดึงข้อมูลมาแสดงได้ทั้งหมดครับ
Tag : PHP, MySQL, HTML/CSS, Linux