|
|
จะไห้กล่องสี่เหลี่ยมสองกล่อง มันเท่ากันเเต่ set ยังไงก้อไม่เท่าอยู่ดี
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->SetLeftMargin( 30 );
$this->Cell(0,5,iconv('UTF-8','TIS-620','บจก. ตั้งใจกลการพัฒนา (ศูนย์ซ่อมบำรุง)'), 0 , 1 );
$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->line(5, 28,200,28);
$this->SetLeftMargin( 5 );
}
function Footer()
{
$this->SetLineWidth(0.5);
$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");
//นับจากขอบกระดาษด้านล่างขึ้นมา 10 มม.
$this->SetY(-38);
$this->Cell(80,0,iconv( 'UTF-8','TIS-620','__________________________________'),0,1,"C");
$this->Cell(190,0,iconv( 'UTF-8','TIS-620','__________________________________'),0,1,"C");
$this->Cell(300,0,iconv( 'UTF-8','TIS-620','__________________________________'),0,1,"C");
//นับจากขอบกระดาษด้านล่างขึ้นมา 10 มม.
$this->SetY(-30);
$this->Cell(300,0,iconv( 'UTF-8','TIS-620','ผู้อนุมัติ'),0,1,"C");
$this->Cell(190,0,iconv( 'UTF-8','TIS-620','คู่ค้า'),0,1,"C");
$this->Cell(80,0,iconv( 'UTF-8','TIS-620','ฝ่ายจัดซื้อ'),0,1,"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');
}
}
//end class
$pdf=new PDF('P','mm','A4');
$pdf->AddPage();
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("motor");
$strSQL = "SELECT M.branch_no,M.date_order,E.branch_name,E.address,E.tel,M.name
FROM po_detail B, po_mas M,branch E
WHERE
B.po_id = M.po_id AND
M.branch_no = E.branch_no AND
B.po_id = '".$_GET["txtKeyword"]."' ";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
$branch_no = $objResult["branch_no"];
$branch_name = $objResult["branch_name"];
$address = $objResult["address"];
$tel = $objResult["tel"];
$date_order = $objResult["date_order"];
$name = $objResult["name"];
$pdf->Ln(15);
$pdf->AddFont('cordiab','','cordiab.php');
$pdf->SetFont('cordiab','',14);
$pdf->MultiCell( 90 , 13 , iconv( 'UTF-8','cp874' , 'บริษัท : '.$branch_name),'LTR');
$pdf->MultiCell( 90 , 13 , iconv( 'UTF-8','cp874' , 'เบอร์โทร :'.$tel ),'LR');
$pdf->MultiCell( 90 , 13 , iconv( 'UTF-8','cp874' , 'ที่อยู่ :'.$address ),'LBR');
$pdf->SetLeftMargin(110 );
$pdf->SetTopMargin( 5 );
$pdf->MultiCell( 90 , 13 , iconv( 'UTF-8','cp874' , 'เลขที่ใบสั่งซื้อ:'. $_GET["txtKeyword"] ),'LTR');
$pdf->MultiCell( 90 , 13 , iconv( 'UTF-8','cp874' , 'วันที่สั่งซื้อ :'.$date_order ) ,'LR');
$pdf->MultiCell( 90 , 13 , iconv( 'UTF-8','cp874' , 'ผู้สั่งซื้อ :'.$name) ,'LBR');
$pdf->SetLeftMargin(5 );
$pdf->Ln(15);
$pdf->AddFont('cordiab','','cordiab.php');
$pdf->SetFont('cordiab','',14);
$pdf->Cell(10,7,iconv('UTF-8','TIS-620','ลำดับ'),1,0,'C');
$pdf->Cell(45,7,iconv('UTF-8','TIS-620','เลขเครื่อง'),1,0,'C');
$pdf->Cell(45,7,iconv('UTF-8','TIS-620','เลขถัง'),1,0,'C');
$pdf->Cell(20,7,iconv('UTF-8','TIS-620','ยี่ห้อ'),1,0,'C');
$pdf->Cell(30,7,iconv('UTF-8','TIS-620','รุ่น'),1,0,'C');
$pdf->Cell(20,7,iconv('UTF-8','TIS-620','สี'),1,0,'C');
$pdf->Cell(25,7,iconv('UTF-8','TIS-620','ราคาซื้อ(บาท)'),1,0,'C');
$pdf->Ln();
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("motor");
$strSQL = "SELECT M.branch_no,B.chassis_id,B.machine_id,M.date_order,B.brand,B.status,C.type_name,D.color_name,B.buy,A.brand_name,E.branch_name
FROM po_detail B, po_mas M,brand A,type C,color D,branch E
WHERE
b.po_id = m.po_id AND
a.brand_id = b.brand AND
c.type_id = b.type AND
d.color_id = b.color AND
M.branch_no = E.branch_no AND
b.po_id = '".$_GET["txtKeyword"]."' ";
//echo mysql_error();
$objQuery = mysql_query($strSQL);
$num=mysql_num_rows($objQuery);
$t = 1;
while($objResult = mysql_fetch_array($objQuery))
{
$status = $objResult["status"];
$pdf->AddFont('cordia','','cordia.php');
$pdf->SetFont('cordia','',13);
$pdf->Cell(10,7,$t,'LR',0,'C');
$pdf->Cell(45,7,$objResult["machine_id"],'LR',0,'L'); //ชื่อ
$pdf->Cell(45,7,$objResult["chassis_id"],'LR',0,'L');
$pdf->Cell(20,7,iconv('UTF-8','TIS-620',$objResult["brand_name"]),'LR',0,'L');
$pdf->Cell(30,7,iconv('UTF-8','TIS-620', $objResult["type_name"]),'LR',0,'L');
$pdf->Cell(20,7,iconv('UTF-8','TIS-620',$objResult["color_name"]),'LR',0,'L');
$pdf->Cell(25,7,iconv('UTF-8','TIS-620',number_format($objResult["buy"],2)),'LR',0,'R');
$pdf->Ln();
$total = $total + $objResult["buy"];
$t++;
}
$pdf->Cell(170,7,iconv('UTF-8','TIS-620','ราคารวม'),1,0,'C');
$pdf->Cell(25,7,iconv('UTF-8','TIS-620',number_format($total,2)),1,0,'R');
$pdf->Output("report_po_search1.pdf","F");
?>
Tag : PHP, MySQL
|
ประวัติการแก้ไข 2013-05-23 15:01:47
|
|
|
|
|
Date :
2013-05-23 15:01:01 |
By :
PALM26 |
View :
5295 |
Reply :
1 |
|
|
|
|
|
|
|
|
|