|
|
|
ต้องการ fix เส้นตารางให้มีความสูงคงที่ ต้องการ fix เส้นตารางให้มีความสูงคงที่ และกำหนดให้ 1 หน้า |
|
|
|
|
|
|
|
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->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 );
$this->Ln(34);
$this->AddFont('cordiab','','cordiab.php');
$this->SetFont('cordiab','',15);
$this->Cell( 283 , -10 , iconv( 'UTF-8','cp874' , 'กำหนดส่งรถ:' ) , 0 , 1 ,'C' );
$this->Cell( 280 , -10 , iconv( 'UTF-8','cp874' , 'วันที่ซื้อรถ :' ) , 0 , 1,'C' );
$this->Cell( 288 , -10 , iconv( 'UTF-8','cp874' , 'เลขที่ :') , 0 , 1,'C' );
$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
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["po_id"]."' ";
$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"];
$this->Ln(30);
$this->AddFont('cordia','','cordia.php');
$this->SetFont('cordia','',15);
$this->Cell( 0 , -10, iconv( 'UTF-8','cp874' , $date_order ) , 0 , 1,'R' );
$this->Cell( 0 , -10 , iconv( 'UTF-8','cp874' , $date_order ) , 0 , 1,'R' );
$this->Cell( 0 , -10 , iconv( 'UTF-8','cp874' , $_GET['po_id'] ) , 0 , 1,'R' );
$this->Ln(31);
$this->AddFont('cordiab','','cordiab.php');
$this->SetFont('cordiab','',15);
$this->Cell( 70 , -10 , iconv( 'UTF-8','cp874' , 'เบอร์โทร :' ) , 0, 1 , 'L' );
$this->Cell( 70 , -10 , iconv( 'UTF-8','cp874' , 'ที่อยู่ :' ) , 0, 1 , 'L' );
$this->Cell( 70 , -10 , iconv( 'UTF-8','cp874' , 'ซื้อรถจากสาขา :') , 0, 1 , 'L' );
$this->AddFont('cordia','','cordia.php');
$this->SetFont('cordia','',15);
$this->Ln(30);
$this->Cell( 82 , -10, iconv( 'UTF-8','cp874' , $tel ) , 0 , 1,'C' );
$this->Cell( 86 , -10, iconv( 'UTF-8','cp874' , $address ) , 0 , 1,'C' );
$this->Cell( 140, -10, iconv( 'UTF-8','cp874' , $branch_no.'-'.$branch_name ) , 0 , 1,'C' );
//ปัดบรรทัด กำหนดความกว้างของบรรทัด 35 หน่วย
$this->Ln(35);
$this->AddFont('cordiab','','cordiab.php');
$this->SetFont('cordiab','',14);
$this->SetFillColor(224,235,255);
$this->Cell(10,7,iconv('UTF-8','TIS-620','ลำดับ'),1,0,'C',true);
$this->Cell(45,7,iconv('UTF-8','TIS-620','เลขเครื่อง'),1,0,'C',true);
$this->Cell(45,7,iconv('UTF-8','TIS-620','เลขถัง'),1,0,'C',true);
$this->Cell(20,7,iconv('UTF-8','TIS-620','ยี่ห้อ'),1,0,'C',true);
$this->Cell(35,7,iconv('UTF-8','TIS-620','รุ่น'),1,0,'C',true);
$this->Cell(20,7,iconv('UTF-8','TIS-620','สี'),1,0,'C',true);
$this->Cell(25,7,iconv('UTF-8','TIS-620','ราคาซื้อ(บาท)'),1,0,'C',true);
$this->Ln();
}
function Footer()
{
$this->SetLineWidth(0.5);
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");
//นับจากขอบกระดาษด้านล่างขึ้นมา 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
$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,C.type_name,B.color,B.color1,D.color_name,F.color_name1,B.buy,A.brand_name,E.branch_name
FROM po_detail B, po_mas M,brand A,model C,color D,color1 F,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
F.color_id1 = b.color1 AND
M.branch_no = E.branch_no AND
b.po_id = '".$_GET["po_id"]."' ";
//echo mysql_error();
$objQuery = mysql_query($strSQL);
echo mysql_error();
$Num_Rows = mysql_num_rows($objQuery);
$t = 1;
$pdf=new PDF('P','mm','A4');
$pdf->AliasNbPages();//จำนวนหน้าทั้งหมด
$pdf->AddPage();
while($objResult = mysql_fetch_array($objQuery))
{
$buy = $objResult["buy"];
$color = $objResult["color"];
$color1 = $objResult["color1"];
$total = $total +$buy;
$pdf->AddFont('cordia','','cordia.php');
$pdf->SetFont('cordia','',13);
$pdf->cell(10,7,$t,'L');
$pdf->cell(45,7,$objResult["machine_id"]); //ชื่อ
$pdf->cell(45,7,$objResult["chassis_id"]);
$pdf->cell(20,7,iconv('UTF-8','TIS-620',$objResult["brand_name"]));
$pdf->cell(35,7,iconv('UTF-8','TIS-620', $objResult["type_name"]));
$pdf->cell(20,7,iconv('UTF-8','TIS-620',$objResult["color_name"].'-'.$objResult["color_name1"]));
$pdf->cell(25,7,number_format($buy,2),'R');
$pdf->Ln();
$t++;
}
/*$pdf->AddFont('cordiab','','cordiab.php');
$pdf->SetFont('cordiab','',14);
$pdf->Cell(175,7,iconv('UTF-8','TIS-620','ราคารวม'),'BTLR');
$pdf->Cell(25,7,iconv('UTF-8','TIS-620',number_format($total,2)),'BTR');
*/
$pdf->Output("report_po.pdf","F");
?>
|
|
|
|
|
Date :
2013-06-18 12:28:46 |
By :
PALM26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|