Exemple #1
2
    public function getReport($id_report)
    {
        $report = end($this->uri->segments);
        $this->setColNames($id_report);
        $this->params['id_report'] = $id_report;
        $this->params['sidx'] = $this->sortColNames;
        $this->params['colNames'] = $this->colNames;
        $this->params['colModels'] = $this->colModels;
        if ($report == 'prev') {
            $this->template->write_view('content', 'custom_report_query/custom_report_query_preview', $this->params, TRUE);
            $this->template->render();
            // render template
        } else {
            if ($report == 'excel') {
                $nColumn = $this->uri->segment(4);
                $segment = 5;
                $listfield = array();
                for ($i = 1; $i < $nColumn; $i++) {
                    $listfield[] = str_replace("%20", " ", $this->uri->segment($segment));
                    $segment++;
                }
                $sName = $this->uri->segment($segment);
                $segment++;
                $sOrder = $this->uri->segment($segment);
                $rows = $this->custom_report_query_model->get_datas($id_report);
                $result = $this->custom_report_query_model->get_report($id_report, $sName, $sOrder)->result_array();
                $oldIncludePath = get_include_path();
                set_include_path(APPPATH . 'libraries/PHPExcel');
                include_once 'PHPExcel.php';
                include_once 'PHPExcel/Writer/Excel2007.php';
                include_once 'PHPExcel/IOFactory.php';
                if ($report == 'excel') {
                    $ext = 'xls';
                    $header = 'vnd.ms-excel';
                    $obj = 'Excel5';
                    $render = false;
                } else {
                    $rendererName = PHPExcel_Settings::PDF_RENDERER_TCPDF;
                    $rendererLibrary = 'tcPDF5.9';
                    $rendererLibraryPath = APPPATH . 'libraries/tcpdf';
                    $ext = 'pdf';
                    $header = 'pdf';
                    $obj = 'PDF';
                    $render = true;
                }
                $objPHPExcel = new PHPExcel();
                $objPHPExcel->getProperties()->setTitle("title")->setDescription("description");
                // Assign cell values
                $objPHPExcel->setActiveSheetIndex(0);
                $sheet = $objPHPExcel->getActiveSheet();
                $sheet->getDefaultStyle()->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
                $styleArray = array('borders' => array('allborders' => array('style' => PHPExcel_Style_Border::BORDER_THIN)));
                $sheet->setShowGridlines(true);
                foreach ($rows as $row) {
                    $row1 = $row['report_name'];
                    $row2 = $row['req_by'];
                    $row3 = date('d-m-Y');
                }
                $sheet->getRowDimension('1')->setRowHeight(10);
                $sheet->setCellValue('A1', $row1);
                $sheet->setCellValue('A2', $row2);
                $sheet->setCellValue('A3', $row3);
                $char = 65;
                $i = 0;
                foreach ($listfield as $fields) {
                    $sheet->setCellValue(chr($char) . '5', $fields);
                    ${'length' . $i} = strlen($fields);
                    $char++;
                    $i++;
                }
                $char = 65;
                if ($report == 'excel') {
                    for ($j = 0; $j < $i; $j++) {
                        $sheet->getColumnDimension(chr($char))->setAutoSize(true);
                        $char++;
                    }
                }
                $counter = 6;
                foreach ($result as $row) {
                    $char = 65;
                    if ($counter == 6 && $report == 'pdf') {
                        $charX = $char;
                        for ($j = 0; $j < $i; $j++) {
                            if (${'length' . $j} > strlen($row[$listfield[$j]])) {
                                $sheet->getColumnDimension(chr($charX))->setWidth(${'length' . $j} + 4);
                            } else {
                                $sheet->getColumnDimension(chr($charX))->setWidth(30);
                            }
                            $charX++;
                        }
                    }
                    for ($j = 0; $j < $i; $j++) {
                        $sheet->setCellValue(chr($char) . $counter, $row[$listfield[$j]]);
                        $char++;
                    }
                    $counter++;
                }
                if ($render) {
                    if (!PHPExcel_Settings::setPdfRenderer($rendererName, $rendererLibraryPath)) {
                        die('NOTICE: Please set the $rendererName and $rendererLibraryPath values' . '<br />' . 'at the top of this script as appropriate for your directory structure');
                    }
                }
                $filename = $row1 . "-" . date('d/m/Y H:i:s') . '.' . $ext . "";
                // Redirect output to a client’s web browser
                header('Content-Type: application/' . $header);
                header('Content-Disposition: attachment;filename="' . $filename . '"');
                header('Cache-Control: max-age=0');
                // Save it as a file
                $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $obj);
                $objWriter->save('php://output');
                set_include_path($oldIncludePath);
            } else {
                if ($report == 'pdf') {
                    $this->load->library('fpdf');
                    $nColumn = $this->uri->segment(4);
                    $segment = 5;
                    $listfield = array();
                    for ($i = 1; $i < $nColumn; $i++) {
                        $listfield[] = str_replace("%20", " ", $this->uri->segment($segment));
                        $segment++;
                    }
                    $sName = $this->uri->segment($segment);
                    $segment++;
                    $sOrder = $this->uri->segment($segment);
                    $rows = $this->custom_report_query_model->get_datas($id_report);
                    $result = $this->custom_report_query_model->get_report($id_report, $sName, $sOrder)->result_array();
                    foreach ($rows as $row) {
                        $row1 = $row['report_name'];
                        $row2 = $row['req_by'];
                        $row3 = date('d-m-Y');
                    }
                    $html = '';
                    $html .= '<table>
						<tr>
							<td>Nama Laporan</td>
							<td>:</td>
							<td>' . $row1 . '</td>
						</tr>
						<tr>
							<td>Request By</td>
							<td>:</td>
							<td>' . $row2 . '</td>
						</tr>
						<tr>
							<td>Tanggal</td>
							<td>:</td>
							<td>' . $row3 . '</td>
						</tr>
						
					</table>';
                    $row1 . $row2 . $row3;
                    $html .= '<table border="1">
			<tr>';
                    $char = 65;
                    $i = 0;
                    foreach ($listfield as $fields) {
                        $html .= '<td><strong>' . $fields . '</strong></td>';
                        $char++;
                        $i++;
                    }
                    $html .= '</tr>';
                    foreach ($result as $row) {
                        $char = 65;
                        $html .= '<tr>';
                        for ($j = 0; $j < $i; $j++) {
                            $html .= '<td>' . $row[$listfield[$j]] . '</td>';
                            $char++;
                        }
                        $html .= '</tr>';
                    }
                    $html .= '
			</table>';
                    $filename = $row1 . "-" . date('d/m/Y H:i:s') . '.pdf';
                    ini_set('memory_limit', '-1');
                    require_once APPPATH . '/libraries/pdftable/pdftable.inc.php';
                    $p = new PDFTable();
                    $p->AddPage();
                    $p->setfont('times', '', 10);
                    $p->htmltable($html);
                    $p->output($filename, 'I');
                }
            }
        }
    }
