Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIXED: Laporan penduduk dengan API database gabungan #1107

Merged
merged 7 commits into from
Feb 3, 2025
Next Next commit
CRATE: penyesuaian pada menu data - kependudukan - laporan penduduk
misarianto committed Jan 23, 2025
commit 7ff1b362f02749e685f768b4e3c41e22a0ebc0bf
5 changes: 5 additions & 0 deletions app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
@@ -204,4 +204,9 @@ protected function kirimTrack()
return;
}
}

protected function isDatabaseGabungan()
{
return ($this->settings['sinkronisasi_database_gabungan'] ?? null) === '1';
}
}
3 changes: 2 additions & 1 deletion app/Http/Controllers/Data/LaporanPendudukController.php
Original file line number Diff line number Diff line change
@@ -55,7 +55,8 @@ public function index(LaporanPenduduk $penduduk)
$page_description = 'Daftar Laporan Penduduk';
$list_desa = DataDesa::get();

return view('data.laporan-penduduk.index', compact('page_title', 'page_description', 'list_desa'));
$view = $this->isDatabaseGabungan() ? 'data.laporan-penduduk.gabungan.index' : 'data.laporan-penduduk.index';
return view($view, compact('page_title', 'page_description', 'list_desa'));
}

/**
128 changes: 128 additions & 0 deletions resources/views/data/laporan-penduduk/gabungan/index.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
@extends('layouts.dashboard_template')

@section('content')
<section class="content-header">
<h1>
{{ $page_title ?? 'Page Title' }}
<small>{{ $page_description ?? '' }}</small>
</h1>
<ol class="breadcrumb">
<li><a href="{{ route('dashboard') }}"><i class="fa fa-dashboard"></i> Dashboard</a></li>
<li class="active">{{ $page_title }}</li>
</ol>
</section>

<section class="content container-fluid">

@include('partials.flash_message')

<div class="box box-primary">

<div class="box-body">
<div class="table-responsive">
<table class="table table-bordered table-hover" id="datadesa-table">
<thead>
<tr>
<th style="max-width: 150px;">Aksi</th>
<th>Desa</th>
<th>Nama</th>
<th>Bulan</th>
<th>Tahun</th>
<th>Tgl. Lapor</th>
</tr>
</thead>
</table>
</div>
</div>
</div>
</section>
@endsection
@include('partials.asset_datatables')
@push('scripts')
<script type="text/javascript">
$(document).ready(function() {


var data = $('#datadesa-table').DataTable({
responsive: true,
processing: true,
serverSide: true,
ajax: {
url: `{{ $settings['api_server_database_gabungan'] ?? '' }}{{ '/api/v1/opendk/laporan-penduduk?'.http_build_query([
'kode_kecamatan' => str_replace('.','',$profil->kecamatan_id),
]) }}`,
headers: {
"Accept" : "application/ld+json",
"Content-Type": "text/json; charset=utf-8",
"Authorization": `Bearer {{ $settings['api_key_database_gabungan'] ?? '' }}`
},
method: 'get',
data: function(row) {
return {
"page[size]": row.length,
"page[number]": (row.start / row.length) + 1,
"filter[search]": row.search.value,
"sort": (row.order[0]?.dir === "asc" ? "" : "-") + row.columns[row.order[0]?.column]
?.name,
};
},
dataSrc: function(json) {
json.recordsTotal = json.meta.pagination.total
json.recordsFiltered = json.meta.pagination.total
return json.data
},
},
columns: [{
data: function(data) {
const _url = data.attributes.path === undefined ? `javascript:void(0)` : `asset('storage/laporan_penduduk')/${data.nama_file}`
const _disabled = data.attributes.path === undefined ? 'disabled' : ''
return `<a href="${_url}" title="Unduh" data-button="download" target="_blank">
<button type="button" class="btn btn-info btn-sm" style="width: 40px;" ${_disabled}>download</button>
</a>`;
},
searchable: false,
orderable: false
},
{
data: 'attributes.config.nama_desa',
render: function(data) {
return data ? data : '<span class="text-muted">Tidak Ada Nama Desa</span>';
}
},
{
data: 'attributes.judul',
render: function(data) {
return data ? data : '<span class="text-muted">Tidak Ada Nama</span>';
}
},
{
data: 'attributes.bulan',
name: 'bulan',
render: function(data) {
return data ? data : '<span class="text-muted">Tidak Ada Bulan</span>';
}
},
{
data: 'attributes.tahun',
name: 'tahun',
render: function(data) {
return data ? data : '<span class="text-muted">Tidak Ada Tahun</span>';
}
},
{
data: 'attributes.tanggal_lapor',
render: function(data) {
return data ? data : '<span class="text-muted">Tidak Ada Tanggal Lapor</span>';
}
},

],
order: [
[1, 'asc']
]
});

});
</script>
@include('forms.datatable-vertical')
@endpush