|
|
|
@ -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){ |
|
|
|
|