<?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){	

            $spacing = 5;
            $kolom_1 = 40;
            $kolom_2 = 20;
            $kolom_3 = 5;
            $kolom_4 = 50;
            $ln = 3;

            $kanan_1 = 30;
            $kanan_2 = 5;
            $kanan_3 = 35;
            $x = $kolom_1+15;

                $this->setFont('Arial','B',12);
                $this->setFillColor(255,255,255);
                $this->setTextColor(0,0,0);
                

                $this->setFont('Arial','',10);
                $y = $this->getY();

                $this->MultiCell($kolom_1, $spacing, 'Nama Disini Disini', 1, "C");
                $this->Ln();
                $this->setFont('Arial','',20);
                $this->MultiCell($kolom_1, 10, $this->masuk->noAuto.$this->masuk->noAuto_ext, 1, "C");

                $this->setFont('Arial','',10);
                $this->setXY($x, $y);

                $this->SetWidths(array($kolom_2, $kolom_3, $kolom_4, $kanan_1, $kanan_2, $kanan_3));
                $this->SetAligns(array('L', "C", "L", "L", "C", "L" ));
                 if($this->masuk->id_pegawai != '0'){
                    $this->Row_noborder(array("Nama", ":", $this->masuk->nama_pegawai, "BNG KTG NO.", ":", $this->masuk_tenun->nama_barang));
                }else if($this->masuk->id_rekanan != '0'){
                    $this->Row_noborder(array("Nama", ":", $this->masuk->nama_rekanan, "BNG KTG NO.", ":", $this->masuk_tenun->nama_barang));
                }else if($this->masuk->id_mesin != '0'){
                    $this->Row_noborder(array("Nama", ":", $this->masuk->nama_rekanan, "BNG KTG NO.", ":", $this->masuk_tenun->nama_barang));
                }

                $this->setX($x);
                $this->SetWidths(array($kolom_2, $kolom_3, $kolom_4+$kanan_1+$kanan_2+$kanan_3));
                $this->SetAligns(array('L', "C", "L"));
                $this->Row_noborder(array("Warna", ":", ""));

                $this->setX($x);
                $this->SetWidths(array($kolom_2, $kolom_3, $kolom_4, $kanan_1, $kanan_2, $kanan_3));
                $this->SetAligns(array('L', "C", "L", "L", "C", "L" ));
                $this->Row_noborder(array("Disekir", ":", "", "Tgl.", ":", tgl_full($this->masuk->tanggal_selesai,'')));

                $this->setX($x);
                $this->SetWidths(array($kolom_2, $kolom_3, $kolom_4, $kanan_1, $kanan_2, $kanan_3));
                $this->SetAligns(array('L', "C", "L", "L", "C", "L" ));
                $this->Row_noborder(array("Motif", ":", $this->masuk_tenun->nama_motif, "PAT No.", ":", ""));

                $this->Ln();


                
                $x1 = 10;
                $this->Cell(10, 10, 'No', 1, 0, "C");
               
                $this->Cell(40, 5, 'Terima', 1, 0, "C");
                $this->Cell(40, 5, 'Setor', 1, 0, "C");
                $y = $this->getY()+5;
                
                $this->Cell(15, 10, 'Jml', 1, 0, "C");
                $this->Cell(40, 10, 'Keterangan', 1, 0, "C");
                $this->Cell(10, 10, 'KWT', 1, 0, "C");
                $this->Cell(10, 10, 'L', 1, 0, "C");
                $this->Cell(10, 10, 'TT', 1, 0, "C");
                $this->Cell(10, 10, 'KPR', 1, 0, "C");
                $this->Cell(10, 10, 'PICK', 1, 0, "C");

                $this->setXY($x1+10, $y);
                $this->Cell(20, 5, 'Tgl', 1, 0, "C");
                $this->Cell(20, 5, 'Pakan', 1, 0, "C");

                $this->setXY($x1+50, $y);
                $this->Cell(20, 5, 'Tgl', 1, 0, "C");
                $this->Cell(20, 5, 'Srg', 1, 0, "C");

                $this->Ln();
                $this->setFont('Arial','',8);
                
                $this->SetWidths(array(10, 20, 20, 20, 20, 15, 40, 10, 10, 10, 10, 10));
                $this->SetAligns(array('C', "L", "R", "L", "R", "R", "C", "R", "R", "R", "R", "R" ));
                $count = count($this->detail_tenun);
                $jum_row = 24-$count;
                $no = 1;
                foreach($this->detail_tenun as $d){ 
                    $this->Row(array($no, "", "", $d->tanggal, $d->jumlah, $d->jumlah, $d->keterangan, "", $d->lebar, "", "", $d->pick));
                    $no++;
                    }
                for($i = $no; $i <= 24; $i++){
                    $this->Row(array($i, "", "", "", "", "", "", "", "", "", "", ""));
                }

                $this->Ln();
                $y = $this->getY();
                $this->setFont('Arial','B',12);
                $this->SetWidths(array(50));
                $this->SetAligns(array('C'));
                $this->Row(array("NO. ORDER BOM"));
                $this->Row(array($this->masuk->no_workorder_barang), 20);

                $this->setXY(60, $y);
                $this->setFont('Arial','BU',12);
                $this->Cell(120, '5', 'PERSENAN PEROLEHAN SARUNG', 0, 0, "C");
                $this->Ln(7);

                $this->setX(70);
                $this->setFont('Arial','B',12);
                $this->Cell(135,'10',' BAIK = ',1,0,'L');
                $this->setXY(107,$this->GetY());
                $this->Cell(50,'10','X Rp. ',0,0,'L');
                $this->setXY(150,$this->GetY());
                $this->Cell(50,'10','= Rp. ',0,0,'L');
                $this->Ln(3);
                $this->Ln();
                
                $this->Ln(10);
                $this->setFont('Arial','B',10);
                $this->SetWidths(array(50));
                $this->SetAligns(array('C'));
                $this->Row(array("SDH DPT BOOM"));
                $this->SetAligns(array('L'));
                $this->Row(array("TGL"), 15);

                $this->setXY(70,$this->GetY()-25);
                $this->cell(40,25,'',1,0,'C');
                $this->cell(40,25,'',1,0,'C');
                $this->setX(70);
                $this->cell(40,5,'MENGETAHUI',0,0,'C');
                $this->cell(40,5,'MAKELAR',0,0,'C');
                $this->setXY(70,$this->GetY()+20);
                $this->setFont('Arial','BU',10);
                $this->Cell(40,5,'MISMAN',0,0,'C');
                $this->Cell(40,5,'......................',0,0,'C');

                $this->Ln(10);
                $this->setXY(150, $this->getY());
                $this->SetWidths(array(40));
                $this->SetAligns(array('L'));
                $this->Row_noborder(array(""), 10);
            }
				
	}
	
	function Content()
	{   
        $this->setFont('Arial','',9);
        $this->setFillColor(255,255,255);
        $this->setTextColor(0,0,0);
        $this->SetWidths(array(40, 80, 37, 37));
        $this->SetAligns(array('C', 'L', 'R', 'R'));

        
	}
	
	function Footer()
	{
		
	}
}
$Pdf = new Pdf();
$Pdf->masuk = $data['masuk'];
$Pdf->detail = $data['barang'];
$Pdf->setor = $data['setor'];
$Pdf->masuk_tenun = $data['masuk_tenun'];
$Pdf->detail_tenun = $data['barang_tenun'];
$Pdf->SetAutoPageBreak(true ,15);

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

?>