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