<?php
ob_start();
include_once "../../common/connect.php";
include_once "../../common/db.php";
include_once "../../common/defines_ext.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";
$bank='Pay to Company Account<br /> 
    Title: i2d Technologies<br /> 
    Account No. : 0408-1004458344<br /> 
    Bank ALFALAH Ltd. Hub Commercial Branch.<br /> 
    Bahria Town Phase-8.<br />
    Rawalpindi';
$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="RENEWAL INVOICE";
$ref_suffix="RP-SP-";
$ref_series="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_old="__________________________________________________________________________________________________";
$line="_________________________________________________________________________________________";


$domain_name="i2dtechnologies.com";
$heading1="Service Name";
$package_title="Pro HOST 1 GB";
$package_term="12 Months / 1 Year Plan";
$domain_price="1500";
$domain_term="1";
$domain_header_type=".com Domain";
$domain_feature1=
'
<ul><li><strong>'.$domain_term.' Year(s) Validity</strong></li>
      <li>Digital Security Code (DSC)</li></ul>
';

$domain_feature2=
'
<ul><li>Privacy Protection</li>
        <li>Theft Protection</li>
    </ul>    
';

$hosting_price="8000";
$hosting_header_type="Package / Plan : Basic 500MB";


$hosting_features1=
'
<ul>
      <li><strong>Cloud Linux 500 MB</strong></li>
      <li>POP3 / IMAP Email User(s)</li>
      <li>Unlimited Email Forwarders</li>
      <li>Web Mail Manager</li>
      <li>Data Base Support</li>
      <li>Hosting Control Panel </li>
    </ul>        
';

$hosting_features2=
'
<ul>
      <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>
';

$unit="PKR";

$package_price="9500";
$tax_value=$package_price*$tax_rate1;
$price_with_tax=$package_price+$tax_value;


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



$inv_header='<p>&nbsp;</p><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="300" 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 />




<table width="660" border="0" align="center" cellpadding="5" cellspacing="0">
  <tr>
    <td width="302" height="10" align="center" bgcolor="#000000"><span style="color:white;"><strong>'.$heading1.'</strong></span></td>
    <td width="318" align="center" bgcolor="#000000"><span style="color:white;"><strong>Payment Details* (In case of Online / Cheque)</strong></span></td>
  </tr>
</table>

<table width="660" border="0" align="center" cellpadding="2" cellspacing="0">
  <tr>&nbsp;<br /></tr>
  <tr>
    <td width="290"><ul>
      <li>'.$package_title.' <br />
        <strong>('.$package_term.')</strong></li>
      <li>Domain : <strong>'.$domain_name.'</strong></li>
    </ul></td>
    <td width="300" align="right">'.$bank.'<br /></td>
  </tr>
</table>

';

$html .=''.$package_feature0.'';

$html .='<table width="660" border="0" align="center" cellpadding="2" cellspacing="0">
  <tr>
    <td width="290"><ul>
      <li>'.$package_title.' <br />
        <strong>('.$package_term.')</strong></li>
      <li>Domain : <strong>'. $domain1 .'</strong></li>
    </ul></td>
    <td width="300" align="right">'. $bank .'</td>
  </tr>
</table>

<table width="660" border="0" align="center" cellpadding="2" cellspacing="0">
  <tr>
    <td height="10"></td>
  </tr>
</table>
';

$package_feature0='<table width="660" border="0" align="center" cellpadding="5" cellspacing="0">
  <tr>
    <td width="302" height="10" align="center" bgcolor="#000000"><span style="color:white;"><strong>Hosting Plan  &amp; Domain</strong></span></td>
    <td width="318" align="center" bgcolor="#000000"><span style="color:white;"><strong>Payment Details* (In case of Online / Cheque)</strong></span></td>
  </tr>
</table>';

$package_feature1='
<!--table Starts-->
<table width="660" border="0" align="center" cellpadding="5" cellspacing="0">
  <tr>
    <td width="302" height="10" align="center" bgcolor="#000000"><span style="color:white;"><strong>Details / Description</strong></span></td>
    <td width="318" align="center" bgcolor="#000000"><span style="color:white;"><strong>Cost /Price</strong></span></td>
  </tr>
</table>


<table width="660" border="0" align="left" cellpadding="4" cellspacing="0">

  
  <tr>
    <td colspan="2" bgcolor="#E6E6E6"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$domain_header_type.'</strong></td>
    <td width="180" align="left" bgcolor="#E6E6E6">&nbsp;</td>
  </tr>
  <tr>&nbsp;<br /></tr>
  <tr>
  
    <td width="244">'.$domain_feature1.'</td>
    <td width="194" align="left">'.$domain_feature2.'
	</td>
    <td width="198" align="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$unit.'&nbsp;'.$domain_price.'</td>
	
	</tr>
  
</table>
<br /><br />
';

$package_feature2='
<table width="660" border="0" align="left" cellpadding="4" cellspacing="0">
  
  <tr>
    <td colspan="2" bgcolor="#E6E6E6"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$hosting_header_type.'</strong> </td>
    <td width="174" align="center" bgcolor="#E6E6E6">&nbsp;</td>
  </tr>
  <tr>&nbsp;<br /></tr>
  <tr>
    <td width="215">'.$hosting_features1.'</td>
    <td width="171">'.$hosting_features2.'</td>
    <td width="174" align="center">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$unit.'&nbsp;'.$hosting_price.'</td>
  </tr>
</table>

';

$costing='
<table width="660" border="0" align="center" cellpadding="2" cellspacing="0">
  <tr>
    <td height="10" width="660" align="left">'.$line.'</td>
  </tr>
</table>

<table width="660" border="0" align="center" cellpadding="2" cellspacing="0">
<tr>&nbsp;<br /></tr>
  <tr>
    <td width="413" height="10">Package Charges :</td>
    <td width="177" align="center">'.$unit.' '.$package_price.'</td>
  </tr>
  <tr>
    <td height="10">General Sales Tax ('.$tax_rate.' %)* :</td>
    <td align="center">'.$unit.'&nbsp;'.$tax_value.'*</td>
  </tr>
</table>

<table width="660" border="0" align="center" cellpadding="2" cellspacing="0">
  <tr>
    <td height="10" width="660" align="left">'.$line.'</td>
  </tr>
</table>

<table width="660" border="0" align="center" cellpadding="2" cellspacing="0">
<tr>&nbsp;<br /></tr>
  <tr>
    <td width="413" height="10"><strong>Total Charges :</strong></td>
    <td width="177" align="center"><strong>'.$unit.'&nbsp;'.$price_with_tax.'</strong></td>
  </tr>
</table>

<table width="660" border="0" align="center" cellpadding="2" cellspacing="0">

  <tr>
    <td height="10" width="660" align="left">'.$line.'</td>
  </tr>
</table>

<table width="660" border="0" align="center" cellpadding="2" cellspacing="0">
<tr>&nbsp;<br /></tr>
  <tr>
    <td width="355" height="10"><h1>BAR CODE LINE</h1></td>
    <td width="235" align="right">Generated By : <br />
      i2d Billing &amp; Accounts Department<br />
    <strong>billing@i2dtechnologies.com</strong></td>
  </tr>
  <tr>
    <td height="10" align="left">'.$tax_note.'</td>
    <td align="right">&nbsp;</td>
  </tr>
</table>';


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

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


// create some HTML content

$pdf->AddPage();

// create some HTML content




/// PART 2

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

$html .='
'.$package_feature1.''.$package_feature2.'


<!--table Ends-->
';

$html .=''.$costing.'';




// 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 /////////////////////////////////












?>