feat(laporan): tambah filter status pada laporan permohonan
Menambahkan fitur filter berdasarkan status pada laporan permohonan: - Menambahkan filter status yang diambil dari model StatusPermohonan - Mengimplementasikan filter status pada controller LaporanPermohonanController - Mengimplementasikan filter status pada export LaporanPermohonanExport - Memastikan filter status berfungsi baik pada tampilan datatable maupun pada ekspor data
This commit is contained in:
@@ -36,6 +36,11 @@
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Apply status filter if provided
|
||||||
|
if ($this->request->has('status') && !empty($this->request->status)) {
|
||||||
|
$query->where('status', $this->request->status);
|
||||||
|
}
|
||||||
|
|
||||||
// Apply search filter if provided
|
// Apply search filter if provided
|
||||||
if ($this->request->has('search') && !empty($this->request->search)) {
|
if ($this->request->has('search') && !empty($this->request->search)) {
|
||||||
$search = $this->request->search;
|
$search = $this->request->search;
|
||||||
|
|||||||
@@ -50,6 +50,11 @@
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Filter by status if provided
|
||||||
|
if (isset($search->status) && !empty($search->status)) {
|
||||||
|
$query->where('status', $search->status);
|
||||||
|
}
|
||||||
|
|
||||||
if(isset($search->search)) {
|
if(isset($search->search)) {
|
||||||
|
|
||||||
$query->where(function ($q) use ($search) {
|
$query->where(function ($q) use ($search) {
|
||||||
|
|||||||
@@ -22,6 +22,14 @@
|
|||||||
<input placeholder="Tanggal Akhir" id="end_date" type="date">
|
<input placeholder="Tanggal Akhir" id="end_date" type="date">
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="flex">
|
||||||
|
<select class="select select-sm" id="status_filter">
|
||||||
|
<option value="">Semua Status</option>
|
||||||
|
@foreach(\Modules\Lpj\Models\StatusPermohonan::where('status', 1)->get() as $status)
|
||||||
|
<option value="{{ $status->slug }}">{{ $status->name }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
<button class="btn btn-sm btn-primary" id="filter_tanggal">Filter</button>
|
<button class="btn btn-sm btn-primary" id="filter_tanggal">Filter</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -104,6 +112,7 @@
|
|||||||
const searchInput = document.getElementById('search');
|
const searchInput = document.getElementById('search');
|
||||||
const startDateInput = document.getElementById('start_date');
|
const startDateInput = document.getElementById('start_date');
|
||||||
const endDateInput = document.getElementById('end_date');
|
const endDateInput = document.getElementById('end_date');
|
||||||
|
const statusFilter = document.getElementById('status_filter');
|
||||||
const filterTanggalButton = document.getElementById('filter_tanggal');
|
const filterTanggalButton = document.getElementById('filter_tanggal');
|
||||||
const exportBtn = document.getElementById('export-btn');
|
const exportBtn = document.getElementById('export-btn');
|
||||||
|
|
||||||
@@ -199,6 +208,7 @@
|
|||||||
let filters = {};
|
let filters = {};
|
||||||
const startDate = startDateInput.value;
|
const startDate = startDateInput.value;
|
||||||
const endDate = endDateInput.value;
|
const endDate = endDateInput.value;
|
||||||
|
const status = statusFilter.value;
|
||||||
|
|
||||||
if (searchInput.value) {
|
if (searchInput.value) {
|
||||||
filters.search = searchInput.value;
|
filters.search = searchInput.value;
|
||||||
@@ -212,6 +222,10 @@
|
|||||||
filters.end_date = endDate;
|
filters.end_date = endDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (status) {
|
||||||
|
filters.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
dataTable.search(filters);
|
dataTable.search(filters);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,6 +245,13 @@
|
|||||||
url.searchParams.delete('end_date');
|
url.searchParams.delete('end_date');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (statusFilter.value) {
|
||||||
|
url.searchParams.set('status', statusFilter.value);
|
||||||
|
} else {
|
||||||
|
url.searchParams.delete('status');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (searchInput.value) {
|
if (searchInput.value) {
|
||||||
url.searchParams.set('search', searchInput.value);
|
url.searchParams.set('search', searchInput.value);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user