Example #1
18
    public function testPdfOutput()
    {
        // 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('Nicola Asuni');
        $pdf->SetTitle('TCPDF Example 001');
        $pdf->SetSubject('TCPDF Tutorial');
        $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
        // set default header data
        $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 001', PDF_HEADER_STRING, array(0, 64, 255), array(0, 64, 128));
        $pdf->setFooterData(array(0, 64, 0), array(0, 64, 128));
        // 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)
        $pdf->setLanguageArray($this->langSettings);
        // ---------------------------------------------------------
        // set default font subsetting mode
        $pdf->setFontSubsetting(true);
        // Set font
        // dejavusans is a UTF-8 Unicode font, if you only need to
        // print standard ASCII chars, you can use core fonts like
        // helvetica or times to reduce file size.
        $pdf->SetFont('dejavusans', '', 14, '', true);
        // Add a page
        // This method has several options, check the source code documentation for more information.
        $pdf->AddPage();
        // set text shadow effect
        $pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.2, 'depth_h' => 0.2, 'color' => array(196, 196, 196), 'opacity' => 1, 'blend_mode' => 'Normal'));
        // Set some content to print
        $html = <<<EOD
<h1>Welcome to <a href="http://www.tcpdf.org" style="text-decoration:none;background-color:#CC0000;color:black;">&nbsp;<span style="color:black;">TC</span><span style="color:white;">PDF</span>&nbsp;</a>!</h1>
<i>This is the first example of TCPDF library.</i>
<p>This text is printed using the <i>writeHTMLCell()</i> method but you can also use: <i>Multicell(), writeHTML(), Write(), Cell() and Text()</i>.</p>
<p>Please check the source code documentation and other examples for further information.</p>
<p style="color:#CC0000;">TO IMPROVE AND EXPAND TCPDF I NEED YOUR SUPPORT, PLEASE <a href="http://sourceforge.net/donate/index.php?group_id=128076">MAKE A DONATION!</a></p>
EOD;
        // Print text using writeHTMLCell()
        $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
        $this->comparePdfs($pdf);
    }
    public function pdfthongkeAction()
    {
        $translate = Zend_Registry::get('Zend_Translate');
        $this->view->title = 'Thống kê - ' . $translate->_('TEXT_DEFAULT_TITLE');
        $this->view->headTitle($this->view->title);
        $layoutPath = APPLICATION_PATH . '/templates/' . TEMPLATE_USED;
        $option = array('layout' => '1_column/layout', 'layoutPath' => $layoutPath);
        Zend_Layout::startMvc($option);
        $date = new Zend_Date();
        $date->subMonth(1);
        $thang = $this->_getParam('thang', $date->toString('M'));
        $nam = $this->_getParam('nam', $date->toString('Y'));
        $auth = Zend_Auth::getInstance();
        $identity = $auth->getIdentity();
        $em_id = $identity->em_id;
        $emModel = new Front_Model_Employees();
        $phongbanModel = new Front_Model_Phongban();
        $my_info = $emModel->fetchRow('em_id=' . $em_id . ' and em_status=1');
        $phong_ban_id = $list_phongban = $phong_ban = array();
        if ($my_info) {
            $phong_ban_id[] = $my_info->em_phong_ban;
            $list_phongban = $phongbanModel->fetchDataStatus($my_info->em_phong_ban, $phong_ban);
        }
        if (sizeof($list_phongban)) {
            foreach ($list_phongban as $phong_ban_info) {
                $phong_ban_id[] = $phong_ban_info->pb_parent;
            }
        }
        $phong_ban_id = implode(',', $phong_ban_id);
        $list_nhan_vien = $emModel->fetchAll("em_phong_ban in ({$phong_ban_id}) and em_status=1");
        $holidaysModel = new Front_Model_Holidays();
        $holidays = $holidaysModel->fetchData();
        $listHoliday = array();
        foreach ($holidays as $holiday) {
            $listHoliday[$holiday['hld_id']] = $holiday['hld_code'];
        }
        $k = 0;
        if ($list_nhan_vien) {
            $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
            $pdf->SetCreator(PDF_CREATOR);
            $pdf->SetAuthor(PDF_AUTHOR);
            $pdf->SetTitle(PDF_HEADER_TITLE);
            $pdf->SetSubject(PDF_HEADER_TITLE);
            $pdf->SetKeywords('bang luong');
            $pdf->setPrintHeader(false);
            $pdf->setFooterData(array(0, 64, 0), array(0, 64, 128));
            $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
            $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
            $pdf->SetMargins(5, PDF_MARGIN_TOP, 5);
            $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
            $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
            $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
            $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
            $pdf->setFontSubsetting(true);
            $pdf->SetFont('dejavusans', '', 14, '', true);
            $pdf->AddPage('L', 'A4');
            $pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.2, 'depth_h' => 0.2, 'color' => array(196, 196, 196), 'opacity' => 1, 'blend_mode' => 'Normal'));
            $text_outout = '
                        <style>
                            .ten-co-quan {
                                color: #000;
                                font-size: 10pt;
                                height: 50px;
                                text-align:center;
                            }
                            .ten-bang-luong{
                                height: 30px;
                                text-align:center;
                                font-size: 10pt;
                            }

                            table.first {
                                color: #003300;
                                font-family: helvetica;
                                font-size: 8pt;
                                border-left: 3px solid red;
                                border-right: 3px solid #FF00FF;
                                border-top: 3px solid green;
                                border-bottom: 3px solid blue;
                                background-color: #ccffcc;
                            }
                            .borders {
                                border: 1px solid #000;
                                font-size: 10px;
                            }

                            .tieu-de{
                                height: 20px;
                                font-size: 11px;
                            }
                            .noi-dung{
                                font-size: 10px;
                            }
                            td.second {
                                border: 2px dashed green;
                            }

                            .lowercase {
                                text-transform: lowercase;
                            }
                            .uppercase {
                                text-transform: uppercase;
                            }
                            .capitalize {
                                text-transform: capitalize;
                            }
                            
                            .error{
                                background-color: #dddddd;
                            }
                        </style>
                        <table width="100%">
                            <tr>
                                <td width="200" class="ten-co-quan uppercase">
                                    TỔNG CỤC HẢI QUAN
                                    <div><strong>CỤC HẢI QUAN HÀ TĨNH</strong></div>
                                </td>
                                <td colspan="2">&nbsp;</td>
                            </tr>
                            <tr>
                                <td colspan="3" class="ten-bang-luong uppercase">BẢNG CHẤM CÔNG VÀ XẾP LOẠI A,B,C THÁNG ' . $thang . '-' . $nam . '</td>
                            </tr>';
            $text_outout .= '<tr>
                                <td colspan="3">
                                    <br/>
                                    <table border="1" class="noi-dung" cellpadding="5" nobr="true">
                                        <tr>
                                            <td style="width: 25pt;" rowspan="2"><strong>STT</strong></td>
                                            <td style="width: 70pt;" rowspan="2"><strong>HỌ TÊN</strong></td>
                                            <td colspan="31" style="text-align:center;"><strong>Ngày Công Trong Tháng</strong></td>
                                            <td style="width: 50pt;" rowspan="2"><strong>Phân loại A,B,C</strong></td>
                                            <td style="width: 50pt;" rowspan="2"><strong>Ghi chú</strong></td>
                                        </tr>
                                        <tr>';
            for ($i = 1; $i <= 31; $i++) {
                $text_outout .= '<td >' . $i . '</td>';
            }
            $text_outout .= '</tr>';
            $k = 0;
            $chamcongModel = new Front_Model_ChamCong();
            foreach ($list_nhan_vien as $nhan_vien) {
                $phan_loai_label = 'A';
                $phan_loai = $this->view->viewGetPhanLoai($nhan_vien->em_id, $thang, $nam);
                if ($phan_loai) {
                    $phan_loai_label = $phan_loai->dg_ptccb_status;
                    if (!$phan_loai_label || $phan_loai_label == null || $phan_loai_label == '-') {
                        $phan_loai_label = 'A';
                    }
                } else {
                    $phan_loai_label = '';
                }
                $text_outout .= '<tr>';
                $k++;
                $cham_cong = $chamcongModel->fetchOneData(array('c_em_id' => $nhan_vien['em_id'], 'c_thang' => (int) $thang, 'c_nam' => (int) $nam));
                $text_outout .= '<td>' . $k . '</td>';
                $text_outout .= '<td>' . $nhan_vien->em_ho . ' ' . $nhan_vien->em_ten_dem . ' ' . $nhan_vien->em_ten . '</td>';
                for ($i = 1; $i <= 31; $i++) {
                    $ngay_chamcong = 'c_ngay_' . $i;
                    $trangthai_ngaycong = $cham_cong->{$ngay_chamcong};
                    $status = !empty($listHoliday[$trangthai_ngaycong]) ? $listHoliday[$trangthai_ngaycong] : '&nbsp;';
                    $text_outout .= '<td ' . $this->view->viewCheckChuNhatThuBay($i, (int) $thang, (int) $nam) . '>' . $status . '</td>';
                }
                $text_outout .= '<td>' . $phan_loai_label . '</td>';
                $text_outout .= '<td></td>';
                $text_outout .= '</tr>';
            }
            $text_outout .= '</table>
                                </td>
                            </tr>';
            $text_outout .= '</table>
                                </td>
                            </tr>';
            $text_outout .= '<tr><td style=""></td><td style="width: 120pt;">&nbsp;</td><td style="width: 50pt;">&nbsp;</td></tr>';
            foreach ($holidays as $holiday) {
                $text_outout .= '<tr class="noi-dung"><td style="width: 32pt;"></td><td style="width: 70pt;">' . $holiday['hld_name'] . '</td><td style="width: 50pt;">' . $holiday['hld_code'] . '</td></tr>';
            }
            $text_outout .= '</table> ';
            $pdf->writeHTMLCell(0, 0, '', '', $text_outout, 0, 1, 0, true, '', true);
            $pdf->Output($file_name, 'I');
            die;
            $k += 5;
            foreach ($holidays as $holiday) {
                $k++;
                $objPHPExcel->getActiveSheet()->SetCellValue('B' . ($k + 7), $holiday['hld_name']);
                $objPHPExcel->getActiveSheet()->SetCellValue('C' . ($k + 7), $holiday['hld_code']);
            }
            if ($k) {
                $objPHPExcel->getActiveSheet()->setTitle('Bảng lương');
                if ($pb_selected && $phong_ban_selected_info) {
                    $file_name = 'Thong_ke_luong_' . str_replace(' ', '_', $this->loc_tieng_viet($phong_ban_selected_info->pb_name)) . '_' . $thang . '-' . $nam . '.xls';
                } else {
                    $file_name = 'Thong_ke_luong_' . $thang . '-' . $nam . '.xls';
                }
                header('Content-Type: application/vnd.ms-excel');
                header('Content-Disposition: attachment;
                filename = "' . $file_name . '"');
                header('Cache-Control: max-age = 0');
                $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
                $objWriter->save('php://output');
                die;
                /*
                                  $file_name = 'Bang_luong_.xls';
                                  $objPHPExcel->getActiveSheet()->setTitle('Bảng lương');
                
                                  header('Content-Type: application/vnd.ms-excel');
                                  header('Content-Disposition: attachment;filename="hungnm.xls"');
                                  header('Cache-Control: max-age=0');
                                  $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
                                  $objWriter->save('php://output'); */
            } else {
                $this->_helper->viewRenderer->setRender('loi');
            }
        } else {
            $this->_helper->viewRenderer->setRender('loi');
        }
    }
 public function __construct(TCPDF $pdf, $title, $slogan, $name, $details)
 {
     $pdf->SetTextColor(255, 255, 255);
     $pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.5, 'depth_h' => 0.5, 'color' => array(0, 0, 0), 'opacity' => 0.5, 'blend_mode' => 'Multiply'));
     $pdf->SetFont('league-gothic', '', 100, '', true);
     $pdf->writeHTMLCell(170, 200, 20, 40, $this->buildHTML('h1', $title), 0, 1, 0, true, 'C');
     $pdf->SetFont('AlegreyaSans-MediumItalic', '', 55, '', true);
     $pdf->writeHTMLCell(170, 200, 20, 63, $this->buildHTML('p', $slogan, 65), 0, 1, 0, true, 'C');
     $pdf->setTextShadow(array('enabled' => false));
     $pdf->SetFont('AlegreyaSans-ExtraBold', '', 25, '', true);
     $pdf->writeHTMLCell(180, 100, 18, 241, $this->buildHTML('h2', $name, 30), 0, 1, 0);
     $pdf->SetFont('AlegreyaSans-Regular', '', 16, '', true);
     $pdf->writeHTMLCell(180, 100, 18, 254, $this->buildHTML('p', $details, 20), 0, 1, 0);
 }
 public function __construct(TCPDF $pdf, $title, $slogan, $name, $details)
 {
     $pdf->SetTextColor(255, 255, 255);
     $pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.5, 'depth_h' => 0.5, 'color' => array(0, 0, 0), 'opacity' => 0.5, 'blend_mode' => 'Multiply'));
     $pdf->SetFont('BubblegumSans', '', 85, '', true);
     $pdf->writeHTMLCell(170, 200, 20, 35, $this->buildHTML('h1', $title), 0, 1, 0, true, 'C');
     $pdf->SetTextColor(247, 220, 102);
     $pdf->SetFont('BubblegumSans', '', 48, '', true);
     $pdf->writeHTMLCell(80, 200, 110, 55, $this->buildHTML('p', $slogan, 58), 0, 1, 0, true, 'C');
     $pdf->SetTextColor(0, 0, 0);
     $pdf->setTextShadow(array('enabled' => false));
     $pdf->SetFont('AlegreyaSans-ExtraBold', '', 25, '', true);
     $pdf->writeHTMLCell(180, 100, 18, 243, $this->buildHTML('h2', $name, 30), 0, 1, 0);
     $pdf->SetFont('AlegreyaSans-Regular', '', 16, '', true);
     $pdf->writeHTMLCell(180, 100, 18, 256, $this->buildHTML('p', $details, 20), 0, 1, 0);
 }
    require_once dirname(__FILE__) . '/lang/eng.php';
    $pdf->setLanguageArray($l);
}
// ---------------------------------------------------------
// set default font subsetting mode
$pdf->setFontSubsetting(true);
// Set font
// dejavusans is a UTF-8 Unicode font, if you only need to
// print standard ASCII chars, you can use core fonts like
// helvetica or times to reduce file size.
$pdf->SetFont('dejavusans', '', 10, '', true);
// Add a page
// This method has several options, check the source code documentation for more information.
$pdf->AddPage();
// set text shadow effect
$pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.2, 'depth_h' => 0.2, 'color' => array(196, 196, 196), 'opacity' => 1, 'blend_mode' => 'Normal'));
$con_error = "cannot be connected";
$mysql_host = "localhost";
$mysql_user = "******";
$mysql_pass = "";
$mysql_db = "users";
$ip = $_GET['var'];
$res = explode(',', $ip);
$cno = $res[0];
$fac = $res[1];
$name = $res[2];
if (!mysql_connect($mysql_host, $mysql_user, $mysql_pass) || !mysql_select_db($mysql_db)) {
    die($con_error);
} else {
    $i = 0;
    $j = 0;
 protected function download_pdf($html)
 {
     $this->load->library('tcpdf');
     $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->SetAuthor('Nicola Asuni');
     $pdf->SetTitle('TCPDF Example 001');
     $pdf->SetSubject('TCPDF Tutorial');
     $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
     $pdf->setPrintHeader(false);
     $pdf->setPrintFooter(false);
     $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 001', PDF_HEADER_STRING, array(0, 64, 255), array(0, 64, 128));
     $pdf->setFooterData(array(0, 64, 0), array(0, 64, 128));
     $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
     $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
     $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);
     }
     $pdf->setFontSubsetting(true);
     $pdf->SetFont('dejavusans', '', 14, '', true);
     $pdf->AddPage();
     $pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.2, 'depth_h' => 0.2, 'color' => array(196, 196, 196), 'opacity' => 1, 'blend_mode' => 'Normal'));
     $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
     $pdf->Output('example_001.pdf', 'I');
 }
 public function process()
 {
     $context = \CADB\Model\Context::instance();
     if (!$this->params['nid']) {
         Error('단체협약서 번호를 입력하세요.');
     }
     if (!$this->themes) {
         $this->themes = $context->getProperty('service.themes');
     }
     $this->fields = \CADB\Agreement::getFieldInfo(1);
     $this->articles = \CADB\Agreement::getAgreement($this->params['nid'], $this->params['did'] ? $this->params['did'] : 0);
     if (!$this->articles) {
         Error('존재하지 않는 단체협약입니다.');
     }
     \CADB\Log::articleLog('pdf', $this->params['nid'], $this->params['did'] ? $this->params['did'] : 0, "단체협약: [" . $this->articles['subject'] . "]을 PDF 조회했습니다.");
     $pdf = new \TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     // set document information
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->SetAuthor($context->getProperty('service.title'));
     $pdf->SetTitle($this->articles['subject']);
     $pdf->SetSubject($this->articles['subject']);
     $pdf->SetKeywords(preg_replace("/[ ]{1,}/i", ", ", $this->article['subject']));
     // set default header data
     $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, $context->getProperty('service.title'), $context->getProperty('service.domain'), array(0, 64, 255), array(0, 64, 128));
     $pdf->setFooterData(array(0, 64, 0), array(0, 64, 128));
     // 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 default font subsetting mode
     $pdf->setFontSubsetting(true);
     $pdf->SetFont('nanumbarungothic', '', 14, '', true);
     $pdf->AddPage();
     // set text shadow effect
     $pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.2, 'depth_h' => 0.2, 'color' => array(196, 196, 196), 'opacity' => 1, 'blend_mode' => 'Normal'));
     $pdf->writeHTMLCell(0, 0, '', '', '<h1>' . $this->articles['subject'] . '</h1><br><br>', 0, 1, 0, true, '', true);
     ob_start();
     $theme_html_file = "";
     if ($this->themes) {
         $theme_html_file = CADB_PATH . "/themes/" . $this->themes . "/articles/pdf.html.php";
         if ($theme_html_file && file_exists($theme_html_file)) {
             include $theme_html_file;
         } else {
             include dirname(__FILE__) . "/pdf.html.php";
         }
     } else {
         include dirname(__FILE__) . "/pdf.html.php";
     }
     $content = ob_get_contents();
     ob_end_clean();
     $pdf->SetFont('nanumbarungothic', '', 12, '', true);
     $pdf->writeHTML($content, true, false, false, false, 'center');
     $pdf->SetFont('nanumbarungothic', '', 14, '', true);
     $pdf->writeHTMLCell(0, 0, '', '', $this->articles['content'], 0, 1, 0, true, '', true);
     $pdf->Output($this->articles['subject'] . '.pdf', 'I');
 }
 public function downAction()
 {
     $translate = Zend_Registry::get('Zend_Translate');
     $this->view->title = 'In lương - ' . $translate->_('TEXT_DEFAULT_TITLE');
     $this->view->headTitle($this->view->title);
     $layoutPath = APPLICATION_PATH . '/templates/' . TEMPLATE_USED;
     $option = array('layout' => '1_column/layout', 'layoutPath' => $layoutPath);
     Zend_Layout::startMvc($option);
     $date = time();
     $thang = $this->_getParam('thang', date('m', $date));
     $nam = $this->_getParam('nam', date('Y', $date));
     $auth = Zend_Auth::getInstance();
     $identity = $auth->getIdentity();
     $em_id = $identity->em_id;
     $emModel = new Front_Model_Employees();
     $em_info = $emModel->fetchRow("em_id={$em_id}");
     $khenthuongModel = new Front_Model_KhenThuong();
     $khen_thuong = $khenthuongModel->fetchByDate($em_id, "{$nam}-{$thang}-01 00:00:00", "{$nam}-{$thang}-31 23:59:59");
     $kyluatModel = new Front_Model_KyLuat();
     $ky_luat = $kyluatModel->fetchByDate($em_id, "{$nam}-{$thang}-01 00:00:00", "{$nam}-{$thang}-31 23:59:59");
     $bangluongModel = new Front_Model_BangLuong();
     $bang_luong = $bangluongModel->fetchByDate($em_id, "{$nam}-{$thang}-01 00:00:00", "{$nam}-{$thang}-31 23:59:59");
     if (!$em_info || !$bang_luong) {
         $this->_helper->viewRenderer->setRender('loi');
     } else {
         $luong_toi_thieu = $bang_luong->bl_luong_toi_thieu;
         $giai_doan = $bang_luong->bl_giai_doan;
         $loai_luong = $bang_luong->bl_loai_luong;
         $luong_thu_viec = $bang_luong->bl_luong_thu_viec;
         $he_so_luong = $bang_luong->bl_hs_luong;
         $bhxh = $bang_luong->bl_bhxh;
         $bhyt = $bang_luong->bl_bhyt;
         $hs_pc_chuc_vu = $bang_luong->bl_hs_pc_cong_viec;
         $hs_pc_trach_nhiem = $bang_luong->bl_hs_pc_trach_nhiem;
         $hs_pc_khu_vuc = $bang_luong->bl_hs_pc_khu_vuc;
         $hs_pc_tnvk_phan_tram = $bang_luong->bl_hs_pc_tnvk;
         $tham_nien = $bang_luong->bl_tham_nien;
         $uu_dai_nghe = $bang_luong->bl_hs_pc_udn;
         $cong_vu = $bang_luong->bl_hs_pc_cong_vu;
         $kiem_nhiem = $bang_luong->bl_pc_kiem_nhiem;
         $hs_pc_khac = $bang_luong->bl_hs_pc_khac;
         $he_so_tang_them = $bang_luong->bl_pc_tang_them;
         $hs_pc_khac_type = $bang_luong->bl_pc_khac_type;
         $hs_pc_thu_hut_phan_tram = $bang_luong->bl_pc_thu_hut;
         $phan_loai = strtoupper($bang_luong->bl_phan_loai);
         $phan_loai_he_so = $bang_luong->bl_phan_loai_he_so;
         $luong_toi_thieu_sau_bh = (int) ($luong_toi_thieu * (100 - ($bhxh + $bhyt)) / 100);
         $luong_toi_thieu_bhyt = (int) ($luong_toi_thieu * (100 - $bhyt) / 100);
         $pc_trach_nhiem = $pc_cong_vu = $pc_khac = $pc_kiem_nhiem = $pc_uu_dai_nghe = $luong_toi_thieu;
         $pc_chuc_vu = $pc_tnvk = $pc_thu_hut = $pc_tham_nien = $luong_toi_thieu_sau_bh;
         $pc_khu_vuc = $luong_toi_thieu_bhyt;
         $thanh_tien_hsl = $luong_toi_thieu_sau_bh * $he_so_luong * $phan_loai_he_so;
         //if ($this->he_so->eh_giai_doan)
         //$hs_pc_chuc_vu = number_format ($this->he_so->eh_pc_cong_viec*(100-$luong_thu_viec)/100, 2);
         $thanh_tien_pc_chuc_vu = $hs_pc_chuc_vu * $pc_chuc_vu * $phan_loai_he_so;
         //if ($this->he_so->eh_giai_doan)
         //$hs_pc_trach_nhiem = number_format ($this->he_so->eh_pc_trach_nhiem*(100-$luong_thu_viec)/100, 2);
         $thanh_tien_pc_trach_nhiem = $hs_pc_trach_nhiem * $pc_trach_nhiem * $phan_loai_he_so;
         //if ($this->he_so->eh_giai_doan)
         //$hs_pc_khu_vuc = number_format ($this->he_so->eh_pc_kv*(100-$luong_thu_viec)/100, 2);
         $thanh_tien_pc_khu_vuc = $hs_pc_khu_vuc * $pc_khu_vuc * $phan_loai_he_so;
         $hs_pc_tnvk = ($he_so_luong + $hs_pc_chuc_vu) * $hs_pc_tnvk_phan_tram / 100;
         //if ($this->he_so->eh_giai_doan)
         //$hs_pc_tnvk = number_format ($hs_pc_tnvk*(100-$luong_thu_viec)/100, 2);
         $thanh_tien_pc_tham_nien_vuot_khung = $hs_pc_tnvk * $pc_tnvk * $phan_loai_he_so;
         $hs_pc_tham_nien = floor(($he_so_luong + $hs_pc_chuc_vu + $hs_pc_trach_nhiem) * $tham_nien / 100 * 100) / 100;
         $thanh_tien_pc_tham_nien = $hs_pc_tham_nien * $pc_tham_nien * $phan_loai_he_so;
         $hs_pc_thu_hut = floor(($he_so_luong + $hs_pc_chuc_vu + $hs_pc_tnvk) * $hs_pc_thu_hut_phan_tram / 100 * 100) / 100;
         $thanh_tien_pc_thu_hut = $hs_pc_thu_hut * $pc_thu_hut * $phan_loai_he_so;
         $hs_pc_uu_dai_nghe = floor(($he_so_luong + $hs_pc_chuc_vu + $hs_pc_tnvk) * $uu_dai_nghe / 100 * 100) / 100;
         $thanh_tien_pc_uu_dai_nghe = $hs_pc_uu_dai_nghe * $pc_uu_dai_nghe * $phan_loai_he_so;
         $hs_pc_cong_vu = floor(($he_so_luong + $hs_pc_chuc_vu + $hs_pc_tnvk) * $cong_vu / 100 * 100) / 100;
         $thanh_tien_pc_cong_vu = $hs_pc_cong_vu * $pc_cong_vu * $phan_loai_he_so;
         $hs_pc_kiem_nhiem = floor(($he_so_luong + $hs_pc_chuc_vu + $hs_pc_tnvk) * $kiem_nhiem / 100 * 100) / 100;
         $thanh_tien_pc_kiem_nhiem = $hs_pc_kiem_nhiem * $pc_kiem_nhiem * $phan_loai_he_so;
         $thanh_tien_pc_khac = $hs_pc_khac * $pc_khac;
         $hs_pc_khac_he_so = $hs_pc_khac;
         if ($hs_pc_khac_type) {
             $thanh_tien_pc_khac = $thanh_tien_pc_khac / 100;
             $hs_pc_khac_he_so = $hs_pc_khac / 100;
         }
         $thanh_tien_pc_khac = $thanh_tien_pc_khac * $phan_loai_he_so;
         $tong_1 = (int) ($thanh_tien_pc_thu_hut + $thanh_tien_hsl + $thanh_tien_pc_chuc_vu + $thanh_tien_pc_trach_nhiem + $thanh_tien_pc_khu_vuc + $thanh_tien_pc_tham_nien_vuot_khung + $thanh_tien_pc_tham_nien + $thanh_tien_pc_uu_dai_nghe + $thanh_tien_pc_cong_vu + $thanh_tien_pc_kiem_nhiem);
         $hs_tang_them = $hs_pc_thu_hut + $he_so_luong + $hs_pc_chuc_vu + $hs_pc_trach_nhiem + $hs_pc_khu_vuc + $hs_pc_tnvk + $hs_pc_tham_nien + $hs_pc_uu_dai_nghe + $hs_pc_cong_vu + $hs_pc_kiem_nhiem + $hs_pc_khac_he_so;
         $ti_le_tang_them = ($hs_tang_them - $hs_pc_kiem_nhiem) * $luong_toi_thieu * $he_so_tang_them * $phan_loai_he_so;
         $tong_2 = (int) $tong_1 + $ti_le_tang_them;
         $tong_khen_thuong = 0;
         if (sizeof($khen_thuong)) {
             foreach ($khen_thuong as $kt) {
                 $tong_khen_thuong += $kt->kt_money;
             }
         }
         $tong_khien_trach = 0;
         if (sizeof($ky_luat)) {
             foreach ($ky_luat as $kl) {
                 $tong_khien_trach += $kl->kl_money;
             }
         }
         $tong_cong = $tong_2 + $tong_khen_thuong - $tong_khien_trach;
         //$mpdf = new mPDF();
         $khen_thuong_text_out = '
             <tr>
                 <td colspan="3" class="tieu-de">Khen thưởng</td>
             </tr>
             <tr>
                 <td colspan="3">
                     <br/>
                     <table border="1" width="100%" class="noi-dung" cellpadding="5" nobr="true">
                         <tr>
                             <td style="width: 36pt;"><strong>#</strong></td>
                             <td><strong>Ngày</strong></td>
                             <td style="width: 235pt;"><strong>Lý do</strong></td>
                             <td style="width: 100pt;"><strong>Mức thưởng</strong></td>
                         </tr>';
         if (sizeof($khen_thuong)) {
             $i = 0;
             foreach ($khen_thuong as $kt) {
                 $i++;
                 $khen_thuong_text_out .= '<tr>
                                     <td>' . $i . '</td>
                                     <td>' . date('d-m-Y', strtotime($kt->kt_date)) . '</td>
                                     <td>' . $kt->kt_ly_do . '</td>
                                     <td>' . number_format($kt->kt_money, 0, '.', ',') . '</td>
                                 </tr>';
             }
         } else {
             $khen_thuong_text_out .= '<tr><td colspan="4">Không có khen thưởng nào!</td></tr>';
         }
         $khen_thuong_text_out .= '
                         <tr>
                             <td colspan="3"><strong>Tổng cộng (III)</strong></td>
                             <td><strong>' . number_format($tong_khen_thuong, 0, '.', ',') . '</strong></td>
                         </tr>
                     </table>
                 </td>
             </tr>';
         $ky_luat_text_out = '
             <tr>
                 <td colspan="3" class="tieu-de">Kỷ luật/Khiển trách</td>
             </tr>
             <tr>
                 <td colspan="3">
                     <br/>
                     <table border="1" width="100%" class="noi-dung" cellpadding="5" nobr="true">
                         <tr>
                             <td style="width: 36pt;"><strong>#</strong></td>
                             <td><strong>Ngày</strong></td>
                             <td style="width: 235pt;"><strong>Lý do</strong></td>
                             <td style="width: 100pt;"><strong>Mức phạt</strong></td>
                         </tr>';
         if (sizeof($ky_luat)) {
             $i = 0;
             foreach ($ky_luat as $kl) {
                 $i++;
                 $ky_luat_text_out .= '<tr>
                                     <td>' . $i . '</td>
                                     <td>' . date('d-m-Y', strtotime($kl->kl_date)) . '</td>
                                     <td>' . $kl->kl_ly_do . '</td>
                                     <td>' . number_format($kl->kl_money, 0, '.', ',') . '</td>
                                 </tr>';
             }
         } else {
             $ky_luat_text_out .= '<tr><td colspan="4">Không có kỷ luật/khiển trách nào nào!</td></tr>';
         }
         $ky_luat_text_out .= '
                         <tr>
                             <td colspan="3"><strong>Tổng cộng (IV)</strong></td>
                             <td><strong>' . number_format($tong_khien_trach, 0, '.', ',') . '</strong></td>
                         </tr>
                     </table>
                 </td>
             </tr>';
         $text_outout = '
             <style>
                 .ten-co-quan {
                     color: #000;
                     font-size: 10pt;
                     height: 50px;
                     text-align:center;
                 }
                 .ten-bang-luong{
                     height: 30px;
                     text-align:center;
                     font-size: 10pt;
                 }
                 
                 table.first {
                     color: #003300;
                     font-family: helvetica;
                     font-size: 8pt;
                     border-left: 3px solid red;
                     border-right: 3px solid #FF00FF;
                     border-top: 3px solid green;
                     border-bottom: 3px solid blue;
                     background-color: #ccffcc;
                 }
                 .borders {
                     border: 1px solid #000;
                     font-size: 10px;
                 }
                 
                 .tieu-de{
                     height: 20px;
                     font-size: 11px;
                 }
                 .noi-dung{
                     font-size: 10px;
                 }
                 td.second {
                     border: 2px dashed green;
                 }
                 
                 .lowercase {
                     text-transform: lowercase;
                 }
                 .uppercase {
                     text-transform: uppercase;
                 }
                 .capitalize {
                     text-transform: capitalize;
                 }
             </style>
             <table width="100%">
                 <tr>
                     <td width="200" class="ten-co-quan uppercase">
                         TỔNG CỤC HẢI QUAN
                         <div><strong>CỤC HẢI QUAN HÀ TĨNH</strong></div>
                     </td>
                     <td colspan="2">&nbsp;</td>
                 </tr>
                 <tr>
                     <td colspan="3" class="ten-bang-luong uppercase">BẢNG LƯƠNG THÁNG ' . $thang . '-' . $nam . '</td>
                 </tr>
                 <tr>
                     <td colspan="3" class="tieu-de">Thông tin cá nhân</td>
                 </tr>
                 <tr>
                     <td colspan="3">
                         <br/>
                         <table border="1" class="noi-dung" cellpadding="5" nobr="true">
                             <tr>
                                 <td style="width: 120pt;"><strong>Họ tên</strong></td>
                                 <td style="width: 80pt;"><strong>Giới tính</strong></td>
                                 <td style="width: 100pt;"><strong>Ngày sinh</strong></td>
                                 <td style="width: 100pt;"><strong>Phòng ban</strong></td>
                                 <td style="width: 96pt;"><strong>Chức vụ</strong></td>
                             </tr>
                             <tr>
                                 <td>' . $em_info->em_ho . ' ' . $em_info->em_ten . '</td>
                                 <td>' . ($em_info->em_gioi_tinh ? 'Nam' : 'Nữ') . '</td>
                                 <td>' . date('d-m-Y', strtotime($em_info->em_ngay_sinh)) . '</td>
                                 <td>' . $this->view->viewGetPhongBanName($em_info->em_phong_ban) . '</td>
                                 <td>' . $this->view->viewGetChucVuName($em_info->em_chuc_vu) . '</td>
                             </tr>
                         </table>
                     </td>
                 </tr>
                 <tr>
                     <td colspan="3" class="tieu-de"></td>
                 </tr>
                 <tr>
                     <td colspan="3" class="tieu-de">Thông số lương cơ bản</td>
                 </tr>
                 <tr>
                     <td colspan="3">
                         <br />
                         <table border="1" width="575pt" class="noi-dung" cellpadding="5" nobr="true">
                             <tr>
                                 <td><strong>Lương cơ bản</strong></td>
                                 ' . ($giai_doan ? '<td><strong>Thử việc</strong></td>  ' : '') . '
                                 <td style="width: 70pt;"><strong>BHXH</strong></td>
                                 <td style="width: 70pt;"><strong>BHYT</strong></td>
                                 <td style="width: 210pt;"><strong>Đã trừ BHXH+BHYT</strong></td>
                             </tr>
                             <tr>
                                 <td>' . number_format($luong_toi_thieu, 0, '.', ',') . '</td>
                                 ' . ($giai_doan ? '<td>' . $luong_thu_viec . '%</td>  ' : '') . '
                                 <td>' . $bhxh . '%</td>
                                 <td>' . $bhyt . '%</td>
                                 <td>
                                     Đã trừ BHYT + BHXH: ' . number_format($luong_toi_thieu_sau_bh, 0, '.', ',') . ' <br>
                                     Đã trừ BHYT: ' . number_format($luong_toi_thieu_bhyt, 0, '.', ',') . '
                                 </td>
                             </tr>
                         </table>
                     </td>
                 </tr>
                 <tr>
                     <td colspan="3" class="tieu-de"></td>
                 </tr>
                 <tr>
                     <td colspan="3" class="tieu-de">Bảng lương</td>
                 </tr>
                 <tr>
                     <td colspan="3">
                         <br/>
                         <table border="1" width="100%" class="noi-dung" cellpadding="5" nobr="true">
                             <tr>
                                 <td style="width: 150pt;"><strong>Tên</strong></td>
                                 <td style="width: 245pt;" colspan="2"><strong>Hệ số</strong></td>
                                 <td style="width: 100pt;"><strong>Thành tiền</strong></td>
                             </tr>
                             <tr>
                                 <td>Kết quả phân loại tháng</td>
                                 <td> ' . $phan_loai . ' </td>
                                 <td> ' . $phan_loai_he_so . '</td>
                                 <td></td>
                             </tr>  
                             <tr>
                                 <td>Hệ số lương</td>
                                 <td colspan="2">' . $he_so_luong . '</td>
                                 <td>' . number_format($thanh_tien_hsl, 0, '.', ',') . '</td>
                             </tr>
                             <tr>
                                 <td>PC chức vụ</td>
                                 <td colspan="2">' . $hs_pc_chuc_vu . '</td>
                                 <td>' . number_format($thanh_tien_pc_cong_viec, 0, '.', ',') . '</td>
                             </tr>
                             <tr>
                                 <td>PC trách nhiệm</td>
                                 <td colspan="2">' . $hs_pc_trach_nhiem . '</td>
                                 <td>' . number_format($thanh_tien_pc_trach_nhiem, 0, '.', ',') . '</td>
                             </tr>
                             <tr>
                                 <td>PC khu vực</td>
                                 <td colspan="2">' . $hs_pc_khu_vuc . '</td>
                                 <td>' . number_format($thanh_tien_pc_khu_vuc, 0, '.', ',') . '</td>
                             </tr>
                             <tr>
                                 <td>PC thu hút</td>
                                 <td>' . $hs_pc_thu_hut_phan_tram . '%</td>
                                 <td>' . $hs_pc_thu_hut . '</td>
                                 <td>' . number_format($thanh_tien_pc_thu_hut, 0, '.', ',') . '</td>
                             </tr>
                             <tr>
                                 <td>PC thâm niên vượt khung</td>
                                 <td>' . $hs_pc_tnvk_phan_tram . '%</td>
                                 <td>' . $hs_pc_tnvk . '</td>
                                 <td>' . number_format($thanh_tien_pc_tham_nien_vuot_khung, 0, '.', ',') . '</td>
                             </tr>
                             <tr>
                                 <td>PC thâm niên</td>
                                 <td>' . $tham_nien . ' Năm</td>
                                 <td>' . $hs_pc_tham_nien . '</td>
                                 <td>' . number_format($thanh_tien_pc_tham_nien, 0, '.', ',') . '</td>
                             </tr>
                             <tr>
                                 <td>PC ưu đãi nghề</td>
                                 <td>' . $uu_dai_nghe . '%</td>
                                 <td>' . $hs_pc_uu_dai_nghe . '</td>
                                 <td>' . number_format($thanh_tien_pc_uu_dai_nghe, 0, '.', ',') . '</td>
                             </tr>
                             <tr>
                                 <td>PC công vụ</td>
                                 <td>' . $cong_vu . '%</td>
                                 <td>' . $hs_pc_cong_vu . '</td>
                                 <td>' . number_format($thanh_tien_pc_cong_vu, 0, '.', ',') . '</td>
                             </tr>
                             <tr>
                                 <td>PC kiêm nhiệm</td>
                                 <td colspan="2">' . $hs_pc_kiem_nhiem . '</td>
                                 <td>' . number_format($thanh_tien_pc_kiem_nhiem, 0, '.', ',') . '</td>
                             </tr>
                             <tr>
                                 <td>PC khác</td>
                                 <td colspan="2">' . $hs_pc_khac . ($hs_pc_khac_type ? '%' : '') . '</td>
                                 <td>' . number_format($thanh_tien_pc_khac, 0, '.', ',') . '</td>
                             </tr>
                             <tr>
                                 <td colspan="3">Tổng cộng (I)</td>
                                 <td>' . number_format($tong_1, 0, '.', ',') . '</td>
                             </tr>
                             <tr>
                                 <td>Tỷ lệ tăng thêm</td>
                                 <td colspan="2">' . $hs_tang_them . '</td>
                                 <td>' . number_format($ti_le_tang_them, 0, '.', ',') . '</td>
                             </tr>
                             <tr>
                                 <td colspan="3"><strong>Tổng cộng (II)</strong></td>
                                 <td><strong>' . number_format($tong_2, 0, '.', ',') . '</strong></td>
                             </tr>
                         </table>                            
                     </td>
                 </tr>
                 <tr>
                     <td colspan="3" class="tieu-de"></td>
                 </tr>  
                 ' . $khen_thuong_text_out . '
                 <tr>
                     <td colspan="3" class="tieu-de"></td>
                 </tr> 
                 ' . $ky_luat_text_out . '
                 <tr>
                     <td colspan="3" class="tieu-de"></td>
                 </tr> 
                 <tr>
                     <td colspan="3">
                         <br/>
                         <table border="1" width="100%" class="noi-dung" cellpadding="5" nobr="true">
                             <tr>
                                 <td style="width: 395pt;"><strong>Tổng được nhận = II + III + IV</strong></td>
                                 <td style="width: 100pt;"><strong>' . number_format($tong_cong, 0, '.', ',') . '</strong></td>
                             </tr>
                         </table>
                     </td>
                 </tr>
             </table> 
           ';
         /*
          $mpdf->WriteHTML($text_outout);
          $file_name = $this->loc_tieng_viet($em_info->em_ho) . '_' . $this->loc_tieng_viet($em_info->em_ten) . '_' . $thang . '-' . $nam . '.pdf';
          $mpdf->Output($file_name, 'D');
         */
         $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
         $pdf->SetCreator(PDF_CREATOR);
         $pdf->SetAuthor(PDF_AUTHOR);
         $pdf->SetTitle(PDF_HEADER_TITLE);
         $pdf->SetSubject(PDF_HEADER_TITLE);
         $pdf->SetKeywords('bang luong');
         $pdf->setPrintHeader(false);
         $pdf->setFooterData(array(0, 64, 0), array(0, 64, 128));
         $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
         $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);
         $pdf->setFontSubsetting(true);
         $pdf->SetFont('dejavusans', '', 14, '', true);
         $pdf->AddPage();
         $pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.2, 'depth_h' => 0.2, 'color' => array(196, 196, 196), 'opacity' => 1, 'blend_mode' => 'Normal'));
         $file_name = $this->loc_tieng_viet($em_info->em_ho) . '_' . $this->loc_tieng_viet($em_info->em_ten) . '_' . $thang . '-' . $nam . '.pdf';
         $pdf->writeHTMLCell(0, 0, '', '', $text_outout, 0, 1, 0, true, '', true);
         // ---------------------------------------------------------
         // Close and output PDF document
         // This method has several options, check the source code documentation for more information.
         $pdf->Output($file_name, 'I');
         die;
     }
 }
