Browse Source

fix schedule dashboard project

pull/3/head
wahyu 1 year ago
parent
commit
6a5c24adcb
  1. 57
      app/Http/Controllers/ProjectController.php
  2. 2
      routes/web.php

57
app/Http/Controllers/ProjectController.php

@ -480,7 +480,7 @@ class ProjectController extends Controller
return response()->json(['status' => 'success', 'code' => 200, 'data' => $userProyek, 'totalRecord' => $totalRecord], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $userProyek, 'totalRecord' => $totalRecord], 200);
} }
public function detail(Request $request, $id, $gantt_id = null){ public function detail(Request $request, $id, $gantt_id = null, $s_curve = null){
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);
@ -495,33 +495,42 @@ class ProjectController extends Controller
$ganttId = $gantt_id; $ganttId = $gantt_id;
} }
$result->projectManager = User::where('id', $result->pm_id)->value('name'); $result->projectManager = User::where('id', $result->pm_id)->value('name');
$result->header = Activity::whereNull('parent_id')->where("proyek_id", $id)->where("version_gantt_id", $ganttId)->first();
// dd($result->header->start_date);
$actualStartExist = Activity::where('version_gantt_id', $ganttId)->whereNotNull('actual_start')->exists(); if (isset($s_curve)) {
$actualEndExist = Activity::where('version_gantt_id', $ganttId)->whereNotNull('actual_end')->exists(); $result->header = Activity::whereNull('parent_id')->where("proyek_id", $id)->first();
$actualStartExist = Activity::where('proyek_id', $id)->whereNotNull('actual_start')->exists();
$actualEndExist = Activity::where('proyek_id', $id)->whereNotNull('actual_end')->exists();
$query = Activity::where('proyek_id', $id);
} else {
$result->header = Activity::whereNull('parent_id')->where("proyek_id", $id)->where("version_gantt_id", $ganttId)->first();
$actualStartExist = Activity::where('version_gantt_id', $ganttId)->whereNotNull('actual_start')->exists();
$actualEndExist = Activity::where('version_gantt_id', $ganttId)->whereNotNull('actual_end')->exists();
$query = Activity::where('version_gantt_id', $ganttId);
}
if ($actualStartExist) { if ($actualStartExist) {
$startDate = Activity::where('version_gantt_id', $ganttId) $startDate = $query->orderBy('actual_start')->value('start_date');
->orderBy('actual_start') } else {
->value('start_date'); $startDate = $query->orderBy('start_date')->value('start_date');
} else { }
$startDate = Activity::where('version_gantt_id', $ganttId)
->orderBy('start_date') if ($actualEndExist) {
->value('start_date'); $endDate = $query->orderByDesc('actual_end')->value('end_date');
} } else {
if ($actualEndExist) { $endDate = $query->orderByDesc('end_date')->value('end_date');
$endDate = Activity::where('version_gantt_id', $ganttId) }
->orderByDesc('actual_end')
->value('end_date'); $plannedStart = Activity::where('version_gantt_id', $ganttId)
} else { ->orderBy('planned_start')
$endDate = Activity::where('version_gantt_id', $ganttId) ->value('planned_start');
->orderByDesc('end_date') $plannedEnd = Activity::where('version_gantt_id', $ganttId)
->value('end_date'); ->orderByDesc('planned_end')
} ->value('planned_end');
$result->header->start_date = $startDate; $result->header->start_date = $startDate;
$result->header->end_date = $endDate; $result->header->end_date = $endDate;
return response()->json(['status'=>'success','code'=> 200,'data'=>$result], 200); $result->header->planned_start = $plannedStart;
$result->header->planned_end = $plannedEnd;
return response()->json(['status'=>'success','code'=> 200,'data'=>$result, 'gantt'=>$ganttId], 200);
} }
public function getOverdueActivities(Request $request){ public function getOverdueActivities(Request $request){

2
routes/web.php

@ -58,7 +58,7 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout
$router->post('/project/add', 'ProjectController@add'); $router->post('/project/add', 'ProjectController@add');
$router->put('/project/update/{id}', 'ProjectController@update'); $router->put('/project/update/{id}', 'ProjectController@update');
$router->get('/project/edit/{id}', 'ProjectController@edit'); $router->get('/project/edit/{id}', 'ProjectController@edit');
$router->get('/project/detail/{id}[/{gantt_id}]', 'ProjectController@detail'); $router->get('/project/detail/{id}[/{gantt_id}[/{s_curve}]]', 'ProjectController@detail');
$router->delete('/project/delete/{id}', 'ProjectController@delete'); $router->delete('/project/delete/{id}', 'ProjectController@delete');
$router->get('/project/list', 'ProjectController@list'); $router->get('/project/list', 'ProjectController@list');
$router->get('/project/set-baseline/{gantt_id}', 'ProjectController@setBaseline'); $router->get('/project/set-baseline/{gantt_id}', 'ProjectController@setBaseline');

Loading…
Cancel
Save