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

 $pdf = new MYPDF('P', 'mm', 'A4', true, 'UTF-8', false);
$pdf->Open();
	
	$pdf->SetTitle($detail->nama);
	
	$pdf->AddPage('P', '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,210,297);

	}else {
	$img_file = 'sertifikat/'.$detail->gbr_sert_depan;
	$pdf->SetAutoPageBreak(false, 0);
	$pdf->Image($img_file,-1,-1,215,297);
	}
    //KODE SERTIFIKAT
	$pdf->SetFont('helvetica', 'B', 7);
	$pdf->Ln(53);
	$pdf->Cell(319, 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="110px"></td><td width="200px" style="font-size: 10px; font-family:Times New Roman;"><br><br><br><br><br><br><i>No Reg : '.$detail->no_register.'<br>Keaslian LoA ini dapat diperiksa dengan memindai QR kode disamping</i></td><td width="37px"></td><td width="550%" style="font-size: 12px; font-family:Arial;"><br>Sidoarjo, '.$detail->jabatan.'</td></tr></table>';
	$ttd = '<table border="0" cellspacing="0" cellpadding="0"><tr><td></td><td></td><td width="10%"></td><td width="30%" style="font-size: 12px; 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: 12px;">'.$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', 22, 237, 25,25, $style, 'Y');

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

    //STEMPEL
	$pdf->Image('ttd/'.$detail->cap.'',105,245,30,30);

    //TTD
	$pdf->Image('ttd/'.$detail->ttd.'',125,248,50,22);
    
	$html = '
		<table border="0" cellspacing="0" cellpadding="0">
			
			<tr>
				<td style="font-size: 10px; text-indent: 90px; font-family:Arial Narrow;">'.$detail->no_register.'</td>
			</tr>
			
			<tr>
				<td><br><br></td>
			</tr>
			<tr height="100px">
				<td style="font-size: 12px; text-indent: 90px; font-family:Arial;"><b>'.$detail->jenis_dokumen.'</b></td>
			</tr>

			<tr>
				<td><br><br></td>
			</tr>
			
			<tr>
				<td><br><br><br></td>
			</tr>
			
			<tr>
				<td width="15%"></td><td width="445px" align="justify;" style="font-size: 14px; font-family:Arial;">'.$detail->nama.'</td>
			</tr>

			<tr>
				<td width="1px"></td><td width="300px" style="font-size: 11px; text-indent: 80px; font-family:Arial;">Sebagai Penulis </td>
			</tr>

			<tr>
				<td width="1px"></td><td width="300px" style="font-size: 12px; text-indent: 80px; font-family:Arial;">di </td>
			</tr>
			
			<tr>
				<td width="5%"></td><td width="445px" style="font-size: 12px; text-indent: 100px; font-family:Arial;">Tempat</td>
			</tr>
			
			<tr>
				<td><br><br></td>
			</tr>

			<tr>
				<td width="7%"></td><td width="97%" align="justify;  font-family:Arial;">'.$keterangan.'</td>
			</tr>
			<tr>
				<td><br><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');
?>