<?php
ob_start();
include_once "../../common/connect.php";
include_once "../../common/db.php";
include_once "../../common/defines.php";
include_once "../../common/db_defines.php";

////////////////////// CORE FUNCTION | MODULE FUNCTION (c) i2d Technologies //////////////////////////////////
if(!empty($_REQUEST['id'])){
$id=i2d_secured_input($_REQUEST['id']);
}
if(!empty($_REQUEST['logo'])){
$logo=i2d_secured_input($_REQUEST['logo']);
}
if(!empty($_REQUEST['ad'])){
$ad=i2d_secured_input($_REQUEST['ad']);
}
$case=1;

$id=56;
$logo=0;
$ad=0;

$stn_number="P12239201";
$ntn_number="12239201";
$tax_rate1="0.16";
$tax_rate=$tax_rate1*100;
$file_title="i2d_hosting_invoice";
$doc_title="i2d Technologies - Client Hosting Invoice";
$tax_note='<h5>Note : Incase of Tax Deductions, please provide deduction certtificate in the name of &quot;i2d Technologies&quot; , Tax no P1128201</h5>';	
$inv_title="PROPOSAL :<br /> 
INTERNET BRAND NAME";
$ref_suffix="RP-SP-";
$ref_series="1001";
$refno="1001";
$doc_keywords="web hosting";
$doc_sub="Cloud Linux - Hosting Services";
$logo_img="logo2019.jpg";
$ad_img="ad2019.jpg";
$footer_img="footer_2019.jpg";
$line="_____________________________________________________________________________________________________";
$line_old="_________________________________________________________________________________________";
$unit="PKR";



$person_name=strtoupper("RAJA WAHEED ZAMAN");
$company_name=strtoupper("double dragon");
$address=strtoupper("Main road westrdge bazar road 13440 street");
$city_name="Rawalpindi";

$dated1=date("l F j, Y");
$dte = strtotime("+7 day");
$dated2= date("l F j, Y", $dte);

$domain_name="i2dtechnologies.com";
$tax_note="*16 % General Sales Tax apllies to all purchases.";

$package1_title="<br />"."Cloud Linux Pro 1 GB";
$package1_features='
<ul>
      <li><strong>'.$domain_name.'</strong></li>
      <li><strong>Cloud Linux 1000 MB</strong></li>
      <li>5 Email Account(s)</li>
      <li>Unlimited Forwarders</li>
      <li>Web Mail Manager</li>
      <li>Data Base Support</li>
      <li>Hosting Control Panel </li>
      <li>File Manager / FTP</li>
      <li>Virus Protection</li>
      <li> Backup Manager</li>
      <li><strong>1 Year Validity</strong></li>
      <li><strong>12 Months Online Support</strong></li>
    </ul>    ';
	
$package1_price=$unit." "."9,500/-"." + Tax";
$package1_duration="12 Months Subscription";
	
$package2_title="<br />"."<strong>Cloud Linux Pro 2 GB</strong>";
$package2_features='
<ul>
      <li><strong>'.$domain_name.'</strong></li>
      <li><strong>Cloud Linux 2000 MB</strong></li>
      <li>10 Email Account(s)</li>
      <li>Unlimited Forwarders</li>
      <li>Web Mail Manager</li>
      <li>Data Base Support</li>
      <li>Hosting Control Panel </li>
      <li>File Manager / FTP</li>
      <li>Virus Protection</li>
      <li> Backup Manager</li>
      <li><strong>1 Year Validity</strong></li>
      <li><strong>12 Months Online Support</strong></li>
    </ul>    ';
	
$package2_price=$unit." "."15,500/-"." + Tax";
$package2_duration="12 Months Subscription";
	

$package3_title="<strong>Cloud Linux Pro 1 GB <br />
      Super Saver! 40% OFF<br />
    (*Time Limited Promo)</strong>";
$package3_features='
<ul>
      <li><strong>'.$domain_name.'</strong></li>
      <li><strong>Cloud Linux 1000 MB</strong></li>
      <li>5 Email Account(s)</li>
      <li>Unlimited Forwarders</li>
      <li>Web Mail Manager</li>
      <li>Data Base Support</li>
      <li>Hosting Control Panel </li>
      <li>File Manager / FTP</li>
      <li>Virus Protection</li>
      <li> Backup Manager</li>
      <li><strong>1 Year Validity</strong></li>
      <li><strong>3 Years Online Support</strong></li>
      <li><strong>*Offer Expires on 09-12-2019</strong></li>
    </ul>    ';
	
