<?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() != 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();

                $y = $this->getY();
                $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->setXY(150, $y);
                $this->MultiCell(50, 5, (count($this->data) > 0) ? $this->data[0]->nama.' '.$this->data[0]->pic:"", 0, "L");

                $this->Ln();

                

            }
				
	}
	
	function Content()
	{   
        $this->SetWidths(array(10, 20, 25, 70, 10, 30, 30));
        $this->SetAligns(array("C", "C", "C","C","C", "C", "C", "C"));
        $this->setFont('Arial','B',10);
        $this->Row(array("No", "Tanggal", "No. Order", "Akun", "Qty", "Harga Satuan", "Jumlah"));
                
        $this->setFont('Arial','',9);
        $this->SetAligns(array("C", "L", "L","L", "C", "R", "R"));

        $total = 0;
        if(count($this->data) > 0){
            $no = 1;
            foreach($this->data as $d){
                $this->Row_bawahputus(array($no, tgl_full($d->tanggal_nota, ''), $d->no_nota."".$d->sufix_no_nota, format_akun_perkiraan($d), $d->jumlah, rupiah2($d->harga_satuan, 2), rupiah2($d->total, 2)));
                 $no++;
                 $total += $d->total;
            }
        }
        $this->setFont('Arial','B',9);
        $this->SetWidths(array(165, 30));
        $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'];
$count = (count($data['data']) > 0) ? $data['data'][0]->nama.' ('.$data['data'][0]->pic.')':"";
$Pdf->SetAutoPageBreak(true ,15);

$Pdf->SetMargins(10,10,10);
$Pdf->AliasNbPages();
$Pdf->AddPage();
$Pdf->SetFont('Arial','',12);
$Pdf->Content();
$Pdf->SetTitle("Laporan Order Service per Penyedia  - ".$count);
$Pdf->Output("Laporan Order Service per Penyedia  - ".$count.".pdf", "I");

?>