|
|
|
PHP PDF......................ใส่รูปในตาราง....แทนข้อความ |
|
|
|
|
|
|
|
ช่วงบรรทัดที่ 162 เป็นต้อนไปอ้ะค้ะ
<?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->Cell(0,0,iconv( 'UTF-8','TIS-620',''),1,0,"C");
$this->SetY(-15);
$this->Ln(5);
//พิมพ์วัน-เวลา ตรงมุมขวาล่าง
$this->Cell(0,0,iconv( 'UTF-8','TIS-620','By... ศูนย์ซ่อมพะยูนมอเตอร์'),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","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("motor");
$strSQL = "SELECT c.sp_code,c.machine_id,s.chassis_id,s.brand,s.type,c.mee,s.plate,b.brand_name,a.class_name,m.type_name,s.color,s.color1,e.color_name,f.color_name1
FROM chk_store c,stock s,brand b,class a,model m,color e,color1 f
WHERE
s.machine_id = c.machine_id AND
s.brand = b.brand_id AND
s.class = a.class_id AND
s.type = m.type_id AND
c.machine_id = '".$_GET["mID"]."' ";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
$brand = $objResult["brand"];
$type = $objResult["type"];
$chassis_id = $objResult["chassis_id"];
$plate = $objResult["plate"];
$color = $objResult["color"];
$color1 = $objResult["color1"];
//end class
$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( 10);
$pdf->AddFont('cordiab','','cordiab.php');
$pdf->SetFont('cordiab','',14);
$pdf->Cell( 0 , 10 , iconv( 'UTF-8','cp874' , 'หมายเลขเครื่อง :' ) , 0, 1,'L' );
$pdf->Cell( 0 , 10 , iconv( 'UTF-8','cp874' , 'รุ่น :') , 0, 1 );
$pdf->Cell( 0 , 10 , iconv( 'UTF-8','cp874' , 'ป้ายทะเบียน :' ) , 0, 1);
$pdf->SetLeftMargin( 38 );
$pdf->AddFont('cordia','','cordia.php');
$pdf->SetFont('cordia','',14);
$pdf->Cell( 0 , -10, iconv( 'UTF-8','cp874' , $plate ) , 0 , 1);
$pdf->Cell( 0 , -10, iconv( 'UTF-8','cp874' , $class_name ) , 0 , 1);
$pdf->Cell( 0 , -10, iconv( 'UTF-8','cp874' , $_GET["mID"] ) , 0 , 1);
$pdf->SetLeftMargin( 80 );
$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( 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' , $type_name ) , 0 , 1 );
$pdf->Cell( 0 , -10 , iconv( 'UTF-8','cp874' , $chassis_id ) , 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' , $color_name.'/'.$color_name1 ) , 0 , 1 );
$pdf->Cell( 0 , -10 , iconv( 'UTF-8','cp874' , $brand_name ) , 0 , 1 );
$pdf->SetLeftMargin( 10 );
$pdf->Ln(30);
$pdf->AddFont('cordiab','','cordiab.php');
$pdf->SetFont('cordiab','',14);
$pdf->SetFillColor(224,235,255);
$pdf->Cell(10,7,iconv('UTF-8','TIS-620','ลำดับ'),1,0,'C',true);
$pdf->Cell(55,7,iconv('UTF-8','TIS-620','รายการ'),1,0,'C',true);
$pdf->Cell(25,7,iconv('UTF-8','TIS-620','มี'),1,0,'C',true);
$pdf->Cell(25,7,iconv('UTF-8','TIS-620','ไม่มี'),1,0,'C',true);
$pdf->Cell(25,7,iconv('UTF-8','TIS-620','ชำรุด'),1,0,'C',true);
$pdf->Cell(25,7,iconv('UTF-8','TIS-620','ใช้งานไม่ได้'),1,0,'C',true);
$pdf->Cell(25,7,iconv('UTF-8','TIS-620','ใช้ได้'),1,0,'C',true);
$pdf->Ln();
$pdf->SetLeftMargin( 10 );
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("motor");
$strSQL = "SELECT c.sp_code,c.machine_id,s.chassis_id,s.brand,s.type,c.mee,c.sapab FROM chk_store c,stock s
WHERE
s.machine_id = c.machine_id AND
c.machine_id = '".$_GET["mID"]."' AND c.error = '1' ";
$objQuery = mysql_query($strSQL);
$rows = mysql_num_rows($objQuery);
$num=1; //ลำดับที่ 123
$i=0;
$rows=21;
while($objResult = mysql_fetch_array($objQuery))
{
$i++;
$sp_code = $objResult["sp_code"];
$sp_name = $objResult["sp_name"];
$mee = $objResult["mee"];
$sapab = $objResult["sapab"];
$pdf->AddFont('cordia','','cordia.php');
$pdf->SetFont('cordia','',13);
$pdf->cell(10,8,$num.'.',1,0,'L');
$pdf->cell(55,8,iconv('UTF-8','TIS-620',$sp_code),1,0);
if($mee =='1')
{
$mee = "มี";
}else if($mee =='2')
{
$mee = "ไม่มี";
}
if($sapab =='1')
{
$sapab = "ชำรุด";
}else if($sapab =='2')
{
$sapab = "ใช้งานไม่ได้";
}else
{
$sapab = "ใช้ได้";
}
$pdf-> Image('image/sq.jpg',80,219,28,18,'jpg','1');
//$pdf-> Cell( 25 , 8 , Image($path,12,10,14),1,0);
$pdf->cell(25,8,iconv('UTF-8','TIS-620',$mee),1,0);
$pdf->cell(25,8,iconv('UTF-8','TIS-620',$mee),1,0);
$pdf->cell(25,8,iconv('UTF-8','TIS-620',$sapab),1,0);
$pdf->cell(25,8,iconv('UTF-8','TIS-620',$sapab),1,0);
$pdf->cell(25,8,iconv('UTF-8','TIS-620',$sapab),1,0);
$pdf->Ln();
if ($i%$rows==0)
{
$pdf->AddPage();
$pdf->SetLeftMargin( 10 );
$pdf->Ln(5);
$pdf->AddFont('cordiab','','cordiab.php');
$pdf->SetFont('cordiab','',14);
$pdf->SetFillColor(224,235,255);
$pdf->Cell(10,7,iconv('UTF-8','TIS-620','ลำดับ'),1,0,'C',true);
$pdf->Cell(55,7,iconv('UTF-8','TIS-620','รายการ'),1,0,'C',true);
$pdf->Cell(25,7,iconv('UTF-8','TIS-620','มี'),1,0,'C',true);
$pdf->Cell(25,7,iconv('UTF-8','TIS-620','ไม่มี'),1,0,'C',true);
$pdf->Cell(25,7,iconv('UTF-8','TIS-620','ชำรุด'),1,0,'C',true);
$pdf->Cell(25,7,iconv('UTF-8','TIS-620','ใช้งานไม่ได้'),1,0,'C',true);
$pdf->Cell(25,7,iconv('UTF-8','TIS-620','ใช้ได้'),1,0,'C',true);
$pdf->Ln();
for($i=0;$i<count($header);$i++)
$pdf->Cell($w[$i],7,iconv('UTF-8', 'TIS-620', $header[$i]));
$i=0;
$rows=21;
}
$num++;
}
$pdf->Output("report_error.pdf","F");
?>
|
|
|
|
|
Date :
2013-06-20 15:15:12 |
By :
PALM26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date :
2013-06-20 15:45:53 |
By :
PALM26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ใช้ if
กับ
Code (PHP)
$pdf->Image('./images/pic.png',18,5,-150);
|
|
|
|
|
Date :
2013-06-20 19:46:34 |
By :
iieszz |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|