<?php
/**********************************************************************
***********************************************************************/

/**
	Document blueprint use following parameters set in doctext.inc:

	$Addr1,	$Addr2 - address info
	$Payment_Terms - payment terms line
	$Footer - footer texts
	$this->company - company info
	$this->title - report title
	$this->formData - some other info
***/

		$this->row = $this->pageHeight - $this->topMargin;

		$upper = $this->row - 2 * $this->lineHeight;
		$lower = $this->bottomMargin + 10 * $this->lineHeight;
		$iline1 = $upper - 1 * $this->lineHeight;
		$iline2 = $iline1 - 4 * $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;
		$icol = $this->pageWidth / 2;
		$ccol = $this->cols[0] + 4;
		$c2col = $ccol + 60;
		$ccol2 = $icol / 2;
		$mcol = $icol + 8;
		$mcol2 = $this->pageWidth - $ccol2;
                
        $header_col1 = 70;
//        $header_col2 = 380;
                
		$cols = count($this->cols);

		$col = $this->leftMargin;


                $this->row = 400;
                
		// Company Logo
		//$this->NewLine();
		$logo = company_path() . "/images/" . $this->company['coy_logo'];
		if ($this->company['coy_logo'] != '' && file_exists($logo))
		{
			$this->AddImage($logo, 20, $this->row - 25, 0, 40);
		}
		else
		{
			$this->fontSize += 4;
			$this->Font('bold');
//			$this->Text($ccol, $this->company['coy_name'], $icol);
			$this->Font();
			$this->fontSize -= 4;
		}
                
		// Document title
		$this->SetTextColor(0, 0, 0);
		$this->fontSize += 4;
		$this->Font('bold');
                $this->TextWrap($header_col1, $this->row, $this->pageWidth - $this->rightMargin - $mcol - 20, $this->company['coy_name']);
		$this->fontSize += 3;
                $this->SetTextColor(0, 0, 0);
                $previous_row = $this->row;
                $this->NewLine(1);
//                $this->TextWrap($header_col1, $this->row - 4, $this->pageWidth - $this->rightMargin - $mcol - 10, $this->title);
                
                $this->Text(400, $this->params['title']);
//                $this->Text(320, $this->title );
                
                $this->row = $previous_row;
		$this->Font();
		$this->fontSize -= 7;
		$this->NewLine();
		$this->SetTextColor(0, 0, 0);
		$adrline = $this->row;

		// Company data
		//$this->TextWrapLines(170, 100, $this->company['postal_address']);
                $this->Text($header_col1, $this->company['postal_address'], $header_col1 + 250);
                $this->NewLine();
                //$this->NewLine();
                
		$this->Font('italic');
		if (@$this->company['phone'])
		{
			$this->Text($header_col1, _("Phone:"), $header_col1 + 50);
			$this->Text($header_col1 + 40, $this->company['phone'], $mcol);
			$this->NewLine();
		}
                                
		if (@$this->company['fax'])
		{
			$this->Text($header_col1 + 140, _("Fax:"), $header_col1 + 50);
			$this->Text($header_col1 + 160, $this->company['fax'], $header_col1 + 250);
			$this->NewLine();
		}
		if (@$this->company['email'])
		{
			$this->Text($header_col1, _("Email:"), $header_col1 + 50);

			$url = "mailto:" . $this->company['email'];
			$this->SetTextColor(0, 0, 255);
			$this->Text($header_col1 + 40, $this->company['email'], $mcol);
			$this->SetTextColor(0, 0, 0);
			$this->addLink($url, $c2col, $this->row, $mcol, $this->row + $this->lineHeight);

//			$this->NewLine();
		}
                
                $this->Text(225, _("Website:"));

                $url = get_sys_prefs_parameter_value("website");
                
                $this->SetTextColor(0, 0, 255);
                $this->Text(275, $url);
//                $this->NewLine();
                $this->SetTextColor(0, 0, 0);
                $this->addLink($url, $c2col, $this->row, $mcol, $this->row + $this->lineHeight);

                $this->NewLine();  
                        
		if (@$this->company['gst_no'])
		{
			$this->Text($header_col1, _("VAT No.:"), $header_col1 + 50);
			$this->Text($header_col1 + 40, $this->company['gst_no'], $mcol);
			$this->NewLine();
		}
		if (@$this->formData['domicile'])
		{
			$this->Text($ccol, _("Domicile"), $c2col);
			$this->Text($c2col, $this->company['domicile'], $mcol);
			$this->NewLine();
		}
		$this->Font();
		$this->row = $adrline;
//		$this->NewLine(1);
//		$this->Text($header_col2, _("Print Out Date:"));
//		$this->Text($header_col2 + 70, Today() . '   ' . Now());

//		$this->NewLine();
//		$this->Text($header_col2, _("Voucher No").":");
//		$this->Text($header_col2 + 70, $this->params['tran_no']);
//                
//                $this->NewLine();
//		$this->Text($header_col2, _("Payment Type").":");
//		$this->Text($header_col2 + 70, "Cash/Cheque");
//                
//                $this->NewLine();
//		$this->Text($header_col2, _("Bank").":");
//		$this->Text($header_col2 + 70, $this->formData['bank_name']);
//                
//                $this->NewLine();
//		$this->Text($header_col2, _("Account No").":");
//		$this->Text($header_col2 + 70, $this->formData['bank_account_number']);
                
                
//return;
		if ($this->pageNumber > 1){
                        $this->NewLine(2);
			$this->Text($this->endLine - 35, _("Page") . ' ' . $this->pageNumber);
        }
		
/*=========================End of header============================*/

		$this->Line($iline1);


		if ($this->pageNumber == 1) {
                    $temp = $iline6 + $this->lineHeight * 3;
                    $this->row = $temp;
                } else {
                    $this->NewLine(2);
                }
?>