$package3_price=$unit." "."20,500/-"." + Tax";
$package3_duration="3 Years Subscription";
	
$opening_letter='
<table width="660" border="0" align="center" cellpadding="2" cellspacing="0">
  <tr>
    <td height="10" align="center">Introducing <strong>'.$domain_name.'</strong> for your business</td>
  </tr>
  <tr>
    <td height="10" align="left">Dear Sir,<br />
      <br />
    i2d Technologies is plaeased to offer you <strong>INTERNET BRAND REGISTRATION</strong> &amp; Secured Cloud Hosting Services for your business.<br />
    <br />
    <strong>We are providing quality services in the Twin Cities since 2008</strong> and have clients ranging from Small Medium Companies to Large Businesses.
    Our Data Center is equipped with state of the art machinery and latest cloud based storage technology. Our Packages feature <strong>World Famous Hosting Management Interface </strong> alongwith <strong>24/7 Online Support</strong> for your account.<br /> 
    <br />
    We would be delighted to provide you with your internet brand name &quot;<strong>tahirgorment.com</strong>&quot; registration services , assuring you quality service backed by intellectual support for a long term business relationship.<br />
    Below are the salient features and pricing of our hosting subscriptions :-<br />
    <br /></td>
  </tr>
</table>
';

$price_tables=
'
<table width="660" border="1" align="center" cellpadding="2" cellspacing="0">
  
  <tr>
    <td align="center" bgcolor="#F4F4F4"><strong>'.$package1_title.'</strong></td>
    <td align="center" bgcolor="#F4F4F4"><strong>'.$package2_title.'</strong></td>
    <td width="197" align="center" bgcolor="#F4F4F4"><strong>'.$package3_title.'</strong></td>
  </tr>
  <tr>
    <td width="220"><br/>'.$package1_features.'<br /></td>
    <td width="220"><br />'.$package2_features.'<br /></td>
    <td width="197"><br />'.$package3_features.'<br /></td>
  </tr>
  <tr>
    <td align="center" bgcolor="#E6E6E6"><strong>'.$package1_price.' + TAX*</strong></td>
    <td align="center" bgcolor="#E6E6E6"><strong>'.$package2_price.' + TAX*</strong></td>
    <td align="center" bgcolor="#E6E6E6"><strong>'.$package3_price.' + TAX*</strong></td>
  </tr>
  <tr>
    <td align="center" bgcolor="#F4F4F4">'.$package1_duration.'</td>
    <td align="center" bgcolor="#F4F4F4">'.$package2_duration.'</td>
    <td align="center" bgcolor="#F4F4F4">'.$package3_duration.'</td>
  </tr>
  <tr>
    <td colspan="3" align="left">*16 % General Sales Tax apllies to all purchases.</td>
  </tr>

</table>

<table width="660" border="0" align="left" cellpadding="2" cellspacing="0">
  <tr>
    <td height="10" align="left"><br /><br /><strong>IMPORTANT NOTE : '.$domain_name.'</strong> is available for purchase on '.$dated1.'. <strong>
    Domain Availability</strong><br /> is subject to International Market Purchases &amp; Global Domain Competition</td>
  </tr>
</table>
<table width="660" border="0" align="left" cellpadding="2" cellspacing="0">
  <tr>
    <td height="10">'.$line.'</td>
  </tr>
</table>
<table width="660" border="0" align="left" cellpadding="2" cellspacing="0">
  <tr>
    <td width="355" height="10"><br /><br />Looking Forward,<br />
i2d Marketing Department<br />
<strong>marketing@i2dtechnologies.com</strong></td>
    <td width="235" align="right">&nbsp;</td>
  </tr>
</table>

';

////////////////////////////////////////////





$inv_header='<p>&nbsp;</p><p>&nbsp;</p>

