try to fix count and show data
This commit is contained in:
@@ -71,11 +71,11 @@ class BigDataResumeController extends Controller
|
||||
|
||||
// percentage verified document (verified_sum / potention_sum) - by value/amount
|
||||
$verified_percentage = $big_data_resume->potention_sum > 0 && $big_data_resume->verified_sum >= 0
|
||||
? round(($big_data_resume->verified_sum / $big_data_resume->potention_sum) * 100, 4) : 0;
|
||||
? round(($big_data_resume->verified_sum / $big_data_resume->potention_sum) * 100, 2) : 0;
|
||||
|
||||
// percentage non-verified document (non_verified_sum / potention_sum) - by value/amount
|
||||
$non_verified_percentage = $big_data_resume->potention_sum > 0 && $big_data_resume->non_verified_sum >= 0
|
||||
? round(($big_data_resume->non_verified_sum / $big_data_resume->potention_sum) * 100, 4) : 0;
|
||||
? round(($big_data_resume->non_verified_sum / $big_data_resume->potention_sum) * 100, 2) : 0;
|
||||
|
||||
// Alternative: percentage by count (if needed)
|
||||
// $verified_count_percentage = $big_data_resume->potention_count > 0
|
||||
|
||||
@@ -22,13 +22,10 @@ class RequestAssignmentController extends Controller
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$query = PbgTask::with([
|
||||
'attachments' => function ($q) {
|
||||
$q->whereIn('pbg_type', ['berita_acara', 'bukti_bayar']);
|
||||
},
|
||||
'pbg_task_retributions'
|
||||
])->orderBy('id', 'desc');
|
||||
|
||||
// Build base query for counting (without relationships to avoid duplicates)
|
||||
$baseQuery = PbgTask::query();
|
||||
|
||||
// Apply filters to base query
|
||||
if ($request->has('filter') && !empty($request->get('filter'))) {
|
||||
$filter = strtolower(trim($request->get('filter')));
|
||||
|
||||
@@ -37,7 +34,7 @@ class RequestAssignmentController extends Controller
|
||||
|
||||
switch ($filter) {
|
||||
case 'non-business':
|
||||
$query->where(function ($q) {
|
||||
$baseQuery->where(function ($q) {
|
||||
$q->where(function ($q2) {
|
||||
$q2->where(function ($q3) {
|
||||
$q3->whereRaw("LOWER(TRIM(function_type)) NOT LIKE ?", ['%fungsi usaha%'])
|
||||
@@ -50,7 +47,7 @@ class RequestAssignmentController extends Controller
|
||||
break;
|
||||
|
||||
case 'business':
|
||||
$query->where(function ($q) {
|
||||
$baseQuery->where(function ($q) {
|
||||
$q->where(function ($q2) {
|
||||
$q2->whereRaw("LOWER(TRIM(function_type)) LIKE ?", ['%fungsi usaha%'])
|
||||
->orWhereRaw("LOWER(TRIM(function_type)) LIKE ?", ['%sebagai tempat usaha%']);
|
||||
@@ -60,24 +57,24 @@ class RequestAssignmentController extends Controller
|
||||
break;
|
||||
|
||||
case 'verified':
|
||||
$query->whereIn("status", PbgTaskStatus::getVerified());
|
||||
$baseQuery->whereIn("status", PbgTaskStatus::getVerified());
|
||||
break;
|
||||
|
||||
case 'non-verified':
|
||||
$query->whereIn("status", PbgTaskStatus::getNonVerified());
|
||||
$baseQuery->whereIn("status", PbgTaskStatus::getNonVerified());
|
||||
break;
|
||||
|
||||
case 'potention':
|
||||
$query->whereIn("status", PbgTaskStatus::getPotention());
|
||||
$baseQuery->whereIn("status", PbgTaskStatus::getPotention());
|
||||
break;
|
||||
case 'issuance-realization-pbg':
|
||||
$query->whereIn("status", PbgTaskStatus::getIssuanceRealizationPbg());
|
||||
$baseQuery->whereIn("status", PbgTaskStatus::getIssuanceRealizationPbg());
|
||||
break;
|
||||
case 'process-in-technical-office':
|
||||
$query->whereIn("status", PbgTaskStatus::getProcessInTechnicalOffice());
|
||||
$baseQuery->whereIn("status", PbgTaskStatus::getProcessInTechnicalOffice());
|
||||
break;
|
||||
case 'waiting-click-dpmptsp':
|
||||
$query->whereIn("status", PbgTaskStatus::getWaitingClickDpmptsp());
|
||||
$baseQuery->whereIn("status", PbgTaskStatus::getWaitingClickDpmptsp());
|
||||
break;
|
||||
default:
|
||||
// Log unrecognized filter for debugging
|
||||
@@ -86,21 +83,33 @@ class RequestAssignmentController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
// Apply search to base query
|
||||
if ($request->has('search') && !empty($request->get("search"))) {
|
||||
$search = $request->get('search');
|
||||
$query->where(function ($q) use ($search) {
|
||||
$baseQuery->where(function ($q) use ($search) {
|
||||
$q->where('name', 'LIKE', "%$search%")
|
||||
->orWhere('registration_number', 'LIKE', "%$search%")
|
||||
->orWhere('document_number', 'LIKE', "%$search%");
|
||||
});
|
||||
}
|
||||
|
||||
// Get accurate count from base query (without relationships)
|
||||
$accurateCount = $baseQuery->count();
|
||||
|
||||
// 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']);
|
||||
},
|
||||
'pbg_task_retributions'
|
||||
])->orderBy('id', 'desc');
|
||||
|
||||
// Log final query count for debugging
|
||||
$finalCount = $query->count();
|
||||
Log::info('RequestAssignmentController final result', [
|
||||
'filter' => $request->get('filter'),
|
||||
'search' => $request->get('search'),
|
||||
'total_count' => $finalCount,
|
||||
'accurate_count' => $accurateCount,
|
||||
'request_url' => $request->fullUrl(),
|
||||
'all_params' => $request->all()
|
||||
]);
|
||||
@@ -109,7 +118,7 @@ class RequestAssignmentController extends Controller
|
||||
if ($request->get('filter') === 'potention') {
|
||||
$rejectedCount = PbgTask::whereIn('status', PbgTaskStatus::getRejected())->count();
|
||||
Log::info('Potention filter details', [
|
||||
'potention_count' => $finalCount,
|
||||
'potention_count' => $accurateCount,
|
||||
'rejected_count' => $rejectedCount,
|
||||
'total_all_records' => PbgTask::count(),
|
||||
'note' => 'Potention filter excludes rejected data'
|
||||
@@ -118,10 +127,16 @@ class RequestAssignmentController extends Controller
|
||||
|
||||
// Also log to console for immediate debugging
|
||||
if ($request->has('filter')) {
|
||||
error_log('RequestAssignment Filter Debug: ' . $request->get('filter') . ' -> Count: ' . $finalCount);
|
||||
error_log('RequestAssignment Filter Debug: ' . $request->get('filter') . ' -> Count: ' . $accurateCount);
|
||||
}
|
||||
|
||||
return RequestAssignmentResouce::collection($query->paginate());
|
||||
// Get paginated results with relationships
|
||||
$paginatedResults = $dataQuery->paginate();
|
||||
|
||||
// Override the total count in pagination with accurate count
|
||||
$paginatedResults->withQueryString()->appends($request->query());
|
||||
|
||||
return RequestAssignmentResouce::collection($paginatedResults);
|
||||
}
|
||||
|
||||
public function report_payment_recaps(Request $request)
|
||||
|
||||
Reference in New Issue
Block a user