<?php
/* $Id: PDFTransPageHeader.inc 6826 2014-08-17 21:53:13Z rchacon $ */

/*	Please note that addTextWrap() prints a font-size-height further down than
	addText() and other functions. Use addText() instead of addTextWrap() to
	print left aligned elements.*/

if (!$FirstPage){ /* only initiate a new page if its not the first */
	$pdf->newPage();
}

$YPos = $Page_Height-$Top_Margin;

$pdf->addJpegFromFile($_SESSION['LogoFile'],$Page_Width/2 -120,$YPos-40,0,60);
$FontSize =15;

	$pdf->addText($Page_Width - 200, $YPos, $FontSize, _('TAX INVOICE') . ' ');


$XPos = $Page_Width - 265;
$YPos -= 111;
/*draw a nice curved corner box around the billing details */
/*from the top right */
$pdf->partEllipse($XPos+225,$YPos+100,0,90,10,10);
/*line to the top left */
$pdf->line($XPos+225, $YPos+110,$XPos, $YPos+110);
/*Dow top left corner */
$pdf->partEllipse($XPos, $YPos+100,90,180,10,10);
/*Do a line to the bottom left corner */
$pdf->line($XPos-10, $YPos+100,$XPos-10, $YPos+5);
/*Now do the bottom left corner 180 - 270 coming back west*/
$pdf->partEllipse($XPos, $YPos+5,180,270,10,10);
/*Now a line to the bottom right */
$pdf->line($XPos, $YPos-5,$XPos+225, $YPos-5);
/*Now do the bottom right corner */
$pdf->partEllipse($XPos+225, $YPos+5,270,360,10,10);
/*Finally join up to the top right corner where started */
$pdf->line($XPos+235, $YPos+5,$XPos+235, $YPos+100);

$YPos = $Page_Height - $Top_Margin - 10;

$FontSize = 10;
$pdf->addText($Page_Width-190, $YPos-8, $FontSize, _('TIN:50-17718-01'));
$pdf->addText($Page_Width-268, $YPos-19, $FontSize, _('Invoice No:'));
$pdf->addText($Page_Width-180, $YPos-19, $FontSize, $InvoiceNo);
$pdf->addText($Page_Width-268, $YPos-30, $FontSize, _('Customer Code'));
$pdf->addText($Page_Width-180, $YPos-30, $FontSize, $debtorno . ' ' . _('Branch') . ' ' . $branchcode);
$pdf->addText($Page_Width-268, $YPos-42, $FontSize, _('Date'));
$pdf->addText($Page_Width-180, $YPos-42, $FontSize, $quotedate);




	$pdf->addText($Page_Width-268, $YPos-52, $FontSize, _('Project ID/Jobno:'));
	$pdf->addText($Page_Width-180, $YPos-52, $FontSize, $jobno);
	$pdf->addText($Page_Width-268, $YPos-65, $FontSize, _('Project/Job Name'));
	$pdf->addText($Page_Width-180, $YPos-65, $FontSize, $projectname);
	$pdf->addText($Page_Width-268, $YPos-78, $FontSize, _('Project Type'));
	$pdf->addText($Page_Width-180, $YPos-78, $FontSize, $projecttype);

$pdf->addText($Page_Width-268, $YPos-108, $FontSize, _('Page'));
$pdf->addText($Page_Width-180, $YPos-108, $FontSize, $PageNumber);

/*End of the text in the right side box */

/*Now print out the company name and address in the middle under the logo */
$XPos = $Page_Width/2 -90;
$YPos = $Page_Height - $Top_Margin-60;
$pdf->addText($XPos, $YPos, $FontSize, $_SESSION['CompanyRecord']['coyname']);

$FontSize=8;
$pdf->addText($XPos, $YPos-10, $FontSize, $_SESSION['TaxAuthorityReferenceName'] . $_SESSION['CompanyRecord']['gstno']);
$pdf->addText($XPos, $YPos-19,$FontSize, $_SESSION['CompanyRecord']['regoffice1']);
$pdf->addText($XPos, $YPos-28,$FontSize, $_SESSION['CompanyRecord']['regoffice2']);
$pdf->addText($XPos, $YPos-37,$FontSize, $_SESSION['CompanyRecord']['regoffice3'] . ' ' . $_SESSION['CompanyRecord']['regoffice4'] . ' ' . $_SESSION['CompanyRecord']['regoffice5']);
$pdf->addText($XPos, $YPos-46, $FontSize, $_SESSION['CompanyRecord']['regoffice6']);
$pdf->addText($XPos, $YPos-54, $FontSize, _('Phone') . ':' . $_SESSION['CompanyRecord']['telephone'] . ' ' . _('Fax') . ': ' . $_SESSION['CompanyRecord']['fax']);
$pdf->addText($XPos, $YPos-63, $FontSize, _('Email') . ': ' . $emailm);

/*Now the customer charged to details top left */

$XPos = $Left_Margin;
$YPos = $Page_Height - $Top_Margin;

$FontSize=10;

$pdf->addText($XPos, $YPos, $FontSize, _('Bill To') . ':');
$XPos +=80;


	$pdf->addText($XPos, $YPos, $FontSize, html_entity_decode($debtorname));
	$pdf->addText($XPos, $YPos-14, $FontSize, html_entity_decode($address1));
	$pdf->addText($XPos, $YPos-28, $FontSize, html_entity_decode($address2));
	$pdf->addText($XPos, $YPos-42, $FontSize, html_entity_decode($address3) . ' ' . html_entity_decode($address4));



$XPos -=80;
$YPos -=($line_height*4);

