|
|
@ -48,9 +48,9 @@ class ActivityController extends Controller |
|
|
|
$dataHeader->planned_start = isset($dataHeader->planned_start) ? date_format(date_create($dataHeader->planned_start), "Y-m-d H:i:s") : NULL; |
|
|
|
$dataHeader->planned_start = isset($dataHeader->planned_start) ? date_format(date_create($dataHeader->planned_start), "Y-m-d H:i:s") : NULL; |
|
|
|
$dataHeader->planned_end = isset($dataHeader->planned_end) ? date_format(date_create($dataHeader->planned_end), "Y-m-d H:i:s") : NULL; |
|
|
|
$dataHeader->planned_end = isset($dataHeader->planned_end) ? date_format(date_create($dataHeader->planned_end), "Y-m-d H:i:s") : NULL; |
|
|
|
|
|
|
|
|
|
|
|
$actualStart = $this->getActivityFirst($dataHeader->id); |
|
|
|
$actualStart = $this->getFirstLastDateActivity($dataHeader->id, "start"); |
|
|
|
$dataHeader->actual_start = date_format(date_create($actualStart), "Y-m-d"); |
|
|
|
$dataHeader->actual_start = date_format(date_create($actualStart), "Y-m-d"); |
|
|
|
$actualEnd = $this->getActivityLast($dataHeader->id); |
|
|
|
$actualEnd = $this->getFirstLastDateActivity($dataHeader->id, "end"); |
|
|
|
$dataHeader->actual_end = isset($actualEnd) ? date_format(date_create($actualEnd), "Y-m-d") : NULL; |
|
|
|
$dataHeader->actual_end = isset($actualEnd) ? date_format(date_create($actualEnd), "Y-m-d") : NULL; |
|
|
|
|
|
|
|
|
|
|
|
$dataHeader->type = "header"; |
|
|
|
$dataHeader->type = "header"; |
|
|
@ -79,9 +79,9 @@ class ActivityController extends Controller |
|
|
|
$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; |
|
|
|
|
|
|
|
|
|
|
|
$actualStart = $this->getActivityFirst($objRow->id); |
|
|
|
$actualStart = $this->getFirstLastDateActivity($objRow->id, "start"); |
|
|
|
$objRow->actual_start = isset($actualStart) ? date_format(date_create($actualStart), "Y-m-d") : NULL; |
|
|
|
$objRow->actual_start = isset($actualStart) ? date_format(date_create($actualStart), "Y-m-d") : NULL; |
|
|
|
$actualEnd = $this->getActivityLast($objRow->id); |
|
|
|
$actualEnd = $this->getFirstLastDateActivity($objRow->id, "end"); |
|
|
|
$objRow->actual_end = isset($actualEnd) ? date_format(date_create($actualEnd), "Y-m-d") : NULL; |
|
|
|
$objRow->actual_end = isset($actualEnd) ? date_format(date_create($actualEnd), "Y-m-d") : NULL; |
|
|
|
|
|
|
|
|
|
|
|
$objRow->progress = $objRow->persentase_progress / 100; |
|
|
|
$objRow->progress = $objRow->persentase_progress / 100; |
|
|
@ -141,10 +141,10 @@ class ActivityController extends Controller |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$objRow->type = "project"; |
|
|
|
$objRow->type = "project"; |
|
|
|
$actualStart = $this->getActivityFirst($objRow->id); |
|
|
|
$actualStart = $this->getFirstLastDateActivity($objRow->id, "start"); |
|
|
|
$objRow->actual_start = isset($actualStart) ? date_format(date_create($actualStart), "Y-m-d") : NULL; |
|
|
|
$objRow->actual_start = isset($actualStart) ? date_format(date_create($actualStart), "Y-m-d") : NULL; |
|
|
|
|
|
|
|
|
|
|
|
$actualEnd = $this->getActivityLast($objRow->id); |
|
|
|
$actualEnd = $this->getFirstLastDateActivity($objRow->id, "end"); |
|
|
|
$objRow->actual_end = isset($actualEnd) ? date_format(date_create($actualEnd), "Y-m-d") : NULL; |
|
|
|
$objRow->actual_end = isset($actualEnd) ? date_format(date_create($actualEnd), "Y-m-d") : NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
$finalData[] = $objRow; |
|
|
|
$finalData[] = $objRow; |
|
|
@ -167,6 +167,52 @@ class ActivityController extends Controller |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getFirstLastDateActivity($id, $params){ |
|
|
|
|
|
|
|
if($params == "start"){ |
|
|
|
|
|
|
|
$data = Activity::select('id', 'parent_id', 'name', 'actual_start')->where('parent_id', $id)->get(); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
$data = Activity::select('id', 'parent_id', 'name', 'actual_end')->where('parent_id', $id)->get(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$dataFinal=[]; |
|
|
|
|
|
|
|
foreach ($data as $val) { |
|
|
|
|
|
|
|
$activity = $this->getchildActivityForActual($val->id, $params); |
|
|
|
|
|
|
|
$dataFinal[] = $val; |
|
|
|
|
|
|
|
$dataFinal = array_merge($dataFinal, $activity); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if($params == "start"){ |
|
|
|
|
|
|
|
$actualStartValues = array_column(array_filter($dataFinal, function($item) { |
|
|
|
|
|
|
|
return isset($item['actual_start']); |
|
|
|
|
|
|
|
}), 'actual_start'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$returnActualStartOrEnd = count($actualStartValues) > 0 ? min($actualStartValues) : null; |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
$actualEndValues = array_column(array_filter($dataFinal, function($item) { |
|
|
|
|
|
|
|
return isset($item['actual_end']); |
|
|
|
|
|
|
|
}), 'actual_end'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$returnActualStartOrEnd = count($actualEndValues) > 0 ? max($actualEndValues) : null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// return json_encode(["min"=>$minActualStart, "max"=>$maxActualStart]); |
|
|
|
|
|
|
|
return $returnActualStartOrEnd; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getchildActivityForActual($parent, $params){ |
|
|
|
|
|
|
|
if($params == "start"){ |
|
|
|
|
|
|
|
$activity = Activity::select('id', 'actual_start')->where('parent_id', $parent)->get(); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
$activity = Activity::select('id', 'actual_end')->where('parent_id', $parent)->get(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$temp = []; |
|
|
|
|
|
|
|
foreach($activity as $val1){ |
|
|
|
|
|
|
|
$getChild = $this->getchildActivityForActual($val1->id, $params); |
|
|
|
|
|
|
|
$temp[] = $val1; |
|
|
|
|
|
|
|
$temp = array_merge($temp, $getChild); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return $temp; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getActivityLast($parentId){ |
|
|
|
public function getActivityLast($parentId){ |
|
|
|
$activity = Activity::where('parent_id', $parentId)->orderByRaw('actual_end DESC')->first(); |
|
|
|
$activity = Activity::where('parent_id', $parentId)->orderByRaw('actual_end DESC')->first(); |
|
|
|
if (!isset($activity)) { |
|
|
|
if (!isset($activity)) { |
|
|
|