Example #9
0
    public function create_pdf()
    {
        /**
         * Creates an example PDF TEST document using TCPDF
         * @package com.tecnick.tcpdf
         * @abstract TCPDF - Example: Default Header and Footer
         * @author Nicola Asuni
         * @since 2008-03-04
         */
        // 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('Guadalajara');
        $pdf->SetTitle('Formato Guadalajara');
        $pdf->SetSubject('Formatos Espacios Abiertos');
        $pdf->SetKeywords('Guadalajara, centro_historico');
        // set default header data
        $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, '', '', array(91, 104, 113), array(91, 104, 113));
        $pdf->setFooterData(array(91, 104, 113), array(91, 104, 113));
        // 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 default font subsetting mode
        $pdf->setFontSubsetting(true);
        // Set font
        // dejavusans is a UTF-8 Unicode font, if you only need to
        // print standard ASCII chars, you can use core fonts like
        // helvetica or times to reduce file size.
        $pdf->SetFont('times', '', 14, '', true);
        // INICIA FORMATO DE DECLARACIÓN PERSONA FÍSICA
        $pdf->AddPage();
        $pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.2, 'depth_h' => 0.2, 'color' => array(196, 196, 196), 'opacity' => 1, 'blend_mode' => 'Normal'));
        $html = <<<EOD
    <br>
    <h1>titulo</h1>
    <p style="text-align: right;">texto</p>
    <br>
    <br>

