<?php

$this->row = $this->pageHeight - $this->topMargin;
$upper = $this->row - 2 * $this->lineHeight;
$lower = $this->bottomMargin + 2 * $this->lineHeight;
$iline1 = $upper - 7.5 * $this->lineHeight;
$iline2 = $iline1 - 8 * $this->lineHeight;
$iline3 = $iline2 - 1.5 * $this->lineHeight;
$iline4 = $iline3 - 1.5 * $this->lineHeight;
$iline5 = $iline4 - 3 * $this->lineHeight;
$iline6 = $iline5 - 1.5 * $this->lineHeight;
$iline7 = $lower;
$right = $this->pageWidth - $this->rightMargin;
$width = ($right - $this->leftMargin) / 5;
$page_width = $this->pageWidth - $this->leftMargin - $this->rightMargin;
$page_height = $this->pageHeight - $this->topMargin - $this->bottomMargin;
$icol = $this->pageWidth / 2;
$ccol = $this->cols[0] + 4;
$c2col = $ccol + 60;
$ccol2 = $icol / 2;
$mcol = $icol + 8;
$mcol2 = $this->pageWidth - $ccol2;

// Company Logo
$this->NewLine();
$logo = company_path().'/images/'.$this->company['coy_logo'];
if ($this->company['coy_logo'] != '' && file_exists($logo))
	$this->Image($logo, 0, $this->topMargin, '', 40, '', '', '', false, '300', 'C');
else {
	$this->fontSize += 4;
	$this->Font('bold');
	$this->Text($ccol, $this->company['coy_name'], $icol);
	$this->Font();
	$this->fontSize -= 4;
}

// Company infomation
$this->NewLine(4);
$this->fontSize += 4;
$this->Font('bold');
$this->TextWrap(0, $this->row, $this->pageWidth, $this->company['coy_name'], 'center');
$this->Font();
$this->fontSize -= 4;

// Document title
$this->row = $this->row - $this->topMargin;
$this->NewLine(7);
$this->fontSize += 10;
$this->Font('bold');
$this->TextWrap(0, $this->row, $this->pageWidth, $this->title, 'center');
$this->Font();
$this->fontSize -= 10;
$this->NewLine(3);

// Lines Headers
$this->NewLine(2);
$this->Font('bold');
$count = count($this->headers);
$this->cols[$count] = $right - 3;
for ($i = 0; $i < $count; $i++)
	$this->TextCol($i, $i + 1, $this->headers[$i]);
$this->Font();

$this->Line($this->row - $this->lineHeight/4);

$this->Font();
$this->row = $upper;
$this->NewLine();