<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

class PDF extends FPDF {
	public $title = '';
	public $logo = '';
	
	public $header_1 = '';
	public $header_2 = '';
	public $header_3 = '';
	public $header_font_family = _DEFAULT_PDF_HEADER_FONT_FAMILY;
	public $header_font_size = _DEFAULT_PDF_HEADER_FONT_SIZE;
	public $header_font_variant = _DEFAULT_PDF_HEADER_FONT_VARIANT;
	public $header_ln = 7;
	
	public $footer_1 = '';
	public $footer_font_family = _DEFAULT_PDF_FOOTER_FONT_FAMILY;
	public $footer_font_size = _DEFAULT_PDF_FOOTER_FONT_SIZE;
	public $footer_font_variant = _DEFAULT_PDF_FOOTER_FONT_VARIANT;
	public $footer_ln = 7;

	
	function setLogo( $path_to_image ) {
		$this->logo = $path_to_image;
	}
	
	function setHeading1( $text ) {
		$this->header_1 = $text;
	}
	
	function setHeading2( $text ) {
		$this->header_2 = $text;
	}

	function setHeading3( $text ) {
		$this->header_3 = $text;
	}

	function setFooter( $text ) {
		$this->footer_1 = $text;
	}
	
	function Header(){
		// Select Arial bold 15
		$this->SetFont( $this->header_font_family, $this->header_font_variant, $this->header_font_size );
		
		// Framed title
		if( empty( $this->logo ) == false ){
			$this->Image( $this->logo );
		}
		
		
		if( empty( $this->header_1 ) == false ){
			$this->Cell( 210, 10, $this->header_1, 0, 0, 'C' );
			$this->Ln( $this->header_ln );
		}
		
		if( empty( $this->header_2 ) == false ){
			$this->SetFontSize( $this->header_font_size - 3 );
			$this->Cell( 210, 10, $this->header_2, 0, 0, 'C' );
			$this->Ln( $this->header_ln );
		}

		if( empty( $this->header_3 ) == false ){
			$this->SetFontSize( $this->header_font_size - 5 );
			$this->Cell( 210, 10, $this->header_3, 0, 0, 'C' );
			$this->Ln( $this->header_ln );
		}

	}
	
	
	function Footer() {
		$this->SetY(-15);
		// parent::Footer();
		$this->SetFont( $this->footer_font_family, $this->footer_font_variant, $this->footer_font_size );
		if( empty( $this->footer_1 ) == false ){
			$this->Cell( 210, 10, $this->footer_1, 1, 0, 'C' );
			$this->Ln( $this->footer_ln );
		}
	}
	
	public function getFontFamily() {
		return $this->FontFamily;
	}
	
	public function setFontStyle( $style ) {
		$this->SetFont( $this->getFontFamily(), $style );
	}
}