fix(laporan-penilai-jaminan): perbaikkan filter tanggal dan stype llaporan
This commit is contained in:
@@ -89,13 +89,16 @@ class LaporanPenilaiJaminanController extends Controller
|
|||||||
$userTeam = TeamsUsers::with('team')->firstWhere('user_id', $user->id);
|
$userTeam = TeamsUsers::with('team')->firstWhere('user_id', $user->id);
|
||||||
$regionId = $userTeam?->team->regions_id;
|
$regionId = $userTeam?->team->regions_id;
|
||||||
}
|
}
|
||||||
|
$paramsSearch = null;
|
||||||
|
// dd($startDate);
|
||||||
// Retrieve data from the database
|
// Retrieve data from the database
|
||||||
$query = Permohonan::query();
|
$query = Permohonan::query();
|
||||||
|
|
||||||
// Apply search filter if provided
|
// Apply search filter if provided
|
||||||
if ($request->has('search') && !empty($request->get('search'))) {
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
$search = $request->get('search');
|
$search = $request->get('search');
|
||||||
|
$paramsSearch = json_decode($search);
|
||||||
|
|
||||||
$query->where(function ($q) use ($search) {
|
$query->where(function ($q) use ($search) {
|
||||||
$q->where('nomor_registrasi', 'LIKE', '%' . $search . '%')
|
$q->where('nomor_registrasi', 'LIKE', '%' . $search . '%')
|
||||||
->orWhere('tanggal_permohonan', 'LIKE', '%' . $search . '%')
|
->orWhere('tanggal_permohonan', 'LIKE', '%' . $search . '%')
|
||||||
@@ -104,10 +107,14 @@ class LaporanPenilaiJaminanController extends Controller
|
|||||||
->orWhereRelation('tujuanPenilaian', 'name', 'LIKE', '%' . $search . '%')
|
->orWhereRelation('tujuanPenilaian', 'name', 'LIKE', '%' . $search . '%')
|
||||||
->orWhereRelation('branch', 'name', 'LIKE', '%' . $search . '%');
|
->orWhereRelation('branch', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
|
||||||
// Split search term by comma to allow multiple statuses
|
if (!empty($paramsSearch->tanggal_awal) && !empty($paramsSearch->tanggal_akhir)) {
|
||||||
|
$q->whereBetween('tanggal_permohonan', [$paramsSearch->tanggal_awal, $paramsSearch->tanggal_akhir]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$statusKeywords = explode(',', $search);
|
$statusKeywords = explode(',', $search);
|
||||||
foreach ($statusKeywords as $keyword) {
|
foreach ($statusKeywords as $keyword) {
|
||||||
$q->orWhere('status', 'LIKE', '%' . trim($keyword) . '%');
|
$q->orWhereRelation('penilai', 'type_penilai', 'LIKE', '%' . trim($keyword) . '%');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,45 +5,45 @@
|
|||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
@push('styles')
|
@push('styles')
|
||||||
<style>
|
<style>
|
||||||
.dropdown {
|
.dropdown {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dropdowns-content {
|
.dropdowns-content {
|
||||||
display: none;
|
display: none;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
background-color: white;
|
background-color: white;
|
||||||
min-width: 224px;
|
min-width: 224px;
|
||||||
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
|
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
/* Hilangkan jarak antara tombol dan dropdown */
|
/* Hilangkan jarak antara tombol dan dropdown */
|
||||||
}
|
}
|
||||||
|
|
||||||
.dropdown:hover .dropdowns-content {
|
.dropdown:hover .dropdowns-content {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Tambahkan hover untuk elemen dropdown agar tidak hilang */
|
/* Tambahkan hover untuk elemen dropdown agar tidak hilang */
|
||||||
.dropdowns-content:hover {
|
.dropdowns-content:hover {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dropdowns-content a {
|
.dropdowns-content a {
|
||||||
color: black;
|
color: black;
|
||||||
padding: 12px 16px;
|
padding: 12px 16px;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dropdowns-content a:hover {
|
.dropdowns-content a:hover {
|
||||||
background-color: #f1f1f1;
|
background-color: #f1f1f1;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@endpush
|
@endpush
|
||||||
<div class="w-full grid gap-5 lg:gap-7.5 mx-auto">
|
<div class="w-full grid gap-5 lg:gap-7.5 mx-auto">
|
||||||
<div class="card border border-agi-100 card-grid min-w-full" data-datatable="false" data-datatable-page-size="10"
|
<div class="card border border-agi-100 card-grid min-w-full" data-datatable="false" data-datatable-page-size="10"
|
||||||
data-datatable-state-save="false" id="laporan-penilai-jaminan-table"
|
data-datatable-state-save="false" id="laporan-penilai-jaminan-table"
|
||||||
@@ -76,9 +76,8 @@
|
|||||||
<div class="flex">
|
<div class="flex">
|
||||||
<!-- Custom dropdown for status filter -->
|
<!-- Custom dropdown for status filter -->
|
||||||
<div class="dropdown" data-dropdown="true" data-dropdown-trigger="click">
|
<div class="dropdown" data-dropdown="true" data-dropdown-trigger="click">
|
||||||
<button
|
<button class="dropdowns-toggle btn btn-light inline-flex justify-between w-full items-center">
|
||||||
class="dropdowns-toggle btn btn-light inline-flex justify-between w-full items-center">
|
Pilih Type Laporan
|
||||||
Pilih Status
|
|
||||||
<i class="ki-outline ki-down dropdown-open:hidden">
|
<i class="ki-outline ki-down dropdown-open:hidden">
|
||||||
</i>
|
</i>
|
||||||
<i class="ki-outline ki-up hidden dropdown-open:block">
|
<i class="ki-outline ki-up hidden dropdown-open:block">
|
||||||
@@ -96,9 +95,16 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<!-- Dinamis Status dari Backend -->
|
<!-- Dinamis Status dari Backend -->
|
||||||
@php
|
@php
|
||||||
$status_laporan = ['Standar', 'Sederhana', 'Memo', 'Resume', 'Call Report', 'RAP'];
|
$status_laporan = [
|
||||||
@endphp
|
'Standar',
|
||||||
|
'Sederhana',
|
||||||
|
'Memo',
|
||||||
|
'Resume',
|
||||||
|
'Call Report',
|
||||||
|
'RAP',
|
||||||
|
];
|
||||||
|
@endphp
|
||||||
@foreach ($status_laporan as $item)
|
@foreach ($status_laporan as $item)
|
||||||
<div class="menu-item">
|
<div class="menu-item">
|
||||||
<label class="menu-link flex items-center px-4 py-2 text-sm text-gray-700">
|
<label class="menu-link flex items-center px-4 py-2 text-sm text-gray-700">
|
||||||
@@ -216,10 +222,15 @@
|
|||||||
const dataTableOptions = {
|
const dataTableOptions = {
|
||||||
apiEndpoint: apiUrl,
|
apiEndpoint: apiUrl,
|
||||||
pageSize: 5,
|
pageSize: 5,
|
||||||
|
params: {
|
||||||
|
startDate: '',
|
||||||
|
endDate: '',
|
||||||
|
},
|
||||||
order: [{
|
order: [{
|
||||||
column: 'nomor_registrasi',
|
column: 'nomor_registrasi',
|
||||||
dir: 'asc'
|
dir: 'asc'
|
||||||
}],
|
}],
|
||||||
|
|
||||||
columns: {
|
columns: {
|
||||||
select: {
|
select: {
|
||||||
render: (item, data, context) => {
|
render: (item, data, context) => {
|
||||||
@@ -292,7 +303,8 @@
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
}
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let dataTable = new KTDataTable(element, dataTableOptions);
|
let dataTable = new KTDataTable(element, dataTableOptions);
|
||||||
@@ -312,14 +324,20 @@
|
|||||||
const tanggalAwal = tanggalAwalInput.value;
|
const tanggalAwal = tanggalAwalInput.value;
|
||||||
const tanggalAkhir = tanggalAkhirInput.value;
|
const tanggalAkhir = tanggalAkhirInput.value;
|
||||||
|
|
||||||
if (tanggalAwal && tanggalAkhir) {
|
let filters = {};
|
||||||
// Reload the table with date filters
|
if (searchInput.value) {
|
||||||
dataTable.setParameter('tanggal_awal', tanggalAwal);
|
filters.search = searchInput.value;
|
||||||
dataTable.setParameter('tanggal_akhir', tanggalAkhir);
|
|
||||||
dataTable.reload();
|
|
||||||
} else {
|
|
||||||
alert('Mohon isi tanggal awal dan tanggal akhir');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tanggalAwal) {
|
||||||
|
filters.tanggal_awal = tanggalAwal
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tanggalAkhir) {
|
||||||
|
filters.tanggal_akhir = tanggalAkhir
|
||||||
|
}
|
||||||
|
|
||||||
|
dataTable.search(filters);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Status filter functionality
|
// Status filter functionality
|
||||||
@@ -342,9 +360,11 @@
|
|||||||
.map(checkbox => checkbox.value);
|
.map(checkbox => checkbox.value);
|
||||||
|
|
||||||
if (selectedStatuses.length === 0) {
|
if (selectedStatuses.length === 0) {
|
||||||
dataTable.setParameter('status', null);
|
dataTable.search('');
|
||||||
|
console.log(selectedStatuses);
|
||||||
} else {
|
} else {
|
||||||
dataTable.setParameter('status', selectedStatuses);
|
dataTable.search(selectedStatuses.join(','), true);
|
||||||
|
console.log(selectedStatuses);
|
||||||
}
|
}
|
||||||
|
|
||||||
dataTable.reload();
|
dataTable.reload();
|
||||||
|
|||||||
Reference in New Issue
Block a user