<?php
include "../../../koneksi.php";
require('../fpdf17/fpdf.php');
/**
 Judul  : Laporan PDF (portait):
 Level  : Menengah
 Author : Hakko Bio Richard
 Blog   : www.hakkoblogs.com
 Web    : www.niqoweb.com
 Email  : hakkobiorichard@ygmail.com
 
 Untuk tutorial yang lainnya silahkan berkunjung ke www.hakkoblogs.com
 
 Butuh jasa pembuatan website, aplikasi, pembuatan program TA dan Skripsi.? Hubungi NiqoWeb ==>> 085694984803
 
 **/
//Menampilkan data dari tabel di database

$result=mysql_query("SELECT * FROM sub_kriteria") or die(mysql_error());

//Inisiasi untuk membuat header kolom

$colomid_kriteria = "";
$colomid_subkriteria = "";
$colomnamasub = "";
$colomnilai = "";
$i=1;
//For each row, add the field to the corresponding column
while($row = mysql_fetch_array($result))
{
	$id_kriteria = $row["id_kriteria"];
    $id_sub = $row["id_sub"];
    $nama_sub = $row["nama_sub"];
    $nilai = $row["bobot"];

	
	$colomid_kriteria = $colomid_kriteria.$id_kriteria."\n";
    $colomid_subkriteria = $colomid_subkriteria.$id_sub."\n";
    $colomnamasub = $colomnamasub.$nama_sub."\n";
    $colomnilai = $colomnilai.$nilai."\n";

//Create a new PDF file
$pdf = new FPDF('P','mm',array(210,297)); //L For Landscape / P For Portrait
$pdf->AddPage();

//Menambahkan Gambar
$pdf->Image('logo.png',7,7,-175);

$pdf->SetFont('Arial','B',13);
$pdf->Cell(80);
$pdf->Cell(30,10,'DINAS PERTANINAN',0,0,'C');
$pdf->Ln();
$pdf->Cell(80);
$pdf->Cell(30,10,'SPK PENENTUAN WILAYAH BERPOTENSI ',0,0,'C');
$pdf->Ln();
$pdf->SetFont('Arial','',10);
$pdf->Cell(5);
$pdf->Cell(115,15,'Adapun Sub kriteria yang digunakan dalam penilaian wilayah ',0,0,'L');
$pdf->Ln();
$pdf->Cell(5);
$pdf->Cell(115,0,' Yang berpotensi untuk ditanami tanaman cengkeh :',0,0,'L');
$pdf->Ln();
$i=$i+1;
}
//Fields Name position
$Y_Fields_Name_position = 50;

//First create each Field Name
//Gray color filling each Field Name box
$pdf->SetFillColor(110,180,230);
//Bold Font for Field Name
$pdf->SetFont('Arial','B',10);
$pdf->SetY($Y_Fields_Name_position);

$pdf->SetX(15);
$pdf->Cell(25,8,'ID Kriteria',1,0,'C',1);
$pdf->SetX(40);
$pdf->Cell(25,8,'ID Sub Kriteria',1,0,'C',1);
$pdf->SetX(65);
$pdf->Cell(110,8,'Nama Sub Kriteria',1,0,'C',1);
$pdf->SetX(175);
$pdf->Cell(25,8,'Nilai',1,0,'C',1);
$pdf->SetX(150);
$pdf->Ln();

//Table position, under Fields Name
$Y_Table_Position =58;

//Now show the columns
$pdf->SetFont('Arial','',10);

$pdf->SetY($Y_Table_Position);
$pdf->SetX(15);
$pdf->MultiCell(25,6,$colomid_kriteria,1,'C');

$pdf->SetY($Y_Table_Position);
$pdf->SetX(40);
$pdf->MultiCell(25,6,$colomid_subkriteria,1,'L');

$pdf->SetY($Y_Table_Position);
$pdf->SetX(65);
$pdf->MultiCell(110,6,$colomnamasub,1,'L');

$pdf->SetY($Y_Table_Position);
$pdf->SetX(175);
$pdf->MultiCell(25,6,$colomnilai,1,'C');

$pdf->Output();
?>
