 <?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 ));
		
    }
	function Header(){
        
		if($this->PageNo() != 0){		
                $this->setFont('Arial','B',14);
                $this->setFillColor(255,255,255);
                
                $this->cell(0,7,'MUTASI BARANG KESELURUHAN',0,0,'C',1);
                $this->Ln(10);
                $this->setFont('Arial','',11);
                
                $this->ln();
                $this->SetWidths(array(40, 10, 150));
                $this->SetAligns(array("L", "L", "L"));
                $barang = "";
                
                if(count($this->induk['barang']) > 0){
                    $barang = $this->induk['barang']->nama_kategori." - ".$this->induk['barang']->nama_sub." - ".$this->induk['barang']->nama_barang;
                }
                
                $this->Row_noborder(array("Nama Barang", ": ", $barang )); //

                $tgl = '';
                if($this->induk['tanggal_awal'] != '' && $this->induk['tanggal_akhir'] != ''){
                    $tgl = date_range($this->induk['tanggal_awal'], $this->induk['tanggal_akhir']);
                }

                $this->Row_noborder(array("Periode", ": ", $tgl));
                $this->Row_noborder(array("Lokasi", ": ", $this->induk['nama_lokasi']));

                $this->Ln();
                $this->setFont('arial','B', 8);
                
                $y = $this->getY();
                $this->Cell(10, 14, "NO", 1, 0, "C", 1);
                $this->Cell(17, 14, "TANGGAL", 1, 0, "C", 1);
                $this->Cell(20, 14, "NO. ORDER", 1, 0, "C", 1);
                $this->Cell(50, 14, "BARANG", 1, 0, "C", 1);
                $this->Cell(60, 7, "JUMLAH BARANG", 1, 0, "C", 1);
                $this->Cell(40, 14, "KETERANGAN", 1, 0, "C", 1);

                
                $this->SetXY(102, $y+7);
                $this->Cell(20, 7, "MASUK", 1, 0, "C", 1);
                $this->SetXY(122, $y+7);
                $this->Cell(20, 7, "KELUAR", 1, 0, "C", 1);
                $this->SetXY(142, $y+7);
                $this->Cell(20, 7, "SISA", 1, 0, "C", 1);

                $this->Ln();

                $this->SetWidths(array(10, 17, 20, 50, 20, 20, 20, 40));
                $this->setFont('arial','',8);
                $this->SetAligns(array('C', 'L', 'L', 'L', 'R', 'R', 'R', 'L'));
            }
				
	}
	
	function Content()
	{   
        $this->SetWidths(array(10, 17, 20, 50, 20, 20, 20, 40));
        $this->setFont('arial','',8);
        $this->SetAligns(array('C', 'L', 'L', 'L', 'R', 'R', 'R', 'L'));
        
    
        $no = 1;
        $arr = array();        

        if(count($this->detail) > 0){
            foreach ($this->detail as $k) {

                $nama_barang = get_empty($k['nama_barang']).get_empty($k['nama_proses']).get_empty($k['inisial_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, tgl_full($k['tanggal'], ''), $k['no_workorder_barang'], $nama_barang, $k['masuk'], $k['keluar'], $k['total'], get_stripe([$k['ket_1'], $k['ket_3']]))); 
                $no++;
            }
        }else{
            $this->Row(array("", "", "", "", "", "", "", "")); 
        }
        
        $this->setFillColor(255,255,255);
        
        
        
        

    
	}
	
	function Footer()
	{
		$this->Ln();
        $this->SetY(-15);
        $this->SetFont('Arial','',9);
        $this->Cell(0,10, $this->PageNo(),0,0,'C');
	}
	
}
$Pdf = new Pdf();
$Pdf->induk=$data['induk'];
$Pdf->where=$data['where'];
$Pdf->detail=$data['detail'];
$Pdf->SetAutoPageBreak(true ,15);

$Pdf->SetMargins(5,5,5);
$Pdf->AliasNbPages();
$Pdf->AddPage();
$Pdf->SetFont('Arial','',12);
$Pdf->Content();
$Pdf->SetTitle("Mutasi _".$data['induk']['barang']->nama_barang."_".date_range($data['induk']['tanggal_awal'], $data['induk']['tanggal_akhir']));
$Pdf->Output("Mutasi _".$data['induk']['barang']->nama_barang."_".date_range($data['induk']['tanggal_awal'], $data['induk']['tanggal_akhir']).".pdf", "I");

?>