<table width="660" border="0" align="center" cellpadding="2" cellspacing="0">
  <tr>
    <td width="290" rowspan="2" align="left">ATTN : <br />
    '. $person_name .' <br />
    '. $company_name .'<br /> 
    '. $address .',<br /> 
    '. $city_name .',.</td>
    <td width="330" align="right"><h2>'. $inv_title .'</h2></td>
  </tr>
  <tr>
    <td align="right"><b>Tracking / Ref: '. $ref_suffix .''. $ref_series .''. $refno .'</b><br />
Invoice Date: '. $dated1 .'<br />
Due Date: '. $dated2 .'<br />
Sales Tax # '. $stn_number .'</td>
  </tr>
  
</table><br /><br />




';

$rec_id = $id;
$refno = $rec_id;

/*
$array_cols=array(id_col,company_name,address,owner_name,dotcom,ref,url);

$tdsettings=array(
	'table'=>i2d_table,
	'id_col'=>id_col,
	'fields_array'=>$array_cols,
	'status_vaue'=>'Active',
	'type'=>'1c',
	'where_col'=>id_col,
	'where_value'=>$rec_id,
	'ref_col'=>ref,
	'ref_value'=>"'market_entry'",
	'order'=>"ASC",
    'limit'=>1);

$printitem=db_fetch($tdsettings);

foreach ($printitem as $item)
{
$company_name=$item[company_name];
$person_name=$item[owner_name];
$address=$item[address];
$domain1=(base64_decode($item[dotcom]));
}

$person_name=strtoupper($person_name);
$company_name=strtoupper($company_name);
$address=strtoupper($address);

*/



require_once('tcpdf_include.php');


// Extend the TCPDF class to create custom Header and Footer
class MYPDF extends TCPDF {

	//Page header
	public function Header() {
if(isset($logo) && $logo!=0){		
		// Logo
		if (count($this->pages) === 1) {
		$image_file = K_PATH_IMAGES.$logo_img;
		$this->Image($image_file, 10, 10, 190, '', 'JPG', '', 'T', false, 300, '', false, false, 0, false, false, false);
		// Set font
		$this->SetFont('helvetica', 'B', 20);}
		
		
		if(isset($ad) && $ad!=0){
		if (count($this->pages) === 2) {
		$img_file = K_PATH_IMAGES.$ad_img;
        $this->Image($img_file, 0, 25, 210, 250, 'JPG', '', '', false, 300, 'C', false, false, 0);
		}
		}
		
}
		}

	// Page footer
	public function Footer() {
		if(isset($logo) && $logo!=0){
if (count($this->pages) === 1) {
	// Position at 15 mm from bottom
		$this->SetY(-15);
		
		// Set font
		$this->SetFont('helvetica', 'I', 8);
		// Page number
		$this->Cell(0, 10, 'Page '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M');
		$image_file = K_PATH_IMAGES.$footer_img;
		$this->Image($image_file, 10, 250, 190, '', 'JPG', '', 'T', false, 300, '', false, false, 0, false, false, false);
		
	}

	
	}
	}
	
	
}

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

// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('i2d Technologies');
$pdf->SetTitle($doc_title.$rec_id);
$pdf->SetSubject($doc_sub);
$pdf->SetKeywords($doc_keywords);

// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);

// 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', '', 9);


// create some HTML content

$pdf->AddPage();

// create some HTML content


$image_path2 = site_images."web.jpg";
$image_path = site_images."web.png";
$img = '<img src="'. $image_path  .'"/>';
$img2 = '<img src="'. $image_path2  .'"/>';

$rt='<h1>'. $image_path  .'</h1>';

/// PART 2

$html = ''.$inv_header.'';

$html .='
'.$opening_letter.''.$price_tables.''.$img2.'


<!--table Ends-->
';



// output the HTML content
$pdf->writeHTML(utf8_encode($html), true, 0, true, 0);
   
//$pdf->AddPage();
// reset pointer to the last page
$pdf->lastPage();

$file=".$file_title."."-".$refno."-".$dated1.".pdf";

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

if($case=="1"){//Close and output PDF document
ob_end_clean();
$pdf->Output($file , 'I');}

if($case=="2"){
	// force print dialog
$js = 'print(true);';

// set javascript
$pdf->IncludeJS($js);
ob_end_clean();
//Close and output PDF document
$pdf->Output($file , 'I');
	
}



//============================================================+
// END OF FILE
//============================================================+


/////////////////////////// function ends /////////////////////////////////












?>