|
|
@ -25,7 +25,7 @@ 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 = []; |
|
|
|
$checkHeader = Activity::where('version_gantt_id', $id)->where('type_activity', 'header')->count(); $finalData = []; |
|
|
|
if($checkHeader > 0){ |
|
|
|
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); |
|
|
@ -42,20 +42,22 @@ class ActivityController extends Controller |
|
|
|
|
|
|
|
|
|
|
|
foreach($data as $objRow){ |
|
|
|
foreach($data as $objRow){ |
|
|
|
$type = "project"; |
|
|
|
$type = "project"; |
|
|
|
|
|
|
|
$dataChildren = $this->getChildren($id, $objRow->id); |
|
|
|
|
|
|
|
$startDate = date_create($objRow->start_date); |
|
|
|
|
|
|
|
$endDate = date_create($objRow->end_date); |
|
|
|
|
|
|
|
|
|
|
|
if($objRow->type_activity=="milestone") |
|
|
|
if($objRow->type_activity=="milestone") |
|
|
|
$type = $objRow->type_activity; |
|
|
|
$type = $objRow->type_activity; |
|
|
|
if(empty($dataChildren)) |
|
|
|
if(empty($dataChildren)) |
|
|
|
$type = "task"; |
|
|
|
$type = "task"; |
|
|
|
|
|
|
|
|
|
|
|
$objRow->text = $objRow->name; |
|
|
|
$objRow->text = $objRow->name; |
|
|
|
$objRow->parent = $objRow->parent_id ? $objRow->parent_id : null; |
|
|
|
$objRow->parent = $objRow->parent_id ? $objRow->parent_id : null; |
|
|
|
$startDate = date_create($objRow->start_date); |
|
|
|
|
|
|
|
$endDate = date_create($objRow->end_date); |
|
|
|
|
|
|
|
$objRow->start_date = date_format($startDate,"Y-m-d H:i:s"); |
|
|
|
$objRow->start_date = date_format($startDate,"Y-m-d H:i:s"); |
|
|
|
$objRow->end_date = date_format($endDate,"Y-m-d H:i:s"); |
|
|
|
$objRow->end_date = date_format($endDate,"Y-m-d H:i:s"); |
|
|
|
$objRow->planned_start = isset($objRow->planned_start) ? date_format(date_create($objRow->planned_start),"Y-m-d H:i:s") : NULL; |
|
|
|
$objRow->planned_start = isset($objRow->planned_start) ? date_format(date_create($objRow->planned_start),"Y-m-d H:i:s") : NULL; |
|
|
|
$objRow->planned_end = isset($objRow->planned_end) ? date_format(date_create($objRow->planned_end),"Y-m-d H:i:s") : NULL; |
|
|
|
$objRow->planned_end = isset($objRow->planned_end) ? date_format(date_create($objRow->planned_end),"Y-m-d H:i:s") : NULL; |
|
|
|
$objRow->progress = (int) $objRow->persentase_progress / 100; |
|
|
|
$objRow->progress = (int) $objRow->persentase_progress / 100; |
|
|
|
$dataChildren = $this->getChildren($id, $objRow->id); |
|
|
|
|
|
|
|
$objRow->type = $type; |
|
|
|
$objRow->type = $type; |
|
|
|
$finalData[] = $objRow; |
|
|
|
$finalData[] = $objRow; |
|
|
|
$finalData = array_merge($finalData, $dataChildren); |
|
|
|
$finalData = array_merge($finalData, $dataChildren); |
|
|
@ -183,7 +185,10 @@ class ActivityController extends Controller |
|
|
|
|
|
|
|
|
|
|
|
$parent = $data['parent_id'] ?? null; |
|
|
|
$parent = $data['parent_id'] ?? null; |
|
|
|
if($parent){ |
|
|
|
if($parent){ |
|
|
|
Activity::find($parent)->update(["type_activity"=>"project"]); |
|
|
|
$parentData = Activity::find($parent); |
|
|
|
|
|
|
|
if($parentData->parent_id) { |
|
|
|
|
|
|
|
$parentData->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(); |
|
|
|
} |
|
|
|
} |
|
|
@ -209,16 +214,11 @@ class ActivityController extends Controller |
|
|
|
if(empty($id) || !is_int((int)$id)) |
|
|
|
if(empty($id) || !is_int((int)$id)) |
|
|
|
return response()->json(['status'=>'failed', 'action'=>'error','message'=>'id is required!','code'=>400], 400); |
|
|
|
return response()->json(['status'=>'failed', 'action'=>'error','message'=>'id is required!','code'=>400], 400); |
|
|
|
|
|
|
|
|
|
|
|
$updateBobot = false; |
|
|
|
$updateBobot = true; |
|
|
|
if(!$data = Activity::find($id)) |
|
|
|
if(!$data = Activity::find($id)) |
|
|
|
return response()->json(['status'=>'failed', 'action'=>'error','message'=>'Data not found!','code'=> 404], 404); |
|
|
|
return response()->json(['status'=>'failed', 'action'=>'error','message'=>'Data not found!','code'=> 404], 404); |
|
|
|
$dataUpdate = $request->all(); |
|
|
|
$dataUpdate = $request->all(); |
|
|
|
|
|
|
|
|
|
|
|
$oldRencanaBiaya = $data->rencana_biaya; |
|
|
|
|
|
|
|
$newRencanaBiaya = str_replace(",",".",$request->rencana_biaya); |
|
|
|
|
|
|
|
if($oldRencanaBiaya != $newRencanaBiaya) |
|
|
|
|
|
|
|
$updateBobot = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$dataUpdate['name'] = $request->text; |
|
|
|
$dataUpdate['name'] = $request->text; |
|
|
|
$dataUpdate['persentase_progress'] = $request->progress*100; |
|
|
|
$dataUpdate['persentase_progress'] = $request->progress*100; |
|
|
|
$dataUpdate['updated_by'] = $this->currentName; |
|
|
|
$dataUpdate['updated_by'] = $this->currentName; |
|
|
|