Skip to content
Snippets Groups Projects
Commit fdca2023 authored by Felix Limanta's avatar Felix Limanta
Browse files

[WIP] PDF report generation that doesn't suck balls

parent 7f0b0210
Branches
No related merge requests found
...@@ -18,6 +18,7 @@ use Illuminate\Support\Facades\File; ...@@ -18,6 +18,7 @@ use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Validator; use Validator;
use PHPExcel_IOFactory; use PHPExcel_IOFactory;
use PHPExcel_Settings;
class DataKompetensiController extends APIBaseController class DataKompetensiController extends APIBaseController
{ {
...@@ -521,11 +522,24 @@ class DataKompetensiController extends APIBaseController ...@@ -521,11 +522,24 @@ class DataKompetensiController extends APIBaseController
$sheet->getCell('AP16')->setValue(floor($obj->manajerial_intensitas_pengarahan)); $sheet->getCell('AP16')->setValue(floor($obj->manajerial_intensitas_pengarahan));
$sheet->getCell('AQ16')->setValue(floor($obj->manajerial_kekuatan_pengawasan)); $sheet->getCell('AQ16')->setValue(floor($obj->manajerial_kekuatan_pengawasan));
$writer = PHPExcel_IOFactory::createWriter($excel, 'Excel2007'); $rendererName = PHPExcel_Settings::PDF_RENDERER_TCPDF;
header('Content-type: application/vnd.ms-excel'); $rendererLibraryPath = base_path() . '/vendor/dompdf/dompdf';
header('Content-Disposition: attachment; filename="file.xlsx"'); PHPExcel_Settings::setPdfRenderer($rendererName, $rendererLibraryPath);
$writer->setIncludeCharts(TRUE);
$writer->save('php://output'); $filename = 'laporan_kompetensi_' . $id . '.pdf';
// $writer = PHPExcel_IOFactory::createWriter($excel, 'Excel2007');
// header('Content-type: application/vnd.ms-excel');
// header('Content-Disposition: attachment; filename="' . $filename . '"');
$writer = PHPExcel_IOFactory::createWriter($excel, 'PDF');;
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="' . $filename . '"');
header('Cache-Control: public');
$writer->setSheetIndex(
$excel->getIndex($excel->getSheetByName('x'))
);
$writer->setIncludeCharts(true);
@$writer->save('php://output');
} }
private function authenticate($role) private function authenticate($role)
......
...@@ -11,7 +11,9 @@ ...@@ -11,7 +11,9 @@
"laravel/framework": "5.6.*", "laravel/framework": "5.6.*",
"laravel/tinker": "^1.0", "laravel/tinker": "^1.0",
"maatwebsite/excel": "~2.1.0", "maatwebsite/excel": "~2.1.0",
"dompdf/dompdf": "~0.6.1" "mpdf/mpdf": "~6.1",
"dompdf/dompdf": "~0.6.1",
"tecnick.com/tcpdf": "~6.0.0"
}, },
"require-dev": { "require-dev": {
"filp/whoops": "^2.0", "filp/whoops": "^2.0",
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "2954465a5843f8ea9d0a1fdded09af12", "content-hash": "1f459f32475d28b5690877054d064269",
"packages": [ "packages": [
{ {
"name": "dnoegel/php-xdg-base-dir", "name": "dnoegel/php-xdg-base-dir",
...@@ -1129,6 +1129,57 @@ ...@@ -1129,6 +1129,57 @@
], ],
"time": "2017-06-19T01:22:40+00:00" "time": "2017-06-19T01:22:40+00:00"
}, },
{
"name": "mpdf/mpdf",
"version": "v6.1.3",
"source": {
"type": "git",
"url": "https://github.com/mpdf/mpdf.git",
"reference": "7f138bf7508eac895ac2c13d2509b056ac7e7e97"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/mpdf/mpdf/zipball/7f138bf7508eac895ac2c13d2509b056ac7e7e97",
"reference": "7f138bf7508eac895ac2c13d2509b056ac7e7e97",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
"php": ">=5.4.0",
"setasign/fpdi": "1.6.*"
},
"require-dev": {
"phpunit/phpunit": "^4.7"
},
"suggest": {
"ext-zlib": "Needed for compression of embedded resources, such as fonts"
},
"type": "library",
"autoload": {
"classmap": [
"mpdf.php",
"classes"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"GPL-2.0"
],
"authors": [
{
"name": "Ian Back",
"role": "Developer"
}
],
"description": "A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support",
"homepage": "http://mpdf.github.io",
"keywords": [
"pdf",
"php",
"utf-8"
],
"time": "2016-12-12T10:42:18+00:00"
},
{ {
"name": "nesbot/carbon", "name": "nesbot/carbon",
"version": "1.25.0", "version": "1.25.0",
...@@ -1719,6 +1770,55 @@ ...@@ -1719,6 +1770,55 @@
], ],
"time": "2018-01-20T00:28:24+00:00" "time": "2018-01-20T00:28:24+00:00"
}, },
{
"name": "setasign/fpdi",
"version": "1.6.2",
"source": {
"type": "git",
"url": "https://github.com/Setasign/FPDI.git",
"reference": "a6ad58897a6d97cc2d2cd2adaeda343b25a368ea"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Setasign/FPDI/zipball/a6ad58897a6d97cc2d2cd2adaeda343b25a368ea",
"reference": "a6ad58897a6d97cc2d2cd2adaeda343b25a368ea",
"shasum": ""
},
"suggest": {
"setasign/fpdf": "FPDI will extend this class but as it is also possible to use \"tecnickcom/tcpdf\" as an alternative there's no fixed dependency configured.",
"setasign/fpdi-fpdf": "Use this package to automatically evaluate dependencies to FPDF.",
"setasign/fpdi-tcpdf": "Use this package to automatically evaluate dependencies to TCPDF."
},
"type": "library",
"autoload": {
"classmap": [
"filters/",
"fpdi.php",
"fpdf_tpl.php",
"fpdi_pdf_parser.php",
"pdf_context.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jan Slabon",
"email": "jan.slabon@setasign.com",
"homepage": "https://www.setasign.com"
}
],
"description": "FPDI is a collection of PHP classes facilitating developers to read pages from existing PDF documents and use them as templates in FPDF. Because it is also possible to use FPDI with TCPDF, there are no fixed dependencies defined. Please see suggestions for packages which evaluates the dependencies automatically.",
"homepage": "https://www.setasign.com/fpdi",
"keywords": [
"fpdf",
"fpdi",
"pdf"
],
"time": "2017-05-11T14:25:49+00:00"
},
{ {
"name": "swiftmailer/swiftmailer", "name": "swiftmailer/swiftmailer",
"version": "v6.0.2", "version": "v6.0.2",
...@@ -2688,6 +2788,70 @@ ...@@ -2688,6 +2788,70 @@
], ],
"time": "2018-04-04T05:10:37+00:00" "time": "2018-04-04T05:10:37+00:00"
}, },
{
"name": "tecnick.com/tcpdf",
"version": "6.0.099",
"source": {
"type": "git",
"url": "https://github.com/tecnickcom/TCPDF.git",
"reference": "75e7ad39458e060d0cae6fcb7d50a2c9f3af1b01"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/75e7ad39458e060d0cae6fcb7d50a2c9f3af1b01",
"reference": "75e7ad39458e060d0cae6fcb7d50a2c9f3af1b01",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"autoload": {
"classmap": [
"fonts",
"config",
"include",
"tcpdf.php",
"tcpdf_parser.php",
"tcpdf_import.php",
"tcpdf_barcodes_1d.php",
"tcpdf_barcodes_2d.php",
"include/tcpdf_colors.php",
"include/tcpdf_filters.php",
"include/tcpdf_font_data.php",
"include/tcpdf_fonts.php",
"include/tcpdf_images.php",
"include/tcpdf_static.php",
"include/barcodes/datamatrix.php",
"include/barcodes/pdf417.php",
"include/barcodes/qrcode.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPLv3"
],
"authors": [
{
"name": "Nicola Asuni",
"email": "info@tecnick.com",
"homepage": "http://nicolaasuni.tecnick.com"
}
],
"description": "TCPDF is a PHP class for generating PDF documents and barcodes.",
"homepage": "http://www.tcpdf.org/",
"keywords": [
"PDFD32000-2008",
"TCPDF",
"barcodes",
"datamatrix",
"pdf",
"pdf417",
"qrcode"
],
"abandoned": "tecnickcom/tcpdf",
"time": "2014-11-15T12:35:49+00:00"
},
{ {
"name": "tijsverkoyen/css-to-inline-styles", "name": "tijsverkoyen/css-to-inline-styles",
"version": "2.2.1", "version": "2.2.1",
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment