<?php 

//===========================================+
// File name   : example_058.php
// Begin       : 2010-04-22
// Last Update : 2013-05-14
//
// Description : Example 058 for TCPDF class
//               SVG Image
//
// Author: Nicola Asuni
//
// (c) Copyright:
//               Nicola Asuni
//               Tecnick.com LTD
//               www.tecnick.com
//               info@tecnick.com
//============================================================+

/**
 * Creates an example PDF TEST document using TCPDF
 * @package com.tecnick.tcpdf
 * @abstract TCPDF - Example: SVG Image
 * @author Nicola Asuni
 * @since 2010-05-02
 */

// Include the main TCPDF library (search for installation path).
require_once('tcpdf_include.php');
$svgImg = $_GET['img'];
$rtype=$_GET['rtype'];

// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Fintrack Pty Ltd');
$pdf->SetTitle('Loan Calculator');
$pdf->SetSubject('Fintrack Pty Ltd - Loan Calculator');
$pdf->SetKeywords('Loan Calculator');

// set default header data
$pdf->SetHeaderData("fint-logo.jpg", PDF_HEADER_LOGO_WIDTH, 'Loan Calculator', 'By Fintrack Pty Ltd');

// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));

// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

// set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

// set some language-dependent strings (optional)
if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
    require_once(dirname(__FILE__).'/lang/eng.php');
    $pdf->setLanguageArray($l);
}

// ---------------------------------------------------------

// set font
$pdf->SetFont('helvetica', '', 10);

// add a page
$pdf->AddPage();


$Oip = str_replace(',','',(str_replace('$', '', $_GET["Oip"])));
$OTotalRp = $Oip + $_GET["lp"];


$CBip = str_replace(',','',(str_replace('$', '', $_GET["CBip"])));
$CBTotalRp = $_GET["lp"] + $CBip;
$CBInterestSaved = $OTotalRp - $CBTotalRp;
$CBInterestSaved = number_format($CBInterestSaved);
$CBTotalRp = number_format($CBTotalRp);
$OTotalRp = number_format($OTotalRp);
$AfterImage='
<table width="100%" border="0">
		<tr><td>
<table width="95%" border="1" height="20" align="center" bordercolor="#999999;">
<tr>
<td width="25%" align="center" style="font-size:13px; font-family:Arial, Helvetica, sans-serif; font-weight:normal">Loan Amount $</td>
<td width="25%" align="center" style="font-size:13px; font-family:Arial, Helvetica, sans-serif; font-weight:normal">Loan Term(years)</td>
<td width="25%" align="center" style="font-size:13px; font-family:Arial, Helvetica, sans-serif; font-weight:normal">Interest Rate %</td>
<td width="25%" align="center" style="font-size:13px; font-family:Arial, Helvetica, sans-serif; font-weight:normal">Repayment</td>
</tr>
<tr>
<td style="font-size:13px; font-family:Arial, Helvetica, sans-serif; font-weight:normal">$'.number_format($_GET['lp']) .'</td>
<td style="font-size:13px; font-family:Arial, Helvetica, sans-serif; font-weight:normal">'. $_GET['lt'].'</td>
<td style="font-size:13px; font-family:Arial, Helvetica, sans-serif; font-weight:normal">'. $_GET['li'] .'% </td>
<td style="font-size:13px; font-family:Arial, Helvetica, sans-serif; font-weight:normal">$'. number_format($_GET['fi']) .'(' .$rtype .')</td>
</tr>
</table>
</td>
</tr>
<tr><td height="10px">
		&nbsp;
</td>
</tr>	
		<tr><td align="center">
		<table width="95%" border="1"  align="center" bordercolor="#999999;" cellpadding="10" cellspacing="1">
  <tr>
    <td width="25%"  align="center" style="border-right:none;font-size:12px; font-family:Arial, Helvetica, sans-serif; font-weight:600">&nbsp;</td>
    <td width="35%" align="left" style="border-right:none;border-left:none; font-size:12px; font-family:Arial, Helvetica, sans-serif; font-weight:600">Original loan</td>
    <td width="40%" align="left" style="font-size:12px; border-left:none; font-family:Arial, Helvetica, sans-serif; font-weight:600">Loan with Cash Back</td>
  </tr>
  <tr>
   <td align="left"   style="font-family:Arial, Helvetica, sans-serif; font-size:11px;text-align:left; border-right:none;">Interest Paid</td>
    <td align="left" style="font-family:Arial, Helvetica, sans-serif; font-size:11px;left; border-left:none; padding-right:18%; border-right:none;">$'.number_format($Oip).'</td>
    <td align="left" style="font-family:Arial, Helvetica, sans-serif; font-size:11px; padding-right:18%; border-left:none;">'.number_format($CBip).'</td>
  </tr>
  <tr>
   <td align="left"   style="font-family:Arial, Helvetica, sans-serif; font-size:11px;text-align:left; border-right:none;">Principal Paid</td>
    <td align="left" style="font-family:Arial, Helvetica, sans-serif; font-size:11px;left; border-left:none; padding-right:18%; border-right:none;">$'.number_format($_GET['lp']) .'</td>
    <td align="left" style="font-family:Arial, Helvetica, sans-serif; font-size:11px; padding-right:18%; border-left:none;">$'.number_format($_GET['lp']) .'</td>
  </tr>
   <tr>
 <td align="left" style="font-family:Arial, Helvetica, sans-serif; font-size:11px;text-align:left; border-right:none;">Total Loan Repayments</td>
    <td align="left" style="font-family:Arial, Helvetica, sans-serif; font-size:11px;border-left:none; border-right:none;">$'.$OTotalRp.'</td>
    <td align="left" style="font-family:Arial, Helvetica, sans-serif; font-size:11px;border-left:none;border-right:none;">$'.$CBTotalRp.'</td>
  </tr>
  <tr>
   <td align="left" style="font-family:Arial, Helvetica, sans-serif; font-size:11px;text-align:left; border-right:none;">Loan Repaid Time</td>
    <td align="left" style="font-family:Arial, Helvetica, sans-serif; font-size:11px;left; border-left:none; padding-right:18%; border-right:none;">'.$_GET['Opot'].'</td>
    <td align="left" style="font-family:Arial, Helvetica, sans-serif; font-size:11px;border-left:none; border-right:none;">'.$_GET['CBpot'].'</td>
  </tr>
 
    <tr>
  <td align="Left" style="font-family:Arial, Helvetica, sans-serif; font-size:11px; border-right:none;font-color:red;font-weight:bold;">Interest Saved</td>
    <td align="left" style="border-left:none;border-right:none;font-family:Arial, Helvetica, sans-serif; font-size:11px;">&nbsp;</td>
    <td align="left" style="font-family:Arial, Helvetica, sans-serif; font-size:11px;border-left:none;border-right:none;font-color:red;font-weight:bold;color: rgb(255, 0, 0);">$'.$CBInterestSaved.'</td>
  </tr>
    <tr>
<td align="Left" style="font-family:Arial, Helvetica, sans-serif; font-size:11px;border-right:none;font-color:red;font-weight:bold;">Time Saved</td>
    <td align="left" style="border-left:none;border-right:none;">&nbsp;</td>
    <td align="left" style="border-left:none;border-right:none;font-weight:bold;color: rgb(255, 0, 0);font-family:Arial, Helvetica, sans-serif; font-size:11px;">'.$_GET['CBts'].'</td>
  </tr>
  <tr>
<td colspan="3" rowspan="1">
<span style="margin-left:6px; padding:0px; font-family:Arial, Helvetica, sans-serif; color:#000000; font-size:14px; text-align:left; font-weight:600">Disclaimer:-</span>
  <p style="text-align:justify; font-family:Arial, Helvetica, sans-serif; font-size:8px;"><b>WHY WE BUILT THIS LOAN CALCULATOR:</b> We wanted to stimulate discussion between YOU and FINTRACK about the difference in savings between the going direct to a lender or by using a Mortgage Broker. This illustration allows you to explore the difference in savings that you could potential make by using our pro consumer service, which entails full rebate of all commissions less GST and our fee.</p>
	<p style="text-align:justify; font-family:Arial, Helvetica, sans-serif; font-size:8px;">
			<b>ASSUMPTIONS MADE IN THIS ILLUSTRATION</b>
			<ul>
			<li>We rebate 100% of lender commission less GST</li>
			<li>We charge a fee of $990 including GST</li>
			<li>Interest rates remain constant for term of the loan</li>
			<li>Lender pays us 0.50% upfront commission on loan amount</li>
			<li>Lender pays us 0.20% trail commission on monthly loan balance</li>
			<li>Lender commission is average of lenders and may vary</li>
			<li>You make your pay minimum repayments and do not default</li>
			</ul>
			</p>
			<p style="text-align:justify; font-family:Arial, Helvetica, sans-serif; font-size:8px;">
			<b>WARNING:</b> This is an illustration of the potential savings you may experience by using the Fintrack pro consumer service. Your individual interest savings may be more or less than the results shown, as the outcomes are valid only for the data you chose and assumptions we have made. No attempt has been made to analyse costs associated with switching lenders including discharge fees, application fees or Lender Mortgage Insurance. This is not a recommendation or offer of finance.
			</p>
			<p style="text-align:justify; font-family:Arial, Helvetica, sans-serif; font-size:8px;">
				<b>CONCLUSION:</b> You should not make a decision to engage our services based purely on this illustrated calculation. What you can do however is contact us for a full and concise individual assessment of your financial needs.
			 </p>
    		
    		
</td>
</tr>
</table> 
</td>
</tr></table> 
	';

// NOTE: Uncomment the following line to rasterize SVG image using the ImageMagick library.
//$pdf->setRasterizeVectorImages(true);


$file='../../export/' .$svgImg;

$pdf->ImageSVG($file, $x=15, $y=25, $w='170', $h='80', $link='http://www.fintrack.com.au', $align='', $palign='', $border=1, $fitonpage=false);

$pdf->setY(110);
$pdf->setX(15);
//$pdf->ImageSVG($file='images/tux.svg', $x=30, $y=100, $w='', $h=100, $link='', $align='', $palign='', $border=0, $fitonpage=false);
$pdf->writeHTML($AfterImage, true, false, true, false, '');





// ---------------------------------------------------------

//Close and output PDF document
$pdf->Output('LoanCalculator.pdf', 'D');

//============================================================+
// END OF FILE
//============================================================+
?>