Browse Source

Merge pull request 'dev-wahyu' (#84) from dev-wahyu into staging

Reviewed-on: ordo/adw-backend#84
pull/3/head
ibnu 1 year ago
parent
commit
8b49a77dad
  1. 12
      app/Http/Controllers/ActivityController.php
  2. 12
      app/Models/Activity.php
  3. 1
      routes/web.php

12
app/Http/Controllers/ActivityController.php

@ -348,6 +348,7 @@ class ActivityController extends Controller
Activity::where('version_gantt_id', $data['ganttId'])->delete(); Activity::where('version_gantt_id', $data['ganttId'])->delete();
$projectId = VersionGantt::where('id', $data['ganttId'])->first()->proyek_id; $projectId = VersionGantt::where('id', $data['ganttId'])->first()->proyek_id;
$dayOffs = VersionGantt::find($data['ganttId'])->first()->config_dayoff;
$activityStack = []; $activityStack = [];
@ -738,4 +739,15 @@ 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) {
$data = $request->all();
foreach ($data as $value) {
$activity = Activity::find($value['id']);
$activity->start_date = $value['start_date'];
$activity->end_date = $value['end_date'];
$activity->save();
}
return response()->json(['status'=>'success','data'=>$request,'message'=>'Update successful!','code'=>200], 200);
}
} }

12
app/Models/Activity.php

@ -36,6 +36,11 @@ class Activity extends Model
public function getStartDateAttribute($value) public function getStartDateAttribute($value)
{ {
if ($value instanceof \DateTime) {
return Carbon::instance($value)
->timezone(env('APP_TIMEZONE'))
->toDateTimeString();
}
return Carbon::createFromTimestamp(strtotime($value)) return Carbon::createFromTimestamp(strtotime($value))
->timezone(env('APP_TIMEZONE')) ->timezone(env('APP_TIMEZONE'))
->toDateTimeString(); ->toDateTimeString();
@ -43,6 +48,11 @@ class Activity extends Model
public function getEndDateAttribute($value) public function getEndDateAttribute($value)
{ {
if ($value instanceof \DateTime) {
return Carbon::instance($value)
->timezone(env('APP_TIMEZONE'))
->toDateTimeString();
}
return Carbon::createFromTimestamp(strtotime($value)) return Carbon::createFromTimestamp(strtotime($value))
->timezone(env('APP_TIMEZONE')) ->timezone(env('APP_TIMEZONE'))
->toDateTimeString(); ->toDateTimeString();
@ -188,6 +198,8 @@ class Activity extends Model
return 0; return 0;
if(!$dataPlan = AssignMaterial::where('activity_id', $this->id)->get()) if(!$dataPlan = AssignMaterial::where('activity_id', $this->id)->get())
return 0; return 0;
if($dataPlan->isEmpty())
return 0;
if($dataPlan[0]->status_activity == 'done') if($dataPlan[0]->status_activity == 'done')
return 100; return 100;
return $this->persentase_progress; return $this->persentase_progress;

1
routes/web.php

@ -202,6 +202,7 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout
$router->get('/activity/{id}/{proyek_id}/get', 'ActivityController@getByGanttId'); $router->get('/activity/{id}/{proyek_id}/get', 'ActivityController@getByGanttId');
$router->get('/activity/search', 'ActivityController@search'); $router->get('/activity/search', 'ActivityController@search');
$router->post('/activity/import', 'ActivityController@import'); $router->post('/activity/import', 'ActivityController@import');
$router->post('/activity/import-update', 'ActivityController@importUpdate');
$router->post('/activity/import-old', 'ActivityController@importOld'); $router->post('/activity/import-old', 'ActivityController@importOld');
$router->post('/task', 'ActivityController@add'); $router->post('/task', 'ActivityController@add');
$router->get('/task/edit/{id}', 'ActivityController@edit'); $router->get('/task/edit/{id}', 'ActivityController@edit');

Loading…
Cancel
Save