EOD;
        $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
        // TERMINA FORMATO DE DECLARACIÓN PERSONA FÍSICA
        // ---------------------------------------------------------
        // Close and output PDF document
        // This method has several options, check the source code documentation for more information.
        $pdf->Output('formatos_guadalajara.pdf', 'I');
        //============================================================+
        // END OF FILE
        //============================================================+
    }
Example #10
0
 public function actionPDF()
 {
     $session = new CHttpSession();
     $session->open();
     if (isset($session['orderVariations']) && is_array($session['orderVariations']) && count($session['orderVariations']) > 0) {
         require_once Yii::getPathOfAlias('webroot.protected.extensions.pdf.tcpdf') . DIRECTORY_SEPARATOR . 'tcpdf.php';
         $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
         $aOrderVariations = $session['orderVariations'];
         $html_output = '<!DOCTYPE HTML><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body><table>';
         $html_output .= '<tr><td colspan="3"></td></tr>';
         $html_output .= '<tr><td colspan="3">' . Yii::t('strings', 'Order products:') . "</td></tr>";
         $html_output .= '<tr><td colspan="3"></td></tr>';
         foreach ($aOrderVariations as $variation_id) {
             $Product2variation = Product2variation::model()->find('variation_id=' . $variation_id);
             if (isset($Product2variation)) {
                 $product = ProductDescription::model()->find('product_id=' . $Product2variation['product_id'] . ' AND language_id=' . $this->language_id);
                 $Variation = Variation::model()->find('variation_id=' . $variation_id);
                 $VariationDescription = VariationDescription::model()->find('variation_id=' . $variation_id . ' AND language_id=' . $this->language_id);
                 $html_output .= '<tr><td colspan="3">' . $product['product_name'] . '</td></tr>';
                 $html_output .= '<tr><td><img src="' . Yii::app()->request->getBaseUrl(true) . '/uploads/images/' . $Variation['variation_image'] . '" alt="product_image" width="100" height="50"/></td>';
                 $html_output .= '<td>' . $VariationDescription['variation_name'] . '<br/>' . $VariationDescription['variation_description'] . "</td></tr>";
                 $html_output .= '<tr><td colspan="3"></td><td></td></tr>';
             }
         }
         $html_output .= '</table></body></html>';
         $pdf->SetHeaderData(PDF_HEADER_LOGO, '', '', '', array(0, 64, 255), array(169, 172, 182));
         $pdf->setFooterData($tc = array(0, 64, 0), $lc = array(0, 64, 128));
         $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);
         $pdf->setLanguageArray($l);
         $pdf->setFontSubsetting(true);
         $pdf->SetFont('dejavusans', '', 14, '', true);
         $pdf->AddPage();
         $pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.2, 'depth_h' => 0.2, 'color' => array(196, 196, 196), 'opacity' => 1, 'blend_mode' => 'Normal'));
         $pdf->writeHTMLCell($w = 0, $h = 0, $x = '', $y = '', $html_output, $border = 0, $ln = 1, $fill = 0, $reseth = true, $align = 'L', $autopadding = true);
         $pdf->Output('order.pdf', 'I');
     }
 }
    /** Creates a PDF for the Message
     *
     */
    private function createPdf($user, $uid)
    {
        require_once PATH_INCLUDE . '/pdf/tcpdf/config/lang/ger.php';
        require_once PATH_INCLUDE . '/pdf/tcpdf/tcpdf.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('LeG Uelzen');
        $pdf->SetKeywords('');
        // set default header data
        $pdf->SetHeaderData('../../../res/images/logo.jpg', 15, 'LeG Uelzen', "Abmeldung von: " . $user['forename'] . " " . $user['name'] . " (geb. am " . $user['birthday'] . ")\nKlasse: " . $user['class'], array(0, 0, 0), array(0, 0, 0));
        $pdf->setFooterData($tc = array(0, 0, 0), $lc = array(0, 0, 0));
        // 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
        $pdf->setLanguageArray($l);
        // ---------------------------------------------------------
        // set default font subsetting mode
        $pdf->setFontSubsetting(true);
        // Set font
        // dejavusans is a UTF-8 Unicode font, if you only need to
        // print standard ASCII chars, you can use core fonts like
        // helvetica or times to reduce file size.
        $pdf->SetFont('helvetica', '', 11, '', true);
        // Add a page
        // This method has several options, check the source code documentation for more information.
        $pdf->AddPage();
        // set text shadow effect
        $pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.2, 'depth_h' => 0.2, 'color' => array(196, 196, 196), 'opacity' => 1, 'blend_mode' => 'Normal'));
        // Set some content to print
        $html = '<p align="center"><h2>R&uuml;ckgabe der LeG-Card / L&ouml;schung der Benutzerdaten</h2></p><br>' . 'Hiermit wird best&auml;tigt, dass die Schulb&uuml;cher von ' . $user['forename'] . ' ' . $user['name'] . ' vollst&auml;ndig zur&uuml;ckgegeben wurden. <br/>
