<?php

// create new PDF document

$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);    



// set document information

$pdf->SetCreator(PDF_CREATOR);

$pdf->SetAuthor('Kikin Kusumah');

$pdf->SetTitle($title);

$pdf->SetSubject('');

$pdf->SetKeywords('TCPDF, PDF, Kikinsoft');



// remove default header/footer

$pdf->setPrintHeader(false);

$pdf->setPrintFooter(false);



// set default monospaced font

$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);



// set margins

$pdf->SetMargins(10, 15, 10);



// set auto page breaks

$pdf->SetAutoPageBreak(TRUE, 10);



// set image scale factor

$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);



// set some language-dependent strings (optional)

if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {

	require_once(dirname(__FILE__).'/lang/eng.php');

	$pdf->setLanguageArray($l);

}



// ---------------------------------------------------------



// set font

$pdf->SetFont('helvetica', '', 8);



// add a page

$pdf->AddPage('P','A4');

//$pdf->Cell(0, 1, 'Nama', 1, 0, 'L','','','','','','T');

// writeHTML($html, $ln=true, $fill=false, $reseth=false, $cell=false, $align='')

// writeHTMLCell($w, $h, $x, $y, $html='', $border=0, $ln=0, $fill=0, $reseth=true, $align='', $autopadding=true)

$html="";

// create some HTML content

$html .= '

<table border="0" cellpadding="2" cellspacing="0">

	<tr>

		<td width="560">

			<font size="+2"><b>'.$cmpy_nm.'</b></font>

		</td>

		<td width="120" align="center">

			<img src="'.site_url($this->modul.'/barcode/'.$rhdr->opname_id).'"><br>

			'.$rhdr->opname_no.'

		</td>

	</tr>	

	<tr>

		<td colspan="2">

			<hr style="height:2px">

		</td>

	</tr>	

	<tr>

		<td colspan="2" align="center"><font size="+1"><b>'.$this->title.'</b></font><br></td>

	</tr>

</table>

<table border="0" cellpadding="2" cellspacing="0">

	<tr>

		<td width="70">Opname No</td>

		<td width="10">:</td>

		<td width="160">'.$rhdr->opname_no.'</td>

		<td width="90">Opname Date</td>

		<td width="10">:</td>

		<td width="110">'.$rhdr->Fopname_date.'</td>

		<td width="90">Line</td>

		<td width="10">:</td>

		<td width="120">'.$rhdr->line.'</td>

	</tr>

</table><br><br>

<table border="1" cellpadding="2" cellspacing="0" style="border-collapse:collapse">

<thead>	

	<tr>

		<td width="100" align="center"><b>Item Code</b></td>

		<td width="450" align="center"><b>Item Description</b></td>

		<td width="80" align="center"><b>Qty.</b></td>

		<td width="40" align="center"><b>UOM</b></td>

	</tr>

</thead>

<tbody>';

//for($i=0;$i<20;$i++){

//print_r($rdet);

foreach($rdet as $r){

	$html .= '<tr>

				<td width="100">'.$r->mat_id.'</td>

				<td width="450">'.$r->NmBarang.'</td>

				<td width="80" align="right">'.$r->Fqty.'</td>

				<td width="40" align="center">'.$r->Sat.'</td>

			</tr>';	

}

//}

	

$html .= '</tbody>

</table>

<br><br>

Notes : '.$rhdr->notes.'<br><br>

';

	

// output the HTML content

$pdf->writeHTML($html, true, false, true, false, '');





// ---------------------------------------------------------    



// Close and output PDF document

// This method has several options, check the source code documentation for more information.

$pdf->Output($rs[$j]->opname_id.'.pdf', 'I');

?>        