From 8a77c82c6c707c9ac378712ca8ec9195f70fe08c Mon Sep 17 00:00:00 2001 From: Fuad Hadisurya Date: Thu, 25 Jul 2024 14:21:27 +0700 Subject: [PATCH 1/5] [Fix] command ActualProgressProject.php --- app/Console/Commands/ActualProgressProject.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/app/Console/Commands/ActualProgressProject.php b/app/Console/Commands/ActualProgressProject.php index de21595..a56a4e1 100644 --- a/app/Console/Commands/ActualProgressProject.php +++ b/app/Console/Commands/ActualProgressProject.php @@ -6,6 +6,7 @@ use App\Helpers\MasterFunctionsHelper; use App\Models\Project; use App\Models\VersionGantt; use Illuminate\Console\Command; +use Illuminate\Support\Facades\Log; class ActualProgressProject extends Command { @@ -40,7 +41,7 @@ class ActualProgressProject extends Command */ public function handle() { - $projects = Project::join('m_type_proyek', 'm_proyek.type_proyek_id', '=', 'm_type_proyek.id') + $projects = Project::leftJoin('m_type_proyek', 'm_proyek.type_proyek_id', '=', 'm_type_proyek.id') ->select('m_proyek.*', 'm_type_proyek.is_multiLocation') ->get(); @@ -55,6 +56,7 @@ class ActualProgressProject extends Command $progress[$key] = $gantt->progress; } $actualProgress = round(array_sum($progress) / count($versionGantt), 2); + $progress = array(); // unset/kosongkan array progress untuk project selanjutnya } else { // untuk project single location $gantt = MasterFunctionsHelper::getLatestGantt($project->id); @@ -65,12 +67,15 @@ class ActualProgressProject extends Command 'gantt_id' => $lastGantt, 'periode' => 'week' ]; - - $project->scurve = MasterFunctionsHelper::getSCurve(collect($arr)); - $actualArray = $project->scurve[0]['data']['percentageReal']; - $actualProgress = !empty($actualArray) ? round(end($actualArray), 2) : 0; + // kondisi jika tidak ada gantt_id + if (empty($arr['gantt_id'])) { + $actualProgress = 0; + } else { + $project->scurve = MasterFunctionsHelper::getSCurve(collect($arr)); + $actualArray = $project->scurve[0]['data']['percentageReal']; + $actualProgress = !empty($actualArray) ? round(end($actualArray), 2) : 0; + } } - Project::where('id', $project->id)->update(['persentase_progress' => $actualProgress]); } } -- 2.25.1 From dd87b2276389ecda42137ec8298eb77ab14a8a88 Mon Sep 17 00:00:00 2001 From: wahyun Date: Thu, 25 Jul 2024 16:50:04 +0700 Subject: [PATCH 2/5] fix: dashboard BOD budget health --- app/Http/Controllers/DashboardBoDController.php | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/app/Http/Controllers/DashboardBoDController.php b/app/Http/Controllers/DashboardBoDController.php index bf47cf8..c458ac3 100644 --- a/app/Http/Controllers/DashboardBoDController.php +++ b/app/Http/Controllers/DashboardBoDController.php @@ -288,10 +288,7 @@ class DashboardBoDController extends Controller ->pluck('id'); // arr overrun - if ($role === 'Super Admin') { - $response['data']['overrun'] = Project::where('budget_health', 'overrun') - ->count(); - } elseif ($all_project == 'true') { + if ($all_project) { $response['data']['overrun'] = Project::whereIn('divisi_id', $divisi) ->where([['budget_health', 'overrun']]) ->count(); @@ -301,10 +298,7 @@ class DashboardBoDController extends Controller ->count(); } // arr warning - if ($role === 'Super Admin') { - $response['data']['warning'] = Project::where('budget_health', 'warning') - ->count(); - } elseif ($all_project == 'true') { + if ($all_project) { $response['data']['warning'] = Project::whereIn('divisi_id', $divisi) ->where([['budget_health', 'warning']]) ->count(); @@ -314,10 +308,7 @@ class DashboardBoDController extends Controller ->count(); } // arr on-budget - if ($role === 'Super Admin') { - $response['data']['on-budget'] = Project::where('budget_health', 'on-budget') - ->count(); - } elseif ($all_project == 'true') { + if ($all_project) { $response['data']['on-budget'] = Project::whereIn('divisi_id', $divisi) ->where([['budget_health', 'on-budget']]) ->count(); -- 2.25.1 From 6c44a2ce16f9f613c05dbce91b0c7126034f4ef2 Mon Sep 17 00:00:00 2001 From: Fuad Hadisurya Date: Mon, 29 Jul 2024 12:16:28 +0700 Subject: [PATCH 3/5] [Fix] Command ActualProgressProject: project multi jika ada gantt tetapi tidak ada hierarcy tidak dihitung --- app/Console/Commands/ActualProgressProject.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/Console/Commands/ActualProgressProject.php b/app/Console/Commands/ActualProgressProject.php index a56a4e1..1af8a85 100644 --- a/app/Console/Commands/ActualProgressProject.php +++ b/app/Console/Commands/ActualProgressProject.php @@ -3,6 +3,7 @@ namespace App\Console\Commands; use App\Helpers\MasterFunctionsHelper; +use App\Models\HierarchyFtth; use App\Models\Project; use App\Models\VersionGantt; use Illuminate\Console\Command; @@ -53,7 +54,13 @@ class ActualProgressProject extends Command ->where('m_version_gantt.proyek_id', $project->id) ->get(); foreach ($versionGantt as $key => $gantt) { - $progress[$key] = $gantt->progress; + $hierarchy = HierarchyFtth::where('id',$gantt->hierarchy_ftth_id)->count(); + // Perhitungan jika project memiliki gantt tetapi tidak ada hierarchy (Kasus perpindahan tipe project dari single location ke multi location) + if($hierarchy == 0){ + $progress[$key] = 0; + } else { + $progress[$key] = $gantt->progress; + } } $actualProgress = round(array_sum($progress) / count($versionGantt), 2); $progress = array(); // unset/kosongkan array progress untuk project selanjutnya -- 2.25.1 From 006be9da232c652a9e35ce1fab1bb8a38d4a7833 Mon Sep 17 00:00:00 2001 From: wahyun Date: Tue, 30 Jul 2024 15:32:36 +0700 Subject: [PATCH 4/5] fix: anggaran biaya <-> nilai kontrak --- app/Http/Controllers/DashboardBoDController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/DashboardBoDController.php b/app/Http/Controllers/DashboardBoDController.php index c458ac3..6f30cff 100644 --- a/app/Http/Controllers/DashboardBoDController.php +++ b/app/Http/Controllers/DashboardBoDController.php @@ -66,11 +66,11 @@ class DashboardBoDController extends Controller return response()->json([ 'data' => [ - 'total_budget' => (int) ($totalBudgets->total_rencana_biaya ?? 0), + 'total_budget' => $totalBudgets->total_value_proyek ?? 0, 'total_expenditure' => $totalExpenditure, 'total_invoice' => $totalInvoice, 'total_paid_invoice' => $totalPaidInvoice, - 'total_value_proyek' => $totalBudgets->total_value_proyek ?? 0, + 'total_value_proyek' => (int) ($totalBudgets->total_rencana_biaya ?? 0), 'total_income_year' => $totalBudgets->total_income_year ?? 0 ] ], 200); -- 2.25.1 From 033373ebf0c2772b0d2dcc21f0e3890d25decd8e Mon Sep 17 00:00:00 2001 From: wahyun Date: Tue, 30 Jul 2024 15:33:01 +0700 Subject: [PATCH 5/5] fix: total_progress update logic --- app/Http/Controllers/ProjectController.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 916c81e..63fdf87 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -291,6 +291,23 @@ class ProjectController extends Controller $builder = $dataBuilder['builder']; $countBuilder = $dataBuilder['count']; $dataGet = $builder->get(); + foreach($dataGet as $p) { + $project = Project::find($p->id); + if (!$project) continue; + + $act = Activity::select('persentase_progress as total_progress') + ->where([ + ['proyek_id', $p->id], + ['parent_id', null] + ]) + ->first(); + if ($act) { + $project->persentase_progress = $act->total_progress; + } else { + $project->persentase_progress = 0; + } + $project->save(); + } $totalRecord = $countBuilder->count(); return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200); } -- 2.25.1