Hiermit wird best&auml;tigt, dass s&auml;mtliche personenbezogenen Daten am ' . date("d.m.Y") . ' aus dem System gel&ouml;scht wurden.<br/>';
        if ($user['credit'] == "0.00") {
            $html .= 'Es liegt kein Restguthaben vor.<br/>';
        } else {
            $html .= 'Es liegt ein Restguthaben in H&ouml;he von ' . $user['credit'] . ' &euro; vor. Dieses muss beim Caterer abgeholt werden.<br/>';
        }
        $html .= 'Mit der R&uuml;ckgabe der LeG-Card kann das Pfandgeld in H&ouml;he von 3,50 &euro; zzgl. 0,50 &euro;, je nach Zustand der H&uuml;lle, ausbezahlt werden.<br/>
Dieses Schreiben wurde maschinell erstellt und ist ohne Unterschrift g&uuml;ltig.
				<hr>
<p align="center"><h3>Auszahlung des Restguthabens</h3></p><br>
Restguthaben in H&ouml;he von ' . $user['credit'] . ' &euro; am ___.___.2013 ausgezahlt.<br><br>
<br>						Unterschrift Caterer
		<br>
		<hr>
<p align="center"><h3>Abschnitt f&uuml;r den Caterer</h3></p><br>
 Restguthaben in H&ouml;he von ' . $user['credit'] . ' &euro; am ___.___.2013 erhalten.<br><br>
		<br><br>Unterschrift ' . $user['forename'] . ' ' . $user['name'] . ' (geb. am ' . $user['birthday'] . ')
		<hr>
