fix search like in quick search and pbg data
This commit is contained in:
@@ -86,11 +86,25 @@ class RequestAssignmentController extends Controller
|
||||
// Apply search to base query
|
||||
if ($request->has('search') && !empty($request->get("search"))) {
|
||||
$search = $request->get('search');
|
||||
|
||||
// Search in pbg_task columns
|
||||
$baseQuery->where(function ($q) use ($search) {
|
||||
$q->where('name', 'LIKE', "%$search%")
|
||||
->orWhere('registration_number', 'LIKE', "%$search%")
|
||||
->orWhere('document_number', 'LIKE', "%$search%");
|
||||
->orWhere('owner_name', 'LIKE', "%$search%")
|
||||
->orWhere('address', 'LIKE', "%$search%");
|
||||
});
|
||||
|
||||
// If search term exists, also find UUIDs from name_building search
|
||||
$namesBuildingUuids = DB::table('pbg_task_details')
|
||||
->where('name_building', 'LIKE', "%$search%")
|
||||
->pluck('pbg_task_uid')
|
||||
->toArray();
|
||||
|
||||
// If we found matching name_building records, include them in the search
|
||||
if (!empty($namesBuildingUuids)) {
|
||||
$baseQuery->orWhereIn('uuid', $namesBuildingUuids);
|
||||
}
|
||||
}
|
||||
|
||||
// Get accurate count from base query (without relationships)
|
||||
@@ -98,6 +112,7 @@ class RequestAssignmentController extends Controller
|
||||
|
||||
// Clone the base query for data fetching with relationships
|
||||
$dataQuery = clone $baseQuery;
|
||||
|
||||
$dataQuery->with([
|
||||
'attachments' => function ($q) {
|
||||
$q->whereIn('pbg_type', ['berita_acara', 'bukti_bayar']);
|
||||
@@ -133,8 +148,8 @@ class RequestAssignmentController extends Controller
|
||||
// Get paginated results with relationships
|
||||
$paginatedResults = $dataQuery->paginate();
|
||||
|
||||
// Override the total count in pagination with accurate count
|
||||
$paginatedResults->withQueryString()->appends($request->query());
|
||||
// Append query parameters to pagination
|
||||
$paginatedResults->appends($request->query());
|
||||
|
||||
return RequestAssignmentResouce::collection($paginatedResults);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Http\Resources\TaskAssignmentsResource;
|
||||
use App\Models\PbgTask;
|
||||
use App\Models\TaskAssignment;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class QuickSearchController extends Controller
|
||||
{
|
||||
@@ -24,18 +25,24 @@ class QuickSearchController extends Controller
|
||||
public function quick_search_datatable(Request $request)
|
||||
{
|
||||
try {
|
||||
$query = PbgTask::orderBy('id', 'desc');
|
||||
$query = PbgTask::leftJoin('pbg_task_details', 'pbg_task.uuid', '=', 'pbg_task_details.pbg_task_uid')
|
||||
->select('pbg_task.*')
|
||||
->orderBy('pbg_task.id', 'desc');
|
||||
|
||||
if ($request->filled('search')) {
|
||||
$search = trim($request->get('search'));
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->where('registration_number', 'LIKE', "%$search%");
|
||||
$q->where('pbg_task.registration_number', 'LIKE', "%$search%")
|
||||
->orWhere('pbg_task.name', 'LIKE', "%$search%")
|
||||
->orWhere('pbg_task.owner_name', 'LIKE', "%$search%")
|
||||
->orWhere('pbg_task.address', 'LIKE', "%$search%")
|
||||
->orWhere('pbg_task_details.name_building', 'LIKE', "%$search%");
|
||||
});
|
||||
}
|
||||
|
||||
return response()->json($query->paginate());
|
||||
} catch (\Throwable $e) {
|
||||
\Log::error("Error fetching datatable data: " . $e->getMessage());
|
||||
Log::error("Error fetching datatable data: " . $e->getMessage());
|
||||
return response()->json([
|
||||
'message' => 'Terjadi kesalahan saat mengambil data.',
|
||||
'error' => $e->getMessage(),
|
||||
@@ -57,10 +64,10 @@ class QuickSearchController extends Controller
|
||||
|
||||
return view("quick-search.detail", compact("data", 'statusOptions', 'applicationTypes'));
|
||||
} catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) {
|
||||
\Log::warning("PbgTask with ID {$id} not found.");
|
||||
Log::warning("PbgTask with ID {$id} not found.");
|
||||
return redirect()->route('quick-search.index')->with('error', 'Data tidak ditemukan.');
|
||||
} catch (\Throwable $e) {
|
||||
\Log::error("Error in QuickSearchController@show: " . $e->getMessage());
|
||||
Log::error("Error in QuickSearchController@show: " . $e->getMessage());
|
||||
return response()->view('pages.404', [], 500); // Optional: create `resources/views/errors/500.blade.php`
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,20 +80,21 @@ class PbgTasks {
|
||||
const config = {
|
||||
columns: [
|
||||
"ID",
|
||||
{ name: "Name" },
|
||||
{ name: "Condition" },
|
||||
"Registration Number",
|
||||
"Document Number",
|
||||
{ name: "Address" },
|
||||
{ name: "Nama Pemohon" },
|
||||
{ name: "Nama Pemilik" },
|
||||
{ name: "Kondisi" },
|
||||
"Nomor Registrasi",
|
||||
"Nomor Dokumen",
|
||||
{ name: "Alamat" },
|
||||
"Status",
|
||||
"Function Type",
|
||||
"Consultation Type",
|
||||
{ name: "Due Date" },
|
||||
"Jenis Fungsi",
|
||||
"Jenis Konsultasi",
|
||||
{ name: "Tanggal Jatuh Tempo" },
|
||||
{
|
||||
name: "Retribution",
|
||||
name: "Retribusi",
|
||||
},
|
||||
{
|
||||
name: "Action",
|
||||
name: "Aksi",
|
||||
formatter: (cell) => {
|
||||
let canUpdate =
|
||||
tableContainer.getAttribute("data-updater") === "1";
|
||||
@@ -188,6 +189,7 @@ class PbgTasks {
|
||||
data.data.map((item) => [
|
||||
item.id,
|
||||
item.name,
|
||||
item.owner_name,
|
||||
item.condition,
|
||||
item.registration_number,
|
||||
item.document_number,
|
||||
|
||||
@@ -93,6 +93,56 @@
|
||||
])
|
||||
@endcomponent
|
||||
|
||||
<div class="square dia-top-right-bottom-left" style="top:80px;left:1050px;width:150px;height:150px;">
|
||||
</div>
|
||||
|
||||
<div class="square dia-top-right-bottom-left" style="top:200px;left:1080px;width:150px;height:70px;">
|
||||
</div>
|
||||
|
||||
<div style="position: absolute; top: 50px; left: 900px; width: 200px; height: 200px; ">
|
||||
<x-custom-circle title="RAB dan Gambar" size="medium" style="background-color: #da6635;float:left;margin-left:250px;"
|
||||
visible_data="true" data_id="business-rab-count" data_count="0"
|
||||
document_url="{{ route('web-spatial-plannings.index', ['menu_id' => $menus->where('url','web-spatial-plannings.index')->first()->id]) }}"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div style="position: absolute; top: 160px; left: 900px; width: 200px; height: 200px; ">
|
||||
<x-custom-circle title="KRK" size="medium" style="background-color: #da6635;float:left;margin-left:250px;"
|
||||
visible_data="true" data_id="business-krk-count" data_count="0"
|
||||
document_url="{{ route('web-spatial-plannings.index', ['menu_id' => $menus->where('url','web-spatial-plannings.index')->first()->id]) }}"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="square dia-top-right-bottom-left" style="top:390px;left:1050px;width:150px;height:70px;">
|
||||
</div>
|
||||
|
||||
<div class="square dia-top-right-bottom-left" style="top:490px;left:1070px;width:150px;height:10px;">
|
||||
</div>
|
||||
|
||||
<div class="square dia-top-left-bottom-right" style="top:490px;left:1030px;width:150px;height:120px;">
|
||||
</div>
|
||||
|
||||
<div style="position: absolute; top: 350px; left: 900px; width: 200px; height: 200px; ">
|
||||
<x-custom-circle title="RAB dan Gambar" size="medium" style="background-color: #da6635;float:left;margin-left:250px;"
|
||||
visible_data="true" data_id="non-business-rab-count" data_count="0"
|
||||
document_url="{{ route('web-spatial-plannings.index', ['menu_id' => $menus->where('url','web-spatial-plannings.index')->first()->id]) }}"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div style="position: absolute; top: 460px; left: 900px; width: 200px; height: 200px; ">
|
||||
<x-custom-circle title="KRK" size="medium" style="background-color: #da6635;float:left;margin-left:250px;"
|
||||
visible_data="true" data_id="non-business-krk-count" data_count="0"
|
||||
document_url="{{ route('web-spatial-plannings.index', ['menu_id' => $menus->where('url','web-spatial-plannings.index')->first()->id]) }}"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div style="position: absolute; top: 570px; left: 900px; width: 200px; height: 200px; ">
|
||||
<x-custom-circle title="DLH" size="medium" style="background-color: #da6635;float:left;margin-left:250px;"
|
||||
visible_data="true" data_id="non-business-dlh-count" data_count="0"
|
||||
document_url="{{ route('web-spatial-plannings.index', ['menu_id' => $menus->where('url','web-spatial-plannings.index')->first()->id]) }}"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@component('components.circle', [
|
||||
'document_title' => 'Usaha',
|
||||
'document_color' => '#5e7c89',
|
||||
|
||||
Reference in New Issue
Block a user