diff --git a/app/Exports/ReportPbgPtspExport.php b/app/Exports/ReportPbgPtspExport.php
new file mode 100644
index 0000000..d2fabaf
--- /dev/null
+++ b/app/Exports/ReportPbgPtspExport.php
@@ -0,0 +1,32 @@
+groupBy('status', 'status_name')
+ ->get();
+ }
+
+ public function headings(): array
+ {
+ return [
+ 'Status Name',
+ 'Total'
+ ];
+ }
+}
diff --git a/app/Http/Controllers/Api/ReportPbgPtspController.php b/app/Http/Controllers/Api/ReportPbgPtspController.php
new file mode 100644
index 0000000..38e908d
--- /dev/null
+++ b/app/Http/Controllers/Api/ReportPbgPtspController.php
@@ -0,0 +1,29 @@
+groupBy('status', 'status_name')
+ ->get();
+ $pdf = Pdf::loadView('exports.ptsp_report', compact('data'));
+ return $pdf->download('laporan-ptsp.pdf');
+ }
+}
diff --git a/app/Http/Controllers/Api/ReportTourismsController.php b/app/Http/Controllers/Api/ReportTourismsController.php
index ec4b5d6..16dcbac 100644
--- a/app/Http/Controllers/Api/ReportTourismsController.php
+++ b/app/Http/Controllers/Api/ReportTourismsController.php
@@ -4,6 +4,8 @@ namespace App\Http\Controllers\Api;
use App\Exports\ReportTourismExport;
use App\Http\Controllers\Controller;
+use App\Models\TourismBasedKBLI;
+use Barryvdh\DomPDF\Facade\Pdf;
use Illuminate\Http\Request;
use Maatwebsite\Excel\Facades\Excel;
@@ -12,4 +14,9 @@ class ReportTourismsController extends Controller
public function export_excel(){
return Excel::download(new ReportTourismExport, 'laporan-pariwisata.xlsx');
}
+ public function export_pdf(){
+ $data = TourismBasedKBLI::all();
+ $pdf = Pdf::loadView('exports.tourisms_report', compact('data'));
+ return $pdf->download('laporan-pariwisata.pdf');
+ }
}
diff --git a/composer.json b/composer.json
index 307ce4d..f6b5f38 100755
--- a/composer.json
+++ b/composer.json
@@ -10,6 +10,7 @@
"license": "MIT",
"require": {
"php": "^8.2",
+ "barryvdh/laravel-dompdf": "^3.1",
"google/apiclient": "^2.12",
"guzzlehttp/guzzle": "^7.9",
"laravel/framework": "^11.31",
diff --git a/composer.lock b/composer.lock
index 1c20bd1..7df82bc 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,8 +4,85 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "41bb51871a746904ab745e4095db8b46",
+ "content-hash": "e657a4f0a463fa048a0110c08babba93",
"packages": [
+ {
+ "name": "barryvdh/laravel-dompdf",
+ "version": "v3.1.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/barryvdh/laravel-dompdf.git",
+ "reference": "8e71b99fc53bb8eb77f316c3c452dd74ab7cb25d"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/barryvdh/laravel-dompdf/zipball/8e71b99fc53bb8eb77f316c3c452dd74ab7cb25d",
+ "reference": "8e71b99fc53bb8eb77f316c3c452dd74ab7cb25d",
+ "shasum": ""
+ },
+ "require": {
+ "dompdf/dompdf": "^3.0",
+ "illuminate/support": "^9|^10|^11|^12",
+ "php": "^8.1"
+ },
+ "require-dev": {
+ "larastan/larastan": "^2.7|^3.0",
+ "orchestra/testbench": "^7|^8|^9|^10",
+ "phpro/grumphp": "^2.5",
+ "squizlabs/php_codesniffer": "^3.5"
+ },
+ "type": "library",
+ "extra": {
+ "laravel": {
+ "aliases": {
+ "PDF": "Barryvdh\\DomPDF\\Facade\\Pdf",
+ "Pdf": "Barryvdh\\DomPDF\\Facade\\Pdf"
+ },
+ "providers": [
+ "Barryvdh\\DomPDF\\ServiceProvider"
+ ]
+ },
+ "branch-alias": {
+ "dev-master": "3.0-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Barryvdh\\DomPDF\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Barry vd. Heuvel",
+ "email": "barryvdh@gmail.com"
+ }
+ ],
+ "description": "A DOMPDF Wrapper for Laravel",
+ "keywords": [
+ "dompdf",
+ "laravel",
+ "pdf"
+ ],
+ "support": {
+ "issues": "https://github.com/barryvdh/laravel-dompdf/issues",
+ "source": "https://github.com/barryvdh/laravel-dompdf/tree/v3.1.1"
+ },
+ "funding": [
+ {
+ "url": "https://fruitcake.nl",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/barryvdh",
+ "type": "github"
+ }
+ ],
+ "time": "2025-02-13T15:07:54+00:00"
+ },
{
"name": "brick/math",
"version": "0.12.1",
@@ -538,6 +615,161 @@
],
"time": "2024-02-05T11:56:58+00:00"
},
+ {
+ "name": "dompdf/dompdf",
+ "version": "v3.1.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/dompdf/dompdf.git",
+ "reference": "a51bd7a063a65499446919286fb18b518177155a"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/dompdf/dompdf/zipball/a51bd7a063a65499446919286fb18b518177155a",
+ "reference": "a51bd7a063a65499446919286fb18b518177155a",
+ "shasum": ""
+ },
+ "require": {
+ "dompdf/php-font-lib": "^1.0.0",
+ "dompdf/php-svg-lib": "^1.0.0",
+ "ext-dom": "*",
+ "ext-mbstring": "*",
+ "masterminds/html5": "^2.0",
+ "php": "^7.1 || ^8.0"
+ },
+ "require-dev": {
+ "ext-gd": "*",
+ "ext-json": "*",
+ "ext-zip": "*",
+ "mockery/mockery": "^1.3",
+ "phpunit/phpunit": "^7.5 || ^8 || ^9 || ^10 || ^11",
+ "squizlabs/php_codesniffer": "^3.5",
+ "symfony/process": "^4.4 || ^5.4 || ^6.2 || ^7.0"
+ },
+ "suggest": {
+ "ext-gd": "Needed to process images",
+ "ext-gmagick": "Improves image processing performance",
+ "ext-imagick": "Improves image processing performance",
+ "ext-zlib": "Needed for pdf stream compression"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Dompdf\\": "src/"
+ },
+ "classmap": [
+ "lib/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "LGPL-2.1"
+ ],
+ "authors": [
+ {
+ "name": "The Dompdf Community",
+ "homepage": "https://github.com/dompdf/dompdf/blob/master/AUTHORS.md"
+ }
+ ],
+ "description": "DOMPDF is a CSS 2.1 compliant HTML to PDF converter",
+ "homepage": "https://github.com/dompdf/dompdf",
+ "support": {
+ "issues": "https://github.com/dompdf/dompdf/issues",
+ "source": "https://github.com/dompdf/dompdf/tree/v3.1.0"
+ },
+ "time": "2025-01-15T14:09:04+00:00"
+ },
+ {
+ "name": "dompdf/php-font-lib",
+ "version": "1.0.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/dompdf/php-font-lib.git",
+ "reference": "6137b7d4232b7f16c882c75e4ca3991dbcf6fe2d"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/dompdf/php-font-lib/zipball/6137b7d4232b7f16c882c75e4ca3991dbcf6fe2d",
+ "reference": "6137b7d4232b7f16c882c75e4ca3991dbcf6fe2d",
+ "shasum": ""
+ },
+ "require": {
+ "ext-mbstring": "*",
+ "php": "^7.1 || ^8.0"
+ },
+ "require-dev": {
+ "symfony/phpunit-bridge": "^3 || ^4 || ^5 || ^6"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "FontLib\\": "src/FontLib"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "LGPL-2.1-or-later"
+ ],
+ "authors": [
+ {
+ "name": "The FontLib Community",
+ "homepage": "https://github.com/dompdf/php-font-lib/blob/master/AUTHORS.md"
+ }
+ ],
+ "description": "A library to read, parse, export and make subsets of different types of font files.",
+ "homepage": "https://github.com/dompdf/php-font-lib",
+ "support": {
+ "issues": "https://github.com/dompdf/php-font-lib/issues",
+ "source": "https://github.com/dompdf/php-font-lib/tree/1.0.1"
+ },
+ "time": "2024-12-02T14:37:59+00:00"
+ },
+ {
+ "name": "dompdf/php-svg-lib",
+ "version": "1.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/dompdf/php-svg-lib.git",
+ "reference": "eb045e518185298eb6ff8d80d0d0c6b17aecd9af"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/dompdf/php-svg-lib/zipball/eb045e518185298eb6ff8d80d0d0c6b17aecd9af",
+ "reference": "eb045e518185298eb6ff8d80d0d0c6b17aecd9af",
+ "shasum": ""
+ },
+ "require": {
+ "ext-mbstring": "*",
+ "php": "^7.1 || ^8.0",
+ "sabberworm/php-css-parser": "^8.4"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Svg\\": "src/Svg"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "LGPL-3.0-or-later"
+ ],
+ "authors": [
+ {
+ "name": "The SvgLib Community",
+ "homepage": "https://github.com/dompdf/php-svg-lib/blob/master/AUTHORS.md"
+ }
+ ],
+ "description": "A library to read, parse and export to PDF SVG files.",
+ "homepage": "https://github.com/dompdf/php-svg-lib",
+ "support": {
+ "issues": "https://github.com/dompdf/php-svg-lib/issues",
+ "source": "https://github.com/dompdf/php-svg-lib/tree/1.0.0"
+ },
+ "time": "2024-04-29T13:26:35+00:00"
+ },
{
"name": "dragonmantank/cron-expression",
"version": "v3.4.0",
@@ -2794,6 +3026,73 @@
},
"time": "2022-12-02T22:17:43+00:00"
},
+ {
+ "name": "masterminds/html5",
+ "version": "2.9.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/Masterminds/html5-php.git",
+ "reference": "f5ac2c0b0a2eefca70b2ce32a5809992227e75a6"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/Masterminds/html5-php/zipball/f5ac2c0b0a2eefca70b2ce32a5809992227e75a6",
+ "reference": "f5ac2c0b0a2eefca70b2ce32a5809992227e75a6",
+ "shasum": ""
+ },
+ "require": {
+ "ext-dom": "*",
+ "php": ">=5.3.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^4.8.35 || ^5.7.21 || ^6 || ^7 || ^8 || ^9"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.7-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Masterminds\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Matt Butcher",
+ "email": "technosophos@gmail.com"
+ },
+ {
+ "name": "Matt Farina",
+ "email": "matt@mattfarina.com"
+ },
+ {
+ "name": "Asmir Mustafic",
+ "email": "goetas@gmail.com"
+ }
+ ],
+ "description": "An HTML5 parser and serializer.",
+ "homepage": "http://masterminds.github.io/html5-php",
+ "keywords": [
+ "HTML5",
+ "dom",
+ "html",
+ "parser",
+ "querypath",
+ "serializer",
+ "xml"
+ ],
+ "support": {
+ "issues": "https://github.com/Masterminds/html5-php/issues",
+ "source": "https://github.com/Masterminds/html5-php/tree/2.9.0"
+ },
+ "time": "2024-03-31T07:05:07+00:00"
+ },
{
"name": "monolog/monolog",
"version": "3.8.1",
@@ -4695,6 +4994,71 @@
],
"time": "2024-04-27T21:32:50+00:00"
},
+ {
+ "name": "sabberworm/php-css-parser",
+ "version": "v8.7.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/MyIntervals/PHP-CSS-Parser.git",
+ "reference": "f414ff953002a9b18e3a116f5e462c56f21237cf"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/MyIntervals/PHP-CSS-Parser/zipball/f414ff953002a9b18e3a116f5e462c56f21237cf",
+ "reference": "f414ff953002a9b18e3a116f5e462c56f21237cf",
+ "shasum": ""
+ },
+ "require": {
+ "ext-iconv": "*",
+ "php": "^5.6.20 || ^7.0.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "5.7.27 || 6.5.14 || 7.5.20 || 8.5.40"
+ },
+ "suggest": {
+ "ext-mbstring": "for parsing UTF-8 CSS"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-main": "9.0.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Sabberworm\\CSS\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Raphael Schweikert"
+ },
+ {
+ "name": "Oliver Klee",
+ "email": "github@oliverklee.de"
+ },
+ {
+ "name": "Jake Hotson",
+ "email": "jake.github@qzdesign.co.uk"
+ }
+ ],
+ "description": "Parser for CSS Files written in PHP",
+ "homepage": "https://www.sabberworm.com/blog/2010/6/10/php-css-parser",
+ "keywords": [
+ "css",
+ "parser",
+ "stylesheet"
+ ],
+ "support": {
+ "issues": "https://github.com/MyIntervals/PHP-CSS-Parser/issues",
+ "source": "https://github.com/MyIntervals/PHP-CSS-Parser/tree/v8.7.0"
+ },
+ "time": "2024-10-27T17:38:32+00:00"
+ },
{
"name": "symfony/clock",
"version": "v7.2.0",
@@ -9474,12 +9838,12 @@
],
"aliases": [],
"minimum-stability": "stable",
- "stability-flags": {},
+ "stability-flags": [],
"prefer-stable": true,
"prefer-lowest": false,
"platform": {
"php": "^8.2"
},
- "platform-dev": {},
+ "platform-dev": [],
"plugin-api-version": "2.6.0"
}
diff --git a/resources/js/report-pbg-ptsp/index.js b/resources/js/report-pbg-ptsp/index.js
index 26376b1..e64fa51 100644
--- a/resources/js/report-pbg-ptsp/index.js
+++ b/resources/js/report-pbg-ptsp/index.js
@@ -7,6 +7,8 @@ class ReportPbgPTSP {
constructor() {
this.table = null;
this.initTableReportPbgPTSP();
+ this.handleExportToExcel();
+ this.handleExportPDF();
}
initTableReportPbgPTSP() {
let tableContainer = document.getElementById("table-report-pbg-ptsp");
@@ -61,6 +63,99 @@ class ReportPbgPTSP {
fixedHeader: true,
}).render(tableContainer);
}
+ async handleExportToExcel() {
+ const button = document.getElementById("btn-export-excel");
+ if (!button) {
+ console.error("Button not found: #btn-export-excel");
+ return;
+ }
+
+ let exportUrl = button.getAttribute("data-url");
+
+ button.addEventListener("click", async () => {
+ button.disabled = true;
+ try {
+ const response = await fetch(`${exportUrl}`, {
+ method: "GET",
+ credentials: "include",
+ headers: {
+ Authorization: `Bearer ${document
+ .querySelector('meta[name="api-token"]')
+ .getAttribute("content")}`,
+ },
+ });
+ if (!response.ok) {
+ console.error("Error fetching data:", response.statusText);
+ button.disabled = false;
+ return;
+ }
+
+ // Convert response to Blob and trigger download
+ const blob = await response.blob();
+ const url = window.URL.createObjectURL(blob);
+ const a = document.createElement("a");
+ a.href = url;
+ a.download = "laporan-ptsp.xlsx";
+ document.body.appendChild(a);
+ a.click();
+ document.body.removeChild(a);
+ window.URL.revokeObjectURL(url);
+ } catch (error) {
+ console.error("Error fetching data:", error);
+ button.disabled = false;
+ return;
+ } finally {
+ button.disabled = false;
+ }
+ });
+ }
+
+ async handleExportPDF() {
+ const button = document.getElementById("btn-export-pdf");
+ if (!button) {
+ console.error("Button not found: #btn-export-pdf");
+ return;
+ }
+
+ let exportUrl = button.getAttribute("data-url");
+
+ button.addEventListener("click", async () => {
+ button.disabled = true;
+ try {
+ const response = await fetch(`${exportUrl}`, {
+ method: "GET",
+ credentials: "include",
+ headers: {
+ Authorization: `Bearer ${document
+ .querySelector('meta[name="api-token"]')
+ .getAttribute("content")}`,
+ },
+ });
+ if (!response.ok) {
+ console.error("Error fetching data:", response.statusText);
+ button.disabled = false;
+ return;
+ }
+
+ // Convert response to Blob and trigger download
+ const blob = await response.blob();
+ const url = window.URL.createObjectURL(blob);
+ const a = document.createElement("a");
+ a.href = url;
+ a.download = "laporan-ptsp.pdf";
+ document.body.appendChild(a);
+ a.click();
+ document.body.removeChild(a);
+ window.URL.revokeObjectURL(url);
+ } catch (error) {
+ console.error("Error fetching data:", error);
+ button.disabled = false;
+ return;
+ } finally {
+ button.disabled = false;
+ }
+ });
+ }
}
document.addEventListener("DOMContentLoaded", function (e) {
new ReportPbgPTSP();
diff --git a/resources/js/report/tourisms/index.js b/resources/js/report/tourisms/index.js
index e5b35a8..bc8d480 100644
--- a/resources/js/report/tourisms/index.js
+++ b/resources/js/report/tourisms/index.js
@@ -18,9 +18,9 @@ new gridjs.Grid({
}).render(document.getElementById("tourisms-report-data-table"));
class TourismReport {
- constructor() {}
init() {
this.handleExportToExcel();
+ this.handleExportPDF();
}
async handleExportToExcel() {
@@ -69,6 +69,53 @@ class TourismReport {
}
});
}
+
+ async handleExportPDF() {
+ const button = document.getElementById("btn-export-pdf");
+ if (!button) {
+ console.error("Button not found: #btn-export-pdf");
+ return;
+ }
+
+ let exportUrl = button.getAttribute("data-url");
+
+ button.addEventListener("click", async () => {
+ button.disabled = true;
+ try {
+ const response = await fetch(`${exportUrl}`, {
+ method: "GET",
+ credentials: "include",
+ headers: {
+ Authorization: `Bearer ${document
+ .querySelector('meta[name="api-token"]')
+ .getAttribute("content")}`,
+ },
+ });
+ if (!response.ok) {
+ console.error("Error fetching data:", response.statusText);
+ button.disabled = false;
+ return;
+ }
+
+ // Convert response to Blob and trigger download
+ const blob = await response.blob();
+ const url = window.URL.createObjectURL(blob);
+ const a = document.createElement("a");
+ a.href = url;
+ a.download = "laporan-pariwisata.pdf";
+ document.body.appendChild(a);
+ a.click();
+ document.body.removeChild(a);
+ window.URL.revokeObjectURL(url);
+ } catch (error) {
+ console.error("Error fetching data:", error);
+ button.disabled = false;
+ return;
+ } finally {
+ button.disabled = false;
+ }
+ });
+ }
}
document.addEventListener("DOMContentLoaded", function () {
diff --git a/resources/views/exports/ptsp_report.blade.php b/resources/views/exports/ptsp_report.blade.php
new file mode 100644
index 0000000..88aa08b
--- /dev/null
+++ b/resources/views/exports/ptsp_report.blade.php
@@ -0,0 +1,33 @@
+
+
+
+
+
+ Laporan PBG PTSP
+
+
+
+ Laporan PBG PTSP
+
+
+
+ | Status |
+ Total |
+
+
+
+ @foreach($data as $item)
+
+ | {{ $item->status_name }} |
+ {{ $item->total }} |
+
+ @endforeach
+
+
+
+
diff --git a/resources/views/exports/tourisms_report.blade.php b/resources/views/exports/tourisms_report.blade.php
new file mode 100644
index 0000000..61fde18
--- /dev/null
+++ b/resources/views/exports/tourisms_report.blade.php
@@ -0,0 +1,33 @@
+
+
+
+
+
+ Laporan Pariwisata
+
+
+
+ Laporan Pariwisata
+
+
+
+ | Jenis Bisnis Pariwisata |
+ Jumlah Total |
+
+
+
+ @foreach($data as $item)
+
+ | {{ $item->kbli_title }} |
+ {{ $item->total_records }} |
+
+ @endforeach
+
+
+
+
diff --git a/resources/views/report-pbg-ptsp/index.blade.php b/resources/views/report-pbg-ptsp/index.blade.php
index e562aff..62fcfcd 100644
--- a/resources/views/report-pbg-ptsp/index.blade.php
+++ b/resources/views/report-pbg-ptsp/index.blade.php
@@ -13,6 +13,19 @@
+
diff --git a/resources/views/report/tourisms/index.blade.php b/resources/views/report/tourisms/index.blade.php
index f96b566..5115c74 100644
--- a/resources/views/report/tourisms/index.blade.php
+++ b/resources/views/report/tourisms/index.blade.php
@@ -16,7 +16,7 @@
.xlsx
-