Browse Source

project detail use gantt id

pull/3/head
wahyu 1 year ago
parent
commit
a6da8da118
  1. 15
      app/Http/Controllers/ProjectController.php
  2. 2
      routes/web.php

15
app/Http/Controllers/ProjectController.php

@ -469,7 +469,7 @@ class ProjectController extends Controller
return response()->json(['status' => 'success', 'code' => 200, 'data' => $userProyek, 'totalRecord' => $totalRecord], 200);
}
public function detail($id){
public function detail(Request $request, $id, $gantt_id = null){
if(empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
@ -477,12 +477,15 @@ class ProjectController extends Controller
if(!$result)
return response()->json(['status'=>'failed','message'=> 'Data not found!','code'=> 404], 404);
$gantt = MasterFunctionsHelper::getLatestGantt($id);
if (!isset($gantt_id)) {
$gantt = MasterFunctionsHelper::getLatestGantt($id);
$ganttId = $gantt['last_gantt_id'];
} else {
$ganttId = $gantt_id;
}
$result->projectManager = User::where('id', $result->pm_id)->value('name');
$result->header = Activity::whereNull('parent_id')->where("proyek_id", $id)->where("version_gantt_id", $gantt['last_gantt_id'])->first();
$result->header = Activity::whereNull('parent_id')->where("proyek_id", $id)->where("version_gantt_id", $ganttId)->first();
// dd($result->header->start_date);
$ganttId = $gantt['last_gantt_id'];
$actualStartExist = Activity::where('version_gantt_id', $ganttId)->whereNotNull('actual_start')->exists();
$actualEndExist = Activity::where('version_gantt_id', $ganttId)->whereNotNull('actual_end')->exists();
@ -507,7 +510,7 @@ class ProjectController extends Controller
}
$result->header->start_date = $startDate;
$result->header->end_date = $endDate;
return response()->json(['status'=>'success','code'=> 200,'data'=>$result, 'gantt'=>$gantt], 200);
return response()->json(['status'=>'success','code'=> 200,'data'=>$result], 200);
}
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->put('/project/update/{id}', 'ProjectController@update');
$router->get('/project/edit/{id}', 'ProjectController@edit');
$router->get('/project/detail/{id}', 'ProjectController@detail');
$router->get('/project/detail/{id}[/{gantt_id}]', 'ProjectController@detail');
$router->delete('/project/delete/{id}', 'ProjectController@delete');
$router->get('/project/list', 'ProjectController@list');
$router->get('/project/set-baseline/{gantt_id}', 'ProjectController@setBaseline');

Loading…
Cancel
Save