update 2025-06-02
This commit is contained in:
@@ -12,42 +12,47 @@ class DashboardController extends Controller
|
||||
use GlobalApiResponse;
|
||||
|
||||
public function businnessDocument(Request $request){
|
||||
$businessData = DB::table('pbg_task')
|
||||
->leftJoin('pbg_task_retributions', 'pbg_task.uuid', '=', 'pbg_task_retributions.pbg_task_uid')
|
||||
->select(
|
||||
DB::raw('COUNT(DISTINCT pbg_task.id) as task_count'),
|
||||
DB::raw('SUM(pbg_task_retributions.nilai_retribusi_bangunan) as total_retribution')
|
||||
)
|
||||
$query = DB::table('pbg_task AS pt')
|
||||
->leftJoin('pbg_task_google_sheet AS ptgs', 'pt.registration_number', '=', 'ptgs.no_registrasi')
|
||||
->leftJoin('pbg_task_retributions AS ptr', 'pt.uuid', '=', 'ptr.pbg_task_uid') // Join ke pbg_task_retributions
|
||||
->where(function ($query) {
|
||||
$query->where("pbg_task.function_type", "LIKE", "sebagai tempat usaha%");
|
||||
$query->whereRaw('LOWER(TRIM(ptgs.status_verifikasi)) != ?', [strtolower(trim('Selesai Verifikasi'))])
|
||||
->orWhereNull('ptgs.status_verifikasi');
|
||||
})
|
||||
->where(function ($query) {
|
||||
$query->whereRaw('LOWER(TRIM(pt.function_type)) = ?', [strtolower(trim('Sebagai Tempat Usaha'))]);
|
||||
})
|
||||
->selectRaw('COUNT(pt.id) AS total_data,
|
||||
SUM(ptr.nilai_retribusi_bangunan) AS total_retribution') // Menambahkan SUM dari pbg_task_retributions
|
||||
->first();
|
||||
$taskCount = $businessData->task_count;
|
||||
$taskTotal = $businessData->total_retribution;
|
||||
$taskCount = $query->total_data;
|
||||
$taskTotal = $query->total_retribution ?? 0;
|
||||
$result = [
|
||||
"count" => $taskCount,
|
||||
"series" => [$taskCount],
|
||||
"total" => $taskTotal
|
||||
];
|
||||
return $this->resSuccess($result);
|
||||
}
|
||||
public function nonBusinnessDocument(Request $request){
|
||||
$businessData = DB::table('pbg_task')
|
||||
->leftJoin('pbg_task_retributions', 'pbg_task.uuid', '=', 'pbg_task_retributions.pbg_task_uid')
|
||||
->select(
|
||||
DB::raw('COUNT(DISTINCT pbg_task.id) as task_count'),
|
||||
DB::raw('SUM(pbg_task_retributions.nilai_retribusi_bangunan) as total_retribution')
|
||||
)
|
||||
|
||||
$query = DB::table('pbg_task AS pt')
|
||||
->leftJoin('pbg_task_google_sheet AS ptgs', 'pt.registration_number', '=', 'ptgs.no_registrasi')
|
||||
->leftJoin('pbg_task_retributions AS ptr', 'pt.uuid', '=', 'ptr.pbg_task_uid') // Join ke pbg_task_retributions
|
||||
->where(function ($query) {
|
||||
$query->where("pbg_task.function_type", "NOT LIKE", "sebagai tempat usaha%")
|
||||
->orWhereNull("pbg_task.function_type");
|
||||
$query->whereRaw('LOWER(TRIM(ptgs.status_verifikasi)) != ?', [strtolower(trim('Selesai Verifikasi'))])
|
||||
->orWhereNull('ptgs.status_verifikasi'); // Include NULL values
|
||||
})
|
||||
->where(function ($query) {
|
||||
$query->whereRaw('LOWER(TRIM(pt.function_type)) != ?', [strtolower(trim('Sebagai Tempat Usaha'))])
|
||||
->orWhereNull('pt.function_type'); // Include NULL values
|
||||
})
|
||||
->selectRaw('COUNT(pt.id) AS total_data,
|
||||
SUM(ptr.nilai_retribusi_bangunan) AS total_retribution') // Menambahkan SUM dari pbg_task_retributions
|
||||
->first();
|
||||
$taskCount = $businessData->task_count;
|
||||
$taskTotal = $businessData->total_retribution;
|
||||
$taskCount = $query->total_data;
|
||||
$taskTotal = $query->total_retribution ?? 0;
|
||||
$result = [
|
||||
"count" => $taskCount,
|
||||
"series" => [$taskCount],
|
||||
"total" => $taskTotal
|
||||
];
|
||||
return $this->resSuccess($result);
|
||||
@@ -64,12 +69,54 @@ class DashboardController extends Controller
|
||||
$taskTotal = $query->total_retribution;
|
||||
$result = [
|
||||
"count" => $taskCount,
|
||||
"series" => [$taskCount],
|
||||
"total" => $taskTotal
|
||||
];
|
||||
return $this->resSuccess($result);
|
||||
}
|
||||
|
||||
public function verificationDocuments(){
|
||||
$query = DB::table('pbg_task AS pt')
|
||||
->leftJoin('pbg_task_google_sheet AS ptgs', 'pt.registration_number', '=', 'ptgs.no_registrasi')
|
||||
->leftJoin('pbg_task_retributions AS ptr', 'pt.uuid', '=', 'ptr.pbg_task_uid') // Menambahkan join ke pbg_task_retributions
|
||||
->whereRaw('LOWER(TRIM(ptgs.status_verifikasi)) = ?', [strtolower(trim('Selesai Verifikasi'))])
|
||||
->selectRaw('COUNT(pt.id) AS total_data,
|
||||
SUM(ptr.nilai_retribusi_bangunan) AS total_retribution')
|
||||
->first();
|
||||
|
||||
$taskCount = $query->total_data;
|
||||
$taskTotal = $query->total_retribution;
|
||||
|
||||
$result = [
|
||||
"count"=> $taskCount,
|
||||
"total"=> $taskTotal
|
||||
];
|
||||
|
||||
return $this->resSuccess($result);
|
||||
}
|
||||
|
||||
public function nonVerificationDocuments(){
|
||||
$query = DB::table('pbg_task AS pt')
|
||||
->leftJoin('pbg_task_google_sheet AS ptgs', 'pt.registration_number', '=', 'ptgs.no_registrasi')
|
||||
->leftJoin('pbg_task_retributions AS ptr', 'pt.uuid', '=', 'ptr.pbg_task_uid') // Join tabel pbg_task_retributions
|
||||
->where(function ($query) {
|
||||
$query->whereRaw('LOWER(TRIM(ptgs.status_verifikasi)) != ?', [strtolower(trim('Selesai Verifikasi'))])
|
||||
->orWhereNull('ptgs.status_verifikasi'); // Include NULL values
|
||||
})
|
||||
->selectRaw('COUNT(pt.id) AS total_data,
|
||||
SUM(ptr.nilai_retribusi_bangunan) AS total_retribution') // Menambahkan SUM dari pbg_task_retributions
|
||||
->first();
|
||||
|
||||
$taskCount = $query->total_data;
|
||||
$taskTotal = $query->total_retribution ?? 0;
|
||||
|
||||
$result = [
|
||||
"count"=> $taskCount,
|
||||
"total"=> $taskTotal
|
||||
];
|
||||
|
||||
return $this->resSuccess($result);
|
||||
}
|
||||
|
||||
public function pbgTaskDocuments(Request $request){
|
||||
$request->validate([
|
||||
'status' => 'required|string'
|
||||
|
||||
Reference in New Issue
Block a user