<?php 
class MYPDF extends TCPDF {
		  function Header(){} 
		  function Footer(){} 
}

 $pdf = new MYPDF('L', 'mm', 'A4', true, 'UTF-8', false);
$pdf->Open();
	
	$pdf->SetTitle($detail->nama);
	
	$pdf->AddPage('L', 'A4');
	
	// set bacground image
	if ($detail->gbr_sert_depan==NULL){
	$img_file = 'sertifikat/sertifikat_lpmp_no_bingkai.png';
	$pdf->SetAutoPageBreak(false, 0);
	$pdf->Image($img_file,0,0,297,210);

	}else {
	$img_file = 'sertifikat/'.$detail->gbr_sert_depan;
	$pdf->SetAutoPageBreak(false, 0);
	$pdf->Image($img_file,0,0,297,210);
	}
    //KODE SERTIFIKAT
	$pdf->SetFont('helvetica', 'B', 9);
	$pdf->Ln(40);
	$pdf->Cell(475, 0, 'No Seri: '.$detail->unik,0, $ln=8, 'C', 0, '', 0, false, 'D', 'T');
    
    //Batas tabel atas 
	
	// Data data dimasukkan html
	$keterangan=$detail->ket_statis_awal;//Yang akan direplasce
	$tgl_acara = tgl_indo($detail->tgl_acara);//Replace tgl acara
	$pesan_0 = str_replace('%TANGGAL_ACARA%',$tgl_acara,$keterangan);

	
	$tgl_acara_1 = tgl_indo($detail->tgl_acara_akhir);//Replace tgl acara
	$pesan_1 = str_replace('%TANGGAL_ACARA_AKHIR%',$tgl_acara_1,$pesan_0);

	$nama_acara = $detail->nama_acara;//Replace 2
	$pesan_2 = str_replace('%NAMA_ACARA%',$nama_acara,$pesan_1);

	$kategori =$detail->kategori;//Replace 3
	$pesan_3 = str_replace('%KATEGORI%',$kategori,$pesan_2);

	$judul = $detail->judul;//Replace 
	$pesan_4 = str_replace('%JUDUL%',$judul,$pesan_3);

	$enter = '<br>';//Replace 5
	$pesan_5 = str_replace('%E%',$enter,$pesan_4);

	$bdepan = '<b>';//Replace 6
	$pesan_6 = str_replace('%BA%',$bdepan,$pesan_5);


	$bbel = '</b>';//Replace 7
	$pesan_7 = str_replace('%BB%',$bbel,$pesan_6);

	$bdepan = '<i>';//Replace 8
	$pesan_8 = str_replace('%IA%',$bdepan,$pesan_7);


	$bbel = '</i>';//Replace 9
	$pesan_9 = str_replace('%IB%',$bbel,$pesan_8);
	

	$yogya = '<table border="0" cellspacing="0" cellpadding="0"><tr><td width="20%"></td><td width="30%" style="font-size: 10px; font-family:Times New Roman;"><br><br><br><br><i>Keabsahan sertifikat ini. <br>No Reg : '.$detail->no_register.'<br>Keaslian sertifikat ini dapat diperiksa dengan memindai QR kode disamping</i></td><td width="150%"></td><td width="32%" style="font-size: 13px; font-family:Arial;">Sidoarjo, '.tgl_indo($detail->tgl_sertifikat).'<br>Direktur Pelatihan dan Pendidikan</td></tr></table>';
	$ttd = '<table border="0" cellspacing="0" cellpadding="0"><tr><td></td><td></td><td style="font-size: 13px; font-family:Arial;">'.$detail->nama_ttd.'<br>'.$detail->nip_ttd.'</td></tr></table>';
	$keterangan = '<table border="0" cellspacing="0" cellpadding="0"><tr><td width="8%"></td><td width="84%" style="font-size: 14px;">'.$pesan_9.' </td><td width="8%"></td></tr></table>';
    
	$base=''.base_url().'';
    //QR CODE
	$msg = $base."verify/no/".$detail->unik;
	$style = array(
	    'border' => 1,
	    'padding' => '1px',
	    'fgcolor' => 1,
	    'bgcolor' => false
	);
	$pdf->write2DBarcode($msg, 'QRCODE,L', 38, 152, 25,25, $style, 'Y');

    //LOGO DIATAS QR CODE
	$pdf->Image('assets/img/lpmpjogja.gif',37,180,10,5);

    //STEMPEL
	$pdf->Image('ttd/'.$detail->cap.'',155,140,45,45);

    //TTD
	$pdf->Image('ttd/'.$detail->ttd.'',183,158,60,20);
    
	$html = '
		<table border="0" cellspacing="0" cellpadding="0">
			
			<tr>
				<td><br><br><br></td>
			</tr>
			<tr height="200px">
				<td align="center" style="font-size: 30px; font-family:Times New Roman;"><b>'.$detail->jenis_dokumen.'</b></td>
			</tr>
			<tr>
				<td align="center" style="font-size: 12px; font-family:Arial Narrow;">Nomor : '.$detail->no_sertifikat.'</td>
			</tr>
			<tr>
				<td><br></td>
			</tr>
			<tr>
				<td align="center" style="font-size: 14px; font-family:Arial Narrow;">diberikan kepada: </td>
			</tr>
			
			<tr>
				<td><br></td>
			</tr>
			<tr>
				<td align="center" style="font-size: 20px; font-family:Cambria; text-decoration: none; "><b>'.$detail->nama.'</b></td>
			</tr>

			<tr>
				<td align="center" style="font-size: 14px; font-family:Arial;">'.$detail->unit_kerja.'</td>
			</tr>

			<tr>
				<td><br></td>
			</tr>

			<tr>
				<td align="center">'.$keterangan.'</td>
			</tr>
			<tr>
				<td><br></td>
			</tr>
			<tr>
			<td>'.$yogya.'</td>
			</tr>
			<tr>
				<td>'.$ttd.'</td>
			</tr>
		</table>';

	// output the HTML content
	$pdf->writeHTML($html, true, false, true, false, '');

	//Buat PDF 
	$pdf->Output($detail->nama.'.pdf', 'I');
?>