//          http://www.gnu.org/copyleft/gpl.html                         //
//                                                                       //
///////////////////////////////////////////////////////////////////////////
require '../../../functions/globales.php';
require '../include/rutas.php';
require '../functions/main.php';
require '../struct/login2.php';
require '../functions/doc_functions.php';
if ($_POST['pdf']) {
    require FPDF_PDF_RUTA . 'lib/pdftable.inc.php';
    $p = new PDFTable('P');
    $p->SetMargins(3, 43, 0);
    $p->SetTitle(date("d-m-Y") . "_revision_direccion");
    $p->SetFillColor(255, 255, 255);
    $p->SetTextColor(0, 0, 0);
    $p->SetDrawColor(0, 0, 0);
    $doc_real = select_normal("Select * from kz_tec_doc_documentos_reales where id = " . $_POST['documento_real'] . "");
    $doc_real = $doc_real[0];
    $p->AddPage('P');
    $p->SetMargins(10, 10, 0);
    $p->setfont('Arial', 'B', 12);
    $color1 = 'A6A6A6';
    $color2 = 'FFFFFF';
    $tit = "bgcolor=#{$color1} color=#{$color2} align=center valign=middle style=bold height=8";
    $nor = "align=center height=5 valign=middle";
    $p->cell(0, 0, $doc_real['titulo'], 0, 0, 'C');
    $p->ln(15);
    $p->setfont('Arial', '', 10);
    $p->MultiCell(188, 5, $doc_real['contenido'], 0, 'J');
    $p->output();
}
        }
    }
    ?>
	</table>
