|
|
@ -6,6 +6,7 @@ use Illuminate\Http\Request; |
|
|
|
use App\Models\HierarchyFtth; |
|
|
|
use App\Models\HierarchyFtth; |
|
|
|
use App\Models\VersionGantt; |
|
|
|
use App\Models\VersionGantt; |
|
|
|
use Illuminate\Support\Facades\Log; |
|
|
|
use Illuminate\Support\Facades\Log; |
|
|
|
|
|
|
|
use Illuminate\Support\Facades\Artisan; |
|
|
|
|
|
|
|
|
|
|
|
class HierarchyFtthController extends Controller |
|
|
|
class HierarchyFtthController extends Controller |
|
|
|
{ |
|
|
|
{ |
|
|
@ -103,35 +104,40 @@ class HierarchyFtthController extends Controller |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function countProgress($project_id) { |
|
|
|
public function countProgress($project_id) { |
|
|
|
$ftthIds = VersionGantt::select('hierarchy_ftth_id') |
|
|
|
// $ftthIds = VersionGantt::select('hierarchy_ftth_id') |
|
|
|
->where('proyek_id', $project_id) |
|
|
|
// ->where('proyek_id', $project_id) |
|
|
|
->groupBy('hierarchy_ftth_id') |
|
|
|
// ->groupBy('hierarchy_ftth_id') |
|
|
|
->get(); |
|
|
|
// ->get(); |
|
|
|
if($ftthIds){ |
|
|
|
// if($ftthIds){ |
|
|
|
foreach ($ftthIds as $ftthId) { |
|
|
|
// foreach ($ftthIds as $ftthId) { |
|
|
|
$gantts = VersionGantt::where('hierarchy_ftth_id', $ftthId->hierarchy_ftth_id)->sum('progress'); |
|
|
|
// $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'); |
|
|
|
// $bobot_planning = VersionGantt::where('hierarchy_ftth_id', $ftthId->hierarchy_ftth_id)->sum('bobot'); |
|
|
|
$ganttCount = VersionGantt::where('hierarchy_ftth_id', $ftthId->hierarchy_ftth_id)->count(); |
|
|
|
// $ganttCount = VersionGantt::where('hierarchy_ftth_id', $ftthId->hierarchy_ftth_id)->count(); |
|
|
|
|
|
|
|
|
|
|
|
$ftth = HierarchyFtth::find($ftthId->hierarchy_ftth_id); |
|
|
|
// $ftth = HierarchyFtth::find($ftthId->hierarchy_ftth_id); |
|
|
|
if($ftth){ |
|
|
|
// if($ftth){ |
|
|
|
$round = $gantts/$ganttCount; |
|
|
|
// $round = $gantts/$ganttCount; |
|
|
|
$round_bobot = $bobot_planning/$ganttCount; |
|
|
|
// $round_bobot = $bobot_planning/$ganttCount; |
|
|
|
$ftth->progress = round($round, 2); |
|
|
|
// $ftth->progress = round($round, 2); |
|
|
|
$ftth->bobot_planning = round($round_bobot, 2); |
|
|
|
// $ftth->bobot_planning = round($round_bobot, 2); |
|
|
|
try { |
|
|
|
// try { |
|
|
|
$ftth->save(); |
|
|
|
// $ftth->save(); |
|
|
|
} catch (\Exception $e) { |
|
|
|
// } catch (\Exception $e) { |
|
|
|
// Log the error or handle it in some other way |
|
|
|
// // Log the error or handle it in some other way |
|
|
|
Log::error($e->getMessage()); |
|
|
|
// Log::error($e->getMessage()); |
|
|
|
} |
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
if($ftth->parent_id){ |
|
|
|
// if($ftth->parent_id){ |
|
|
|
$this->countParent($ftth); |
|
|
|
// $this->countParent($ftth); |
|
|
|
} |
|
|
|
// } |
|
|
|
} |
|
|
|
// } |
|
|
|
} |
|
|
|
// } |
|
|
|
} |
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// calculate ke curva berdasarkan site |
|
|
|
|
|
|
|
Artisan::call('calculate:progressgantt', [ |
|
|
|
|
|
|
|
'project_id' => $project_id |
|
|
|
|
|
|
|
]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function countParent($ftth){ |
|
|
|
public function countParent($ftth){ |
|
|
@ -180,6 +186,7 @@ class HierarchyFtthController extends Controller |
|
|
|
public function getTreeByProject($project_id) |
|
|
|
public function getTreeByProject($project_id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$this->countProgress(intval($project_id)); |
|
|
|
$this->countProgress(intval($project_id)); |
|
|
|
|
|
|
|
|
|
|
|
$data = HierarchyFtth::where('project_id', $project_id)->whereNull('parent_id')->orderByRaw('id ASC')->get(); |
|
|
|
$data = HierarchyFtth::where('project_id', $project_id)->whereNull('parent_id')->orderByRaw('id ASC')->get(); |
|
|
|
$finalData = []; |
|
|
|
$finalData = []; |
|
|
|
foreach($data as $objRow){ |
|
|
|
foreach($data as $objRow){ |
|
|
|