<p align="center"><h3>Pfanderstattung</h3></p><br>
Bitte geben Sie diesen Abschnitt im Gnissel-B&uuml;ro im Lessing-Gymnasium ab.<br>
Bitte kreuzen Sie an, ob Sie den Pfandbetrag an die Sch&uuml;lergenossenschaft Gnissel des LeG Uelzen spenden m&ouml;chten
		oder eine &Uuml;berweisung auf ein Bankkonto w&uuml;nschen.<br>

[&nbsp;&nbsp;] Das Pfandgeld m&ouml;chte ich an Gnissel spenden<br>
[&nbsp;&nbsp;] Ich m&ouml;chte das Pfandgeld auf folgendes Konto &uuml;berwiesen haben:<br>
Kontoinhaber:   <br>
Kontonummer:<br>
BLZ:		<br>
Kreditinstitut: <br><br>

Uelzen, den ___.___.2013
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Unterschrift ' . $user['forename'] . ' ' . $user['name'] . ' (geb. am ' . $user['birthday'] . ')<br>



		';
        // Print text using writeHTMLCell()
        $pdf->writeHTMLCell($w = 0, $h = 0, $x = '', $y = '', $html, $border = 0, $ln = 1, $fill = 0, $reseth = true, $align = '', $autopadding = true);
        // ---------------------------------------------------------
        if (!is_dir('../include/pdf/tempPdf')) {
            mkdir('../include/pdf/tempPdf');
        }
        // Close and output PDF document
        // This method has several options, check the source code documentation for more information.
        $pdf->Output('../include/pdf/tempPdf/deleted_' . $uid . '.pdf', 'F');
        return true;
    }
