|
|
@ -1,5 +1,4 @@ |
|
|
|
<?php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers; |
|
|
|
namespace App\Http\Controllers; |
|
|
|
|
|
|
|
|
|
|
|
use App\Models\Activity; |
|
|
|
use App\Models\Activity; |
|
|
@ -18,7 +17,7 @@ class ActivityController extends Controller |
|
|
|
{ |
|
|
|
{ |
|
|
|
public function getByGanttId($id, $proyek_id) |
|
|
|
public function getByGanttId($id, $proyek_id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(Activity::where("version_gantt_id", $id)->count() == 0) { |
|
|
|
if(Activity::where('proyek_id', $proyek_id)->where("version_gantt_id", $id)->count() == 0) { |
|
|
|
$this->cloneTemplate($id, $proyek_id); |
|
|
|
$this->cloneTemplate($id, $proyek_id); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -29,6 +28,8 @@ class ActivityController extends Controller |
|
|
|
|
|
|
|
|
|
|
|
private function getDataActivity($id) |
|
|
|
private function getDataActivity($id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
$checkHeader = Activity::where('version_gantt_id', $id)->where('type_activity', 'header')->count(); $finalData = []; |
|
|
|
|
|
|
|
if($checkHeader > 0){ |
|
|
|
$dataHeader = Activity::where('version_gantt_id', $id)->where('type_activity', 'header')->first(); |
|
|
|
$dataHeader = Activity::where('version_gantt_id', $id)->where('type_activity', 'header')->first(); |
|
|
|
$startDate = date_create($dataHeader->start_date); |
|
|
|
$startDate = date_create($dataHeader->start_date); |
|
|
|
$endDate = date_create($dataHeader->end_date); |
|
|
|
$endDate = date_create($dataHeader->end_date); |
|
|
@ -38,9 +39,9 @@ class ActivityController extends Controller |
|
|
|
$dataHeader->text = $dataHeader->name; |
|
|
|
$dataHeader->text = $dataHeader->name; |
|
|
|
$finalData[] = $dataHeader; |
|
|
|
$finalData[] = $dataHeader; |
|
|
|
$data = Activity::where('version_gantt_id', $id)->where('parent_id', $dataHeader->id)->orderBy('id', 'asc')->get(); |
|
|
|
$data = Activity::where('version_gantt_id', $id)->where('parent_id', $dataHeader->id)->orderBy('id', 'asc')->get(); |
|
|
|
|
|
|
|
}else{ |
|
|
|
if(Activity::where('version_gantt_id', $id)->where('type_activity', 'header')->count() == 0) |
|
|
|
|
|
|
|
$data = Activity::where('version_gantt_id', $id)->whereNull('parent_id')->orderBy('id', 'asc')->get(); |
|
|
|
$data = Activity::where('version_gantt_id', $id)->whereNull('parent_id')->orderBy('id', 'asc')->get(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
foreach($data as $objRow){ |
|
|
|
foreach($data as $objRow){ |
|
|
|
$type = "project"; |
|
|
|
$type = "project"; |
|
|
@ -117,7 +118,7 @@ class ActivityController extends Controller |
|
|
|
|
|
|
|
|
|
|
|
private function cloneTemplate($id, $proyek_id) |
|
|
|
private function cloneTemplate($id, $proyek_id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$project = Project::findOrFail($proyek_id); |
|
|
|
$project = Project::find($proyek_id); |
|
|
|
|
|
|
|
|
|
|
|
$rootActivity = Activity::create([ |
|
|
|
$rootActivity = Activity::create([ |
|
|
|
'version_gantt_id'=>$id, |
|
|
|
'version_gantt_id'=>$id, |
|
|
@ -126,7 +127,7 @@ class ActivityController extends Controller |
|
|
|
'kode_sortname'=>$project->kode_sortname, |
|
|
|
'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'=> str_replace(".","", $project->rencana_biaya), |
|
|
|
'rencana_biaya'=> $project->rencana_biaya, |
|
|
|
'type_activity'=> 'header', |
|
|
|
'type_activity'=> 'header', |
|
|
|
'created_by'=>$this->currentName, |
|
|
|
'created_by'=>$this->currentName, |
|
|
|
]); |
|
|
|
]); |
|
|
@ -186,7 +187,6 @@ class ActivityController extends Controller |
|
|
|
|
|
|
|
|
|
|
|
$parent = $data['parent_id'] ?? null; |
|
|
|
$parent = $data['parent_id'] ?? null; |
|
|
|
if($parent){ |
|
|
|
if($parent){ |
|
|
|
$this->updateTypeProject($parent); |
|
|
|
|
|
|
|
Activity::find($parent)->update(["type_activity"=>"project"]); |
|
|
|
Activity::find($parent)->update(["type_activity"=>"project"]); |
|
|
|
CommentActivity::where('activity_id', $parent)->delete(); |
|
|
|
CommentActivity::where('activity_id', $parent)->delete(); |
|
|
|
UserToActivity::where('activity_id', $parent)->delete(); |
|
|
|
UserToActivity::where('activity_id', $parent)->delete(); |
|
|
|