Browse Source

Format ActivityController

pull/3/head
Wahyu Ramadhan 1 year ago
parent
commit
96222016f0
  1. 30
      app/Http/Controllers/ActivityController.php
  2. 7
      app/Http/Controllers/ProjectController.php

30
app/Http/Controllers/ActivityController.php

@ -36,7 +36,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 = []; $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);
@ -79,8 +80,7 @@ class ActivityController extends Controller
$dataLink = Link::where('version_gantt_id', $id)->get(); $dataLink = Link::where('version_gantt_id', $id)->get();
$finalLink = []; $finalLink = [];
foreach($dataLink as $objRow) foreach ($dataLink as $objRow) {
{
$dataRow = array( $dataRow = array(
'id' => $objRow->id, 'id' => $objRow->id,
'source' => $objRow->s_activity_id, 'source' => $objRow->s_activity_id,
@ -129,7 +129,8 @@ class ActivityController extends Controller
return $finalData; return $finalData;
} }
private function cloneTemplate($id, $proyek_id, $hierarchy_ftth_id = null) { private function cloneTemplate($id, $proyek_id, $hierarchy_ftth_id = null)
{
$project = Project::find($proyek_id); $project = Project::find($proyek_id);
if ($hierarchy_ftth_id) { if ($hierarchy_ftth_id) {
$gantt = VersionGantt::find($id); $gantt = VersionGantt::find($id);
@ -233,7 +234,8 @@ class ActivityController extends Controller
return response()->json(['status' => 'success', 'action' => 'inserted', 'tid' => $result->id, 'code' => 200], 200); return response()->json(['status' => 'success', 'action' => 'inserted', 'tid' => $result->id, 'code' => 200], 200);
} }
public function edit($id){ public function edit($id)
{
if (empty($id) || !is_int((int) $id)) if (empty($id) || !is_int((int) $id))
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
@ -270,7 +272,8 @@ class ActivityController extends Controller
return response()->json(['status' => 'success', 'update_bobot' => $updateBobot, 'data' => $dataUpdate, 'action' => 'updated', 'message' => 'Activity updated!', 'code' => 200], 200); return response()->json(['status' => 'success', 'update_bobot' => $updateBobot, 'data' => $dataUpdate, 'action' => 'updated', 'message' => 'Activity updated!', 'code' => 200], 200);
} }
private function updateOrder($taskId, $target){ private function updateOrder($taskId, $target)
{
$nextTask = false; $nextTask = false;
$targetId = $target; $targetId = $target;
@ -293,7 +296,8 @@ class ActivityController extends Controller
$updatedTask->save(); $updatedTask->save();
} }
public function updateRegular(Request $request, $id){ public function updateRegular(Request $request, $id)
{
if (empty($id) || !is_int((int) $id)) if (empty($id) || !is_int((int) $id))
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
@ -396,7 +400,8 @@ class ActivityController extends Controller
$data['activities'][$key]['weight'] = $parentWeight / $siblingsCount; $data['activities'][$key]['weight'] = $parentWeight / $siblingsCount;
} }
}; }
;
} }
$projectStart = Project::select('mulai_proyek')->where('id', $projectId)->first(); $projectStart = Project::select('mulai_proyek')->where('id', $projectId)->first();
foreach ($data['activities'] as $i => $activity_row) { foreach ($data['activities'] as $i => $activity_row) {
@ -527,7 +532,8 @@ class ActivityController extends Controller
return response()->json(['stack' => $activityStack, 'status' => 'success', 'message' => 'Data imported!', 'projectId' => $projectId, 'code' => 200], 200); return response()->json(['stack' => $activityStack, 'status' => 'success', 'message' => 'Data imported!', 'projectId' => $projectId, 'code' => 200], 200);
} }
private function getLatestGantt($id){ private function getLatestGantt($id)
{
$maxGanttId = VersionGantt::where("proyek_id", $id)->max("id"); $maxGanttId = VersionGantt::where("proyek_id", $id)->max("id");
$data = array( $data = array(
"last_gantt_id" => $maxGanttId, "last_gantt_id" => $maxGanttId,
@ -696,7 +702,8 @@ class ActivityController extends Controller
"date" => $tempDate, "date" => $tempDate,
"percentage" => $tempPercentage, "percentage" => $tempPercentage,
"data_details" => $arr_ActualM, "data_details" => $arr_ActualM,
"budget_control" =>array("current_budget"=> $totalRencanaBudget, "budget_control" => array(
"current_budget" => $totalRencanaBudget,
"acwp" => round($totalACWP, 0), "acwp" => round($totalACWP, 0),
"bcwp" => round($totalBCWP, 0), "bcwp" => round($totalBCWP, 0),
"rem_to_complete" => ($totalRencanaBudget - round($totalACWP, 0)), "rem_to_complete" => ($totalRencanaBudget - round($totalACWP, 0)),
@ -756,7 +763,8 @@ class ActivityController extends Controller
return response()->json(['status' => 'failed', 'message' => 'File is required!', 'code' => 400], 400); return response()->json(['status' => 'failed', 'message' => 'File is required!', 'code' => 400], 400);
} }
public function importUpdate(Request $request) { public function importUpdate(Request $request)
{
$data = $request->all(); $data = $request->all();
foreach ($data as $value) { foreach ($data as $value) {
$activity = Activity::find($value['id']); $activity = Activity::find($value['id']);

7
app/Http/Controllers/ProjectController.php

@ -393,9 +393,14 @@ class ProjectController extends Controller
public function setBaseline($gantt_id) public function setBaseline($gantt_id)
{ {
$activities = Activity::where("version_gantt_id", $gantt_id)->get(); $activities = Activity::where("version_gantt_id", $gantt_id)->orderBy('id')->get();
foreach ($activities as $activity) { foreach ($activities as $activity) {
$successor = Link::where('t_activity_id', $activity->id)->first();
if ($successor) {
$predecessor = Activity::find($successor->s_activity_id);
$activity->start_date = $predecessor->end_date;
}
$activity->update([ $activity->update([
"planned_start"=>$activity->start_date, "planned_start"=>$activity->start_date,
"planned_end"=>$activity->end_date, "planned_end"=>$activity->end_date,

Loading…
Cancel
Save