From a74b8fa22fdf796b6ef1745ea1d80221a90c08eb Mon Sep 17 00:00:00 2001 From: Habibie Date: Tue, 21 Jul 2026 14:39:45 +0700 Subject: [PATCH 1/2] Lengkapi fungsi laporan desa aktif --- .../LaporanDesaAktifController.php | 58 ++++++++++++++++++- .../views/laporan/desa_aktif/cetak.blade.php | 8 ++- .../views/laporan/desa_aktif/index.blade.php | 51 ++++++++++++++++ routes/web.php | 3 +- 4 files changed, 116 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/LaporanDesaAktifController.php b/app/Http/Controllers/LaporanDesaAktifController.php index d13190951..bee22c1de 100644 --- a/app/Http/Controllers/LaporanDesaAktifController.php +++ b/app/Http/Controllers/LaporanDesaAktifController.php @@ -21,7 +21,7 @@ public function index(Request $request) return view('laporan.desa_aktif.index', compact('title')); } - public function cetak(Request $request) + protected function getDesaAktifData(Request $request): array { $filter = array_filter($request->all()); @@ -46,8 +46,62 @@ public function cetak(Request $request) $params['page[number]'] = 1; // Use ApiProxyService to get data - $response = $this->apiProxyService->get('desa-aktif', $params); + $response = $this->apiProxyService->get('desa-aktif', $params); $data = $response['data'] ?? []; + + return array_map(function ($item) { + $item['attributes']['status_aktif'] = $this->hitungStatusAktif($item['attributes'] ?? []); + + return $item; + }, $data); + } + + protected function hitungStatusAktif(array $attributes): string + { + $loginTerakhir = ! empty($attributes['login_terakhir']) && $attributes['login_terakhir'] !== '0000-00-00' && $attributes['login_terakhir'] !== '0000-00-00 00:00:00' + ? $attributes['login_terakhir'] : null; + $perubahanTerakhir = ! empty($attributes['perubahan_terakhir']) && $attributes['perubahan_terakhir'] !== '0000-00-00' && $attributes['perubahan_terakhir'] !== '0000-00-00 00:00:00' + ? $attributes['perubahan_terakhir'] : null; + + $batas = \Carbon\Carbon::now()->subDays(7); + + $loginAktif = false; + if ($loginTerakhir) { + try { + $loginAktif = \Carbon\Carbon::parse($loginTerakhir)->gte($batas); + } catch (\Exception $e) { + $loginAktif = false; + } + } + + $perubahanAktif = false; + if ($perubahanTerakhir) { + try { + $perubahanAktif = \Carbon\Carbon::parse($perubahanTerakhir)->gte($batas); + } catch (\Exception $e) { + $perubahanAktif = false; + } + } + + return ($loginAktif || $perubahanAktif) ? 'Aktif' : 'Tidak Aktif'; + } + + public function cetak(Request $request) + { + $data = $this->getDesaAktifData($request); + return view('laporan.desa_aktif.cetak', compact('data')); } + + public function exportExcel(Request $request) + { + $data = $this->getDesaAktifData($request); + $excel = true; + + $html = view('laporan.desa_aktif.cetak', compact('data', 'excel'))->render(); + + return response($html) + ->header('Content-Type', 'application/vnd.ms-excel') + ->header('Content-Disposition', 'attachment; filename="laporan-desa-aktif.xls"'); + } } diff --git a/resources/views/laporan/desa_aktif/cetak.blade.php b/resources/views/laporan/desa_aktif/cetak.blade.php index 829a65e68..0b1852783 100644 --- a/resources/views/laporan/desa_aktif/cetak.blade.php +++ b/resources/views/laporan/desa_aktif/cetak.blade.php @@ -9,26 +9,30 @@ No Desa + Kecamatan Artikel Terbit Jumlah Akses Jml Surat Penduduk + Status @if (empty($data)) - Tidak ada data + Tidak ada data @else @foreach ($data as $index => $item) {{ ((int) $index) + 1 }} {{ $item['attributes']['nama_desa'] ?? '' }} + {{ $item['attributes']['nama_kecamatan'] ?? '' }} {{ $item['attributes']['artikel'] ?? 0 }} {{ $item['attributes']['traffic'] ?? 0 }} {{ $item['attributes']['surat'] ?? 0 }} {{ $item['attributes']['penduduk'] ?? 0 }} + {{ $item['attributes']['status_aktif'] ?? 'Tidak Aktif' }} @endforeach @endif @@ -36,7 +40,9 @@ @stop @push('scripts') +@if (!isset($excel)) +@endif @endpush \ No newline at end of file diff --git a/resources/views/laporan/desa_aktif/index.blade.php b/resources/views/laporan/desa_aktif/index.blade.php index 1ed51ea6e..18af52e6d 100644 --- a/resources/views/laporan/desa_aktif/index.blade.php +++ b/resources/views/laporan/desa_aktif/index.blade.php @@ -15,6 +15,9 @@ +
@@ -23,10 +26,12 @@ class="fa fa-print"> No Desa + Kecamatan Artikel
Terbit Jumlah
Akses Jml Surat Penduduk + Status @@ -81,6 +86,9 @@ class="fa fa-print"> { data: 'attributes.nama_desa' }, + { + data: 'attributes.nama_kecamatan' + }, { data: 'attributes.artikel', className: 'text-center' @@ -97,12 +105,49 @@ className: 'text-center' data: 'attributes.penduduk', className: 'text-center' }, + { + data: null, + className: 'text-center' + }, ], columnDefs: [{ targets: 0, render: function(data, type, row, meta) { return meta.row + meta.settings._iDisplayStart + 1; } + }, + { + targets: 7, + render: function(data, type, row) { + const attr = row.attributes || {}; + const loginTerakhir = attr.login_terakhir; + const perubahanTerakhir = attr.perubahan_terakhir; + + const batasWaktu = new Date(); + batasWaktu.setDate(batasWaktu.getDate() - 7); + + let loginAktif = false; + if (loginTerakhir && loginTerakhir !== '0000-00-00' && loginTerakhir !== '0000-00-00 00:00:00') { + const tglLogin = new Date(loginTerakhir); + if (!isNaN(tglLogin.getTime()) && tglLogin >= batasWaktu) { + loginAktif = true; + } + } + + let perubahanAktif = false; + if (perubahanTerakhir && perubahanTerakhir !== '0000-00-00' && perubahanTerakhir !== '0000-00-00 00:00:00') { + const tglPerubahan = new Date(perubahanTerakhir); + if (!isNaN(tglPerubahan.getTime()) && tglPerubahan >= batasWaktu) { + perubahanAktif = true; + } + } + + const aktif = loginAktif || perubahanAktif; + + return aktif + ? 'Aktif' + : 'Tidak Aktif'; + } }], order: [ [1, 'asc'] @@ -115,6 +160,12 @@ className: 'text-center' window.open(url.href, '_blank'); }); + $('#export-excel').on('click', function() { + let url = new URL("{{ url('laporan/desa-aktif/export-excel') }}"); + url.searchParams.append("search", $('input[aria-controls="desaAktifTable"]').val() ?? ''); + window.open(url.href, '_blank'); + }); + }) @endpush \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 8d0c95aa1..aa5d0c5a2 100644 --- a/routes/web.php +++ b/routes/web.php @@ -286,7 +286,8 @@ Route::prefix('laporan')->group(function () { Route::prefix('desa-aktif')->group(function () { Route::get('', [App\Http\Controllers\LaporanDesaAktifController::class, 'index'])->name('laporan.desa-aktif.index'); - Route::get('cetak', [App\Http\Controllers\LaporanDesaAktifController::class, 'cetak'])->name('laporan.desa-aktif.cetak'); + Route::get('cetak', [App\Http\Controllers\LaporanDesaAktifController::class, 'cetak'])->name('laporan.desa-aktif.cetak'); + Route::get('export-excel', [App\Http\Controllers\LaporanDesaAktifController::class, 'exportExcel'])->name('laporan.desa-aktif.export-excel'); }); }); Route::prefix('data-presisi')->group(function () { From 12685e2964fcecc8df5485d12edd1702e522df55 Mon Sep 17 00:00:00 2001 From: Abah Roland <59082428+vickyrolanda@users.noreply.github.com> Date: Thu, 30 Jul 2026 11:26:30 +0700 Subject: [PATCH 2/2] [ci skip] memutahirkan catatan rilis --- catatan_rilis.md | 1 + 1 file changed, 1 insertion(+) diff --git a/catatan_rilis.md b/catatan_rilis.md index f214e9ae2..9d670ec61 100644 --- a/catatan_rilis.md +++ b/catatan_rilis.md @@ -6,6 +6,7 @@ Di rilis ini, versi 2607.0.0 berisi penambahan dan perbaikan yang diminta penggu 1. [#1094](https://github.com/OpenSID/OpenKab/issues/1094) Perbaikan pangan error data table. 2. [#1098](https://github.com/OpenSID/OpenKab/issues/1098) Perbaikan tampilan durasi lockout akun login (menit dan detik) serta koreksi perhitungan selisih waktu carbon. +3. [#1100](https://github.com/OpenSID/OpenKab/issues/1100) Lengkapi fungsi laporan desa aktif. #### Perubahan Teknis