Example #12
0
    function print_pdf($title, $html_content, $lp, $fsize)
    {
        global $root;
        ob_clean();
        $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
        $usr = $root->query("SELECT `Emri`,`Mbiemri` FROM administrata WHERE User = '******'username'] . "'");
        $pdf->SetCreator(PDF_CREATOR);
        $pdf->SetAuthor($usr[0]['Emri'] . " " . $usr[0]['Mbiemri']);
        $pdf->SetTitle($title);
        $pdf->SetSubject($title);
        $pdf->SetKeywords($title);
        // set default header data
        $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 001', PDF_HEADER_STRING, array(0, 64, 255), array(0, 64, 128));
        $pdf->setFooterData(array(0, 64, 0), array(0, 64, 128));
        // 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 default font subsetting mode
        $pdf->setFontSubsetting(true);
        // Set font
        // dejavusans is a UTF-8 Unicode font, if you only need to
        // print standard ASCII chars, you can use core fonts like
        // helvetica or times to reduce file size.
        $pdf->SetFont('helvetica', '', $fsize, '', true);
        // Add a page
        // This method has several options, check the source code documentation for more information.
        $pdf->AddPage($lp, 'A4');
        // set text shadow effect
        $pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.2, 'depth_h' => 0.2, 'color' => array(196, 196, 196), 'opacity' => 1, 'blend_mode' => 'Normal'));
        // Set some content to print
        $html = <<<EOD
        {$html_content}
EOD;
        // Print text using writeHTMLCell()
        $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
        // ---------------------------------------------------------
        // Close and output PDF document
        // This method has several options, check the source code documentation for more information.
        $pdf->Output('example_001.pdf', 'I');
        ob_end_clean();
        //============================================================+
        // END OF FILE
        //============================================================+
    }
Example #13
0
/**
 * 设置PDF文件
 */
