 <?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(){
        $set_h = 10;

        $this->setFont('Arial','B',12);
        $label_cv = "CV KETJUBUNG";
        $this->Cell(60, $set_h, $label_cv, 1, 0, "C");

        $this->setFont('Arial','B',15);
        $judul = strtoupper("Bukti Bank Masuk");
        $this->Cell(70, $set_h, $judul, 1, 0, "C");

        $this->setFont('Arial','',11);

        $this->Rect($this->getX(), $this->getY(), 60, $set_h);
        $this->Cell(20, $set_h, "Nomor", 0, 0, "L");
        $this->Cell(3, $set_h, ":", 0, 0, "L");
        $this->Cell(42, $set_h, "9999/BS/12/9999", 0, 1, "L");

        $this->Rect($this->getX(), $this->getY(), 130, $set_h*2);
        $this->Cell(130, $set_h-2, "Dibayarkan kepada :", 0, 0, "L");

        $this->Rect($this->getX(), $this->getY(), 60, $set_h);
        $this->setX($this->getX());
        $this->Cell(20, $set_h, "Tanggal", 0, 0, "L");
        $this->Cell(3, $set_h, ":", 0, 0, "L");
        $this->Cell(42, $set_h, "", 0, 1, "L");

        $this->setFont('Arial','B',12);
        $this->setY($this->getY()-2);
        $nama_penerima = "Penerima";
        $this->Cell(130, $set_h+2, $nama_penerima, 0, 0, "L");

        $this->setFont('Arial','',11);
        $this->Rect($this->getX(), $this->getY()+2, 60, $set_h);
        $this->setXY($this->getX(), $this->getY()+2);
        $this->Cell(20, $set_h, "Lampiran", 0, 0, "L");
        $this->Cell(3, $set_h, ":", 0, 0, "L");
        $jumlah_lampiran = 0;
        if($jumlah_lampiran == 0) $jumlah_lampiran = "-";
        $this->Cell(42, $set_h, $jumlah_lampiran."     Lembar", 0, 1, "L");
				
	}
	
	function Content(){
        $set_h = 5;
        $total_uraian = 0;

        $this->setFont('Arial','B',11);
        $this->setWidths([130, 60]);
        $this->setAligns(["C", "C"]);
        $this->Row(["Uraian", "Jumlah"], $set_h+1);
        // detail uraian

        // total
        $this->setFont('Arial','',11);
        $this->setWidths([130, 60]);
        $this->setAligns(["R", "R"]);
        $set_total_uraian = "Rp".rupiah2($total_uraian, 2);
        $this->Row(["Total", $set_total_uraian], $set_h+1);

        // terbilang
        $this->setWidths([40, 150]);
        $this->setAligns(["C", "L"]);
        $terbilang_total_uraian = terbilang($total_uraian);
        $this->Row(["Total", $terbilang_total_uraian], $set_h+5);

        $this_x = $this->getX();
        $this_y = $this->getY();

	}
	
	function Footer()
	{

	}

	function MultiCells($w, $h, $txt, $border=0, $ln=0, $align='J', $fill=false)
    {
        // Custom Tomaz Ahlin
        if($ln == 0) {
            $current_y = $this->GetY();
            $current_x = $this->GetX();
        }

        // Output text with automatic or explicit line breaks
        $cw = &$this->CurrentFont['cw'];
        if($w==0)
            $w = $this->w-$this->rMargin-$this->x;
        $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize;
        $s = str_replace("\r",'',$txt);
        $nb = strlen($s);
        if($nb>0 && $s[$nb-1]=="\n")
            $nb--;
        $b = 0;
        if($border)
        {
            if($border==1)
            {
                $border = 'LTRB';
                $b = 'LRT';
                $b2 = 'LR';
            }
            else
            {
                $b2 = '';
                if(strpos($border,'L')!==false)
                    $b2 .= 'L';
                if(strpos($border,'R')!==false)
                    $b2 .= 'R';
                $b = (strpos($border,'T')!==false) ? $b2.'T' : $b2;
            }
        }
        $sep = -1;
        $i = 0;
        $j = 0;
        $l = 0;
        $ns = 0;
        $nl = 1;
        while($i<$nb)
        {
            // Get next character
            $c = $s[$i];
            if($c=="\n")
            {
                // Explicit line break
                if($this->ws>0)
                {
                    $this->ws = 0;
                    $this->_out('0 Tw');
                }
                $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
                $i++;
                $sep = -1;
                $j = $i;
                $l = 0;
                $ns = 0;
                $nl++;
                if($border && $nl==2)
                    $b = $b2;
                continue;
            }
            if($c==' ')
            {
                $sep = $i;
                $ls = $l;
                $ns++;
            }
            $l += $cw[$c];
            if($l>$wmax)
            {
                // Automatic line break
                if($sep==-1)
                {
                    if($i==$j)
                        $i++;
                    if($this->ws>0)
                    {
                        $this->ws = 0;
                        $this->_out('0 Tw');
                    }
                    $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
                }
                else
                {
                    if($align=='J')
                    {
                        $this->ws = ($ns>1) ?     ($wmax-$ls)/1000*$this->FontSize/($ns-1) : 0;
                        $this->_out(sprintf('%.3F Tw',$this->ws*$this->k));
                    }
                    $this->Cell($w,$h,substr($s,$j,$sep-$j),$b,2,$align,$fill);
                    $i = $sep+1;
                }
                $sep = -1;
                $j = $i;
                $l = 0;
                $ns = 0;
                $nl++;
                if($border && $nl==2)
                    $b = $b2;
            }
            else
                $i++;
        }
        // Last chunk
        if($this->ws>0)
        {
            $this->ws = 0;
            $this->_out('0 Tw');
        }
        if($border && strpos($border,'B')!==false)
            $b .= 'B';
        $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
        $this->x = $this->lMargin;

        // Custom Tomaz Ahlin
        if($ln == 0) {
            $this->SetXY($current_x + $w, $current_y);
        }
    }
}
$Pdf = new Pdf();
$Pdf->transaksi=$transaksi;
$Pdf->label_cv=$label_cv;
$Pdf->tanggal_cetak=$tanggal_cetak;
$Pdf->SetAutoPageBreak(true ,15);

$Pdf->SetMargins(10,10,10);
$Pdf->AliasNbPages();
$Pdf->AddPage();
$Pdf->SetFont('Arial','',12);
$Pdf->Content();
$Pdf->SetTitle("Cetak Bukti Pemasukan");
$Pdf->Output("Cetak_Bukti_Pemasukan.pdf", "I");


?>