<?php
require_once(PATH_CODE . 'tcpdf/tcpdf.php');

class RequestPdf extends TCPDF {
    public function Footer() {

        // set color for background
        $this->SetFillColor(255, 255, 255);
        // set margins
        $this->SetMargins(PDF_MARGIN_LEFT, 10, PDF_MARGIN_RIGHT);

        // log::write("page footer 1 = ".$this->GetY());

        // Position at 40 mm from bottom        
        $this->SetY(-40);

        // set font
        // $fontname = "garudabook";
        $fontname = "lomabook";

        $this->SetFont($fontname, '', 9);

        $txt = "I would like ".$this->coy_name." to proceed with the preliminary preparation and followed by the actual services";
        $rowWidth = ($this->getPageWidth() - PDF_MARGIN_LEFT - PDF_MARGIN_RIGHT);
        $estimate = $this->getStringHeight($rowWidth, $txt);

        $rowHeight = 5;
        if($estimate > $rowHeight) {
            $rowHeight = $estimate; 
            $this->SetY(-40 - $rowHeight);
        }

        $this->MultiCell($rowWidth, $rowHeight, $txt, 0, 'C', 1, 1, PDF_MARGIN_LEFT, $this->getY(), true);
        
        // set font
        $this->SetFont($fontname, '', 9);
        $this->MultiCell(100, 10, "   "."Name: ", 'BR', 'L'           , 1, 0, PDF_MARGIN_LEFT, $this->getY(), true);
        $this->MultiCell(40, 10, "", 0, 'L', 1, 1, 0, $this->getY(), true);

        $this->MultiCell(70, 10, "   "."Designation: ", 'T', 'L'           , 1, 0, PDF_MARGIN_LEFT, $this->getY(), true);
        $this->MultiCell(30, 10, "Date: ", 'TR', 'L', 1, 0, PDF_MARGIN_LEFT+70, $this->getY(), true);
        $this->MultiCell(60, 10, "   "."\n Signature & Company Stamp", 'L', 'L', 1, 1, PDF_MARGIN_LEFT+100, $this->getY(), true);

        // set line style
        $this->SetLineStyle(array("width" => 0.3, "cap" => "butt", "join" => "miter", "dash" => 0, "color" => array(0, 0, 0)));

        // set rounded rectangle
        $this->RoundedRect($this->getX(), ($this->getY()-20), $rowWidth, 20, 3.5, "1111");

        // Position at 15 mm from bottom        
        $this->SetY(-15);

        // Set font
        $this->SetFont($fontname, '', 9);

        // set line style
        $this->SetLineStyle(array("width" => 0, "cap" => "", "join" => "", "dash" => 0, "color" => array(0, 0, 0)));

        // Page number
        // $this->MultiCell(0, 0, 'Printed on '.date_create('now')->format('d/m/Y'), 'T', 'L', 0, 1, PDF_MARGIN_LEFT, '', true);
        // $this->MultiCell(0, 0, 'Monday-Friday   9am-4.30pm Normal Daily Consulting Rate', 'T', 'L', 0, 1, PDF_MARGIN_LEFT, '', true);
        // $this->MultiCell(0, 0, 'Monday-Friday   after 4.30pm 1.5x Normal Daily Consulting Rate', '', 'L', 0, 1, PDF_MARGIN_LEFT, '', true);
        // $this->MultiCell(0, 0, 'Saturday&Sunday 9am-4.30pm 2x Normal Daily Consulting Rate', '', 'L', 0, 1, PDF_MARGIN_LEFT, '', true);
        // $this->MultiCell(0, 8, 'E & O.E', '', 'L', 0, 0, PDF_MARGIN_LEFT, '', true);
        $this->SetY(-15);

        $this->MultiCell(0, 0, $this->PageNo(), '', 'C', 0, 0, PDF_MARGIN_RIGHT, '', true);
        /*
        $this->SetFont($fontname, '', 8);
        $this->Cell(0, 10, 'Page '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(),   0, false, 'R', 0, '', 0, false, 'T', 'M');
         * */

        // log::write("page footer 2 = ".$this->GetY());
    }
}
?>
