Codenya sbb:
<?php
require_once"koneksivar.php";
$conn = new mysqli($DBServer, $DBUser, $DBPass, $DBName);
if ($conn->connect_error) {
trigger_error('Database connection failed: ' . $conn->connect_error, E_USER_ERROR);
}
define('FPDF_FONTPATH', 'libPDF/fpdf/font/');
require('libPDF/fpdf/fpdf.php');
class PDF extends FPDF{
function Header(){
$this->Image("aray.jpg", 1, 0 ,2.5, 2, "JPG", "http://www.lp2maray.com");
$this->SetTextColor(128,0,0);
$this->SetFont('Arial','B','14');// $this->SetFont('Times','',12);
$this->Cell(20,0,' Data Jabatan',5,1,'L');
$this->Ln();
$this->Cell(20,1,' YAYASAN LP2M ARAY JAKARTA SELATAN',0,1,'L');
}
function Footer(){
$this->SetY(-4,5);
$this->SetY(-2,5);
$this->Cell(0,1,$this->PageNo(),0,0,'C');
}
}
$sql = "select * from `$tbjabatan`";
$jml = getJum($conn,$sql);
$i=0;
$arr=getData($conn,$sql);
foreach($arr as $d) {
$cell[$i][0]=$d["kode_jabatan"];
$cell[$i][1]=$d["nama_jabatan"];
$cell[$i][2]=RP($d["gaji_pokok"]);
$cell[$i][3]=RP($d["uang_makan"]);
$cell[$i][4]=RP($d["uang_transport"]);
$cell[$i][5]=$d["keterangan"];
$i++;
}
$pdf=new PDF('L','cm','A4');//$pdf=new PDF("P","in","Letter");
$pdf->Open();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Arial','B','9');
$pdf->SetFillColor(192,192,192);
$pdf->Cell(1,1,'no','LR',0,'L',1);
//$pdf->MultiCell(0, 0.5, $lipsum1, 'LR', "L");
$pdf->Cell(3,1,'kode_jabatan','LR',0,'C',1);
$pdf->Cell(7,1,'nama_jabatan','LR',0,'C',1);
$pdf->Cell(3,1,'gaji_pokok','LR',0,'C',1);
$pdf->Cell(3,1,'uang_makan','LR',0,'C',1);
$pdf->Cell(3,1,'uang_transport','LR',0,'C',1);
$pdf->Cell(8,1,'keterangan','LR',0,'C',1);
$pdf->Ln();
$pdf->SetFont('Arial','','8');
for ($j=0;$j<$i;$j++){
$pdf->Cell(1,1,$j+1,'B',0,'L'); // no
$pdf->Cell(3,1,$cell[$j][0],'B',0,'L'); // kode_jabatan
$pdf->Cell(7,1,$cell[$j][1],'B',0,'L'); // nama_jabatan
$pdf->Cell(3,1,$cell[$j][2],'B',0,'L'); // gaji_pokok
$pdf->Cell(3,1,$cell[$j][3],'B',0,'L'); // uang_makan
$pdf->Cell(3,1,$cell[$j][4],'B',0,'L'); // uang_transport
$pdf->Cell(8,1,$cell[$j][5],'B',0,'L'); // keterangan
$pdf->Ln();
}
$pdf->Output();
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
function getJum($conn,$sql){
$rs=$conn->query($sql);
$jum= $rs->num_rows;
$rs->free();
return $jum;
}
function getData($conn,$sql){
$rs=$conn->query($sql);
$rs->data_seek(0);
$arr = $rs->fetch_all(MYSQLI_ASSOC);
$rs->free();
return $arr;
}
function RP($rupiah){return number_format($rupiah,"2",",",".");}
?>
Atau silakan Download dimari
Langganan:
Posting Komentar (Atom)
Selisih Waktu Berjalan
Berikut adalah fungsi PHP yang menghitung selisih hari antara tanggal saat ini dengan tanggal 2024-08-22 . Jika tanggal saat ini kurang dari...
-
<?php // <a href='download.php?file=$file' title='Download File'>Download Dokumen</a> $direktori = ...
-
Teman2 ...mungkin sering dapat kode random..... btw ini ada share sedikit ttg membuat soal random.....yang beda disini adalah sy menggunaka...
-
<?php $sql="select `id_admin` from `$tbadmin` order by `id_admin` desc"; $jum= getJum($conn,$sql); $kd="ADM"...
Tidak ada komentar:
Posting Komentar