function pdf_four()
{
    //包含类文件
    require_once 'tcpdf.php';
    //创建TCPDF对象
    //PDF_PAGE_ORIENTATION: 页面方向横向P纵向L,默认P
    //PDF_UNIT: 档的最小度量单位,点pt/毫米mm/厘米cm/英寸in。(默认为mm)
    //PDF_PAGE_FORMAT: 设置 PDF 页面格式,默认为 A4 纸
    //True:是否为唯一编码格式,true 为是
    //编码格式
    //最后一个参数是:确定是否需要磁盘高速缓存,默认为否
    //false=PDF/X true=PDF/A
    $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false, false);
    //设置文档信息
    $pdf->SetCreator('*****@*****.**');
    $pdf->SetAuthor('Leju');
    $pdf->SetTitle('标题TCPDF');
    $pdf->SetSubject('这是一个生成PDF文件简单的例子');
    $pdf->SetKeywords('TCPDF, PDF, example, 测试, guide');
    //设置页眉和页脚数据
    //204,255,51 绿色
    //255,51,102 红色
    $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, 'TCPDF header info111', 'www.leju.com', array(0, 64, 255), array(0, 64, 128));
    $pdf->setFooterData(array(0, 64, 0), array(0, 64, 128));
    //设置页眉和页脚字体
    $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
    $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
    //设置间距
    //PDF_MARGIN_LEFT 左边距
    //PDF_MARGIN_TOP 顶部距离
    //PDF_MARGIN_RIGHT 右边距
    $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->setFontSubsetting(true);
    //设置字体
    //dejavusans 是 UTF-8 编码字体, 如果你需要输出标准的ASCII字符,你可以使用
    //helvetica 或者 times 减小文件的体积.
    $pdf->SetFont('dejavusans', '', 14, '', true);
    //添加页面
    $pdf->AddPage();
    //设置文字阴影效果
    $pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.8, 'depth_h' => 0.2, 'color' => array(196, 196, 196), 'opacity' => 1, 'blend_mode' => 'Normal'));
    //内容部分
    $html = '
	<h1> Welcome to <a href="http://www.tcpdf.org" style="text-decoration:none;background-color:#CC0000;color:black;">&nbsp;<span style="color:black;">TC</span><span style="color:white;">PDF</span>&nbsp;</a>!</h1>
	<i>This is the first example of TCPDF library.</i>
	<p>This text is printed using the <i>writeHTMLCell()</i> method but you can also use: <i>Multicell(), writeHTML(), Write(), Cell() and Text()</i>.</p>
	<p>Please check the source code documentation and other examples for further information.</p>
	<p style="color:#CC0000;">TO IMPROVE AND EXPAND TCPDF I NEED YOUR SUPPORT, PLEASE <a href="http://sourceforge.net/donate/index.php?group_id=128076">MAKE A DONATION!</a></p>';
    //生成内容
    $pdf->writeHTML($html);
    //输出内容
    $pdf->Output('example.pdf', 'I');
}
 public function ConstructFlightEventsList($extFlightId, $sections = [], $colored = false)
 {
     $flightId = $extFlightId;
     $user = $this->_user->username;
     $Fl = new Flight();
     $flightInfo = $Fl->GetFlightInfo($flightId);
     $bruType = $flightInfo['bruType'];
     unset($Fl);
     $Bru = new Bru();
     $bruInfo = $Bru->GetBruInfo($bruType);
     $flightApHeaders = $Bru->GetBruApHeaders($bruType);
     $flightBpHeaders = $Bru->GetBruBpHeaders($bruType);
     $prefixArr = $Bru->GetBruApCycloPrefixes($bruType);
     unset($Bru);
     $Frame = new Frame();
     $framesCount = $Frame->GetFramesCount($flightInfo['apTableName'], $prefixArr[0]);
     //giving just some prefix
     unset($Frame);
     // create new PDF document
     $pdf = new TCPDF('L', 'mm', 'A4', true, 'UTF-8', false);
     // set document information
     $pdf->SetCreator($user);
     $pdf->SetAuthor($user);
     $pdf->SetTitle('Flight events list');
     $pdf->SetSubject('Flight events list');
     // $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
     $bort = $flightInfo['bort'];
     $voyage = $flightInfo['voyage'];
     $copyDate = date('H:i:s d-m-Y', $flightInfo['startCopyTime']);
     $Fr = new Frame();
     $flightDuration = $Fr->FrameCountToDuration($framesCount, $bruInfo['stepLength']);
     unset($Fr);
     $usrInfo = $this->_user->userInfo;
     $headerStr = $usrInfo['company'];
     $imageFile = '';
     if ($colored && $usrInfo['logo'] != '') {
         $imageFile = SITE_ROOT_DIR . '/fileUploader/files/' . uniqid() . '.png';
         file_put_contents($imageFile, $usrInfo['logo']);
         $img = file_get_contents($imageFile);
         $pdf->SetHeaderData('$' . $img, "20", $headerStr, "", [0, 10, 50], [0, 10, 50]);
     } else {
         // set default header data
         $pdf->SetHeaderData("", "", $headerStr, "", [0, 10, 50], [0, 10, 50]);
     }
     $pdf->setFooterData([0, 10, 50], [0, 10, 50]);
     // set header and footer fonts
     $pdf->setHeaderFont(array('dejavusans', '', 11));
     $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 default font subsetting mode
     $pdf->setFontSubsetting(true);
     // Set font
     // dejavusans is a UTF-8 Unicode font, if you only need to
     // print standard ASCII chars, you can use core fonts like
     // helvetica or times to reduce file size.
     $pdf->SetFont('dejavusans', '', 12, '', true);
     // Add a page
     // This method has several options, check the source code documentation for more information.
     $pdf->AddPage();
     if ($imageFile !== '') {
         unlink($imageFile);
     }
     // set text shadow effect
     $pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.2, 'depth_h' => 0.2, 'color' => [196, 196, 196], 'opacity' => 1, 'blend_mode' => 'Normal'));
     // Pasport
     $strStyle = "text-align:center; font-size: xx-large; font-weight: bold; color: rgb(0, 10, 64);";
     $str = '<p style="' . $strStyle . '">' . $this->lang->pasport . '</p>';
     $pdf->writeHTML($str, true, false, false, false, '');
     // Pasport info
     $strStyle = "text-align:center;";
     $str = '<p style="' . $strStyle . '">' . $this->lang->bruType . ' - ' . $bruInfo['bruType'] . '. <br>' . $this->lang->bort . ' - ' . $flightInfo['bort'] . '; ' . $this->lang->voyage . ' - ' . $flightInfo['voyage'] . '; ' . $this->lang->route . ' : ' . ($new_string = preg_replace('/[^a-zA-z0-9]/', '', $flightInfo['departureAirport']) . ' - ' . preg_replace('/[^a-zA-z1-9]/', '', $flightInfo['arrivalAirport']) . '. <br>' . $this->lang->flightDate . ' - ' . date('H:i:s d-m-Y', $flightInfo['startCopyTime']) . '; ' . $this->lang->duration . ' - ' . $flightDuration . '. <br>');
     $fileName = date('Y-m-d_H.i.s', $flightInfo['startCopyTime']) . '_' . $flightInfo['bort'] . '_' . $flightInfo['voyage'] . '_' . $bruInfo['bruType'];
     if (strpos($bruInfo['aditionalInfo'], ";") >= 0) {
         $counterNeedBrake = false;
         $aditionalInfoArr = explode(";", $flightInfo['flightAditionalInfo']);
         foreach ($aditionalInfoArr as $aditionalInfo) {
             if ($aditionalInfo != "") {
                 $nameVal = explode(":", $aditionalInfo);
                 if (count($nameVal) > 1) {
                     $name = $nameVal[0];
                     $val = $nameVal[1];
                     if ($counterNeedBrake) {
                         $str .= (isset($this->lang->{$name}) ? $this->lang->{$name} : $name) . " - " . $val . "; </br>";
                         $counterNeedBrake = !$counterNeedBrake;
                     } else {
                         $str .= (isset($this->lang->{$name}) ? $this->lang->{$name} : $name) . " - " . $val . "; ";
                         $counterNeedBrake = !$counterNeedBrake;
                     }
                 }
             }
         }
     }
     $str .= "</p>";
     $pdf->writeHTML($str, true, false, false, false, '');
     if ($flightInfo['exTableName'] != "") {
         $FEx = new FlightException();
         $excEventsList = $FEx->GetFlightEventsList($flightInfo['exTableName']);
         $Frame = new Frame();
         // change frame num to time
         for ($i = 0; $i < count($excEventsList); $i++) {
             $event = $excEventsList[$i];
             $excEventsList[$i]['start'] = date("H:i:s", $excEventsList[$i]['startTime'] / 1000);
             $reliability = "checked";
             // converting false alarm to reliability
             if ($excEventsList[$i]['falseAlarm'] == 0) {
                 $reliability = true;
             } else {
                 $reliability = false;
             }
             $excEventsList[$i]['reliability'] = $reliability;
             $excEventsList[$i]['end'] = date("H:i:s", $excEventsList[$i]['endTime'] / 1000);
             $excEventsList[$i]['duration'] = $Frame->TimeStampToDuration($excEventsList[$i]['endTime'] - $excEventsList[$i]['startTime']);
         }
         unset($Frame);
         // if isset events
         if (!empty($excEventsList)) {
             $pdf->SetFont('dejavusans', '', 9, '', true);
             $strStyle = 'style="text-align:center; font-weight: bold; background-color:#708090; color:#FFF"';
             $str = '<p><table border="1" cellpadding="1" cellspacing="1">' . '<tr ' . $strStyle . '><td width="70"> ' . $this->lang->start . '</td>' . '<td width="70">' . $this->lang->end . '</td>' . '<td width="70">' . $this->lang->duration . '</td>' . '<td width="70">' . $this->lang->code . '</td>' . '<td width="260">' . $this->lang->eventName . '</td>' . '<td width="110">' . $this->lang->algText . '</td>' . '<td width="180">' . $this->lang->aditionalInfo . '</td>' . '<td width="110">' . $this->lang->comment . '</td></tr>';
             for ($i = 0; $i < count($excEventsList); $i++) {
                 $event = $excEventsList[$i];
                 $excInfo = $FEx->GetExcInfo($bruInfo['excListTableName'], $event['refParam'], $event['code']);
                 $codePrefix = substr($event['code'], 0, 3);
                 if ($event['reliability'] && (in_array($codePrefix, $sections) || !preg_match('/00[0-9]/', $codePrefix) && in_array('other', $sections))) {
                     if ($colored && $excInfo['status'] == "C") {
                         $style = "background-color:LightCoral";
                     } else {
                         if ($colored && $excInfo['status'] == "D") {
                             $style = "background-color:LightYellow";
                         } else {
                             if ($colored && $excInfo['status'] == "E") {
                                 $style = "background-color:LightGreen";
                             } else {
                                 $style = "";
                             }
                         }
                     }
                     $excAditionalInfo = $event['excAditionalInfo'];
                     $excAditionalInfo = str_replace(";", ";<br>", $excAditionalInfo);
                     $excInfo['algText'] = str_replace('<', "less", $excInfo['algText']);
                     $str .= '<tr style="' . $style . '" nobr="true">' . '<td width="70" style="text-align:center;">' . $event['start'] . '</td>' . '<td width="70" style="text-align:center;">' . $event['end'] . '</td>' . '<td width="70" style="text-align:center;">' . $event['duration'] . '</td>' . '<td width="70" style="text-align:center;">' . $event['code'] . '</td>' . '<td width="260" style="text-align:center;">' . $excInfo['comment'] . '</td>' . '<td width="110" style="text-align:center;">' . $excInfo['algText'] . '</td>' . '<td width="180" style="text-align:center;">' . $excAditionalInfo . '</td>' . '<td width="110" style="text-align:center;"> ' . $event['userComment'] . '</td></tr>';
                 }
             }
             unset($FEx);
             $str .= "</table></p>";
             $pdf->writeHTML($str, false, false, false, false, '');
             $pdf->SetFont('dejavusans', '', 12, '', true);
             $str = "</br></br>" . $this->lang->performer . ' : ' . '_____________________ ' . $flightInfo['performer'] . ', ' . date('d-m-Y') . '';
             $pdf->writeHTML($str, false, false, false, false, '');
         } else {
             $strStyle = "text-align:center; font-size: xx-large; font-weight: bold; color: rgb(128, 10, 0);";
             $str = '<p style="' . $strStyle . '">' . $this->lang->noEvents . '</p>';
             $pdf->writeHTML($str, false, false, false, false, '');
         }
     }
     $pdf->Output($fileName, 'I');
 }
    public function create_pdf()
    {
        //============================================================+
        // File name   : example_001.php
        // Begin       : 2008-03-04
        // Last Update : 2013-05-14
        //
        // Description : Example 001 for TCPDF class
        //               Default Header and Footer
        //
        // 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: Default Header and Footer
         * @author Nicola Asuni
         * @since 2008-03-04
         */
        // 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('Nicola Asuni');
        $pdf->SetTitle('TCPDF Example 001');
        $pdf->SetSubject('TCPDF Tutorial');
        $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
        // set default header data
        $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 001', PDF_HEADER_STRING, array(0, 64, 255), array(0, 64, 128));
        $pdf->setFooterData(array(0, 64, 0), array(0, 64, 128));
        // 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 default font subsetting mode
        $pdf->setFontSubsetting(true);
        // Set font
        // dejavusans is a UTF-8 Unicode font, if you only need to
        // print standard ASCII chars, you can use core fonts like
        // helvetica or times to reduce file size.
        $pdf->SetFont('dejavusans', '', 14, '', true);
        // Add a page
        // This method has several options, check the source code documentation for more information.
        $pdf->AddPage();
        // set text shadow effect
        $pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.2, 'depth_h' => 0.2, 'color' => array(196, 196, 196), 'opacity' => 1, 'blend_mode' => 'Normal'));
        // Set some content to print
        $html = <<<EOD
   hehe
