| Server IP : 172.67.216.113 / 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 : /home2/cp648411/public_html/ilawasia.onnud20.com/Report/ |
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
*/
$Set_title='AgedDebtPdf';
$Set_filename='AgedDebtPdf.pdf';
// Include the main TCPDF library (search for installation path).
require_once('tcpdf_include.php');
// 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);
// set default header data
//$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 061', 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));
// remove default header/footer
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
// 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);
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);
// add a page
$pdf->AddPage('L', 'A4');
/* NOTE:
* *********************************************************
* You can load external XHTML using :
*
* $html = file_get_contents('/path/to/your/file.html');
*
* External CSS files will be automatically loaded.
* Sometimes you need to fix the path of the external CSS.
* *********************************************************
*/
// define some HTML content with style
header('Content-type: text/plain');
//header('Content-type: text/html');
//header('Content-type: application/json');
$request = array(
'StartDate' => @$_GET['StartDate'],
'EndDate' => @$_GET['EndDate'],
'CustomerId' => @$_GET['CustomerId'],
);
$Load = $report_db->AgedDebtExcelandPdf($request);
$image = "../Assets/logo_blue-01.png";
//$image = "public_html/corporatemodule/Assets/logo_blue-01.png";
$template = file_get_contents('Pdf/_AgedDebt.html', r);
//echo $template;
$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']);
exit();
echo "<pre>";
print_r($Load);
echo "</pre>";
*/
if(count($Load['Data']) > 1){
$content="";
$lastCustomerCode = "";
$netDays = 0; $netOutStanding = 0; $net1 = 0; $net2 = 0; $net3 = 0; $net4 = 0; $net5 = 0; $net6 = 0;
$sumDays = 0; $sumOutStanding = 0; $sum1 = 0; $sum2 = 0; $sum3 = 0; $sum4 = 0; $sum5 = 0; $sum6 = 0;
$customerName = "-"; $stDate = "-"; $nDate = "-";
$stDate = $_GET['StartDate'];
$nDate = $_GET['EndDate'];
if(@$_GET['CustomerId']){
$customerName = $customer_db->Index($request);
$customerName =$customerName['Data'][0]['NamesName'];
}
foreach ($Load['Data'] as $key => $value) {
if($lastCustomerCode != $value['CustomerCode']){
if($sumOutStanding > 0){
$content .= '<tr>' .
'<td colspan="2" style="text-align:right;"><strong>Total:</strong></td>' .
'<td class="total" style="text-align:right;"><strong>' . number_format($sumOutStanding,2) . '</strong></td>' .
'<td class="total" style="text-align:right;"><strong>' . number_format($sumDays,2) . '</strong></td>' .
'<td class="total" style="text-align:right;"><strong>' . number_format($sum1,2) . '</strong></td>' .
'<td class="total" style="text-align:right;"><strong>' . number_format($sum2,2) . '</strong></td>' .
'<td class="total" style="text-align:right;"><strong>' . number_format($sum3,2) . '</strong></td>' .
'<td class="total" style="text-align:right;"><strong>' . number_format($sum4,2) . '</strong></td>' .
'<td class="total" style="text-align:right;"><strong>' . number_format($sum5,2) . '</strong></td>' .
'<td class="total" style="text-align:right;"><strong>' . number_format($sum6,2) . '</strong></td>' .
'</tr>';
$netDays = floatval($netDays) + floatval($sumDays);
$netOutStanding = floatval($netOutStanding) + floatval($sumOutStanding);
$net1 = floatval($net1) + floatval($sum1);
$net2 = floatval($net2) + floatval($sum2);
$net3 = floatval($net3) + floatval($sum3);
$net4 = floatval($net4) + floatval($sum4);
$net5 = floatval($net5) + floatval($sum5);
$net6 = floatval($net6) + floatval($sum6);
$sumDays = 0;
$sumOutStanding = 0;
$sum1 = 0;
$sum2 = 0;
$sum3 = 0;
$sum4 = 0;
$sum5 = 0;
$sum6 = 0;
}
$content .= '<tr>' .
'<td colspan="10"><strong>' . $value['CustomerName'] . '</strong></td>' .
'</tr>';
$lastCustomerCode = $value['CustomerCode'];
}
$row1 = ($value['DiffDays'] >= 0 && $value['DiffDays'] <= 30)? number_format($value['OutStanding'],2) : "0.00";
$row2 = ($value['DiffDays'] >= 31 && $value['DiffDays'] <= 60)? number_format($value['OutStanding'],2) : "0.00";
$row3 = ($value['DiffDays'] >= 61 && $value['DiffDays'] <= 90)? number_format($value['OutStanding'],2) : "0.00";
$row4 = ($value['DiffDays'] >= 91 && $value['DiffDays'] <= 120)? number_format($value['OutStanding'],2) : "0.00";
$row5 = ($value['DiffDays'] >= 121 && $value['DiffDays'] <= 180)? number_format($value['OutStanding'],2) : "0.00";
$row6 = ($value['DiffDays'] > 180) ? number_format($value['OutStanding'],2) : "0.00";
/*
$st_date = explode(" ",$value['CreateDateTime']);
$st_date = $st_date[0];
*/
$st_date = $util_class->date_chang_2($value['CreateDateTime']);
$content .= '<tr>' .
'<td>' . $st_date. '</td>' .
'<td>' . $value['InvoiceNo'] . '</td>' .
'<td style="text-align:right;"><strong>' . number_format($value['OutStanding'],2). "</strong></td>" .
'<td style="text-align:right;">' . number_format($value['DiffDays']) . '</td>' .
'<td style="text-align:right;">' . $row1 . '</td>' .
'<td style="text-align:right;">' . $row2 . '</td>' .
'<td style="text-align:right;">' . $row3 . '</td>' .
'<td style="text-align:right;">' . $row4 . '</td>' .
'<td style="text-align:right;">' . $row5 . '</td>' .
'<td style="text-align:right;">' . $row6 . '</td>' .
'</tr>';
$sumDays = floatval($sumDays) + floatval($value['DiffDays']);
$sumOutStanding = floatval($sumOutStanding) + floatval($value['OutStanding']);
$sum1 = floatval($sum1) + ($value['DiffDays'] >= 0 && $value['DiffDays'] <= 30) ? floatval($value['OutStanding']) : 0;
$sum2 = floatval($sum2) + ($value['DiffDays'] >= 31 && $value['DiffDays'] <= 60) ? floatval($value['OutStanding']) : 0;
$sum3 = floatval($sum3) + ($value['DiffDays'] >= 61 && $value['DiffDays'] <= 90) ? floatval($value['OutStanding']) : 0;
$sum4 = floatval($sum4) + ($value['DiffDays'] >= 91 && $value['DiffDays'] <= 120) ? floatval($value['OutStanding']) : 0;
$sum5 = floatval($sum5) + ($value['DiffDays'] >= 121 && $value['DiffDays'] <= 180) ? floatval($value['OutStanding']) : 0;
$sum6 = floatval($sum6) + ($value['DiffDays'] > 180) ? $value['OutStanding'] : 0;
}
if($sumOutStanding > 0){
$content .= '<tr>' .
'<td colspan="2" style="text-align:right;"><strong>Total:</strong></td>' .
'<td class="total" style="text-align:right;"><strong>'. number_format($sumOutStanding, 2) . '</strong></td>' .
'<td class="total" style="text-align:right;"><strong>' . number_format($sumDays, 2) . '</strong></td>' .
'<td class="total" style="text-align:right;"><strong>' . number_format($sum1, 2) . '</strong></td>' .
'<td class="total" style="text-align:right;"><strong>' . number_format($sum2, 2) . '</strong></td>' .
'<td class="total" style="text-align:right;"><strong>' . number_format($sum3, 2) . '</strong></td>' .
'<td class="total" style="text-align:right;"><strong>' . number_format($sum4, 2) . '</strong></td>' .
'<td class="total" style="text-align:right;"><strong>' . number_format($sum5, 2) . '</strong></td>' .
'<td class="total" style="text-align:right;"><strong>' . number_format($sum6, 2) . '</strong></td>' .
'</tr>';
$netDays = floatval($netDays) + floatval($sumDays);
$netOutStanding = floatval($netOutStanding) + floatval($sumOutStanding);
$net1 = floatval($net1) + floatval($sum1);
$net2 = floatval($net2) + floatval($sum2);
$net3 = floatval($net3) + floatval($sum3);
$net4 = floatval($net4) + floatval($sum4);
$net5 = floatval($net5) + floatval($sum5);
$net6 = floatval($net6) + floatval($sum6);
$content .= '<tr>' .
'<td colspan="2" style="text-align:right;"><strong>Grand Total:</strong></td>' .
'<td class="total" style="text-align:right;"><strong>'. number_format($sumOutStanding, 2) . '</strong></td>' .
'<td class="total" style="text-align:right;"><strong>' . number_format($sumDays, 2) . '</strong></td>' .
'<td class="total" style="text-align:right;"><strong>' . number_format($sum1, 2) . '</strong></td>' .
'<td class="total" style="text-align:right;"><strong>' . number_format($sum2, 2) . '</strong></td>' .
'<td class="total" style="text-align:right;"><strong>' . number_format($sum3, 2) . '</strong></td>' .
'<td class="total" style="text-align:right;"><strong>' . number_format($sum4, 2) . '</strong></td>' .
'<td class="total" style="text-align:right;"><strong>' . number_format($sum5, 2) . '</strong></td>' .
'<td class="total" style="text-align:right;"><strong>' . number_format($sum6, 2) . '</strong></td>' .
'</tr>';
}
$template = str_replace("[startDate]",$stDate, $temp2 );
$template = str_replace("[endDate]",$nDate, $template );
$template = str_replace("[customer]",$customerName, $template );
$template = str_replace("[content]",$content, $template );
}else {
$template = '<h1 style="text-align: center;">No data found</h1>';
}
//echo $temp1;
$html = <<<EOF
<!-- EXAMPLE OF CSS STYLE -->
<style>
$temp1
</style>
$template
EOF;
//echo $html;
//exit();
// output the HTML content
$pdf->writeHTML($html, 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
//============================================================+