001.
<?php
002.
require
(
'pdf/fpdf.php'
);
003.
004.
class
PDF
extends
FPDF
005.
{
006.
007.
008.
function
LoadData(
$file
)
009.
{
010.
011.
$lines
=file(
$file
);
012.
$data
=
array
();
013.
foreach
(
$lines
as
$line
)
014.
$data
[]=
explode
(
';'
,
chop
(
$line
));
015.
return
$data
;
016.
}
017.
018.
019.
function
BasicTable(
$header
,
$data
)
020.
{
021.
022.
$w
=
array
(10,35,25,25,25);
023.
024.
for
(
$i
=0;
$i
<
count
(
$header
);
$i
++)
025.
$this
->Cell(
$w
[
$i
],7,
$header
[
$i
],1,0,
'C'
);
026.
$this
->Ln();
027.
028.
foreach
(
$data
as
$eachResult
)
029.
{
030.
$this
->Cell(10,6,
$i
++,1,0,
'C'
);
031.
$this
->Cell(35,6,
$eachResult
[
"Date_Time"
],1,0,
'C'
);
032.
$this
->Cell(25,6,number_format(
$eachResult
[
"Money_Old"
],2),1,0,
'R'
);
033.
$this
->Cell(25,6,number_format(
$eachResult
[
"Deposit"
],2),1,0,
'R'
);
034.
$this
->Cell(25,6,number_format(
$eachResult
[
"Balance"
],2),1,0,
'R'
);
035.
$this
->Ln();
036.
}
037.
}
038.
039.
040.
function
FancyTable(
$header
,
$data
)
041.
{
042.
043.
$this
->SetFillColor(255,0,0);
044.
$this
->SetTextColor(255);
045.
$this
->SetDrawColor(128,0,0);
046.
$this
->SetLineWidth(.3);
047.
$this
->SetFont(
''
,
'B'
);
048.
049.
$w
=
array
(10,35,25,25,25);
050.
for
(
$i
=0;
$i
<
count
(
$header
);
$i
++)
051.
$this
->Cell(
$w
[
$i
],7,
$header
[
$i
],1,0,
'C'
,true);
052.
$this
->Ln();
053.
054.
$this
->SetFillColor(224,235,255);
055.
$this
->SetTextColor(0);
056.
$this
->SetFont(
''
);
057.
058.
$fill
=false;
059.
foreach
(
$data
as
$row
)
060.
{
061.
$this
->Cell(
$w
[0],6,
$row
[0],
'LR'
,0,
'C'
,
$fill
);
062.
$this
->Cell(
$w
[1],6,
$row
[1],
'LR'
,0,
'C'
,
$fill
);
063.
$this
->Cell(
$w
[2],6,number_format(
$row
[2]),
'LR'
,0,
'R'
,
$fill
);
064.
$this
->Cell(
$w
[3],6,number_format(
$row
[3]),
'LR'
,0,
'R'
,
$fill
);
065.
$this
->Cell(
$w
[4],6,number_format(
$row
[4]),
'LR'
,0,
'R'
,
$fill
);
066.
$this
->Ln();
067.
$fill
=!
$fill
;
068.
}
069.
$this
->Cell(
array_sum
(
$w
),0,
''
,
'T'
);
070.
}
071.
}
072.
073.
$pdf
=
new
PDF();
074.
075.
076.
$header
=
array
(
'ลำดับ'
,
'วันที่'
,
'เงินในบัญชี'
,
'ฝาก'
,
'คงเหลือ'
);
077.
078.
079.
080.
include
"connect.php"
;
081.
$strSQL
=
"SELECT * FROM deposit WHERE Date2 BETWEEN '"
.
$_GET
['dateInput
']."'
and
'".$_GET['
dateInput2
']."'
order by ID ASC ";
082.
mysql_query(
"SET NAMES TIS620"
);
083.
$objQuery
= mysql_query(
$strSQL
);
084.
$resultData
=
array
();
085.
for
(
$i
=0;
$i
<mysql_num_rows(
$objQuery
);
$i
++) {
086.
$result
= mysql_fetch_array(
$objQuery
);
087.
array_push
(
$resultData
,
$result
);
088.
}
089.
090.
091.
define(
'FPDF_FONTPATH'
,
'font/'
);
092.
093.
094.
include
"connect.php"
;
095.
$strSQL
=
"SELECT * FROM deposit WHERE ID_Account = '"
.
$_SESSION
['ID_Account
']."'
";
096.
mysql_query(
"SET NAMES TIS620"
);
097.
$objQuery
= mysql_query(
$strSQL
);
098.
$objResult
= mysql_fetch_array(
$objQuery
);
099.
$Name_Account
=
$objResult
[
"Name_Account"
];
100.
101.
102.
$pdf
->AddPage();
103.
$pdf
->AddFont(
'angsa'
,
''
,
'angsa.php'
);
104.
$pdf
->SetFont(
'angsa'
,
''
,14);
105.
$pdf
->Image(
'pdf/logo.jpg'
,95,8,20);
106.
$pdf
->Ln(25);
107.
$pdf
->Cell(0,1,
'รายงานการฝากเงินของ '
.
$Name_Account
.
' '
,0,1,
"C"
);
108.
$pdf
->Ln(5);
109.
$pdf
->Cell(0,1,
'จากวันที่ '
.
$_GET
[
'dateInput'
].
' ถึงวันที่ '
.
$_GET
[
'dateInput2'
].
' '
,0,1,
"C"
);
110.
$pdf
->Ln(5);
111.
$pdf
->BasicTable(
$header
,
$resultData
);
112.
113.
$pdf
->Output(
"pdf/MyPDF/show-deposit.pdf"
,
"F"
);
114.
?>