diff --git a/app/Console/Commands/CalculateProgressGantt.php b/app/Console/Commands/CalculateProgressGantt.php new file mode 100644 index 0000000..8e6796f --- /dev/null +++ b/app/Console/Commands/CalculateProgressGantt.php @@ -0,0 +1,29 @@ +argument('project_id'); + $project = Project::find($project_id); + + $project->calculation_status = true; + $project->save(); + + $data = MasterFunctionsHelper::CalculateSCurve($project_id); + + $project->scurve = json_encode($data); + $project->calculation_status = true; + $project->save(); + } +} diff --git a/app/Helpers/MasterFunctionsHelper.php b/app/Helpers/MasterFunctionsHelper.php index fec14b8..2f1770e 100644 --- a/app/Helpers/MasterFunctionsHelper.php +++ b/app/Helpers/MasterFunctionsHelper.php @@ -609,24 +609,8 @@ class MasterFunctionsHelper $progressActualWeek = ($keyActualM->qty_actual / $keyActualM->qty_plan) * $keyActualM->bobot_planning; } } - if($keyActualM->status_activity == 'done'){ - // if($keyActualM->count_report > 1){ - // $progressActualWeek = $keyActualM->bobot_planning/$keyActualM->count_report; - // }else{ - $progressActualWeek = $keyActualM->bobot_planning / $keyActualM->count_report; - // } - // if($progressActualWeek > $keyActualM->bobot_planning){ - // $progressActualWeek = $keyActualM->bobot_planning; - // }else if($keyActualM->qty_actual == 0){ - // $progressActualWeek = $keyActualM->bobot_planning; - // }else if($keyActualM->qty_plan == $keyActualM->sum_qty_actual){ - // $progressActualWeek = $keyActualM->bobot_planning; - // }else { - // $progressActualWeek = $progressActualWeek; - // } - // $progressActualWeek = $progressActualWeek > $keyActualM->bobot_planning ? $keyActualM->bobot_planning : $progressActualWeek; - // jika report lebih dari 1 x, maka harusnya di bagi sabanyak jumlah report, - // contoh ada 3 report, report ke 1 adalah 5 maka 100/3 dan di looping + if($keyActualM->status_activity == 'done'){ + $progressActualWeek = $keyActualM->bobot_planning / $keyActualM->count_report; } else{ $progressActualWeek = $progressActualWeek > ($keyActualM->bobot_planning*95)/100 ? ($keyActualM->bobot_planning*95)/100 : $progressActualWeek; diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php index c2a8223..610c5fc 100644 --- a/app/Http/Controllers/ActivityController.php +++ b/app/Http/Controllers/ActivityController.php @@ -1156,4 +1156,9 @@ class ActivityController extends Controller } return response()->json(['status' => 'success', 'data' => $request, 'message' => 'Update successful!', 'code' => 200], 200); } + + // public function recalculateProject($by, $id){ + // // query get activity + // $cekActivity = + // } } diff --git a/app/Http/Controllers/HierarchyFtthController.php b/app/Http/Controllers/HierarchyFtthController.php index 3b3f64f..a31c626 100644 --- a/app/Http/Controllers/HierarchyFtthController.php +++ b/app/Http/Controllers/HierarchyFtthController.php @@ -6,6 +6,7 @@ use Illuminate\Http\Request; use App\Models\HierarchyFtth; use App\Models\VersionGantt; use Illuminate\Support\Facades\Log; +use Illuminate\Support\Facades\Artisan; class HierarchyFtthController extends Controller { @@ -103,35 +104,40 @@ class HierarchyFtthController extends Controller } public function countProgress($project_id) { - $ftthIds = VersionGantt::select('hierarchy_ftth_id') - ->where('proyek_id', $project_id) - ->groupBy('hierarchy_ftth_id') - ->get(); - if($ftthIds){ - foreach ($ftthIds as $ftthId) { - $gantts = VersionGantt::where('hierarchy_ftth_id', $ftthId->hierarchy_ftth_id)->sum('progress'); - $bobot_planning = VersionGantt::where('hierarchy_ftth_id', $ftthId->hierarchy_ftth_id)->sum('bobot'); - $ganttCount = VersionGantt::where('hierarchy_ftth_id', $ftthId->hierarchy_ftth_id)->count(); - - $ftth = HierarchyFtth::find($ftthId->hierarchy_ftth_id); - if($ftth){ - $round = $gantts/$ganttCount; - $round_bobot = $bobot_planning/$ganttCount; - $ftth->progress = round($round, 2); - $ftth->bobot_planning = round($round_bobot, 2); - try { - $ftth->save(); - } catch (\Exception $e) { - // Log the error or handle it in some other way - Log::error($e->getMessage()); - } - - if($ftth->parent_id){ - $this->countParent($ftth); - } - } - } - } + // $ftthIds = VersionGantt::select('hierarchy_ftth_id') + // ->where('proyek_id', $project_id) + // ->groupBy('hierarchy_ftth_id') + // ->get(); + // if($ftthIds){ + // foreach ($ftthIds as $ftthId) { + // $gantts = VersionGantt::where('hierarchy_ftth_id', $ftthId->hierarchy_ftth_id)->sum('progress'); + // $bobot_planning = VersionGantt::where('hierarchy_ftth_id', $ftthId->hierarchy_ftth_id)->sum('bobot'); + // $ganttCount = VersionGantt::where('hierarchy_ftth_id', $ftthId->hierarchy_ftth_id)->count(); + + // $ftth = HierarchyFtth::find($ftthId->hierarchy_ftth_id); + // if($ftth){ + // $round = $gantts/$ganttCount; + // $round_bobot = $bobot_planning/$ganttCount; + // $ftth->progress = round($round, 2); + // $ftth->bobot_planning = round($round_bobot, 2); + // try { + // $ftth->save(); + // } catch (\Exception $e) { + // // Log the error or handle it in some other way + // Log::error($e->getMessage()); + // } + + // if($ftth->parent_id){ + // $this->countParent($ftth); + // } + // } + // } + // } + + // calculate ke curva berdasarkan site + Artisan::call('calculate:progressgantt', [ + 'project_id' => $project_id + ]); } public function countParent($ftth){ @@ -180,6 +186,7 @@ class HierarchyFtthController extends Controller public function getTreeByProject($project_id) { $this->countProgress(intval($project_id)); + $data = HierarchyFtth::where('project_id', $project_id)->whereNull('parent_id')->orderByRaw('id ASC')->get(); $finalData = []; foreach($data as $objRow){