fix non business where unit is more than one
This commit is contained in:
@@ -114,7 +114,7 @@ class RequestAssignmentController extends Controller
|
|||||||
// No additional filters, just return all valid records
|
// No additional filters, just return all valid records
|
||||||
break;
|
break;
|
||||||
case 'non-business':
|
case 'non-business':
|
||||||
// Match BigdataResume non-business logic exactly
|
// Non-business: function_type NOT LIKE usaha AND (unit IS NULL OR unit <= 1)
|
||||||
$query->where(function ($q) {
|
$query->where(function ($q) {
|
||||||
$q->where(function ($q2) {
|
$q->where(function ($q2) {
|
||||||
$q2->where(function ($q3) {
|
$q2->where(function ($q3) {
|
||||||
@@ -123,17 +123,40 @@ class RequestAssignmentController extends Controller
|
|||||||
})
|
})
|
||||||
->orWhereNull('function_type');
|
->orWhereNull('function_type');
|
||||||
})
|
})
|
||||||
->whereIn("status", PbgTaskStatus::getNonVerified());
|
->whereIn("status", PbgTaskStatus::getNonVerified())
|
||||||
|
// Additional condition: unit IS NULL OR unit <= 1
|
||||||
|
->where(function ($q3) {
|
||||||
|
$q3->whereDoesntHave('pbg_task_detail', function ($q4) {
|
||||||
|
$q4->where('unit', '>', 1);
|
||||||
|
})
|
||||||
|
->orWhereDoesntHave('pbg_task_detail');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'business':
|
case 'business':
|
||||||
// Match BigdataResume business logic exactly
|
// Business: function_type LIKE usaha OR (non-business with unit > 1)
|
||||||
$query->where(function ($q) {
|
$query->where(function ($q) {
|
||||||
$q->where(function ($q2) {
|
$q->where(function ($q2) {
|
||||||
$q2->whereRaw("LOWER(TRIM(function_type)) LIKE ?", ['%fungsi usaha%'])
|
// Traditional business: function_type LIKE usaha
|
||||||
|
$q2->where(function ($q3) {
|
||||||
|
$q3->whereRaw("LOWER(TRIM(function_type)) LIKE ?", ['%fungsi usaha%'])
|
||||||
->orWhereRaw("LOWER(TRIM(function_type)) LIKE ?", ['%sebagai tempat usaha%']);
|
->orWhereRaw("LOWER(TRIM(function_type)) LIKE ?", ['%sebagai tempat usaha%']);
|
||||||
})
|
})
|
||||||
|
// OR non-business with unit > 1 (becomes business)
|
||||||
|
->orWhere(function ($q3) {
|
||||||
|
$q3->where(function ($q4) {
|
||||||
|
$q4->where(function ($q5) {
|
||||||
|
$q5->whereRaw("LOWER(TRIM(function_type)) NOT LIKE ?", ['%fungsi usaha%'])
|
||||||
|
->whereRaw("LOWER(TRIM(function_type)) NOT LIKE ?", ['%sebagai tempat usaha%']);
|
||||||
|
})
|
||||||
|
->orWhereNull('function_type');
|
||||||
|
})
|
||||||
|
->whereHas('pbg_task_detail', function ($q4) {
|
||||||
|
$q4->where('unit', '>', 1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
->whereIn("status", PbgTaskStatus::getNonVerified());
|
->whereIn("status", PbgTaskStatus::getNonVerified());
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
@@ -169,7 +192,7 @@ class RequestAssignmentController extends Controller
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'non-business-rab':
|
case 'non-business-rab':
|
||||||
// Non-business tasks that have RAB documents (data_type = 3) with at least one status != 1
|
// Non-business tasks: function_type NOT LIKE usaha AND (unit IS NULL OR unit <= 1)
|
||||||
$query->where(function ($q) {
|
$query->where(function ($q) {
|
||||||
$q->where(function ($q2) {
|
$q->where(function ($q2) {
|
||||||
$q2->where(function ($q3) {
|
$q2->where(function ($q3) {
|
||||||
@@ -178,7 +201,14 @@ class RequestAssignmentController extends Controller
|
|||||||
})
|
})
|
||||||
->orWhereNull('function_type');
|
->orWhereNull('function_type');
|
||||||
})
|
})
|
||||||
->whereIn("status", PbgTaskStatus::getNonVerified());
|
->whereIn("status", PbgTaskStatus::getNonVerified())
|
||||||
|
// Additional condition: unit IS NULL OR unit <= 1
|
||||||
|
->where(function ($q3) {
|
||||||
|
$q3->whereDoesntHave('pbg_task_detail', function ($q4) {
|
||||||
|
$q4->where('unit', '>', 1);
|
||||||
|
})
|
||||||
|
->orWhereDoesntHave('pbg_task_detail');
|
||||||
|
});
|
||||||
})
|
})
|
||||||
->whereExists(function ($query) {
|
->whereExists(function ($query) {
|
||||||
$query->select(DB::raw(1))
|
$query->select(DB::raw(1))
|
||||||
@@ -190,7 +220,7 @@ class RequestAssignmentController extends Controller
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'non-business-krk':
|
case 'non-business-krk':
|
||||||
// Non-business tasks that have KRK documents (data_type = 2) with at least one status != 1
|
// Non-business tasks: function_type NOT LIKE usaha AND (unit IS NULL OR unit <= 1)
|
||||||
$query->where(function ($q) {
|
$query->where(function ($q) {
|
||||||
$q->where(function ($q2) {
|
$q->where(function ($q2) {
|
||||||
$q2->where(function ($q3) {
|
$q2->where(function ($q3) {
|
||||||
@@ -199,7 +229,14 @@ class RequestAssignmentController extends Controller
|
|||||||
})
|
})
|
||||||
->orWhereNull('function_type');
|
->orWhereNull('function_type');
|
||||||
})
|
})
|
||||||
->whereIn("status", PbgTaskStatus::getNonVerified());
|
->whereIn("status", PbgTaskStatus::getNonVerified())
|
||||||
|
// Additional condition: unit IS NULL OR unit <= 1
|
||||||
|
->where(function ($q3) {
|
||||||
|
$q3->whereDoesntHave('pbg_task_detail', function ($q4) {
|
||||||
|
$q4->where('unit', '>', 1);
|
||||||
|
})
|
||||||
|
->orWhereDoesntHave('pbg_task_detail');
|
||||||
|
});
|
||||||
})
|
})
|
||||||
->whereExists(function ($query) {
|
->whereExists(function ($query) {
|
||||||
$query->select(DB::raw(1))
|
$query->select(DB::raw(1))
|
||||||
@@ -211,12 +248,28 @@ class RequestAssignmentController extends Controller
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'business-rab':
|
case 'business-rab':
|
||||||
// Business tasks that have RAB documents (data_type = 3) with at least one status != 1
|
// Business tasks: function_type LIKE usaha OR (non-business with unit > 1)
|
||||||
$query->where(function ($q) {
|
$query->where(function ($q) {
|
||||||
$q->where(function ($q2) {
|
$q->where(function ($q2) {
|
||||||
$q2->whereRaw("LOWER(TRIM(function_type)) LIKE ?", ['%fungsi usaha%'])
|
// Traditional business: function_type LIKE usaha
|
||||||
|
$q2->where(function ($q3) {
|
||||||
|
$q3->whereRaw("LOWER(TRIM(function_type)) LIKE ?", ['%fungsi usaha%'])
|
||||||
->orWhereRaw("LOWER(TRIM(function_type)) LIKE ?", ['%sebagai tempat usaha%']);
|
->orWhereRaw("LOWER(TRIM(function_type)) LIKE ?", ['%sebagai tempat usaha%']);
|
||||||
})
|
})
|
||||||
|
// OR non-business with unit > 1 (becomes business)
|
||||||
|
->orWhere(function ($q3) {
|
||||||
|
$q3->where(function ($q4) {
|
||||||
|
$q4->where(function ($q5) {
|
||||||
|
$q5->whereRaw("LOWER(TRIM(function_type)) NOT LIKE ?", ['%fungsi usaha%'])
|
||||||
|
->whereRaw("LOWER(TRIM(function_type)) NOT LIKE ?", ['%sebagai tempat usaha%']);
|
||||||
|
})
|
||||||
|
->orWhereNull('function_type');
|
||||||
|
})
|
||||||
|
->whereHas('pbg_task_detail', function ($q4) {
|
||||||
|
$q4->where('unit', '>', 1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
->whereIn("status", PbgTaskStatus::getNonVerified());
|
->whereIn("status", PbgTaskStatus::getNonVerified());
|
||||||
})
|
})
|
||||||
->whereExists(function ($query) {
|
->whereExists(function ($query) {
|
||||||
@@ -229,12 +282,28 @@ class RequestAssignmentController extends Controller
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'business-krk':
|
case 'business-krk':
|
||||||
// Business tasks that have KRK documents (data_type = 2) with at least one status != 1
|
// Business tasks: function_type LIKE usaha OR (non-business with unit > 1)
|
||||||
$query->where(function ($q) {
|
$query->where(function ($q) {
|
||||||
$q->where(function ($q2) {
|
$q->where(function ($q2) {
|
||||||
$q2->whereRaw("LOWER(TRIM(function_type)) LIKE ?", ['%fungsi usaha%'])
|
// Traditional business: function_type LIKE usaha
|
||||||
|
$q2->where(function ($q3) {
|
||||||
|
$q3->whereRaw("LOWER(TRIM(function_type)) LIKE ?", ['%fungsi usaha%'])
|
||||||
->orWhereRaw("LOWER(TRIM(function_type)) LIKE ?", ['%sebagai tempat usaha%']);
|
->orWhereRaw("LOWER(TRIM(function_type)) LIKE ?", ['%sebagai tempat usaha%']);
|
||||||
})
|
})
|
||||||
|
// OR non-business with unit > 1 (becomes business)
|
||||||
|
->orWhere(function ($q3) {
|
||||||
|
$q3->where(function ($q4) {
|
||||||
|
$q4->where(function ($q5) {
|
||||||
|
$q5->whereRaw("LOWER(TRIM(function_type)) NOT LIKE ?", ['%fungsi usaha%'])
|
||||||
|
->whereRaw("LOWER(TRIM(function_type)) NOT LIKE ?", ['%sebagai tempat usaha%']);
|
||||||
|
})
|
||||||
|
->orWhereNull('function_type');
|
||||||
|
})
|
||||||
|
->whereHas('pbg_task_detail', function ($q4) {
|
||||||
|
$q4->where('unit', '>', 1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
->whereIn("status", PbgTaskStatus::getNonVerified());
|
->whereIn("status", PbgTaskStatus::getNonVerified());
|
||||||
})
|
})
|
||||||
->whereExists(function ($query) {
|
->whereExists(function ($query) {
|
||||||
@@ -247,12 +316,28 @@ class RequestAssignmentController extends Controller
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'business-dlh':
|
case 'business-dlh':
|
||||||
// Business tasks that have DLH documents (data_type = 5) with at least one status != 1
|
// Business tasks: function_type LIKE usaha OR (non-business with unit > 1)
|
||||||
$query->where(function ($q) {
|
$query->where(function ($q) {
|
||||||
$q->where(function ($q2) {
|
$q->where(function ($q2) {
|
||||||
$q2->whereRaw("LOWER(TRIM(function_type)) LIKE ?", ['%fungsi usaha%'])
|
// Traditional business: function_type LIKE usaha
|
||||||
|
$q2->where(function ($q3) {
|
||||||
|
$q3->whereRaw("LOWER(TRIM(function_type)) LIKE ?", ['%fungsi usaha%'])
|
||||||
->orWhereRaw("LOWER(TRIM(function_type)) LIKE ?", ['%sebagai tempat usaha%']);
|
->orWhereRaw("LOWER(TRIM(function_type)) LIKE ?", ['%sebagai tempat usaha%']);
|
||||||
})
|
})
|
||||||
|
// OR non-business with unit > 1 (becomes business)
|
||||||
|
->orWhere(function ($q3) {
|
||||||
|
$q3->where(function ($q4) {
|
||||||
|
$q4->where(function ($q5) {
|
||||||
|
$q5->whereRaw("LOWER(TRIM(function_type)) NOT LIKE ?", ['%fungsi usaha%'])
|
||||||
|
->whereRaw("LOWER(TRIM(function_type)) NOT LIKE ?", ['%sebagai tempat usaha%']);
|
||||||
|
})
|
||||||
|
->orWhereNull('function_type');
|
||||||
|
})
|
||||||
|
->whereHas('pbg_task_detail', function ($q4) {
|
||||||
|
$q4->where('unit', '>', 1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
->whereIn("status", PbgTaskStatus::getNonVerified());
|
->whereIn("status", PbgTaskStatus::getNonVerified());
|
||||||
})
|
})
|
||||||
->whereExists(function ($query) {
|
->whereExists(function ($query) {
|
||||||
@@ -285,7 +370,7 @@ class RequestAssignmentController extends Controller
|
|||||||
});
|
});
|
||||||
|
|
||||||
// If search term exists, also find UUIDs from name_building search
|
// If search term exists, also find UUIDs from name_building search
|
||||||
$namesBuildingUuids = DB::table('pbg_task_details')
|
$namesBuildingUuids = DB::table('pbg_task_detail')
|
||||||
->where('name_building', 'LIKE', "%$search%")
|
->where('name_building', 'LIKE', "%$search%")
|
||||||
->pluck('pbg_task_uid')
|
->pluck('pbg_task_uid')
|
||||||
->toArray();
|
->toArray();
|
||||||
@@ -429,9 +514,25 @@ class RequestAssignmentController extends Controller
|
|||||||
case 'business':
|
case 'business':
|
||||||
$bigdataResumeCount = PbgTask::where(function ($q) {
|
$bigdataResumeCount = PbgTask::where(function ($q) {
|
||||||
$q->where(function ($q2) {
|
$q->where(function ($q2) {
|
||||||
$q2->whereRaw("LOWER(TRIM(function_type)) LIKE ?", ['%fungsi usaha%'])
|
// Traditional business: function_type LIKE usaha
|
||||||
|
$q2->where(function ($q3) {
|
||||||
|
$q3->whereRaw("LOWER(TRIM(function_type)) LIKE ?", ['%fungsi usaha%'])
|
||||||
->orWhereRaw("LOWER(TRIM(function_type)) LIKE ?", ['%sebagai tempat usaha%']);
|
->orWhereRaw("LOWER(TRIM(function_type)) LIKE ?", ['%sebagai tempat usaha%']);
|
||||||
})
|
})
|
||||||
|
// OR non-business with unit > 1 (becomes business)
|
||||||
|
->orWhere(function ($q3) {
|
||||||
|
$q3->where(function ($q4) {
|
||||||
|
$q4->where(function ($q5) {
|
||||||
|
$q5->whereRaw("LOWER(TRIM(function_type)) NOT LIKE ?", ['%fungsi usaha%'])
|
||||||
|
->whereRaw("LOWER(TRIM(function_type)) NOT LIKE ?", ['%sebagai tempat usaha%']);
|
||||||
|
})
|
||||||
|
->orWhereNull('function_type');
|
||||||
|
})
|
||||||
|
->whereHas('pbg_task_detail', function ($q4) {
|
||||||
|
$q4->where('unit', '>', 1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
->whereIn("status", PbgTaskStatus::getNonVerified());
|
->whereIn("status", PbgTaskStatus::getNonVerified());
|
||||||
})
|
})
|
||||||
->where('is_valid', true)
|
->where('is_valid', true)
|
||||||
@@ -448,7 +549,14 @@ class RequestAssignmentController extends Controller
|
|||||||
})
|
})
|
||||||
->orWhereNull('function_type');
|
->orWhereNull('function_type');
|
||||||
})
|
})
|
||||||
->whereIn("status", PbgTaskStatus::getNonVerified());
|
->whereIn("status", PbgTaskStatus::getNonVerified())
|
||||||
|
// Additional condition: unit IS NULL OR unit <= 1
|
||||||
|
->where(function ($q3) {
|
||||||
|
$q3->whereDoesntHave('pbg_task_detail', function ($q4) {
|
||||||
|
$q4->where('unit', '>', 1);
|
||||||
|
})
|
||||||
|
->orWhereDoesntHave('pbg_task_detail');
|
||||||
|
});
|
||||||
})
|
})
|
||||||
->where('is_valid', true)
|
->where('is_valid', true)
|
||||||
->whereYear('task_created_at', $year)
|
->whereYear('task_created_at', $year)
|
||||||
|
|||||||
@@ -73,19 +73,35 @@ class BigdataResume extends Model
|
|||||||
->whereYear('task_created_at', $year)
|
->whereYear('task_created_at', $year)
|
||||||
->count();
|
->count();
|
||||||
|
|
||||||
// Business count (same logic as RequestAssignmentController)
|
// Business count: function_type LIKE usaha OR (non-business with unit > 1)
|
||||||
$business_count = PbgTask::where(function ($q) {
|
$business_count = PbgTask::where(function ($q) {
|
||||||
$q->where(function ($q2) {
|
$q->where(function ($q2) {
|
||||||
$q2->whereRaw("LOWER(TRIM(function_type)) LIKE ?", ['%fungsi usaha%'])
|
// Traditional business: function_type LIKE usaha
|
||||||
|
$q2->where(function ($q3) {
|
||||||
|
$q3->whereRaw("LOWER(TRIM(function_type)) LIKE ?", ['%fungsi usaha%'])
|
||||||
->orWhereRaw("LOWER(TRIM(function_type)) LIKE ?", ['%sebagai tempat usaha%']);
|
->orWhereRaw("LOWER(TRIM(function_type)) LIKE ?", ['%sebagai tempat usaha%']);
|
||||||
})
|
})
|
||||||
|
// OR non-business with unit > 1 (becomes business)
|
||||||
|
->orWhere(function ($q3) {
|
||||||
|
$q3->where(function ($q4) {
|
||||||
|
$q4->where(function ($q5) {
|
||||||
|
$q5->whereRaw("LOWER(TRIM(function_type)) NOT LIKE ?", ['%fungsi usaha%'])
|
||||||
|
->whereRaw("LOWER(TRIM(function_type)) NOT LIKE ?", ['%sebagai tempat usaha%']);
|
||||||
|
})
|
||||||
|
->orWhereNull('function_type');
|
||||||
|
})
|
||||||
|
->whereHas('pbg_task_detail', function ($q4) {
|
||||||
|
$q4->where('unit', '>', 1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
->whereIn("status", PbgTaskStatus::getNonVerified());
|
->whereIn("status", PbgTaskStatus::getNonVerified());
|
||||||
})
|
})
|
||||||
->where('is_valid', true)
|
->where('is_valid', true)
|
||||||
->whereYear('task_created_at', $year)
|
->whereYear('task_created_at', $year)
|
||||||
->count();
|
->count();
|
||||||
|
|
||||||
// Non-business count (same logic as RequestAssignmentController)
|
// Non-business count: function_type NOT LIKE usaha AND (unit IS NULL OR unit <= 1)
|
||||||
$non_business_count = PbgTask::where(function ($q) {
|
$non_business_count = PbgTask::where(function ($q) {
|
||||||
$q->where(function ($q2) {
|
$q->where(function ($q2) {
|
||||||
$q2->where(function ($q3) {
|
$q2->where(function ($q3) {
|
||||||
@@ -94,7 +110,14 @@ class BigdataResume extends Model
|
|||||||
})
|
})
|
||||||
->orWhereNull('function_type');
|
->orWhereNull('function_type');
|
||||||
})
|
})
|
||||||
->whereIn("status", PbgTaskStatus::getNonVerified());
|
->whereIn("status", PbgTaskStatus::getNonVerified())
|
||||||
|
// Additional condition: unit IS NULL OR unit <= 1
|
||||||
|
->where(function ($q3) {
|
||||||
|
$q3->whereDoesntHave('pbg_task_detail', function ($q4) {
|
||||||
|
$q4->where('unit', '>', 1);
|
||||||
|
})
|
||||||
|
->orWhereDoesntHave('pbg_task_detail');
|
||||||
|
});
|
||||||
})
|
})
|
||||||
->where('is_valid', true)
|
->where('is_valid', true)
|
||||||
->whereYear('task_created_at', $year)
|
->whereYear('task_created_at', $year)
|
||||||
@@ -271,8 +294,6 @@ class BigdataResume extends Model
|
|||||||
')
|
')
|
||||||
->value('total_count') ?? 0;
|
->value('total_count') ?? 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Debug: Check if there are non-verified tasks and their retribution data
|
// Debug: Check if there are non-verified tasks and their retribution data
|
||||||
$debug_non_verified = PbgTask::whereIn('status', PbgTaskStatus::getNonVerified())
|
$debug_non_verified = PbgTask::whereIn('status', PbgTaskStatus::getNonVerified())
|
||||||
->where('is_valid', true)
|
->where('is_valid', true)
|
||||||
|
|||||||
@@ -535,7 +535,9 @@ class BigData {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
initChartNonBusinessDLH() {
|
initChartNonBusinessDLH() {
|
||||||
document.querySelectorAll("#business-dlh-count").forEach((element) => {
|
document
|
||||||
|
.querySelectorAll("#non-business-dlh-count")
|
||||||
|
.forEach((element) => {
|
||||||
const count = this.safeGet(
|
const count = this.safeGet(
|
||||||
this.resumeBigData,
|
this.resumeBigData,
|
||||||
"business_dlh_count",
|
"business_dlh_count",
|
||||||
|
|||||||
Reference in New Issue
Block a user