Browse Source

update type condition

pull/1/head
farhantock 1 year ago
parent
commit
b44644f13a
  1. 29
      app/Http/Controllers/ActivityController.php

29
app/Http/Controllers/ActivityController.php

@ -1,4 +1,5 @@
<?php <?php
namespace App\Http\Controllers; namespace App\Http\Controllers;
use DateTime; use DateTime;
@ -37,7 +38,8 @@ class ActivityController extends Controller
return response()->json(['status' => 'success', 'data' => $dataGantt, 'code' => 200], 200); return response()->json(['status' => 'success', 'data' => $dataGantt, 'code' => 200], 200);
} }
public function activitySCurve($proyek_id, $gantt_id){ public function activitySCurve($proyek_id, $gantt_id)
{
// "data": [ // "data": [
// { // {
@ -122,7 +124,6 @@ class ActivityController extends Controller
); );
return response()->json(['status' => 'success', 'data' => $resultData, 'code' => 200], 200); return response()->json(['status' => 'success', 'data' => $resultData, 'code' => 200], 200);
} }
private function getDataActivity($id) private function getDataActivity($id)
@ -281,7 +282,8 @@ class ActivityController extends Controller
return $finalData; return $finalData;
} }
public function getActivityFirst($parentId){ public function getActivityFirst($parentId)
{
$activity = Activity::where('parent_id', $parentId)->orderByRaw('actual_start ASC')->first(); $activity = Activity::where('parent_id', $parentId)->orderByRaw('actual_start ASC')->first();
if (!isset($activity)) { if (!isset($activity)) {
return null; return null;
@ -292,10 +294,10 @@ class ActivityController extends Controller
} else { } else {
return $this->getActivityFirst($activity->id); return $this->getActivityFirst($activity->id);
} }
} }
public function getFirstLastDateActivity($id, $params){ public function getFirstLastDateActivity($id, $params)
{
if ($params == "start") { if ($params == "start") {
$data = Activity::select('id', 'parent_id', 'name', 'actual_start')->where('parent_id', $id)->get(); $data = Activity::select('id', 'parent_id', 'name', 'actual_start')->where('parent_id', $id)->get();
} else { } else {
@ -307,7 +309,6 @@ class ActivityController extends Controller
$activity = $this->getchildActivityForActual($val->id, $params); $activity = $this->getchildActivityForActual($val->id, $params);
$dataFinal[] = $val; $dataFinal[] = $val;
$dataFinal = array_merge($dataFinal, $activity); $dataFinal = array_merge($dataFinal, $activity);
} }
if ($params == "start") { if ($params == "start") {
$actualStartValues = array_column(array_filter($dataFinal, function ($item) { $actualStartValues = array_column(array_filter($dataFinal, function ($item) {
@ -333,7 +334,8 @@ class ActivityController extends Controller
return $returnActualStartOrEnd; return $returnActualStartOrEnd;
} }
public function getchildActivityForActual($parent, $params){ public function getchildActivityForActual($parent, $params)
{
if ($params == "start") { if ($params == "start") {
$activity = Activity::select('id', 'actual_start')->where('parent_id', $parent)->get(); $activity = Activity::select('id', 'actual_start')->where('parent_id', $parent)->get();
} else { } else {
@ -348,7 +350,8 @@ class ActivityController extends Controller
return $temp; 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)) {
return null; return null;
@ -359,7 +362,6 @@ class ActivityController extends Controller
} else { } else {
return $this->getActivityLast($activity->id); return $this->getActivityLast($activity->id);
} }
} }
private function cloneTemplate($id, $proyek_id, $hierarchy_ftth_id = null) private function cloneTemplate($id, $proyek_id, $hierarchy_ftth_id = null)
@ -547,7 +549,8 @@ class ActivityController extends Controller
return response()->json(['status' => 'success', 'message' => 'Activity Updated!', 'code' => 200], 200); return response()->json(['status' => 'success', 'message' => 'Activity Updated!', 'code' => 200], 200);
} }
public function updateSchedule($ganttId){ public function updateSchedule($ganttId)
{
if (empty($ganttId) || !is_int((int) $ganttId)) if (empty($ganttId) || !is_int((int) $ganttId))
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
@ -604,7 +607,7 @@ class ActivityController extends Controller
$activityToUpdate = $activity->firstWhere('id', $entity['data']['id']); $activityToUpdate = $activity->firstWhere('id', $entity['data']['id']);
$entity['data']['name'] = $entity['data']['text']; $entity['data']['name'] = $entity['data']['text'];
$entity['data']['persentase_progress'] = $entity['data']['progress'] * 100; $entity['data']['persentase_progress'] = $entity['data']['progress'] * 100;
$entity['data']['type_activity'] = $entity['data']['type']; $entity['data']['type_activity'] = $entity['data']['type'] ?? 'task';
if (isset($entity['data']['rencana_biaya'])) { if (isset($entity['data']['rencana_biaya'])) {
$entity['data']['rencana_biaya'] = str_replace(",", ".", $entity['data']['rencana_biaya']); $entity['data']['rencana_biaya'] = str_replace(",", ".", $entity['data']['rencana_biaya']);
} }
@ -777,8 +780,7 @@ 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) {
@ -1137,7 +1139,6 @@ class ActivityController extends Controller
return response()->json(['status' => 'failed', 'message' => 'Upload failed!', 'code' => 500], 500); return response()->json(['status' => 'failed', 'message' => 'Upload failed!', 'code' => 500], 500);
} }
return response()->json(['status' => 'success', 'message' => 'Upload successful!', 'code' => 200], 200); return response()->json(['status' => 'success', 'message' => 'Upload successful!', 'code' => 200], 200);
} }
return response()->json(['status' => 'failed', 'message' => 'Upload failed!', 'code' => 500], 500); return response()->json(['status' => 'failed', 'message' => 'Upload failed!', 'code' => 500], 500);
} }

Loading…
Cancel
Save