|
|
@ -16,8 +16,13 @@ class ActivityController extends Controller |
|
|
|
{ |
|
|
|
{ |
|
|
|
public function getByGanttId($id, $proyek_id) |
|
|
|
public function getByGanttId($id, $proyek_id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(Activity::where('proyek_id', $proyek_id)->where("version_gantt_id", $id)->count() == 0) { |
|
|
|
$gantt = VersionGantt::find($id); |
|
|
|
$this->cloneTemplate($id, $proyek_id); |
|
|
|
if(Activity::where('proyek_id', $proyek_id)->where("version_gantt_id", $id)->count() == 0) { |
|
|
|
|
|
|
|
if(!$gantt->hierarchy_ftth_id) { |
|
|
|
|
|
|
|
$this->cloneTemplate($id, $proyek_id); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$this->cloneTemplate($id, $proyek_id, $gantt->hierarchy_ftth_id); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$dataGantt = $this->getDataActivity($id); |
|
|
|
$dataGantt = $this->getDataActivity($id); |
|
|
@ -120,21 +125,33 @@ class ActivityController extends Controller |
|
|
|
return $finalData; |
|
|
|
return $finalData; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private function cloneTemplate($id, $proyek_id) |
|
|
|
private function cloneTemplate($id, $proyek_id, $hierarchy_ftth_id = null) { |
|
|
|
{ |
|
|
|
$project = Project::find($proyek_id); |
|
|
|
$project = Project::find($proyek_id); |
|
|
|
if($hierarchy_ftth_id){ |
|
|
|
|
|
|
|
$gantt = VersionGantt::find($id); |
|
|
|
$rootActivity = Activity::create([ |
|
|
|
$rootActivity = Activity::create([ |
|
|
|
'version_gantt_id'=>$id, |
|
|
|
'version_gantt_id'=>$id, |
|
|
|
'proyek_id'=>$proyek_id, |
|
|
|
'proyek_id'=>$proyek_id, |
|
|
|
'name'=> $project->nama, |
|
|
|
'name'=> $gantt->name_version, |
|
|
|
'kode_sortname'=>$project->kode_sortname, |
|
|
|
'start_date'=> $project->mulai_proyek, |
|
|
|
'start_date'=> $project->mulai_proyek, |
|
|
|
'end_date'=> $project->akhir_proyek, |
|
|
|
'end_date'=> $project->akhir_proyek, |
|
|
|
'rencana_biaya'=> $project->rencana_biaya, |
|
|
|
'rencana_biaya'=> $project->rencana_biaya, |
|
|
|
'type_activity'=> 'project', |
|
|
|
'type_activity'=> 'project', |
|
|
|
'created_by'=>$this->currentName, |
|
|
|
'created_by'=>$this->currentName, |
|
|
|
]); |
|
|
|
]); |
|
|
|
} else { |
|
|
|
|
|
|
|
$rootActivity = Activity::create([ |
|
|
|
|
|
|
|
'version_gantt_id'=>$id, |
|
|
|
|
|
|
|
'proyek_id'=>$proyek_id, |
|
|
|
|
|
|
|
'name'=> $project->nama, |
|
|
|
|
|
|
|
'kode_sortname'=>$project->kode_sortname, |
|
|
|
|
|
|
|
'start_date'=> $project->mulai_proyek, |
|
|
|
|
|
|
|
'end_date'=> $project->akhir_proyek, |
|
|
|
|
|
|
|
'rencana_biaya'=> $project->rencana_biaya, |
|
|
|
|
|
|
|
'type_activity'=> 'project', |
|
|
|
|
|
|
|
'created_by'=>$this->currentName, |
|
|
|
|
|
|
|
]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$resultTypeProject = TemplateGantt::where('proyek_type_id', $project->type_proyek_id) |
|
|
|
$resultTypeProject = TemplateGantt::where('proyek_type_id', $project->type_proyek_id) |
|
|
|
->whereNull('parent_id') |
|
|
|
->whereNull('parent_id') |
|
|
|