|
|
|
PHP PDF Multicolumn สามารถแยกคอลัมน์ออกจากกันได้หรือไม่ |
|
|
|
|
|
|
|
ทำได้แล้วค่ะ
Code (PHP)
<?php
require('fpdf.php');
define('FPDF_FONTPATH','font/');
class PDF extends FPDF
{
function LoadData($file)
{
//Read file lines
$lines=file($file);
$data=array();
foreach($lines as $line)
$data[]=explode(';',chop($line));
return $data;
}
function Header()
{
$this->Image('image/logo.jpg',5,6,20);
$this->AddFont('cordiab','','cordiab.php');
$this->SetFont('cordiab','',12);
$this->Cell(0,0,iconv( 'UTF-8','TIS-620','หน้าที่... '.$this->PageNo()),0,1,"R");
$this->SetLeftMargin( 30 );
$this->SetLeftMargin( 5 );
$this->Cell(0,5,iconv('UTF-8','TIS-620','บริษัท พะยูนมอเตอร์ จำกัด'), 0 , 1 );
$this->SetLeftMargin( 30 );
$this->Cell(0,5,iconv('UTF-8','TIS-620','เลขที่ 62/49 ถ.วังตอ ต.ทับเที่ยง อ.เมือง จ.ตรัง 92000'), 0 , 1 );
$this->Cell(0,5,iconv('UTF-8','TIS-620','โทรศัพท์ : 081-111-2233'), 0 , 1 );
$this->SetLeftMargin( 5 );
$this->line(5, 28,200,28);
$this->Ln();
//ปัดบรรทัด กำหนดความกว้างของบรรทัด 35 หน่วย
}
function Footer()
{
$this->SetLineWidth(0.1);
include("time.php");
$this->AddFont('cordia','B','cordia.php');
$this->SetFont('cordia','B',12);
//นับจากขอบกระดาษด้านล่างขึ้นมา 15 มม.
//$this->SetY(-15);
$this->SetXY(5,-15);
$this->Cell(0,0,iconv( 'UTF-8','TIS-620',''),1,0,"C");
//$this->SetY(-15);
$this->Ln(5);
$this->SetXY(5,-10);
//พิมพ์วัน-เวลา ตรงมุมขวาล่าง
$this->Cell(0,0,iconv( 'UTF-8','TIS-620','ศูนย์ซ่อมพะยูนมอเตอร์'),0,0,"L");
$this->Cell(0,0,iconv('UTF-8','TIS-620','เวลาพิมพ์ :: '). date('d').'/'. date('m').'/'.( date('Y')+543 ).' '. date('H:i:s') ,0,0,'R');
}
}
$objConnect = mysql_connect("localhost","koxaota123_koxao","mgcda") or die("Error Connect to Database");
$objDB = mysql_select_db("koxaota123_koxao");
$strSQL = "SELECT * FROM potran
INNER JOIN brand ON brand.brand_id = potran.brand_id
INNER JOIN class ON class.class_id = potran.class_id
INNER JOIN model ON model.type_id = potran.type_id
INNER JOIN col1 ON col1.color_id1 = potran.col1
INNER JOIN col2 ON col2.color_id2 = potran.col2
WHERE strno = '".$_GET["sID"]."' ";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
$pdf=new PDF('P','mm','A4');
$pdf->AliasNbPages();//จำนวนหน้าทั้งหมด
$pdf->AddPage();
$pdf->AddFont('cordiab','','cordiab.php');
$pdf->SetFont('cordiab','',17);
$pdf->Cell(0,5,iconv('UTF-8','TIS-620','รายงานรับรถ'), 0 , 1 ,'C' );
$pdf->Ln();
$pdf->SetLeftMargin( 5);
$pdf->AddFont('cordiab','','cordiab.php');
$pdf->SetFont('cordiab','',14);
$pdf->Cell( 0 , 7 , iconv( 'UTF-8','cp874' , 'หมายเลขเครื่อง :' ) , 0, 1,'L' );
$pdf->Cell( 0 , 7 , iconv( 'UTF-8','cp874' , 'รุ่น :') , 0, 1 );
$pdf->Cell( 0 , 7 , iconv( 'UTF-8','cp874' , 'ป้ายทะเบียน :' ) , 0, 1);
$pdf->SetLeftMargin( 38 );
$pdf->AddFont('cordia','','cordia.php');
$pdf->SetFont('cordia','',14);
$pdf->Cell( 0 , -7, iconv( 'UTF-8','cp874' , $objResult["regno"]) , 0 , 1);
$pdf->Cell( 0 , -7, iconv( 'UTF-8','cp874' , $objResult["class_name"]) , 0 , 1);
$pdf->Cell( 0 , -7, iconv( 'UTF-8','cp874' , $objResult["engno"] ) , 0 , 1);
$pdf->SetLeftMargin( 80 );
$pdf->Ln(28);
$pdf->AddFont('cordiab','','cordiab.php');
$pdf->SetFont('cordiab','',14);
$pdf->Cell( 0 , -10 , iconv( 'UTF-8','cp874' , '' ) , 0 , 1 );
$pdf->Cell( 0 , -10 , iconv( 'UTF-8','cp874' , 'แบบ :' ) , 0 , 1 );
$pdf->Cell( 0 , -10 , iconv( 'UTF-8','cp874' , 'หมายเลขตัวถัง :') , 0 , 1);
$pdf->SetLeftMargin( 108 );
$pdf->Ln(30);
$pdf->AddFont('cordia','','cordia.php');
$pdf->SetFont('cordia','',14);
$pdf->Cell( 0 , -10 , iconv( 'UTF-8','cp874' , '') , 0 , 1 );
$pdf->Cell( 0 , -10 , iconv( 'UTF-8','cp874' , $objResult["type_name"]) , 0 , 1 );
$pdf->Cell( 0 , -10 , iconv( 'UTF-8','cp874' , $objResult["strno"] ) , 0 , 1 );
$pdf->SetLeftMargin( 145 );
$pdf->Ln(30);
$pdf->AddFont('cordiab','','cordiab.php');
$pdf->SetFont('cordiab','',14);
$pdf->Cell( 0 , -10 , iconv( 'UTF-8','cp874' , '' ) , 0 , 1 );
$pdf->Cell( 0 , -10 , iconv( 'UTF-8','cp874' , 'สี :' ) , 0 , 1 );
$pdf->Cell( 0 , -10 , iconv( 'UTF-8','cp874' , 'ยี่ห้อ :' ) , 0 , 1 );
$pdf->SetLeftMargin( 170 );
$pdf->Ln(30);
$pdf->AddFont('cordia','','cordia.php');
$pdf->SetFont('cordia','',14);
$pdf->Cell( 0 , -10 , iconv( 'UTF-8','cp874' , '' ) , 0 , 1 );
$pdf->Cell( 0 , -10 , iconv( 'UTF-8','cp874' , $objResult["color_name1"].'/'.$objResult["color_name2"] ) , 0 , 1 );
$pdf->Cell( 0 , -10 , iconv( 'UTF-8','cp874' , $objResult["brand_name"]) , 0 , 1 );
$pdf->SetLeftMargin( 5 );
$pdf->Ln(26);
$pdf->AddFont('cordiab','','cordiab.php');
$pdf->SetFont('cordiab','',12);
$pdf->SetFillColor(240,231,155);
$pdf->Cell(80,7,iconv('UTF-8','TIS-620','ตามใบตรวจสภาพ '),1,0,'C',true);
$pdf->Ln();
$pdf->SetFillColor(224,235,255);
$pdf->Cell(10,7,iconv('UTF-8','TIS-620','#'),1,0,'C',true);
$pdf->Cell(40,7,iconv('UTF-8','TIS-620','รายการ'),1,0,'C',true);
$pdf->Cell(10,7,iconv('UTF-8','TIS-620','ใช้ได้'),1,0,'C',true);
$pdf->Cell(10,7,iconv('UTF-8','TIS-620','ชำรุด'),1,0,'C',true);
$pdf->Cell(10,7,iconv('UTF-8','TIS-620','ไม่มี'),1,0,'C',true);
$pdf->Ln();
$pdf->SetLeftMargin( 5 );
$strSQL = "SELECT * FROM chk_store WHERE strno = '".$_GET["sID"]."' ORDER BY idno";
$objQuery = mysql_query($strSQL);
$rows = mysql_num_rows($objQuery);
$i = 1;
while($objResult = mysql_fetch_array($objQuery))
{
$sp_code = $objResult["sp_code"];
$sp_name = $objResult["sp_name"];
$bill = $objResult["bill"];
if($bill =='1')
{
$bill1 = 'image/ok1.jpg';
}else if($bill =='2')
{
$bill1 = 'image/ok2.jpg';
}else if($bill =='3')
{
$bill1 = 'image/ok2.jpg';
}
//--------------------------//
if($bill =='1')
{
$bill2 = 'image/ok2.jpg';
}else if($bill =='2')
{
$bill2 = 'image/ok1.jpg';
}else if($bill =='3')
{
$bill2 = 'image/ok2.jpg';
}
//--------------------------//
if($bill =='1')
{
$bill3 = 'image/ok2.jpg';
}else if($bill =='2')
{
$bill3 = 'image/ok2.jpg';
}else if($bill =='3')
{
$bill3 = 'image/ok1.jpg';
}
//--------------------------//
$pdf->SetLeftMargin( 5 );
$pdf->AddFont('cordia','','cordia.php');
$pdf->SetFont('cordia','',12);
$pdf->cell(10,6,$i.'.',1,0,'C');
$pdf->cell(40,6,iconv('UTF-8','TIS-620',$sp_name),1,0);
$pdf->Image('./image/ok1.jpg',18,5,-150);
$pdf->cell(10,6,$pdf->Image($bill1,$pdf->GetX(),$pdf->GetY(),6,6,'',$bill1),1,0);
$pdf->cell(10,6,$pdf->Image($bill2,$pdf->GetX(),$pdf->GetY(),6,6,'',$bill2),1,0);
$pdf->cell(10,6,$pdf->Image($bill3,$pdf->GetX(),$pdf->GetY(),6,6,'',$bill3),1,0);
/* if($bill =='1')
{
$bill1 = 'image/ok1.jpg';
}else if($bill =='2')
{
$bill1 = 'image/ok2.jpg';
}else if($bill =='3')
{
$bill1 = 'image/ok2.jpg';
}
//--------------------------//
if($bill =='1')
{
$bill2 = 'image/ok2.jpg';
}else if($bill =='2')
{
$bill2 = 'image/ok1.jpg';
}else if($bill =='3')
{
$bill2 = 'image/ok2.jpg';
}
//--------------------------//
if($bill =='1')
{
$bill3 = 'image/ok2.jpg';
}else if($bill =='2')
{
$bill3 = 'image/ok2.jpg';
}else if($bill =='3')
{
$bill3 = 'image/ok1.jpg';
}
//--------------------------//
$pdf->SetLeftMargin( 5 );
$pdf->AddFont('cordia','','cordia.php');
$pdf->SetFont('cordia','',12);
$pdf->cell(10,6,$i.'.',1,0,'C');
$pdf->cell(40,6,iconv('UTF-8','TIS-620',$sp_name),1,0);
$pdf->Image('./image/ok1.jpg',18,5,-150);
$pdf->cell(10,6,$pdf->Image($bill1,$pdf->GetX(),$pdf->GetY(),6,6,'',$bill1),1,0);
$pdf->cell(10,6,$pdf->Image($bill2,$pdf->GetX(),$pdf->GetY(),6,6,'',$bill2),1,0);
$pdf->cell(10,6,$pdf->Image($bill3,$pdf->GetX(),$pdf->GetY(),6,6,'',$bill3),1,0);
*/
$i++;
$pdf->Ln();
}
$pdf->SetLeftMargin( 108 );
//$pdf->Ln(25);
$pdf->setXY( 108, 64);
$pdf->AddFont('cordiab','','cordiab.php');
$pdf->SetFont('cordiab','',12);
$pdf->SetFillColor(240,231,155);
$pdf->Cell(80,7,iconv('UTF-8','TIS-620','ตามที่ตรวจจริง'),1,0,'C',true);
$pdf->Ln();
$pdf->SetFillColor(224,235,255);
$pdf->Cell(10,7,iconv('UTF-8','TIS-620','#'),1,0,'C',true);
$pdf->Cell(40,7,iconv('UTF-8','TIS-620','รายการ'),1,0,'C',true);
$pdf->Cell(10,7,iconv('UTF-8','TIS-620','ใช้ได้'),1,0,'C',true);
$pdf->Cell(10,7,iconv('UTF-8','TIS-620','ชำรุด'),1,0,'C',true);
$pdf->Cell(10,7,iconv('UTF-8','TIS-620','ไม่มี'),1,0,'C',true);
$pdf->Ln();
$pdf->SetLeftMargin( 90 );
$strSQL = "SELECT * FROM chk_store WHERE strno = '".$_GET["sID"]."' ORDER BY idno";
$objQuery = mysql_query($strSQL);
$rows = mysql_num_rows($objQuery);
$i = 1;
while($objResult = mysql_fetch_array($objQuery))
{
$sp_code = $objResult["sp_code"];
$sp_name = $objResult["sp_name"];
$jing = $objResult["jing"];
if($jing =='1')
{
$jing1 = 'image/ok1.jpg';
}else if($jing =='2')
{
$jing1 = 'image/ok2.jpg';
}else if($jing =='3')
{
$jing1 = 'image/ok2.jpg';
}
//--------------------------//
if($jing =='1')
{
$jing2 = 'image/ok2.jpg';
}else if($jing =='2')
{
$jing2 = 'image/ok1.jpg';
}else if($jing =='3')
{
$jing2 = 'image/ok2.jpg';
}
//--------------------------//
if($jing =='1')
{
$jing3 = 'image/ok2.jpg';
}else if($jing =='2')
{
$jing3 = 'image/ok2.jpg';
}else if($jing =='3')
{
$jing3 = 'image/ok1.jpg';
}
//--------------------------//
$pdf->SetLeftMargin( 108 );
$pdf->AddFont('cordia','','cordia.php');
$pdf->SetFont('cordia','',12);
$pdf->cell(10,6,$i.'.',1,0,'C');
$pdf->cell(40,6,iconv('UTF-8','TIS-620',$sp_name),1,0);
$pdf->Image('./image/ok1.jpg',18,5,-150);
$pdf->cell(10,6,$pdf->Image($jing1,$pdf->GetX(),$pdf->GetY(),6,6,'',$jing1),1,0);
$pdf->cell(10,6,$pdf->Image($jing2,$pdf->GetX(),$pdf->GetY(),6,6,'',$jing2),1,0);
$pdf->cell(10,6,$pdf->Image($jing3,$pdf->GetX(),$pdf->GetY(),6,6,'',$jing3),1,0);
$i++;
$pdf->Ln();
}
//$pdf->setXY( 10, 240);
$pdf->Ln();
$pdf->Cell(0,6,iconv('UTF-8','TIS-620','ลงชื่อ_________________________________________ผู้ตรวจสภาพ'),0,1);
$pdf->Cell(0,6,iconv('UTF-8','TIS-620', ' '.$fname.' '.$lname.''),0,1);
$pdf->Cell(0,6,iconv('UTF-8','TIS-620','วันที่_________________/_____________/_____________ '),0,1);
$pdf->Output("MyPDF/report_error.pdf","F");
?>
|
ประวัติการแก้ไข 2013-11-12 10:38:22
|
|
|
|
Date :
2013-11-12 10:28:29 |
By :
PALM26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตัวอย่้างไฟล์ PDF ที่ทำได้
|
|
|
|
|
Date :
2013-11-12 10:39:53 |
By :
PALM26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
น่าจะแยกได้นะ รูปแบบ
$pdf->Cell(10,6,'งานงานงาน',1,0,'C');
$pdf->Cell(55,6,'งานงานงาน',0,0,'C');
$pdf->Cell(80,6,'งานงานงาน',1,1,'C');
พิจารณาเลข 0 กับ 1 ลองเปลี่ยนลองเล่นดูครับ
5555555555+ ตอบไม่ทัน
|
ประวัติการแก้ไข 2013-11-12 10:41:56
|
|
|
|
Date :
2013-11-12 10:41:09 |
By :
apisitp |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|