|
|
|
@ -42,20 +42,22 @@ class ActivityController extends Controller
|
|
|
|
|
|
|
|
|
|
foreach($data as $objRow){ |
|
|
|
|
$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") |
|
|
|
|
$type = $objRow->type_activity; |
|
|
|
|
if(empty($dataChildren)) |
|
|
|
|
$type = "task"; |
|
|
|
|
|
|
|
|
|
$objRow->text = $objRow->name; |
|
|
|
|
$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->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_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; |
|
|
|
|
$dataChildren = $this->getChildren($id, $objRow->id); |
|
|
|
|
$objRow->type = $type; |
|
|
|
|
$finalData[] = $objRow; |
|
|
|
|
$finalData = array_merge($finalData, $dataChildren); |
|
|
|
@ -183,7 +185,10 @@ class ActivityController extends Controller
|
|
|
|
|
|
|
|
|
|
$parent = $data['parent_id'] ?? null; |
|
|
|
|
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(); |
|
|
|
|
UserToActivity::where('activity_id', $parent)->delete(); |
|
|
|
|
} |
|
|
|
@ -209,16 +214,11 @@ class ActivityController extends Controller
|
|
|
|
|
if(empty($id) || !is_int((int)$id)) |
|
|
|
|
return response()->json(['status'=>'failed', 'action'=>'error','message'=>'id is required!','code'=>400], 400); |
|
|
|
|
|
|
|
|
|
$updateBobot = false; |
|
|
|
|
$updateBobot = true; |
|
|
|
|
if(!$data = Activity::find($id)) |
|
|
|
|
return response()->json(['status'=>'failed', 'action'=>'error','message'=>'Data not found!','code'=> 404], 404); |
|
|
|
|
$dataUpdate = $request->all(); |
|
|
|
|
|
|
|
|
|
$oldRencanaBiaya = $data->rencana_biaya; |
|
|
|
|
$newRencanaBiaya = str_replace(",",".",$request->rencana_biaya); |
|
|
|
|
if($oldRencanaBiaya != $newRencanaBiaya) |
|
|
|
|
$updateBobot = true; |
|
|
|
|
|
|
|
|
|
$dataUpdate['name'] = $request->text; |
|
|
|
|
$dataUpdate['persentase_progress'] = $request->progress*100; |
|
|
|
|
$dataUpdate['updated_by'] = $this->currentName; |
|
|
|
|