<?php
class Pdf extends PDF_MC_Table{
	//Page header
    public $paper_w = 210, $paper_h = 330;
    function __construct() {
        //set Page 
        parent::__construct('P','mm',array($this->paper_w ,$this->paper_h));
        /*$this->AddFont("tahoma","","tahoma.php");
        $this->AddFont("tahoma","B","tahomabd.php");*/
    }

	function Header(){
        
		if($this->PageNo() != 0){		
                $this->setFont('Arial','B',12);
                $this->setFillColor(255,255,255);
                $this->setTextColor(0,0,0);
                
                $this->cell(100, 5, $this->judul, 0, 0, "L");
                $this->Ln();

                $this->setFont('Arial','',10);
                $this->cell(20, 5, "Periode", 0, 0, "L");
                $this->cell(5, 5, ":", 0, 0, "L");
                $this->MultiCell(100, 5, $this->periode, "FJ");
                $this->Ln();

                

            }
				
	}
	
	function Content()
	{
        $this->SetWidths(array(
                    $this->paper_w*5/100,
                    $this->paper_w*10/100,
                    $this->paper_w*50/100,
                    $this->paper_w*25/100
                ));
        $this->SetAligns(array("C", "C", "C", "C"));
        $this->setFont('Arial','B',10);
        $this->Row(array("No", "Kode", " Nama Akun", "Jumlah"));
                
        $this->setFont('Arial','',9);
        $this->SetAligns(array("C", "C", "L", "R", "R"));

        $total = 0;
        if(count($this->data) > 0){
            $no = 1;
            foreach($this->data as $d){
                $this->Row_bawahputus(array($no, $d->kode_perkiraan, $d->nama_perkiraan, rupiah2($d->total_ttl, 2)));
                $no++;
                $total += $d->total_ttl;
            }
        }
        $this->setFont('Arial','B',9);
        $this->SetWidths(array(
                    $this->paper_w*65/100,
                    $this->paper_w*25/100
                ));
        $this->SetAligns(array("R", "R"));
        $this->Row(array("Total Order Service", rupiah2($total, 2)));

        
	}
	
	function Footer()
	{
		$this->SetY(-15);
        $this->SetFont('Arial','',9);
        $this->Cell(0,10, $this->PageNo(),0,0,'C');
	}
}
$Pdf = new Pdf();
$Pdf->judul=$data['judul'];
$Pdf->periode=$data['periode'];
$Pdf->data=$data['data'];

$Pdf->SetAutoPageBreak(true ,15);

$Pdf->SetMargins(10,10,10);
$Pdf->AliasNbPages();
$Pdf->AddPage();
$Pdf->SetFont('Arial','',12);
$Pdf->Content();
$Pdf->SetTitle("$data[judul] periode".$data['periode']);
$Pdf->Output("$data[judul] periode".$data['periode'].".pdf", "I");

?>