 <?php
class Pdf extends PDF_MC_Table{
	//Page header
	//public $kas_masuk,$tgl1,$tgl2;
	function __construct() {
		//set Page 
		parent::__construct('P','mm',array(210 ,330 ));
		/*$this->AddFont("tahoma","","tahoma.php");
		$this->AddFont("tahoma","B","tahomabd.php");*/
    }
	function Header(){
        
		if($this->PageNo() == 1){		
                $this->setFont('Arial','B',18);
                $this->setFillColor(255,255,255);

                $this->cell(0,7,'Kartu Inventaris '.$this->header,0, 0,'C',1);
                $this->setFont('Arial','',10);
                $this->Ln();
                $this->cell(0,7, $this->sub_header,0, 0,'C',1);  
                $this->Ln(); 
                $this->cell(0,7, date('d-m-Y H:i'),0, 0,'C',1);   
                $this->Ln();
                $this->Ln();                                            

            }
				
	}
	
	function Content()
	{        
        $this->setFont('arial','B',9);
        $this->SetWidths(array(10, 30, 90, 30, 15, 15   ));
        $this->SetAligns(array('C', 'C', 'C', 'C','C'));
        $this->Row(array("No", "Kode Barang", "Nama Barang", "Gudang", "Jumlah", "Satuan"));  

        $this->setFont('Arial','',8);
        $this->SetAligns(array('C', "L", "L", "L", "R","L"));

                $no = 1;
                if(count($this->detail) > 0){
                    foreach ($this->detail as $k) {
                        $nama_barang = get_empty($k['nama_barang']).get_empty($k['nama_komposisi']).get_empty($k['nama_kualitas_proses']).get_empty($k['nama_corak']).get_empty($k['nama_motif']).get_empty($k['nama_kualitas']).get_empty($k['kualitas_dudul']).get_empty($k['nama_kualitas_periksa']).get_empty($k['nama_label']).get_empty($k['nama_cap']).get_empty($k['nama_kemasan']).get_empty($k['nama_kemasansatuan']).get_empty($k['nama_kemasansepuluh']).get_empty($k['nama_kemasanseratus']);

                        $this->Row(array($no, $k['kode_barang'], $nama_barang, $k['nama_gudang'], format_angkav2($k['stok']), $k['nama_satuan']));

                        $no++;
                    }
                }else{
                    $this->Row(array("", "", "", "", "", ''));
                }
	}
	
	function Footer()
	{
		$this->Ln();
       	
		$this->SetY(-15);
		//buat garis horizontal
		
		//Arial italic 9
		$this->SetFont('Arial','B',9);
        $this->Cell(0,10,'',0,0,'L');
		//nomor halaman
		//$this->SetFont('tahoma','',9);
		//$this->Cell(0,10,'Halaman '.$this->PageNo().' dari {nb}',0,0,'R');
	}
	
}
$Pdf = new Pdf();
/*$Pdf->detail=$data['detail'];
$Pdf->data=$data['data'];*/
$Pdf->detail = $data['detail'];
$Pdf->header = $data['header'];
$Pdf->sub_header = $data['sub_header'];
$Pdf->SetAutoPageBreak(true ,15);

$Pdf->SetMargins(10,10,10);
$Pdf->AliasNbPages();
$Pdf->AddPage();
$Pdf->SetFont('Arial','',12);
$Pdf->Content();
$Pdf->SetTitle("Persediaan");
$Pdf->Output("Persediaan.pdf", "I");
/*$Pdf->SetTitle("Bon Bahan - ".$data['data']->id_barangkeluar);
$Pdf->Output("Bon Bahan - ".$data['data']->id_barangkeluar.".pdf", "I");*/


?>