| Server IP : 104.21.37.246 / Your IP : 104.23.243.32 [ Web Server : Apache System : Linux cpanel01wh.bkk1.cloud.z.com 2.6.32-954.3.5.lve1.4.59.el6.x86_64 #1 SMP Thu Dec 6 05:11:00 EST 2018 x86_64 User : cp648411 ( 1354) PHP Version : 7.2.34 Disable Function : NONE Domains : 0 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/cp648411/www/ilawasia.onnud20.com/TaxInvoice/ |
Upload File : |
<?php
//============================================================+
// File name : example_061.php
// Begin : 2010-05-24
// Last Update : 2014-01-25
//
// Description : Example 061 for TCPDF class
// XHTML + CSS
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com LTD
// www.tecnick.com
// [email protected]
//============================================================+
/**
* Creates an example PDF TEST document using TCPDF
* @package com.tecnick.tcpdf
* @abstract TCPDF - Example: XHTML + CSS
* @author Nicola Asuni
* @since 2010-05-25
*/
// Include the main TCPDF library (search for installation path).
require_once('tcpdf_include.php');
$Load = $taxInvoice_db->ExportPdf($_GET['Id']);
$Data = $Load['Data'][0];// inv
$Data2 = $Load['Data2']; // invItems
$Data3 = $Load['Data3']; // caseList
$Set_title = $Data['TaxInvoiceNo'];
$Set_filename = 'InvoiceNo.pdf';
// 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($Set_title);
$pdf->SetTitle($Set_title);
$pdf->SetSubject($Set_title);
$pdf->SetKeywords($Set_title);
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
require_once(dirname(__FILE__).'/lang/eng.php');
$pdf->setLanguageArray($l);
}
define('TH_REGULAR', TCPDF_FONTS::addTTFfont('../fonts/THSarabunNew.ttf', 'TrueTypeUnicode'));
define('TH_BOLD', TCPDF_FONTS::addTTFfont('../fonts/TH Sarabun New Bold.ttf', 'TrueTypeUnicode'));
$pdf->SetFont(TH_REGULAR, '', 14);
$pdf->AddPage();
header('Content-type: text/plain');
$request = array(
'StartDate' => @$_GET['StartDate'],
'EndDate' => @$_GET['EndDate'],
'CustomerId' => @$_GET['CustomerId'],
);
$image = "..";
$template = file_get_contents('Pdf/_Export_2.html', r);
$temp1 = explode("style>", $template);
$temp1 = str_replace("</","", $temp1[1]);
$temp2 = explode("<body>", $template);
$temp2 = explode("</body>", $temp2[1]);
$temp2 = $temp2[0];
//$temp2 = str_replace("</","", $temp2[1]);
/*
echo strlen($Load['Data']);
echo count($Load['Data']);
*/
$isConsultService=($Data['IsConsultService']==1)?1:0;
$invItems = $Data;
$matterNo="";
if(count($Data3) > 0){
$matter = (count($Data3) > 1)?"/-" : "/-";
$matterNo = $Data3[0]['CaseNumber'] . $matter;
}else {
$sql_case = array('table'=>'ct_case c INNER JOIN ct_case_quotation d ON c.CaseId = d.CaseId',
'where'=>"d.QuotationId = '".@$Data["QuotationId"]."'");
$view_sql_case = $view_db->view($sql_case);
$request_case = $view_db->q_ro($view_sql_case);
$num_case = $view_db->q_nr($request_case);
$row_case = $view_db->q($view_sql_case);
if($num_case >0){
$matter = (count($Data3) > 1)?"/-" : "";
$matterNo = $Data3[0]['CaseNumber'] . $matter;
}
}
$webUrl = "..";
if($Data['UpdateDateTime']!=''){
$date=date_create($Data['UpdateDateTime']);
$date_new_format = date_format($date,"F j, Y");
}else{
$date=date_create($Data['CreateDateTime']);
$date_new_format = date_format($date,"F j, Y");
}
$template = str_replace("[webUrl]",$webUrl, $temp2 );
$template = str_replace("[docNo]",$Data['TaxInvoiceNo'], $template );
$template = str_replace("[invNo]",$Data['InvoiceNo'], $template );
$template = str_replace("[matNo]",$matterNo, $template );
$template = str_replace("[date]",$date_new_format, $template );
$template = str_replace("[date]",$date_format, $template );
$template = str_replace("[cusName]",$Data['CustomerName'], $template );
$template = str_replace("[address]",$Data['Address'], $template );
$template = str_replace("[taxID]",$Data['TaxID'], $template );
$content = ""; $content2 = "";
$total = 0;$totalExcludeVat=0;$sum=0;
if(!@$isConsultService){
foreach ($Data2 as $key => $value) {
$txt_Remark = ($value['Remark']=='')? $value['Description']:$value['Remark'];
$co = count($Load['Data2'])-1;
if($key == $co){
$borderedbottom = "bordered-bottom";
}
$content .='<tr>'.
'<td class="bordered-left '.$borderedbottom.'" colspan="2" style="width: 83%;">'. $txt_Remark. '</td>' .
'<td class="bordered-left-right '.$borderedbottom.'" style="text-align: right;width: 17%;">' . number_format($value['Amount'],2) . '</td>' .
'</tr>';
$content2 .= '<tr>' .
'<td ><strong>' . ($total == 0) ? "Charged Total" : "" . '</strong></td>' .
'<td ><strong>' . $txt_Remark . '</strong></td>' .
'<td style="text-align:right;" ><strong>' . number_format($value['Amount'],2) . '</strong ></td>' .
'<td style="text-align:right;" ><strong>' . strtoupper($Data['Currency']) . '</strong ></td>' .
'</tr>';
if($value['IsExcludeVat']!=1){
$total = $total + $value['Amount'];
}else {
$totalExcludeVat = $totalExcludeVat + $value['Amount'];
}
}
}else {
foreach ($Data2 as $key => $value) {
$content2 .= '<tr>' .
'<td>' . $value['ActionDate'] . '</td>' .
'<td>' . $value['Category'] . '</td>' .
'<td>' . $value['Description'] . " " . $value['Remark'] . '</td>' .
'<td style="text-align:right;" colspan="2" ><strong>' . number_format(@$value['Amount'],2) . ' </strong ></td> '.
'</tr>';
if($value['IsExcludeVat']!=1){
$total = $total + $value['Amount'];
}else {
$totalExcludeVat = $totalExcludeVat + $value['Amount'];
}
}
$sum = $total + $totalExcludeVat;
$content .= '<tr>'.
'<td class="bordered no-top no-bottom" colspan="2" style="width: 83%;" >Expense (See Billing Details) :</td>' .
'<td class="bordered no-left no-top no-bottom" style="width:17%; text-align: right;"> '. number_format($sum,2) . '</td>' .
'</tr>';
}
$vat = $total * $Data['Vat'] / 100;
$netTotal = $total + $totalExcludeVat + $vat;
$docType = "ORIGINAL";
$template = str_replace("[total]",number_format($total,2), $template );
$template = str_replace("[vat]",$Data['Vat'], $template );
$template = str_replace("[vatAmount]",number_format($vat,2), $template );
$template = str_replace("[netTotal]",number_format($netTotal,2), $template );
$template = str_replace("[currency]",strtoupper($Data['Currency']), $template );
$template = str_replace("[docType]",$docType, $template );
$template = str_replace("[content]",$content, $template );
$html = <<<EOF
<!-- EXAMPLE OF CSS STYLE -->
<style>
$temp1
</style>
$template
EOF;
/*
echo $content;
echo $html;
exit();
*/
// output the HTML content
$pdf->writeHTML($html, true, false, true, false, '');
$pdf->AddPage();
$template2 = file_get_contents('Pdf/_Export_2.html', r);
$temp3 = explode("style>", $template2);
$temp3 = str_replace("</","", $temp3[1]);
$temp4 = explode("<body>", $template2);
$temp4 = explode("</body>", $temp4[1]);
$temp4 = $temp4[0];
$template2 = $temp4;
$template2 = str_replace("[webUrl]",$image, $temp4 );
$template2 = str_replace("[docNo]",$Data['TaxInvoiceNo'], $template2 );
$template2 = str_replace("[invNo]",$Data['InvoiceNo'], $template2 );
$template2 = str_replace("[matNo]",$matterNo, $template2 );
$template2 = str_replace("[date]",$date_format, $template2 );
$template2 = str_replace("[cusName]",$Data['CustomerName'], $template2 );
$template2 = str_replace("[address]",$Data['Address'], $template2 );
$template2 = str_replace("[taxID]",$Data['TaxID'], $template2 );
$docType = "COPY";
$template2 = str_replace("[docType]",$docType, $template2);
$template2 = str_replace("[total]",number_format($total,2), $template2 );
$template2 = str_replace("[vat]",$Data['Vat'], $template2 );
$template2 = str_replace("[vatAmount]",number_format($vat,2), $template2 );
$template2 = str_replace("[netTotal]",number_format($netTotal,2), $template2 );
$template2 = str_replace("[currency]",strtoupper($Data['Currency']), $template2 );
//$template2 = str_replace("[content]",strtoupper($content), $template2 );
$template2 = str_replace("[content]",$content, $template2 );
/*
//$template = '<h1 style="text-align: center;">No data found</h1>';
echo $temp1;
echo $template;
exit();
*/
$Set_filename = str_replace("/", "_", $Data['TaxInvoiceNo']).'.pdf';
$html2 = <<<EOF
<!-- EXAMPLE OF CSS STYLE -->
<style>
$temp3
</style>
$template2
EOF;
/*
echo $html;
echo $html2;
exit();
*/
// output the HTML content
$pdf->writeHTML($html2, true, false, true, false, '');
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// reset pointer to the last page
$pdf->lastPage();
// ---------------------------------------------------------
//Close and output PDF document
$pdf->Output($Set_filename, 'I');
//============================================================+
// END OF FILE
//============================================================+