|
|
|
php pdf ใส่เส้นและตัว header บางส่วนในหน้าที่ 2..... |
|
|
|
|
|
|
|
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()
{
include("time.php");
$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 เวลาพิมพ์ ').date('d').'/'. date('m').'/'.( date('Y')+543 ).' '. date('H:i:s'), 0 , 1 );
$this->line(5, 28,200,28);
$this->SetLeftMargin( 5 );
$this->AddFont('cordiab','','cordiab.php');
$this->SetFont('cordiab','',18);
$this->Ln(10);
$this->Cell(0,5,iconv('UTF-8','TIS-620','ใบสั่งซื้อรถ'), 0 , 1 ,'C' );
$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,8,iconv('UTF-8','TIS-620','ลำดับ'),1,0,'C',true);
$this->Cell(45,8,iconv('UTF-8','TIS-620','เลขเครื่อง'),1,0,'C',true);
$this->Cell(45,8,iconv('UTF-8','TIS-620','เลขถัง'),1,0,'C',true);
$this->Cell(20,8,iconv('UTF-8','TIS-620','ยี่ห้อ'),1,0,'C',true);
$this->Cell(35,8,iconv('UTF-8','TIS-620','รุ่น'),1,0,'C',true);
$this->Cell(20,8,iconv('UTF-8','TIS-620','สี'),1,0,'C',true);
$this->Cell(25,8,iconv('UTF-8','TIS-620','ราคาซื้อ(บาท)'),1,0,'C',true);
$this->Ln();
}
}
//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);
$rows = mysql_num_rows($objQuery);
$num=1; //ลำดับที่ 123
$i=0;
$rows=23;
$pdf=new PDF('P','mm','A4');
$pdf->AddPage();
while($objResult = mysql_fetch_array($objQuery))
{
$i++;
$buy = $objResult["buy"];
$color = $objResult["color"];
$color1 = $objResult["color1"];
$total = $total +$buy;
$pdf->AddFont('cordia','','cordia.php');
$pdf->SetFont('cordia','',13);
$pdf->cell(10,8,$num,'L');
$pdf->cell(45,8,$objResult["machine_id"]); //ชื่อ
$pdf->cell(45,8,$objResult["chassis_id"]);
$pdf->cell(20,8,iconv('UTF-8','TIS-620',$objResult["brand_name"]));
$pdf->cell(35,8,iconv('UTF-8','TIS-620', $objResult["type_name"]));
$pdf->cell(20,8,iconv('UTF-8','TIS-620',$objResult["color_name"].'-'.$objResult["color_name1"]));
$pdf->cell(25,8,number_format($buy,2),'R');
$pdf->Ln();
if ($i%$rows==0){
$pdf->AddPage();
for($i=0;$i<count($header);$i++)
$pdf->Cell($w[$i],7,iconv('UTF-8', 'TIS-620', $header[$i]));
$i=0;
$rows=23;
}
$num++;
}
$pdf->AddFont('cordia','B','cordia.php');
$pdf->SetFont('cordia','B',12);
$pdf->Cell(80,0,iconv( 'UTF-8','TIS-620','__________________________________'),0,1,"C");
$pdf->Cell(320,0,iconv( 'UTF-8','TIS-620','__________________________________'),0,1,"C");
$pdf->Ln(16);
$pdf->Cell(320,0,iconv( 'UTF-8','TIS-620','คู่ค้า'),0,1,"C");
$pdf->Cell(80,0,iconv( 'UTF-8','TIS-620','ฝ่ายจัดซื้อ'),0,1,"C");
$pdf->Output("report_po.pdf","F");
?>
|
|
|
|
|
Date :
2013-06-18 15:53:53 |
By :
PALM26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|