From d2864db88aa95681ea0d86eb2eba1ce0b023e875 Mon Sep 17 00:00:00 2001 From: Sveemaaa Date: Sun, 19 Apr 2026 15:37:45 +0700 Subject: [PATCH] laporan, excel, pdf --- project/app/Exports/LaporanExport.php | 71 +++ .../Http/Controllers/LaporanController.php | 79 ++- project/composer.json | 3 +- project/composer.lock | 592 +++++++++++++++++- .../resources/views/laporan/index.blade.php | 261 ++++++++ .../views/laporan/pdf_balita.blade.php | 51 ++ .../views/laporan/pdf_ibu_hamil.blade.php | 0 project/routes/web.php | 9 +- 8 files changed, 1053 insertions(+), 13 deletions(-) create mode 100644 project/app/Exports/LaporanExport.php create mode 100644 project/resources/views/laporan/index.blade.php create mode 100644 project/resources/views/laporan/pdf_balita.blade.php create mode 100644 project/resources/views/laporan/pdf_ibu_hamil.blade.php diff --git a/project/app/Exports/LaporanExport.php b/project/app/Exports/LaporanExport.php new file mode 100644 index 0000000..f473010 --- /dev/null +++ b/project/app/Exports/LaporanExport.php @@ -0,0 +1,71 @@ +bulan = $bulan; + $this->tahun = $tahun; + $this->kategori = $kategori; + } + + public function query() + { + if ($this->kategori == 'balita') { + return PengukuranBalita::with('balita') + ->whereMonth('tanggal', $this->bulan) // Harus pakai variabel ini! + ->whereYear('tanggal', $this->tahun) // Harus pakai variabel ini! + ->orderBy('tanggal', 'asc'); + } else { + return PengukuranIbuHamil::with('ibuHamil') + ->whereMonth('tanggal', $this->bulan) + ->whereYear('tanggal', $this->tahun) + ->orderBy('tanggal', 'asc'); + } + } + + public function headings(): array + { + if ($this->kategori == 'balita') { + return ["No", "Nama Balita", "Tanggal Ukur", "Usia (Bulan)", "BB (kg)", "TB (cm)", "ZS-TB/U", "Hasil/Status"]; + } + return ["No", "Nama Ibu", "Tanggal Ukur", "Usia Hamil (Minggu)", "BB (kg)", "LILA (cm)", "IMT", "Status Gizi"]; + } + + public function map($item): array + { + static $no = 1; + if ($this->kategori == 'balita') { + return [ + $no++, + $item->balita->nama ?? '-', + $item->tanggal, + $item->usia_saat_ukur, + $item->berat_badan, + $item->tinggi_badan, + $item->zs_tbu, + $item->hasil + ]; + } + return [ + $no++, + $item->ibuHamil->nama ?? '-', + $item->tanggal, + $item->usia_kehamilan, + $item->berat_badan, + $item->lila, + $item->imt, + $item->status_gizi + ]; + } +} diff --git a/project/app/Http/Controllers/LaporanController.php b/project/app/Http/Controllers/LaporanController.php index 97fb66a..4da5e3f 100644 --- a/project/app/Http/Controllers/LaporanController.php +++ b/project/app/Http/Controllers/LaporanController.php @@ -3,26 +3,87 @@ namespace App\Http\Controllers; use App\Models\PengukuranBalita; +use App\Models\PengukuranIbuHamil; use Illuminate\Http\Request; +use Maatwebsite\Excel\Facades\Excel; // Pastikan sudah install laravel-excel +use Barryvdh\DomPDF\PDF; +use App\Exports\LaporanExport; // Tambahkan ini class LaporanController extends Controller { public function index(Request $request) { - $query = PengukuranBalita::with('balita'); + // 1. Ambil Parameter Filter (Default ke bulan & tahun sekarang) + $bulan = $request->get('bulan', date('n')); + $tahun = $request->get('tahun', date('Y')); - // Filter berdasarkan Status Stunting (Hasil AI) - if ($request->has('status') && $request->status != '') { - $query->where('hasil', $request->status); + // 2. Query Data Balita + $queryBalita = PengukuranBalita::with('balita') + ->whereMonth('tanggal', $bulan) + ->whereYear('tanggal', $tahun); + + // 3. Query Data Ibu Hamil + $queryIbuHamil = PengukuranIbuHamil::with('ibuHamil') + ->whereMonth('tanggal', $bulan) + ->whereYear('tanggal', $tahun); + + // 4. Hitung Statistik untuk Summary Cards + $stats = [ + 'total_balita' => $queryBalita->count(), + 'total_ibu' => $queryIbuHamil->count(), + 'stunting' => (clone $queryBalita)->whereIn('hasil', ['Stunting', 'Sangat Pendek', 'Pendek'])->count(), + 'normal' => (clone $queryBalita)->where('hasil', 'Normal')->count(), + ]; + + // 5. Eksekusi Data untuk Tabel + $laporanBalita = $queryBalita->latest()->get(); + $laporanIbuHamil = $queryIbuHamil->latest()->get(); + + return view('laporan.index', compact('laporanBalita', 'laporanIbuHamil', 'stats', 'bulan', 'tahun')); + } + + public function exportExcel(Request $request) + { + $bulan = $request->bulan; + $tahun = $request->tahun; + $kategori = $request->kategori; + + // CEK: Apakah ada datanya? + if ($kategori == 'balita') { + $exists = PengukuranBalita::whereMonth('tanggal', $bulan)->whereYear('tanggal', $tahun)->exists(); + } else { + $exists = PengukuranIbuHamil::whereMonth('tanggal', $bulan)->whereYear('tanggal', $tahun)->exists(); } - // Filter berdasarkan Bulan/Tahun (Optional) - if ($request->has('bulan') && $request->bulan != '') { - $query->whereMonth('tanggal', $request->bulan); + if (!$exists) { + return back()->with('error', 'Maat, tidak ada data pengukuran untuk periode yang dipilih.'); } - $laporan = $query->latest()->get(); + return Excel::download(new LaporanExport($bulan, $tahun, $kategori), "Laporan_{$kategori}_{$bulan}_{$tahun}.xlsx"); + } - return view('laporan.index', compact('laporan')); + public function exportPdf(Request $request) + { + $bulan = $request->bulan ?? date('n'); + $tahun = $request->tahun ?? date('Y'); + $kategori = $request->kategori; + + if ($kategori == 'balita') { + $items = PengukuranBalita::with('balita')->whereMonth('tanggal', $bulan)->whereYear('tanggal', $tahun)->get(); + $view = 'laporan.pdf_balita'; + } else { + $items = PengukuranIbuHamil::with('ibuHamil')->whereMonth('tanggal', $bulan)->whereYear('tanggal', $tahun)->get(); + $view = 'laporan.pdf_ibuhamil'; + } + + $data = [ + 'title' => 'LAPORAN BULANAN POSYANDU POSSEHAT', + 'sub' => 'Kategori: ' . ucfirst($kategori) . " - Periode: $bulan/$tahun", + 'date' => date('d/m/Y'), + 'items' => $items + ]; + + $pdf = \Barryvdh\DomPDF\Facade\Pdf::loadView($view, $data); + return $pdf->download("Laporan_{$kategori}_{$bulan}_{$tahun}.pdf"); } } diff --git a/project/composer.json b/project/composer.json index d33723b..22de063 100644 --- a/project/composer.json +++ b/project/composer.json @@ -10,7 +10,8 @@ "guzzlehttp/guzzle": "^7.2", "laravel/framework": "^10.10", "laravel/sanctum": "^3.3", - "laravel/tinker": "^2.8" + "laravel/tinker": "^2.8", + "maatwebsite/excel": "^3.1" }, "require-dev": { "fakerphp/faker": "^1.9.1", diff --git a/project/composer.lock b/project/composer.lock index 435d650..a63e1d2 100644 --- a/project/composer.lock +++ b/project/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "50a9cf43c3c522104b200bfdbe2e0e54", + "content-hash": "081d5da149ebec75a83fc53f40468a8b", "packages": [ { "name": "barryvdh/laravel-dompdf", @@ -212,6 +212,162 @@ ], "time": "2023-12-11T17:09:12+00:00" }, + { + "name": "composer/pcre", + "version": "3.3.2", + "source": { + "type": "git", + "url": "https://github.com/composer/pcre.git", + "reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/pcre/zipball/b2bed4734f0cc156ee1fe9c0da2550420d99a21e", + "reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0" + }, + "conflict": { + "phpstan/phpstan": "<1.11.10" + }, + "require-dev": { + "phpstan/phpstan": "^1.12 || ^2", + "phpstan/phpstan-strict-rules": "^1 || ^2", + "phpunit/phpunit": "^8 || ^9" + }, + "type": "library", + "extra": { + "phpstan": { + "includes": [ + "extension.neon" + ] + }, + "branch-alias": { + "dev-main": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Pcre\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "PCRE wrapping library that offers type-safe preg_* replacements.", + "keywords": [ + "PCRE", + "preg", + "regex", + "regular expression" + ], + "support": { + "issues": "https://github.com/composer/pcre/issues", + "source": "https://github.com/composer/pcre/tree/3.3.2" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2024-11-12T16:29:46+00:00" + }, + { + "name": "composer/semver", + "version": "3.4.4", + "source": { + "type": "git", + "url": "https://github.com/composer/semver.git", + "reference": "198166618906cb2de69b95d7d47e5fa8aa1b2b95" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/semver/zipball/198166618906cb2de69b95d7d47e5fa8aa1b2b95", + "reference": "198166618906cb2de69b95d7d47e5fa8aa1b2b95", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.11", + "symfony/phpunit-bridge": "^3 || ^7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Semver\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nils Adermann", + "email": "naderman@naderman.de", + "homepage": "http://www.naderman.de" + }, + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + }, + { + "name": "Rob Bast", + "email": "rob.bast@gmail.com", + "homepage": "http://robbast.nl" + } + ], + "description": "Semver library that offers utilities, version constraint parsing and validation.", + "keywords": [ + "semantic", + "semver", + "validation", + "versioning" + ], + "support": { + "irc": "ircs://irc.libera.chat:6697/composer", + "issues": "https://github.com/composer/semver/issues", + "source": "https://github.com/composer/semver/tree/3.4.4" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + } + ], + "time": "2025-08-20T19:15:30+00:00" + }, { "name": "dflydev/dot-access-data", "version": "v3.0.3", @@ -740,6 +896,67 @@ ], "time": "2025-03-06T22:45:56+00:00" }, + { + "name": "ezyang/htmlpurifier", + "version": "v4.19.0", + "source": { + "type": "git", + "url": "https://github.com/ezyang/htmlpurifier.git", + "reference": "b287d2a16aceffbf6e0295559b39662612b77fcf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/b287d2a16aceffbf6e0295559b39662612b77fcf", + "reference": "b287d2a16aceffbf6e0295559b39662612b77fcf", + "shasum": "" + }, + "require": { + "php": "~5.6.0 || ~7.0.0 || ~7.1.0 || ~7.2.0 || ~7.3.0 || ~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0" + }, + "require-dev": { + "cerdic/css-tidy": "^1.7 || ^2.0", + "simpletest/simpletest": "dev-master" + }, + "suggest": { + "cerdic/css-tidy": "If you want to use the filter 'Filter.ExtractStyleBlocks'.", + "ext-bcmath": "Used for unit conversion and imagecrash protection", + "ext-iconv": "Converts text to and from non-UTF-8 encodings", + "ext-tidy": "Used for pretty-printing HTML" + }, + "type": "library", + "autoload": { + "files": [ + "library/HTMLPurifier.composer.php" + ], + "psr-0": { + "HTMLPurifier": "library/" + }, + "exclude-from-classmap": [ + "/library/HTMLPurifier/Language/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-2.1-or-later" + ], + "authors": [ + { + "name": "Edward Z. Yang", + "email": "admin@htmlpurifier.org", + "homepage": "http://ezyang.com" + } + ], + "description": "Standards compliant HTML filter written in PHP", + "homepage": "http://htmlpurifier.org/", + "keywords": [ + "html" + ], + "support": { + "issues": "https://github.com/ezyang/htmlpurifier/issues", + "source": "https://github.com/ezyang/htmlpurifier/tree/v4.19.0" + }, + "time": "2025-10-17T16:34:55+00:00" + }, { "name": "fruitcake/php-cors", "version": "v1.4.0", @@ -2120,6 +2337,271 @@ ], "time": "2024-09-21T08:32:55+00:00" }, + { + "name": "maatwebsite/excel", + "version": "3.1.68", + "source": { + "type": "git", + "url": "https://github.com/SpartnerNL/Laravel-Excel.git", + "reference": "1854739267d81d38eae7d8c623caf523f30f256b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/SpartnerNL/Laravel-Excel/zipball/1854739267d81d38eae7d8c623caf523f30f256b", + "reference": "1854739267d81d38eae7d8c623caf523f30f256b", + "shasum": "" + }, + "require": { + "composer/semver": "^3.3", + "ext-json": "*", + "illuminate/support": "5.8.*||^6.0||^7.0||^8.0||^9.0||^10.0||^11.0||^12.0||^13.0", + "php": "^7.0||^8.0", + "phpoffice/phpspreadsheet": "^1.30.0", + "psr/simple-cache": "^1.0||^2.0||^3.0" + }, + "require-dev": { + "laravel/scout": "^7.0||^8.0||^9.0||^10.0||^11.0", + "orchestra/testbench": "^6.0||^7.0||^8.0||^9.0||^10.0||^11.0", + "predis/predis": "^1.1" + }, + "type": "library", + "extra": { + "laravel": { + "aliases": { + "Excel": "Maatwebsite\\Excel\\Facades\\Excel" + }, + "providers": [ + "Maatwebsite\\Excel\\ExcelServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Maatwebsite\\Excel\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Patrick Brouwers", + "email": "patrick@spartner.nl" + } + ], + "description": "Supercharged Excel exports and imports in Laravel", + "keywords": [ + "PHPExcel", + "batch", + "csv", + "excel", + "export", + "import", + "laravel", + "php", + "phpspreadsheet" + ], + "support": { + "issues": "https://github.com/SpartnerNL/Laravel-Excel/issues", + "source": "https://github.com/SpartnerNL/Laravel-Excel/tree/3.1.68" + }, + "funding": [ + { + "url": "https://laravel-excel.com/commercial-support", + "type": "custom" + }, + { + "url": "https://github.com/patrickbrouwers", + "type": "github" + } + ], + "time": "2026-03-17T20:51:10+00:00" + }, + { + "name": "maennchen/zipstream-php", + "version": "3.1.1", + "source": { + "type": "git", + "url": "https://github.com/maennchen/ZipStream-PHP.git", + "reference": "6187e9cc4493da94b9b63eb2315821552015fca9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/maennchen/ZipStream-PHP/zipball/6187e9cc4493da94b9b63eb2315821552015fca9", + "reference": "6187e9cc4493da94b9b63eb2315821552015fca9", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "ext-zlib": "*", + "php-64bit": "^8.1" + }, + "require-dev": { + "ext-zip": "*", + "friendsofphp/php-cs-fixer": "^3.16", + "guzzlehttp/guzzle": "^7.5", + "mikey179/vfsstream": "^1.6", + "php-coveralls/php-coveralls": "^2.5", + "phpunit/phpunit": "^10.0", + "vimeo/psalm": "^5.0" + }, + "suggest": { + "guzzlehttp/psr7": "^2.4", + "psr/http-message": "^2.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "ZipStream\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paul Duncan", + "email": "pabs@pablotron.org" + }, + { + "name": "Jonatan Männchen", + "email": "jonatan@maennchen.ch" + }, + { + "name": "Jesse Donat", + "email": "donatj@gmail.com" + }, + { + "name": "András Kolesár", + "email": "kolesar@kolesar.hu" + } + ], + "description": "ZipStream is a library for dynamically streaming dynamic zip files from PHP without writing to the disk at all on the server.", + "keywords": [ + "stream", + "zip" + ], + "support": { + "issues": "https://github.com/maennchen/ZipStream-PHP/issues", + "source": "https://github.com/maennchen/ZipStream-PHP/tree/3.1.1" + }, + "funding": [ + { + "url": "https://github.com/maennchen", + "type": "github" + } + ], + "time": "2024-10-10T12:33:01+00:00" + }, + { + "name": "markbaker/complex", + "version": "3.0.2", + "source": { + "type": "git", + "url": "https://github.com/MarkBaker/PHPComplex.git", + "reference": "95c56caa1cf5c766ad6d65b6344b807c1e8405b9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/95c56caa1cf5c766ad6d65b6344b807c1e8405b9", + "reference": "95c56caa1cf5c766ad6d65b6344b807c1e8405b9", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "dev-master", + "phpcompatibility/php-compatibility": "^9.3", + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0", + "squizlabs/php_codesniffer": "^3.7" + }, + "type": "library", + "autoload": { + "psr-4": { + "Complex\\": "classes/src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mark Baker", + "email": "mark@lange.demon.co.uk" + } + ], + "description": "PHP Class for working with complex numbers", + "homepage": "https://github.com/MarkBaker/PHPComplex", + "keywords": [ + "complex", + "mathematics" + ], + "support": { + "issues": "https://github.com/MarkBaker/PHPComplex/issues", + "source": "https://github.com/MarkBaker/PHPComplex/tree/3.0.2" + }, + "time": "2022-12-06T16:21:08+00:00" + }, + { + "name": "markbaker/matrix", + "version": "3.0.1", + "source": { + "type": "git", + "url": "https://github.com/MarkBaker/PHPMatrix.git", + "reference": "728434227fe21be27ff6d86621a1b13107a2562c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/MarkBaker/PHPMatrix/zipball/728434227fe21be27ff6d86621a1b13107a2562c", + "reference": "728434227fe21be27ff6d86621a1b13107a2562c", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "dev-master", + "phpcompatibility/php-compatibility": "^9.3", + "phpdocumentor/phpdocumentor": "2.*", + "phploc/phploc": "^4.0", + "phpmd/phpmd": "2.*", + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0", + "sebastian/phpcpd": "^4.0", + "squizlabs/php_codesniffer": "^3.7" + }, + "type": "library", + "autoload": { + "psr-4": { + "Matrix\\": "classes/src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mark Baker", + "email": "mark@demon-angel.eu" + } + ], + "description": "PHP Class for working with matrices", + "homepage": "https://github.com/MarkBaker/PHPMatrix", + "keywords": [ + "mathematics", + "matrix", + "vector" + ], + "support": { + "issues": "https://github.com/MarkBaker/PHPMatrix/issues", + "source": "https://github.com/MarkBaker/PHPMatrix/tree/3.0.1" + }, + "time": "2022-12-02T22:17:43+00:00" + }, { "name": "masterminds/html5", "version": "2.10.0", @@ -2694,6 +3176,114 @@ ], "time": "2024-11-21T10:36:35+00:00" }, + { + "name": "phpoffice/phpspreadsheet", + "version": "1.30.3", + "source": { + "type": "git", + "url": "https://github.com/PHPOffice/PhpSpreadsheet.git", + "reference": "d28d4827f934469e7ca4de940ab0abd0788d1e65" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/d28d4827f934469e7ca4de940ab0abd0788d1e65", + "reference": "d28d4827f934469e7ca4de940ab0abd0788d1e65", + "shasum": "" + }, + "require": { + "composer/pcre": "^1||^2||^3", + "ext-ctype": "*", + "ext-dom": "*", + "ext-fileinfo": "*", + "ext-gd": "*", + "ext-iconv": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-simplexml": "*", + "ext-xml": "*", + "ext-xmlreader": "*", + "ext-xmlwriter": "*", + "ext-zip": "*", + "ext-zlib": "*", + "ezyang/htmlpurifier": "^4.15", + "maennchen/zipstream-php": "^2.1 || ^3.0", + "markbaker/complex": "^3.0", + "markbaker/matrix": "^3.0", + "php": ">=7.4.0 <8.5.0", + "psr/simple-cache": "^1.0 || ^2.0 || ^3.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "dev-main", + "doctrine/instantiator": "^1.5", + "dompdf/dompdf": "^1.0 || ^2.0 || ^3.0", + "friendsofphp/php-cs-fixer": "^3.2", + "mitoteam/jpgraph": "^10.3", + "mpdf/mpdf": "^8.1.1", + "phpcompatibility/php-compatibility": "^9.3", + "phpstan/phpstan": "^1.1", + "phpstan/phpstan-phpunit": "^1.0", + "phpunit/phpunit": "^8.5 || ^9.0", + "squizlabs/php_codesniffer": "^3.7", + "tecnickcom/tcpdf": "^6.5" + }, + "suggest": { + "dompdf/dompdf": "Option for rendering PDF with PDF Writer", + "ext-intl": "PHP Internationalization Functions", + "mitoteam/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers", + "mpdf/mpdf": "Option for rendering PDF with PDF Writer", + "tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer" + }, + "type": "library", + "autoload": { + "psr-4": { + "PhpOffice\\PhpSpreadsheet\\": "src/PhpSpreadsheet" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Maarten Balliauw", + "homepage": "https://blog.maartenballiauw.be" + }, + { + "name": "Mark Baker", + "homepage": "https://markbakeruk.net" + }, + { + "name": "Franck Lefevre", + "homepage": "https://rootslabs.net" + }, + { + "name": "Erik Tilt" + }, + { + "name": "Adrien Crivelli" + }, + { + "name": "Owen Leibman" + } + ], + "description": "PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine", + "homepage": "https://github.com/PHPOffice/PhpSpreadsheet", + "keywords": [ + "OpenXML", + "excel", + "gnumeric", + "ods", + "php", + "spreadsheet", + "xls", + "xlsx" + ], + "support": { + "issues": "https://github.com/PHPOffice/PhpSpreadsheet/issues", + "source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/1.30.3" + }, + "time": "2026-04-10T03:47:16+00:00" + }, { "name": "phpoption/phpoption", "version": "1.9.5", diff --git a/project/resources/views/laporan/index.blade.php b/project/resources/views/laporan/index.blade.php new file mode 100644 index 0000000..7d4b536 --- /dev/null +++ b/project/resources/views/laporan/index.blade.php @@ -0,0 +1,261 @@ +@extends('layouts.dashboard') + +@section('title', 'Laporan Rekapitulasi') + +@section('content') + + +
+

Laporan PosSehat

+

Rekapitulasi data bulanan dan tahunan PosSehat.

+
+ +
+
+
+
+ + +
+
+ + +
+
+
+ + Excel + PDF +
+
+
+
+
+ +{{--
+
+
+
+
+
Total Balita

124

+
+
+
+
+
+
+
+
Ibu Hamil

45

+
+
+
+
+
+
+
+
Indikasi Stunting

8

+
+
+
+
+
+
+
+
Gizi Normal

116

+
+
+
+
--}} + +
+
+ + +
+
+
Rekapitulasi Pengukuran Balita
+
+ + + + + + + + + + + + + + @forelse ($laporanBalita as $index => $item) + + + + + + + + + + @empty + + + + @endforelse + +
NoNIKNama & Usia BalitaBB/TBZ-Score TB/UStatus GiziTanggal
{{ $index + 1 }}{{ $item->balita->nik ?? '-' }} +
{{ $item->balita->nama ?? '-' }}
+ {{ $item->usia_saat_ukur }} Bulan +
+ BB: {{ $item->berat_badan }}kg
+ TB: {{ $item->tinggi_badan }}cm +
{{ $item->zs_tbu }} + @php + $statusClass = match(strtolower($item->hasil)) { + 'normal' => 'bg-success', + 'pendek', 'sangat pendek' => 'bg-danger', + default => 'bg-warning' + }; + @endphp + + {{ strtoupper($item->hasil) }} + + +
{{ \Carbon\Carbon::parse($item->tanggal)->translatedFormat('d M Y') }}
+ {{ $item->petugas->nama ?? '-' }} +
Data pengukuran balita bulan ini kosong.
+
+
+
Rekapitulasi Pengukuran Ibu Hamil
+
+ + + + + + + + + + + + + @forelse ($laporanIbuHamil as $index => $item) + + + + + + + + + @empty + + + + @endforelse + +
NoIdentitas IbuUsia HamilFisik (BB/TB/LILA)IMT & StatusTanggal & Petugas
{{ $index + 1 }} +
{{ $item->ibuHamil->nama ?? '-' }}
+ {{ \Carbon\Carbon::parse($item->ibuHamil->tgl_lahir)->age }} Tahun +
{{ $item->usia_kehamilan ?? '0' }} Minggu
+
+ BB: {{ $item->berat_badan }}kg + TB: {{ $item->tinggi_badan }}cm
+ LILA: {{ $item->lila ?? '-' }} cm +
+
+
IMT: {{ $item->imt ?? '0' }}
+ @php + $statusIbu = match(strtolower($item->status_gizi ?? '')) { + 'gizi kurang' => 'bg-danger', + 'gizi normal', 'normal' => 'bg-success', + 'gizi lebih', 'obesitas' => 'bg-warning text-dark', + default => 'bg-secondary' + }; + @endphp + + {{ strtoupper($item->status_gizi ?? 'TIDAK ADA DATA') }} + +
+
{{ \Carbon\Carbon::parse($item->tanggal)->translatedFormat('d M Y') }}
+ {{ $item->petugas->nama ?? '-' }} +
Data pengukuran ibu hamil bulan ini kosong.
+
+
+
+ + + + +@endsection diff --git a/project/resources/views/laporan/pdf_balita.blade.php b/project/resources/views/laporan/pdf_balita.blade.php new file mode 100644 index 0000000..6e210a4 --- /dev/null +++ b/project/resources/views/laporan/pdf_balita.blade.php @@ -0,0 +1,51 @@ + + + + Laporan Balita + + + +
+

{{ $title }}

+

{{ $sub }}

+

Dicetak pada: {{ $date }}

+
+ + + + + + + + + + + + + + + @foreach($items as $index => $item) + + + + + + + + + + @endforeach + +
NoNama BalitaUsiaBB (kg)TB (cm)Z-Score TB/UHasil Stunting
{{ $index + 1 }}{{ $item->balita->nama }}{{ $item->usia_saat_ukur }} Bulan{{ $item->berat_badan }}{{ $item->tinggi_badan }}{{ $item->zs_tbu }}{{ strtoupper($item->hasil) }}
+ + diff --git a/project/resources/views/laporan/pdf_ibu_hamil.blade.php b/project/resources/views/laporan/pdf_ibu_hamil.blade.php new file mode 100644 index 0000000..e69de29 diff --git a/project/routes/web.php b/project/routes/web.php index feb6656..38946b7 100644 --- a/project/routes/web.php +++ b/project/routes/web.php @@ -82,7 +82,12 @@ Route::post('/cetak-balita/{id}', [PengukuranBalitaController::class, 'cetakPdf']); -Route::middleware(['auth','role:admin'])->group(function () { -Route::get('/laporan', [LaporanController::class, 'index'])->name('laporan'); +Route::middleware(['auth', 'role:admin'])->group(function () { + // Halaman Utama Laporan + Route::get('/laporan', [LaporanController::class, 'index'])->name('laporan.index'); + + // Route untuk Export (Pastikan name-nya sesuai dengan yang dipanggil di View/JS) + Route::get('/laporan/excel', [LaporanController::class, 'exportExcel'])->name('laporan.excel'); + Route::get('/laporan/pdf', [LaporanController::class, 'exportPdf'])->name('laporan.pdf'); });