<?php
class PDF extends FPDF{
    function sertifikat($id){
        ob_clean();
        $cetak = mysql_query("SELECT detail_user.nama ,detail_user.alamat_kantor ,skp.no_permohonan ,skp.tanggal_cetak ,skp.tanggal_berlaku ,skp_produk.id_produk ,skp_produk.jenis_produk FROM detail_user ,skp ,skp_produk WHERE detail_user.id_user = skp.id_user AND skp.id_skp = skp_produk.id_skp AND skp_produk.id_produk = $id");
        $c=mysql_fetch_array($cetak);

	$temp = mysql_query("SELECT kolom.* FROM kolom ,temp WHERE  kolom.id_temp = temp.id_temp ORDER BY kolom.orders");
	
	$i = 1;
	while($tmp=mysql_fetch_array($temp)){
            $alur = mysql_query("SELECT * FROM skp_alur WHERE id_produk = $c[id_produk] ORDER BY id_alur");
            
                while($a=mysql_fetch_array($alur)){
                    $al .= "".$a[alur].",";
                }
                
                $list = substr($al,0,-1);
			if($i==1){
				$tm = $c[no_permohonan];
			}elseif($i==2){
				$tm = $c[nama];
			}elseif($i==3){
				$tm = $c[alamat_kantor];
			}elseif($i==4){
				$tm = $c[jenis_produk];
			}elseif($i==5){
				$tm = $list;
			}elseif($i==6){
				$tm = $c[tanggal_cetak];
			}elseif($i==7){
				$tm = $c[tanggal_berlaku];
			}
		
		
	
		$this->Ln($tmp[jarak_bawah]);
		$this->Cell($tmp[jarak_kiri]);
		//Save the current position
		$x=$this->GetX();
		$y=$this->GetY();
		//Print the text
		$this->MultiCell($tmp[lebar],$tmp[tinggi],$tm,0,'L');
		//Put the position to the right of the cell
		$this->SetXY($x+90,$y);
		
		$i++;
	}
}
}