<?php 
} else {
    $acpm = select_normal("SELECT * FROM kz_tec_mej_acpm where 1 = 1 {$filtros} order by {$orden} fecha_apertura desc");
    if ($_POST['pdf']) {
        require FPDF_PDF_RUTA . 'lib/pdftable.inc.php';
        $p = new PDFTable('P');
        $p->SetMargins(3, 43, 0);
        if ($_POST['modo_resumen']) {
            $p->AddPage('L');
            $p->SetMargins(3, 10, 0);
            $p->titulo(5, $titulo);
            $p->setfont('Arial', '', 8);
            $p->SetTitle(date("d-m-Y") . "_informe");
            $p->SetFillColor(255, 255, 255);
            $p->SetTextColor(0, 0, 0);
            $p->SetDrawColor(0, 0, 0);
            $filtrostab = "<table>";
            $filtrostab .= $l_filtros;
            $filtrostab .= "</table>";
            $p->HTMLtable($filtrostab);
            $p->ln(5);
            $tabla_cantidad = "<table>\n\t\t\t\t<tr><td>Cantidad total de Acciones Correctivas: " . count($acpm) . "</td></tr>\t\n\t\t\t</table>";
            $p->HTMLtable($tabla_cantidad);
            $p->ln(5);
            $color1 = 'A6A6A6';
            $color2 = 'FFFFFF';
            $tit = "bgcolor=#{$color1} color=#{$color2} align=center valign=middle style=bold height=8";
    if ($row['tanggal'] != "0000-00-00 00:00:00") {
        $acara .= ", tanggal " . $tgl_text;
    }
    if ($jam != "00:00") {
        $acara .= " pukul " . $jam;
    }
    if ($row[8] != "") {
        $acara .= " di " . $row[8];
    }
    //$acara.=" di ".$row[7];
    //$tgl_diterima=date("d-M-Y", strtotime($row['tgl_terima']));
    $hr1 = date("d", strtotime($row['tgl_terima']));
    $bln1 = date("n", strtotime($row['tgl_terima']));
    $thn1 = date("Y", strtotime($row['tgl_terima']));
    $nama_bln1 = $bulan[$bln1];
    $tgl_diterima = $hr1 . "-" . $nama_bln1 . "-" . $thn1;
}
$rhs = "Rahasia";
$spasi = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
//echo $no_agenda;
$data = "coba";
//echo $data;
$table1 = "\n<table border=1 align=center >\n<tr  > \n    <td colspan=4 align=center border=0><b>LEMBAR DISPOSISI</b></td>\n  </tr>\n  <tr> \n    <td height=15 colspan=4 align=center border=0><b>BIRO HUKUM DAN ORGANISASI</b></td>\n  </tr>\n\n <tr> \n    <td colspan=4 align=right border=0><b>No. Agenda TU  : </b>" . $agenda_tu . "</td>\n   </tr>\n  <tr> \n    <td colspan=4 valign=middle><b>Nomor Agenda   : </b>" . $no_agenda . "</td>\n   </tr>\n  <tr> \n    <td colspan=4 valign=middle><i>Tanggal Diterima : </i>" . $tgl_diterima . "</td>\n  </tr>\n \n  <tr> \n    <td colspan=2 valign=middle>Tanggal Surat : " . $tgl_undangan . "</td>\n    <td colspan=2>Nomor Surat : " . $no_surat . "</td>\n  </tr>\n  <tr> \n    <td colspan=4 valign=middle>Asal Surat : " . $pengirim . "</td>\n  </tr>\n    <tr> \n    <td colspan=4 heihgt=25 valign=middle>Hal :<br> " . $acara . "</td>\n  </tr>\n  <tr> \n    <td colspan=4>Diteruskan Kepada :</td>\n  </tr>\n  <tr> \n    <td height=15 width=7 valign=middle>1.</td>\n    <td  width=85 valign=middle>Kepala Bagian Peraturan Perundang-undangan</td>\n    <td> </td>\n\t<td rowspan=5 width=75>Untuk:<br>[  ] Diikuti disposisi Menteri/Wamen/Sesjen<br>[  ] Diketahui<br>[  ] Diperhatikan<br>[  ] Diberi penjelasan<br>[  ] Diwakili\n\t<br>[  ] Dibicarakan dengan saya<br>[  ] Diproses sesuai prosedur<br>[  ] Ditindaklanjuti<br>[  ] Dilaksanakan/sempurnakan<br>[  ] Dijawab dengan surat<br>[  ] Disiapkan bahan<br>[  ] Disiapkan sambutan tertulis<br>[  ] Ditanggapi/saran-saran<br>[  ] Arsip</td>\n  </tr>\n  <tr> \n    <td height=15 valign=middle>2.</td>\n    <td valign=middle>Kepala Bagian Bantuan Hukum</td>\n    <td> </td>\n  </tr>\n  <tr> \n    <td height=15 valign=middle>3.</td>\n    <td valign=middle>Kepala Bagian Kelembagaan</td>\n    <td width=8>" . $spasi . " </td>\n  </tr>\n  <tr> \n    <td height=15 valign=middle>4.</td>\n    <td valign=middle>Kepala Bagian Ketatalaksanaan</td>\n    <td> </td>\n  </tr>\n  <tr> \n    <td height=15 valign=middle>5.</td>\n    <td valign=middle>Sekretariat</td>\n    <td> </td>\n  </tr>\n  <tr> \n    <td height=25 colspan=4>Keterangan:</td>\n  </tr>\n    <tr> \n    <td colspan=3 align=right border=0>" . $spasi . " </td><td align=left border=0><b>Jakarta ,....................................... 2014</b></td>\n  </tr>\n    </tr>\n    <tr> \n    <td colspan=3 align=right border=0>" . $spasi . " </td><td height=25 align=left border=0><b>Kepala Biro Hukum dan Organisasi,</b></td>\n  </tr>\n  </tr>\n    <tr> \n    <td colspan=3 align=right border=0>" . $spasi . " </td><td border=0><b>Ani Nurdiani Azizah</b></td>\n  </tr>\n  </tr>\n    <tr> \n    <td colspan=3 align=rght border=0>" . $spasi . " </td><td border=0><b>NIP 195812011985032001 </b></td>\n  </tr>\n</table>\n";
define('FPDF_FONTPATH', 'font/');
require 'lib/pdftable.inc.php';
$p = new PDFTable();
$p->AddPage();
$p->SetMargins(1, 1, 1, 1);
$p->setfont('arial', '', 11);
$p->htmltable($table1);
$p->output();
Exemple #5
0
<?php

$table1 = "\r\n<table border=1 align=center>\r\n  <tr> \r\n    <td rowspan=2 valign=middle border=0>rowspan=2, valign=middle</td>\r\n    <td>Normal</td>\r\n    <td>Normal</td>\r\n    <td>Normal</td>\r\n    <td colspan=2 rowspan=2 valign=bottom bgcolor=#FF00FF>colspan=2<br>rowspan=2<br>valign=bottom</td>\r\n  </tr>\r\n  <tr> \r\n    <td height=15>Normal</td>\r\n    <td rowspan=2 align=right bgcolor=#aaaaaa border=0>rowspan=2</td>\r\n    <td border=0>border=0</td>\r\n  </tr>\r\n  <tr> \r\n    <td>Normal</td>\r\n    <td>Normal</td>\r\n    <td>Normal</td>\r\n    <td rowspan=3 valign=top bgcolor=#CC3366>rowspan=3</td>\r\n    <td>Normal</td>\r\n  </tr>\r\n  <tr bgcolor=#cccccc> \r\n    <td>Normal</td>\r\n    <td colspan=3 align=center>align center, colspan=3</td>\r\n    <td>Normal</td>\r\n  </tr>\r\n  <tr> \r\n    <td align=right valign=bottom>align=right<br>valign=bottom</td>\r\n    <td>Normal</td>\r\n    <td>&nbsp;</td>\r\n    <td>Normal</td>\r\n    <td height=20>height=20</td>\r\n  </tr>\r\n</table>\r\n";
define('FPDF_FONTPATH', 'font/');
require 'lib/pdftable.inc.php';
$p = new PDFTable();
$p->AddPage();
$p->setfont('times', '', 12);
$p->htmltable($table1);
$p->output('example.pdf', 'F');
require '../functions/dir_functions.php';
$titulo = "" . html_entity_decode("Pol&iacute;tica de Calidad") . "";
if ($_POST['politica'] != '') {
    $filtropolitica = " where id = " . $_POST['politica'] . "";
}
$politicas = select_normal("SELECT * FROM kz_tec_dir_politicas {$filtropolitica} order by nombre asc");
if ($politicas) {
    if ($_POST['pdf']) {
        require FPDF_PDF_RUTA . 'lib/pdftable.inc.php';
        $p = new PDFTable('P');
        $p->SetMargins(15, 43, 300);
        foreach ($politicas as $key => $valor) {
            $p->AddPage('P');
            $p->SetMargins(15, 10, 170);
            $p->titulo(5, $titulo);
            $p->setfont('Arial', '', 12);
            $p->SetTitle(date("d-m-Y") . "_informe");
            $p->SetFillColor(255, 255, 255);
            $p->SetTextColor(0, 0, 0);
            $p->SetDrawColor(0, 0, 0);
            $p->SetTextColor(0, 0, 0);
            $p->SetFont('Arial', '', 12);
            $p->MultiCell(180, 5, $valor['politica'], 0, "J", false);
            $p->ln(15);
            $p->MultiCell(180, 6, $valor['fecha'], 0, "R", false);
        }
        $p->output();
    }
} else {
    echo "<script>alert('No se puede mostrar el informe. " . html_entity_decode("No hay pol&iacute;tica") . ".');</script>";
    echo "<script>window.close();</script>";