 <?php
class Pdf extends PDF_MC_Table{
    //Page header
    //public $kas_masuk,$tgl1,$tgl2;
    function __construct() {
        //set Page 
        parent::__construct('L','mm', array(140, 100));
        /*$this->AddFont("tahoma","","tahoma.php");
        $this->AddFont("tahoma","B","tahomabd.php");*/
    }
    function Header(){
        
                
        $this->setFont('Arial','B',10);
        $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('Arial','B',12);
            $this->cell(0,7, 'TANDA TERIMA BARANG',0, 0,'C',1);
            $this->Ln(7);
        }

        
                
    }
    
    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('Arial','',8);
        $this->cell(25 ,4 , 'NOMOR', 0, 0, 'L', 1);
        $this->cell(5 ,4 , ':', 0, 0, 'C', 1);
        $this->MultiCell(40 ,4 , $no_terima.$faktur_terima, 0, 'L');

        $this->cell(25 ,4 , 'TANGGAL', 0, 0, 'L', 1);
        $this->cell(5 ,4 , ':', 0, 0, 'C', 1);
        $this->MultiCell(40 ,4 , $tgl_terima, 0, 'L');

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

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

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

        $this->Ln(2);
        $this->setFont('arial','B',8);
        $this->SetWidths(array(10, 50, 20, 20, 23));
        $this->SetAligns(array('C', 'C', 'C', 'C','C'));
        $this->Row(array("NO", "KETERANGAN", "SATUAN", "JUMLAH", "CATATAN"));  

        $this->setFont('Arial','',8);
        $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), ''));
            $no++;
            }
        }else{
            $this->Row(array("", "", "", "", ""));
        } 

        
        $this->Ln(3);
        $y = $this->getY();
        $no_terima = $this->data->no_faktur;
        $faktur_terima = $this->data->sufix_no_faktur;

        $this->setFont('arial','',8);
        $this->SetWidths(array(35, 35, 19, 5, 30));
        $this->SetAligns(array('L', 'L', 'L', 'C', 'L'));
        $this->Row_noborder(array("Diserahkan Oleh :", "Diterima Oleh :", "PO NO", ":", $no_terima.$faktur_terima));
        $this->Row_noborder(array("", "", "NO SJ", ":", $this->data->no_suratjalan));
        $this->Row_noborder(array("", "", "TANGGAL", ":", tgl_full($this->data->tanggal_faktur, '')));

        $this->Ln(2);
        $this->SetWidths(array(20, 15, 20, 15));
        $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(80, $y);
        $this->setFont('arial','',8);
        $this->SetWidths(array(19, 5, 30));
        $this->SetAligns(array('L', 'C', 'L'));
        $this->Row_noborder(array("PO NO", ":", $no_terima.$faktur_terima), 4);

        $y = $this->getY();
        $this->setXY(80, $y);
        $this->setFont('arial','',8);
        $this->SetWidths(array(19, 5, 30));
        $this->SetAligns(array('L', 'C', 'L'));
        $this->Row_noborder(array("NO SJ", ":", $this->data->no_suratjalan), 4);

        $y = $this->getY();
        $this->setXY(80, $y);
        $this->setFont('arial','',8);
        $this->SetWidths(array(19, 5, 30));
        $this->SetAligns(array('L', 'C', 'L'));
        $this->Row_noborder(array("TANGGAL ", ":", tgl_full($this->data->tanggal_faktur, '')), 4);*/

    }
    
    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,5,5);
$Pdf->AliasNbPages();
$Pdf->AddPage();
$Pdf->SetFont('Arial','',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");


?>