Browse Source

Merge pull request 'upload-23-04-15' (#85) from staging into master

Reviewed-on: ordo/adw-backend#85
pull/3/head
ibnu 2 years ago
parent
commit
cfe4e26aa8
  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();
$projectId = VersionGantt::where('id', $data['ganttId'])->first()->proyek_id;
$dayOffs = VersionGantt::find($data['ganttId'])->first()->config_dayoff;
$activityStack = [];
@ -738,4 +739,15 @@ class ActivityController extends Controller
}
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)
{
if ($value instanceof \DateTime) {
return Carbon::instance($value)
->timezone(env('APP_TIMEZONE'))
->toDateTimeString();
}
return Carbon::createFromTimestamp(strtotime($value))
->timezone(env('APP_TIMEZONE'))
->toDateTimeString();
@ -43,6 +48,11 @@ class Activity extends Model
public function getEndDateAttribute($value)
{
if ($value instanceof \DateTime) {
return Carbon::instance($value)
->timezone(env('APP_TIMEZONE'))
->toDateTimeString();
}
return Carbon::createFromTimestamp(strtotime($value))
->timezone(env('APP_TIMEZONE'))
->toDateTimeString();
@ -188,6 +198,8 @@ class Activity extends Model
return 0;
if(!$dataPlan = AssignMaterial::where('activity_id', $this->id)->get())
return 0;
if($dataPlan->isEmpty())
return 0;
if($dataPlan[0]->status_activity == 'done')
return 100;
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/search', 'ActivityController@search');
$router->post('/activity/import', 'ActivityController@import');
$router->post('/activity/import-update', 'ActivityController@importUpdate');
$router->post('/activity/import-old', 'ActivityController@importOld');
$router->post('/task', 'ActivityController@add');
$router->get('/task/edit/{id}', 'ActivityController@edit');

Loading…
Cancel
Save