$YPos-5$YPos-5<?php

/*	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
// $PageNumber is initialised in 0 by includes/PDFStarter.php.
$PageNumber ++;// Increments $PageNumber before printing.
if($PageNumber>1) {// Inserts a page break if it is not the first page.
	$pdf->newPage();
} elements.*/

//if (!$FirstPage){ /* only initiate a new page if its not the first */
//	$pdf->newPage();
//}
if($PageNumber >1) {// Inserts a page break if it is not the first page.
	$pdf->newPage();
}
$Page_Width=842; $Page_Height=595; $Top_Margin=30; $Bottom_Margin=30; $Left_Margin=40; $Right_Margin=30;
$YPos = $Page_Height-$Top_Margin;

$pdf->addJpegFromFile($_SESSION['LogoFile'],$Page_Width/2 -90,520,0,60);

$FontSize =15;

$pdf->SetFont('Helvetica', 'B', 15,' ' , 'false');


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

$FontSize = 9;
$pdf->SetFont('Helvetica', 'B', 9,' ' , 'false');
        $pdf->addText($Page_Width - 180, $YPos-15, $FontSize,$request->IT. _(' REFUND'));
$FontSize = 10;
$pdf->SetFont('Helvetica', '', 10,' ' , 'false');
$pdf->addTextWrap($Page_Width-$Left_Margin-42, $YPos+5, 72, $FontSize, _('Page') . ' ' . $PageNumber);

$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;

$pdf->addText($Page_Width-268, $YPos-13, $FontSize, _('ERP CreditNote:'));
$pdf->addText($Page_Width-190, $YPos-13, $FontSize, $CreditNo);

$pdf->addText($Page_Width-268, $YPos-26, $FontSize, _('Customer TIN:'));
$pdf->addText($Page_Width-190, $YPos-26, $FontSize,$customertaxref);

$pdf->addText($Page_Width-140, $YPos-26, $FontSize, _('CustomerCode:').$debtorno  );


$pdf->addText($Page_Width-268, $YPos-39, $FontSize, _('ERP Date:'));
$pdf->addText($Page_Width-190, $YPos-39, $FontSize, $erpfijidate);




	$pdf->addText($Page_Width-268, $YPos-52, $FontSize, _('JobNo:'));
	$pdf->addText($Page_Width-190, $YPos-52, $FontSize,$projectno);
	$pdf->addText($Page_Width-268, $YPos-65, $FontSize, _('Department:'));
	$pdf->addText($Page_Width-190, $YPos-65, $FontSize, $departmentname);
	$pdf->addText($Page_Width-268, $YPos-78, $FontSize, _('Cust.Account:'));
	$pdf->addText($Page_Width-190, $YPos-78, $FontSize, $account);
	$pdf->addText($Page_Width-268, $YPos-91, $FontSize, _('UserTIN:'));
	$pdf->addText($Page_Width-190, $YPos-91, $FontSize, $usertin);



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

/*Now print out the company name and address in the middle under the logo */
$FontSize=15;
$XPos = $Page_Width/2 -90;
$YPos = $Page_Height - $Top_Margin-60;

$pdf->addText($XPos, $YPos+10, $FontSize,_('TIN:') . $_SESSION['CompanyRecord']['gstno']);
$FontSize=12;
$pdf->addText($XPos, $YPos-10,$FontSize, $_SESSION['CompanyRecord']['regoffice1']);
$pdf->addText($XPos, $YPos-20,$FontSize, $_SESSION['CompanyRecord']['regoffice2']. ' ,' . $_SESSION['CompanyRecord']['regoffice6']);

$pdf->addText($XPos, $YPos-32, $FontSize, _('Phone') . ':' . $_SESSION['CompanyRecord']['telephone'] );
$pdf->addText($XPos, $YPos-42, $FontSize, _('Email') . ': ' . $_SESSION['CompanyRecord']['email']);
$pdf->SetFont('Helvetica', 'B', 15,' ' , 'false');
$pdf->addText($XPos, $YPos-55, $FontSize, _('CREDIT NOTE'));
$pdf->SetFont('Helvetica', '0', 10,' ' , 'false');
/*Now the customer charged to details top left */



$XPos = $Left_Margin;

$YPos = 470;
/*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+10, $YPos+110);
/*Dow top left corner */
$pdf->partEllipse($XPos+10, $YPos+100,90,180,10,10);

/*Do a line to the bottom left corner */
$pdf->line($XPos, $YPos+100,$XPos, $YPos-20);

/*middle line to separate sold and delivery address */
$pdf->line($XPos, $YPos+35,$XPos+235, $YPos+35);

/*middle line to separate sold and delivery address */
$pdf->line($XPos, $YPos,$XPos+235, $YPos);


/*Now do the bottom left corner 180 - 270 coming back west*/
$pdf->partEllipse($XPos+10, $YPos-20,180,270,10,10);

/*Now a line to the bottom right */
$pdf->line($XPos+10, $YPos-30,$XPos+225, $YPos-30);


/*Now do the bottom right corner */
$pdf->partEllipse($XPos+225, $YPos-20,270,360,10,10);
/*Finally join up to the top right corner where started */
$pdf->line($XPos+235, $YPos-20,$XPos+235, $YPos+100);

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

$FontSize=10;

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


	$pdf->addText($XPos-45, $YPos, $FontSize, ($debtorname));
	$pdf->addText($XPos-45, $YPos-14, $FontSize, ($address1));
	
	$pdf->addText($XPos-45, $YPos-28, $FontSize, $address4.' '.$address5.' '. $address6 );

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



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

	$pdf->addText($XPos, $YPos, $FontSize, $delivery);
	
	$pdf->addText($XPos-50, $YPos-42, $FontSize, $notes);
	
	
	;
	$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);

$pdf->SetFont('Helvetica', 'B', 12,' ' , 'false');


$pdf->SetFont('Helvetica', '', 12,' ' , 'false');



/*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->SetFont('Helvetica', 'B', 10,' ' , 'false');
$pdf->addText($Left_Margin + 2, $YPos, $FontSize, _('Credit Type') . ':');
$pdf->addText($Left_Margin+80, $YPos, $FontSize,  _('N/A'));


$pdf->SetFont('Helvetica', '', 10,' ' , 'false');
/*Print a vertical line */
$pdf->line($Left_Margin+248, $YPos-10+$line_height+3,$Left_Margin+248, $YPos - 18);

	$pdf->addText($Left_Margin + 252, $YPos, $FontSize, _('SDCInvRef:') . ':');
	$pdf->addText($Left_Margin+305, $YPos, $FontSize, _('N/A'));

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

$pdf->addText($Left_Margin+453, $YPos, $FontSize, _('By') . ':');
$pdf->addText($Left_Margin+470, $YPos, $FontSize, $realname.' '._('Email:'). $emailm);

$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+550, $YPos, $FontSize, _('Unit Price'));
$pdf->addText($Left_Margin+640, $YPos, $FontSize, _('Quantity'));
//$pdf->addText($Left_Margin+555, $YPos, $FontSize, _('UOM'));
$pdf->addText($Left_Margin+680, $YPos, $FontSize, _('TaxLabel'));
$pdf->addText($Left_Margin+740, $YPos, $FontSize, _('Total'));

$YPos-=8;

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

$YPos -= ($line_height);

?>
