 <?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(){
        
                
        $this->setFont('Courier','B',12);
        $this->setFillColor(255,255,255);
        if($this->PageNo() == 1){   
            if($this->data->cv == 1){
                $this->cell(0,7,'CV. KETJUBUNG',0, 0,'L',1);
                $this->Ln();
            } 
            
            $this->setFont('Courier','B',14);
            $this->cell(0,7, 'TANDA TERIMA BARANG',0, 0,'C',1);
            $this->Ln(15);
        }


        
                
    }
    
    function Content()
    {   
        $no_terima = $this->data->no_faktur_terima;
        $faktur_terima = $this->data->faktur_terima;
        $tgl_terima = $this->data->tanggal_terima;
        if($no_terima == '' || $faktur_terima == ''){
            $no_terima = $this->data->no_faktur;
            $faktur_terima = $this->data->sufix_no_faktur;
        }

        if($tgl_terima == ''){
            $tgl_terima = tgl_full($this->data->tanggal_faktur, '');
        }else{
            $tgl_terima = tgl_full($this->data->tanggal_terima, '');
        }

        $this->setFillColor(255,255,255);
        $y = $this->getY();
        $this->setFont('Courier','B',11);
        $this->cell(31 ,7 , 'NOMOR', 0, 0, 'L', 1);
        $this->cell(5 ,7 , ':', 0, 0, 'C', 1);
        $this->MultiCell(70 ,7 , $no_terima.$faktur_terima, 0, 'L');

        $this->cell(31 ,7 , 'TANGGAL', 0, 0, 'L', 1);
        $this->cell(5 ,7 , ':', 0, 0, 'C', 1);
        $this->MultiCell(70 ,7 , $tgl_terima, 0, 'L');

        $this->SetXY(110, $y);
        $this->cell(31 ,7 , 'DITERIMA DARI', 0, 0, 'L', 1);
        $this->cell(5 ,7 , ':', 0, 0, 'C', 1);
        $this->MultiCell(70 ,7 , $this->data->nama_penyedia, 0, 'L');
        $y2 = $this->getY();
        $this->SetXY(110, $y2);
        $this->cell(31 ,7 , 'NO KENDARAAN', 0, 0, 'L', 1);
        $this->cell(5 ,7 , ':', 0, 0, 'C', 1);
        $this->MultiCell(70 ,7 , $this->data->nopol, 0, 'L');

        $y3 = $this->getY();
        $this->SetXY(110, $y3);
        $this->cell(31 ,7 , 'NAMA SUPIR', 0, 0, 'L', 1);
        $this->cell(5 ,7 , ':', 0, 0, 'C', 1);
        $this->MultiCell(70 ,7 , $this->data->nama_supir, 0, 'L');

        $this->Ln(5);
        $this->MultiCell(0 , 5, 'Dengan ini kami menyatakan bahwa kami telah menerima sejumlah barang dengan kondisi baik dengan jumlah dan deskripsi sebagai berikut :', 0, 'FJ');


        $this->setFont('Courier','B',11);
        $this->SetWidths(array(10, 90, 30, 30, 30));
        $this->SetAligns(array('C', 'C', 'C', 'C','C'));
        $this->Row(array("NO", "KETERANGAN", "SATUAN", "JUMLAH", "CATATAN"));  

        $this->setFont('Courier','B', 11);
        $this->SetAligns(array('C', "L", "C", "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, $nama_barang, $k->nama_satuan, format_angka($k->jumlah), ''), 10);
            $no++;
            }
        }else{
            $this->Row(array("", "", "", "", ""));
        } 

        
        $this->Ln(10);
        $y = $this->getY();

        $this->setFont('Courier','B',10);
        $this->SetWidths(array(50, 50));
        $this->SetAligns(array('L', 'L'));
        $this->Row_noborder(array("Diserahkan Oleh :", "Diterima Oleh :"));

        $this->Ln(15);
        $this->SetWidths(array(30, 20, 30, 20));
        $this->SetAligns(array('L', 'L', 'L', 'L'));
        $this->Row_noborder(array("Nama", "Tanggal", "Nama", "Tanggal"));

        $no_terima = $this->data->no_faktur;
        $faktur_terima = $this->data->sufix_no_faktur;
        
        $this->setXY(130, $y);
        $this->setFont('Courier','B',10);
        $this->SetWidths(array(20, 5, 50));
        $this->SetAligns(array('L', 'C', 'L'));
        $this->Row_noborder(array("PO NO", ":", $no_terima.$faktur_terima));

        $y = $this->getY();
        $this->setXY(130, $y);
        $this->SetWidths(array(20, 5, 50));
        $this->SetAligns(array('L', 'C', 'L'));
        $this->Row_noborder(array("NO SJ ", ":", $this->data->no_suratjalan));
        
        $y = $this->getY();
        $this->setXY(130, $y);
        $this->SetWidths(array(20, 5, 50));
        $this->SetAligns(array('L', 'C', 'L'));
        $this->Row_noborder(array("TANGGAL ", ":", tgl_full($this->data->tanggal_faktur, '')));

    }
    
    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->data=$data['data'];
$Pdf->detail=$data['detail'];
$Pdf->SetAutoPageBreak(true ,15);

$Pdf->SetMargins(10,10,10);
$Pdf->AliasNbPages();
$Pdf->AddPage();
$Pdf->SetFont('Courier','B',12);
$Pdf->Content();
$Pdf->SetTitle("Penerimaan Barang ".$data['data']->no_faktur.$data['data']->sufix_no_faktur." ");
$Pdf->Output("Penerimaan Barang ".$data['data']->no_faktur.$data['data']->sufix_no_faktur." .pdf", "I");
/*$Pdf->SetTitle("Bon Bahan - ".$data['data']->id_barangkeluar);
$Pdf->Output("Bon Bahan - ".$data['data']->id_barangkeluar.".pdf", "I");*/


?>