if ($InvOrCredit=='Invoice') {

	$pdf->addText($XPos, $YPos, $FontSize, _('Job To Deliver at') . ':');
	$XPos +=80;
// Before trying to call htmlspecialchars_decode, check that its supported, if not substitute a compatible version
if (!function_exists('htmlspecialchars_decode')) {
        function htmlspecialchars_decode($str) {
                $trans = get_html_translation_table(HTML_SPECIALCHARS);

                $decode = ARRAY();
                foreach ($trans AS $char=>$entity) {
                        $decode[$entity] = $char;
                }

                $str = strtr($str, $decode);

                return $str;
        }
}
	$pdf->addText($XPos, $YPos, $FontSize, html_entity_decode($branchname));
	$pdf->addText($XPos, $YPos-14, $FontSize, html_entity_decode($branchad1));
	$pdf->addText($XPos, $YPos-28, $FontSize, html_entity_decode($branchad2));
	$pdf->addText($XPos, $YPos-42, $FontSize, html_entity_decode($branchad3) . ' ' . html_entity_decode($branchad4) . ' ' . html_entity_decode($branchad5));
	$XPos -=80;
}


$XPos = $Left_Margin;

$YPos = $Page_Height - $Top_Margin - 80;
/*draw a line under the company address and charge to address
$pdf->line($XPos, $YPos,$Right_Margin, $YPos); */

$XPos = $Page_Width/2;

$XPos = $Left_Margin;
$YPos -= ($line_height*2);

include($PathPrefix . 'includes/CurrenciesArray.php'); // To get the currency name from the currency code.
$pdf->addText($Left_Margin, $YPos-8, $FontSize, _('All amounts stated in Fijian(FJ) Dollars') . ': ' . $myrow['currcode'] . ' ' . $CurrencyName[$myrow['currcode']]);

/*draw a box with nice round corner for entering line items */
/*90 degree arc at top right of box 0 degrees starts a bottom */
$pdf->partEllipse($Page_Width-$Right_Margin-10, $Bottom_Margin+390,0,90,10,10);
/*line to the top left */
$pdf->line($Page_Width-$Right_Margin-10, $Bottom_Margin+400,$Left_Margin+10, $Bottom_Margin+400);
/*Dow top left corner */
$pdf->partEllipse($Left_Margin+10, $Bottom_Margin+390,90,180,10,10);
/*Do a line to the bottom left corner */
$pdf->line($Left_Margin, $Bottom_Margin+390,$Left_Margin, $Bottom_Margin+10);
/*Now do the bottom left corner 180 - 270 coming back west*/
$pdf->partEllipse($Left_Margin+10, $Bottom_Margin+10,180,270,10,10);
/*Now a line to the bottom right */
$pdf->line($Left_Margin+10, $Bottom_Margin,$Page_Width-$Right_Margin-10, $Bottom_Margin);
/*Now do the bottom right corner */
$pdf->partEllipse($Page_Width-$Right_Margin-10, $Bottom_Margin+10,270,360,10,10);
/*Finally join up to the top right corner where started */
$pdf->line($Page_Width-$Right_Margin, $Bottom_Margin+10,$Page_Width-$Right_Margin, $Bottom_Margin+390);


$YPos -= ($line_height*2);
/*Set up headings */
$FontSize=10;
$pdf->addText($Left_Margin + 2, $YPos, $FontSize, _('Customer Account Number') . ':');
$pdf->addText($Left_Margin+120, $YPos, $FontSize, $myrow['account_number']);

/*Print a vertical line for departement. Get department Name */


	
	      

$pdf->line($Left_Margin+160, $YPos-10+$line_height+3,$Left_Margin+160, $YPos - 18);

	$pdf->addText($Left_Margin + 164, $YPos, $FontSize, _('Department') . ':');
	$pdf->addText($Left_Margin+220, $YPos, $FontSize, $department );



/*Print a vertical line */
$pdf->line($Left_Margin+350, $YPos-10+$line_height+3,$Left_Margin+350, $YPos - 18);

	$pdf->addText($Left_Margin + 352, $YPos, $FontSize, _('Customer Order Ref/LPO:') . ':');
	$pdf->addText($Left_Margin+470, $YPos, $FontSize, $invoiceterms);

/*Print a vertical line */
$pdf->line($Left_Margin+550, $YPos+$line_height-7,$Left_Margin+550,$YPos-18);

$pdf->addText($Left_Margin+553, $YPos, $FontSize, _('Prepared by') . ':');
$pdf->addText($Left_Margin+610, $YPos, $FontSize, $realname);

$YPos -= 8;
/*draw a line */
$pdf->line($XPos, $YPos-10,$Page_Width-$Right_Margin, $YPos-10);

$YPos -= 12;

$TopOfColHeadings = $YPos-10;

$pdf->addText($Left_Margin+5, $YPos, $FontSize, _('Item Code'));
$pdf->addText($Left_Margin+100, $YPos, $FontSize, _('Description'));
$pdf->addText($Left_Margin+382, $YPos, $FontSize, _('Unit Price'));
$pdf->addText($Left_Margin+485, $YPos, $FontSize, _('Quantity'));
$pdf->addText($Left_Margin+555, $YPos, $FontSize, _('UOM'));
$pdf->addText($Left_Margin+595, $YPos, $FontSize, _('Discount'));
$pdf->addText($Left_Margin+690, $YPos, $FontSize, _('Price'));

$YPos-=8;

/*draw a line */
$pdf->line($XPos, $YPos-5,$Page_Width-$Right_Margin, $YPos-5);

$YPos -= ($line_height);

?>