EOD;
        // Print text using writeHTMLCell()
        $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
        // ---------------------------------------------------------
        // Close and output PDF document
        // This method has several options, check the source code documentation for more information.
        $pdf->Output('example_001.pdf', 'I');
        //============================================================+
        // END OF FILE
        //============================================================+
    }
 /**
  * generate_pdf.
  */
 public function generate_pdf($get_by_order_id = 0)
 {
     if (!isset($_GET['pdf_invoice']) && 0 == $get_by_order_id) {
         return;
     }
     $order_id = 0 == $get_by_order_id ? $_GET['pdf_invoice'] : $get_by_order_id;
     if (!is_user_logged_in() && 0 == $get_by_order_id) {
         return;
     }
     if (!current_user_can('administrator') && !is_shop_manager() && get_current_user_id() != intval(get_post_meta($order_id, '_customer_user', true)) && 0 == $get_by_order_id) {
         return;
     }
     // Include the main TCPDF library (search for installation path).
     //require_once('tcpdf_include.php');
     require_once 'lib/tcpdf_min/tcpdf.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( 'Algoritmika Ltd.' );
     $pdf->SetTitle('Invoice');
     $pdf->SetSubject('Invoice PDF');
     $pdf->SetKeywords('invoice, PDF');
     // set default header data
     // TODO 2014.09.21
     //		$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 001', PDF_HEADER_STRING, array(0,64,255), array(0,64,128));
     //$pdf->SetHeaderData( get_option( 'wcj_pdf_invoices_seller_logo_url' ), 30, get_option( 'wcj_pdf_invoices_header_title' ), get_option( 'wcj_pdf_invoices_header_string' ), array(0,64,255), array(0,64,128));
     $pdf->SetPrintHeader(false);
     $pdf->setFooterData(array(0, 64, 0), array(0, 64, 128));
     //$pdf->SetPrintFooter(false);
     // 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 default font subsetting mode
     $pdf->setFontSubsetting(true);
     // Set font
     // dejavusans is a UTF-8 Unicode font, if you only need to
     // print standard ASCII chars, you can use core fonts like
     // helvetica or times to reduce file size.
     $pdf->SetFont(apply_filters('wcj_get_option_filter', 'dejavusans', get_option('wcj_pdf_invoices_general_font_family', 'dejavusans')), '', apply_filters('wcj_get_option_filter', 8, get_option('wcj_pdf_invoices_general_font_size')), '', true);
     // Add a page
     // This method has several options, check the source code documentation for more information.
     $pdf->AddPage();
     if ('yes' === get_option('wcj_pdf_invoices_general_font_shadowed', 'yes')) {
         // set text shadow effect
         $pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.2, 'depth_h' => 0.2, 'color' => array(196, 196, 196), 'opacity' => 1, 'blend_mode' => 'Normal'));
     }
     $html = $this->get_invoice_html($order_id);
     // Print text using writeHTMLCell()
     $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
     // ---------------------------------------------------------
     // Close and output PDF document
     // This method has several options, check the source code documentation for more information.
     //		$the_order = new WC_Order( $order_id );
     //		$order_number = $the_order->get_order_number();
     /**/
     if ($get_by_order_id > 0) {
         return $pdf->Output('invoice-' . $order_id . '.pdf', 'S');
     } else {
         $file_name = 'invoice-' . $order_id . '.pdf';
         $file_path = sys_get_temp_dir() . '/' . $file_name;
         $result = file_put_contents($file_path, $pdf->Output('', 'S'));
         //echo $pdf->Output( '', 'S' );
         if (isset($_GET['save_pdf_invoice']) && '1' == $_GET['save_pdf_invoice']) {
             //$pdf->Output('invoice-' . $order_id . '.pdf', 'D');
             header("Content-Type: application/octet-stream");
             //$file = $file_name;//$_GET["file"] .".pdf";
             header("Content-Disposition: attachment; filename=" . urlencode($file_name));
             header("Content-Type: application/octet-stream");
             header("Content-Type: application/download");
             header("Content-Description: File Transfer");
         } else {
             //$pdf->Output('invoice-' . $order_id . '.pdf', 'I');
             header("Content-type: application/pdf");
             header("Content-Disposition: inline; filename=" . urlencode($file_name));
         }
         header("Content-Length: " . filesize($file_path));
         flush();
         // this doesn't really matter.
         if (false !== ($fp = fopen($file_path, "r"))) {
             while (!feof($fp)) {
                 echo fread($fp, 65536);
                 flush();
                 // this is essential for large downloads
             }
             fclose($fp);
         } else {
             die(__('Unexpected error', 'woocommerce-jetpack'));
         }
     }
     /**/
     /**
     
     
     		if ( $get_by_order_id > 0 )
     			return $pdf->Output('invoice-' . $order_id . '.pdf', 'S');
     		if ( isset( $_GET['save_pdf_invoice'] ) && '1' == $_GET['save_pdf_invoice'] )
     			$pdf->Output('invoice-' . $order_id . '.pdf', 'D');
     		else
     			$pdf->Output('invoice-' . $order_id . '.pdf', 'I');
     
     			/**/
 }