|
|
|
@ -11,145 +11,31 @@ use App\Models\{
|
|
|
|
|
}; |
|
|
|
|
class ProjectCarausellController extends Controller |
|
|
|
|
{ |
|
|
|
|
// public function invoke() { |
|
|
|
|
// // Master Data |
|
|
|
|
// $projectData = Project::query() |
|
|
|
|
// ->select("id","nama","kode_sortname","pm_id","budget_health","calculation_status","mulai_proyek","akhir_proyek","rencana_biaya","company","scurve") |
|
|
|
|
// ->get(); |
|
|
|
|
// $projectRisk = ProjectRisks::query() |
|
|
|
|
// ->select('proyek_id','description','level_risk','preventive_risk') |
|
|
|
|
// ->get(); |
|
|
|
|
// $projectIssue = ProjectIssues::query() |
|
|
|
|
// ->select('proyek_id','description','level_issue') |
|
|
|
|
// ->get(); |
|
|
|
|
// $ganttData = VersionGantt::query() |
|
|
|
|
// ->select('id', 'name_version','hierarchy_ftth_id','cost_to_complete','proyek_id','calculation_type') |
|
|
|
|
// ->get(); |
|
|
|
|
|
|
|
|
|
// $arr = []; |
|
|
|
|
// foreach ($ganttData as $gantt) { |
|
|
|
|
// $projectArr = []; |
|
|
|
|
// $riskProject = []; |
|
|
|
|
// $issueProject = []; |
|
|
|
|
// foreach($projectData as $project) { |
|
|
|
|
// if($project['id'] === $gantt['proyek_id']) { |
|
|
|
|
// foreach ($projectRisk as $risk) { |
|
|
|
|
// if ($risk['proyek_id'] === $project['id']) { |
|
|
|
|
// $riskProject[] = [ |
|
|
|
|
// 'level_risk' => $risk['level_risk'], |
|
|
|
|
// 'preventive_risk' => $risk['preventive_risk'], |
|
|
|
|
// 'description' => $risk['description'] |
|
|
|
|
// ]; |
|
|
|
|
// } |
|
|
|
|
// } |
|
|
|
|
// foreach ($projectIssue as $issue) { |
|
|
|
|
// if ($issue['proyek_id'] === $project['id']) { |
|
|
|
|
// $issueProject[] = [ |
|
|
|
|
// 'level_issue' => $issue['level_issue'], |
|
|
|
|
// 'description' => $issue['description'] |
|
|
|
|
// ]; |
|
|
|
|
// } |
|
|
|
|
// } |
|
|
|
|
// $projectArr[] = [ |
|
|
|
|
// "project" => [ |
|
|
|
|
// "id" => $project['id'], |
|
|
|
|
// "pm_id" => $project['pm_id'], |
|
|
|
|
// "nama" => $project['nama'], |
|
|
|
|
// "kode_sortname" => $project['kode_sortname'], |
|
|
|
|
// "budget_health" => $project['budget_health'], |
|
|
|
|
// "calculation_status" => $project['calculation_status'], |
|
|
|
|
// "mulai_proyek" => $project['mulai_proyek'], |
|
|
|
|
// "akhir_proyek" => $project['akhir_proyek'], |
|
|
|
|
// "rencana_biaya" => $project['rencana_biaya'], |
|
|
|
|
// "company" => $project['company'], |
|
|
|
|
// "scurve" => $project['scurve'], |
|
|
|
|
// "project_risk" => $riskProject, |
|
|
|
|
// "project_issues" => $issueProject |
|
|
|
|
// ], |
|
|
|
|
// ]; |
|
|
|
|
// } |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
// $arr[] = [ |
|
|
|
|
// "gantt" => [ |
|
|
|
|
// "gantt_id" => $gantt['id'], |
|
|
|
|
// 'proyek_id' => $gantt['proyek_id'], |
|
|
|
|
// "name_version" => $gantt['name_version'], |
|
|
|
|
// "hierarchy_ftth_id" => $gantt['hierarchy_ftth_id'], |
|
|
|
|
// "cost_to_complete" => $gantt['cost_to_complete'], |
|
|
|
|
// "calculation_type" => $gantt['calculation_type'], |
|
|
|
|
// "project"=> $projectArr |
|
|
|
|
// ], |
|
|
|
|
// ]; |
|
|
|
|
// } |
|
|
|
|
// return response()->json(['status'=>'success','code'=> 200,'data'=>$projectArr, "total_project"=>count($arr)], 200); |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
// public function getParents(&$data, $id) { |
|
|
|
|
// $ftth = HierarchyFtth::find($id); |
|
|
|
|
// array_push($data, $ftth); |
|
|
|
|
// if ($ftth->parent_id) { |
|
|
|
|
// $this->getParents($data, $ftth->parent_id); |
|
|
|
|
// } |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
public function invoke() { |
|
|
|
|
// Master Data |
|
|
|
|
$projectData = Project::query() |
|
|
|
|
->select("id","nama","kode_sortname","pm_id","budget_health","calculation_status","mulai_proyek","akhir_proyek","rencana_biaya","company","scurve") |
|
|
|
|
->get(); |
|
|
|
|
|
|
|
|
|
$arr = []; |
|
|
|
|
foreach($projectData as $project) { |
|
|
|
|
$projectRisk = ProjectRisks::query() |
|
|
|
|
->select('proyek_id','description','level_risk','preventive_risk') |
|
|
|
|
->get(); |
|
|
|
|
->where('proyek_id', $project['id']) |
|
|
|
|
->get() |
|
|
|
|
->toArray(); |
|
|
|
|
$projectIssue = ProjectIssues::query() |
|
|
|
|
->select('proyek_id','description','level_issue') |
|
|
|
|
->get(); |
|
|
|
|
->where('proyek_id',$project['id']) |
|
|
|
|
->get() |
|
|
|
|
->toArray(); |
|
|
|
|
$ganttData = VersionGantt::query() |
|
|
|
|
->select('id', 'name_version','hierarchy_ftth_id','cost_to_complete','proyek_id','calculation_type') |
|
|
|
|
->get(); |
|
|
|
|
|
|
|
|
|
// Nested looping |
|
|
|
|
|
|
|
|
|
$arr = []; |
|
|
|
|
foreach ($ganttData as $gantt) { |
|
|
|
|
$riskProject = []; |
|
|
|
|
$issueProject = []; |
|
|
|
|
foreach ($projectRisk as $risk) { |
|
|
|
|
if ($risk['proyek_id'] === $gantt['proyek_id']) { |
|
|
|
|
$riskProject[] = [ |
|
|
|
|
'level_risk' => $risk['level_risk'], |
|
|
|
|
'preventive_risk' => $risk['preventive_risk'], |
|
|
|
|
'description' => $risk['description'] |
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
foreach ($projectIssue as $issue) { |
|
|
|
|
if ($issue['proyek_id'] === $gantt['proyek_id']) { |
|
|
|
|
$issueProject[] = [ |
|
|
|
|
'level_issue' => $issue['level_issue'], |
|
|
|
|
'description' => $issue['description'] |
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$arr[$gantt['proyek_id']][] = [ |
|
|
|
|
"gantt" => [ |
|
|
|
|
"gantt_id" => $gantt['id'], |
|
|
|
|
'proyek_id' => $gantt['proyek_id'], |
|
|
|
|
"name_version" => $gantt['name_version'], |
|
|
|
|
"hierarchy_ftth_id" => $gantt['hierarchy_ftth_id'], |
|
|
|
|
"cost_to_complete" => $gantt['cost_to_complete'], |
|
|
|
|
"calculation_type" => $gantt['calculation_type'], |
|
|
|
|
], |
|
|
|
|
"project_risk" => $riskProject, |
|
|
|
|
"project_issue"=>$issueProject |
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
foreach($projectData as $project) { |
|
|
|
|
->where('proyek_id',$project['id']) |
|
|
|
|
->orderByDesc('id') |
|
|
|
|
->first(); |
|
|
|
|
$projectManager = User::where('id', $project['pm_id'])->value('name'); |
|
|
|
|
$arr[$project['id']][] = [ |
|
|
|
|
$arr[]= [ |
|
|
|
|
"project" => [ |
|
|
|
|
"id" => $project['id'], |
|
|
|
|
"pm_id" => $project['pm_id'], |
|
|
|
@ -161,12 +47,14 @@ class ProjectCarausellController extends Controller
|
|
|
|
|
"akhir_proyek" => $project['akhir_proyek'], |
|
|
|
|
"rencana_biaya" => $project['rencana_biaya'], |
|
|
|
|
"company" => $project['company'], |
|
|
|
|
"project_manager" => $projectManager, |
|
|
|
|
"scurve" => $project['scurve'] |
|
|
|
|
"scurve" => $project['scurve'], |
|
|
|
|
], |
|
|
|
|
"project_manager" => $projectManager, |
|
|
|
|
"project_risk" => $projectRisk, |
|
|
|
|
"project_issue" => $projectIssue, |
|
|
|
|
"gantt"=> $ganttData |
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return response()->json(['status'=>'success','code'=> 200,'data'=> $arr, "total_project"=>count($arr)], 200); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|