From 3270b42a7778cca697aebd2c1b2307c93298835d Mon Sep 17 00:00:00 2001 From: wahyu Date: Mon, 16 Oct 2023 16:27:21 +0700 Subject: [PATCH 01/12] default page --- app/Http/Controllers/RoleController.php | 3 +++ app/Models/Role.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/RoleController.php b/app/Http/Controllers/RoleController.php index 4a29066..57b8c58 100644 --- a/app/Http/Controllers/RoleController.php +++ b/app/Http/Controllers/RoleController.php @@ -18,6 +18,9 @@ class RoleController extends Controller $data = $request->all(); $data['created_by'] = $this->currentName; + if (!isset($data['default_page'])) { + $data['default_page'] = 29; // dashboard + } $result = Role::create($data); diff --git a/app/Models/Role.php b/app/Models/Role.php index 0363567..73de4a2 100644 --- a/app/Models/Role.php +++ b/app/Models/Role.php @@ -12,6 +12,6 @@ class Role extends Model const UPDATED_AT = 'updated_at'; protected $fillable = [ - 'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by' + 'name', 'description', 'default_page', 'created_at', 'created_by', 'updated_at', 'updated_by' ]; } From 0c2eea2395f632b543a27599fac1e1d5bd8c709d Mon Sep 17 00:00:00 2001 From: wahyu Date: Tue, 17 Oct 2023 11:11:08 +0700 Subject: [PATCH 02/12] division zero handle --- app/Helpers/MasterFunctionsHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Helpers/MasterFunctionsHelper.php b/app/Helpers/MasterFunctionsHelper.php index d681c40..ae74952 100644 --- a/app/Helpers/MasterFunctionsHelper.php +++ b/app/Helpers/MasterFunctionsHelper.php @@ -687,7 +687,7 @@ class MasterFunctionsHelper // } - $totalACWP += $keyActualM->biaya_actual / $keyActualM->duration; + $totalACWP += $keyActualM->duration > 0 ? $keyActualM->biaya_actual / $keyActualM->duration : 0; } catch (\DivisionByZeroError $e) { return response()->json(['message' => $e->getMessage()]); } From 937ae248cdd9412fb85244830e7c4b390da20ed7 Mon Sep 17 00:00:00 2001 From: wahyu Date: Tue, 17 Oct 2023 19:31:17 +0700 Subject: [PATCH 03/12] access creator only --- app/Http/Controllers/ProjectController.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index f5b921b..91fbb3d 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -229,6 +229,7 @@ class ProjectController extends Controller $dataBuilder = $this->setUpPayload($payload, 'm_proyek'); $builder = $dataBuilder['builder']; $countBuilder = $dataBuilder['count']; + $builder->where("selfTable.created_by",$this->currentName); $dataGet = $builder->get(); $totalRecord = $countBuilder->count(); @@ -274,7 +275,9 @@ class ProjectController extends Controller 'created_by', 'updated_at', 'updated_by' - )->orderBy('id', 'desc')->get(); + )->orderBy('id', 'desc') + ->where("created_by",$this->currentName) + ->get(); $countData = $data->count(); if(!$data) From ea33a29ca81b669b675fc99dc99c3e76237b3055 Mon Sep 17 00:00:00 2001 From: wahyu Date: Wed, 18 Oct 2023 13:26:46 +0700 Subject: [PATCH 04/12] custom search for report analysis --- app/Http/Controllers/ProjectController.php | 4 ++-- app/Http/Controllers/UserToActivityController.php | 10 ++++++++++ routes/web.php | 3 ++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 91fbb3d..46c529d 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -229,7 +229,7 @@ class ProjectController extends Controller $dataBuilder = $this->setUpPayload($payload, 'm_proyek'); $builder = $dataBuilder['builder']; $countBuilder = $dataBuilder['count']; - $builder->where("selfTable.created_by",$this->currentName); + // $builder->where("selfTable.created_by",$this->currentName); $dataGet = $builder->get(); $totalRecord = $countBuilder->count(); @@ -276,7 +276,7 @@ class ProjectController extends Controller 'updated_at', 'updated_by' )->orderBy('id', 'desc') - ->where("created_by",$this->currentName) + // ->where("created_by",$this->currentName) ->get(); $countData = $data->count(); diff --git a/app/Http/Controllers/UserToActivityController.php b/app/Http/Controllers/UserToActivityController.php index 2c3a658..a1a9583 100644 --- a/app/Http/Controllers/UserToActivityController.php +++ b/app/Http/Controllers/UserToActivityController.php @@ -129,6 +129,16 @@ class UserToActivityController extends Controller return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); } + public function searchAnalysis(Request $request) + { + $dataBuilder = $this->setUpPayload($request->all(), 'assign_hr_to_activity'); + $builder = $dataBuilder['builder']; + $countBuilder = $dataBuilder['count']; + $dataGet = $builder->get(); + $totalRecord = $countBuilder->count(); + return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200); + } + public function search(Request $request) { $payload = $request->all(); diff --git a/routes/web.php b/routes/web.php index 7f62207..f449cef 100644 --- a/routes/web.php +++ b/routes/web.php @@ -197,6 +197,7 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout $router->get('/user-to-activity/edit/{id}', 'UserToActivityController@edit'); $router->put('/user-to-activity/update/{id}', 'UserToActivityController@update'); $router->post('/user-to-activity/search', 'UserToActivityController@search'); + $router->post('/user-to-activity/search-analysis', 'UserToActivityController@searchAnalysis'); $router->post('/user-to-activity/list-filtered', 'UserToActivityController@listFiltered'); $router->delete('/user-to-activity/delete/{id}', 'UserToActivityController@delete'); $router->get('/user-to-activity/list', 'UserToActivityController@list'); @@ -204,7 +205,7 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout $router->get('/sumVolActualM/{id}', 'ActivityController@sumVolumeActualMaterial'); $router->get('/activity/{id}/{proyek_id}/get', 'ActivityController@getByGanttId'); - $router->get('/activity/search', 'ActivityController@search'); + $router->post('/activity/search', 'ActivityController@search'); $router->post('/activity/import', 'ActivityController@import'); $router->post('/activity/import-update', 'ActivityController@importUpdate'); $router->post('/activity/import-old', 'ActivityController@importOld'); From 6ba8f63717f410405a5af5421b4b4372bafdc544 Mon Sep 17 00:00:00 2001 From: wahyu Date: Thu, 19 Oct 2023 08:03:40 +0700 Subject: [PATCH 05/12] fix endline --- app/Models/HumanResource.php | 76 ++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/app/Models/HumanResource.php b/app/Models/HumanResource.php index 222a835..d3c98d1 100644 --- a/app/Models/HumanResource.php +++ b/app/Models/HumanResource.php @@ -1,38 +1,38 @@ - Date: Thu, 19 Oct 2023 08:05:39 +0700 Subject: [PATCH 06/12] fix endline --- app/Models/CommentActivity.php | 44 +++++++++++++++++----------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/app/Models/CommentActivity.php b/app/Models/CommentActivity.php index e747af2..0cd259e 100644 --- a/app/Models/CommentActivity.php +++ b/app/Models/CommentActivity.php @@ -1,22 +1,22 @@ - Date: Thu, 19 Oct 2023 08:06:59 +0700 Subject: [PATCH 07/12] fix endline --- app/Models/VersionGantt.php | 154 ++++++++++++++++++------------------ 1 file changed, 77 insertions(+), 77 deletions(-) diff --git a/app/Models/VersionGantt.php b/app/Models/VersionGantt.php index 4409af8..765ddf1 100644 --- a/app/Models/VersionGantt.php +++ b/app/Models/VersionGantt.php @@ -1,77 +1,77 @@ -updateActDuration(); - }); - } - - public function updateActDuration(){ - $daysOff = explode(',', $this->config_dayoff); - if (in_array('0', $daysOff)) { - $key = array_search('0', $daysOff, false); - $daysOff[$key] = '7'; - } - $activities = Activity::where('version_gantt_id', $this->id)->get(); - foreach ($activities as $value) { - $exist = Link::where('t_activity_id', $value->id)->exists(); - $startDate = new DateTime($value->start_date); - $endDate = new DateTime($value->end_date); - $duration = $endDate->diff($startDate)->days + 1; - if ($exist) { - $duration--; - } - - // Iterate through each day and subtract the days off - for ($i = 0; $i < $duration; $i++) { - $currentDate = clone $startDate; - $currentDate->modify("+$i day"); - - $currentDayOfWeek = $currentDate->format('N'); // Get the day of the week (1 - Monday, 7 - Sunday) - - if (in_array($currentDayOfWeek, $daysOff)) { - $duration--; // Subtract one day from the duration for each day off - } - } - - // Update the activity duration - $value->duration = $duration; - $value->save(); - } - } -} +updateActDuration(); + }); + } + + public function updateActDuration(){ + $daysOff = explode(',', $this->config_dayoff); + if (in_array('0', $daysOff)) { + $key = array_search('0', $daysOff, false); + $daysOff[$key] = '7'; + } + $activities = Activity::where('version_gantt_id', $this->id)->get(); + foreach ($activities as $value) { + $exist = Link::where('t_activity_id', $value->id)->exists(); + $startDate = new DateTime($value->start_date); + $endDate = new DateTime($value->end_date); + $duration = $endDate->diff($startDate)->days + 1; + if ($exist) { + $duration--; + } + + // Iterate through each day and subtract the days off + for ($i = 0; $i < $duration; $i++) { + $currentDate = clone $startDate; + $currentDate->modify("+$i day"); + + $currentDayOfWeek = $currentDate->format('N'); // Get the day of the week (1 - Monday, 7 - Sunday) + + if (in_array($currentDayOfWeek, $daysOff)) { + $duration--; // Subtract one day from the duration for each day off + } + } + + // Update the activity duration + $value->duration = $duration; + $value->save(); + } + } +} From ef500ad9754c954b4dcc270b42ee3e8990a19162 Mon Sep 17 00:00:00 2001 From: wahyu Date: Thu, 19 Oct 2023 10:21:54 +0700 Subject: [PATCH 08/12] custom activity search --- app/Http/Controllers/ActivityController.php | 11 +++++++++++ routes/web.php | 1 + 2 files changed, 12 insertions(+) diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php index acd94b0..df66558 100644 --- a/app/Http/Controllers/ActivityController.php +++ b/app/Http/Controllers/ActivityController.php @@ -527,6 +527,17 @@ class ActivityController extends Controller return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200); } + public function searchAnalysis(Request $request) + { + $dataBuilder = $this->setUpPayload($request->all(), 'm_activity'); + $builder = $dataBuilder['builder']; + $dataGet = $builder->select('selfTable.*','m_version_gantt.name_version', 'm_users.name as user_name') + ->join('m_version_gantt', 'm_version_gantt.id', '=', 'selfTable.version_gantt_id') + ->join('assign_hr_to_activity', 'assign_hr_to_activity.activity_id', '=', 'selfTable.id') + ->join('m_users', 'assign_hr_to_activity.user_id', '=', 'm_users.id') + ->get(); + return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet ], 200); + } // before upload file public function importOld(Request $request) { diff --git a/routes/web.php b/routes/web.php index f449cef..73b90db 100644 --- a/routes/web.php +++ b/routes/web.php @@ -206,6 +206,7 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout $router->get('/sumVolActualM/{id}', 'ActivityController@sumVolumeActualMaterial'); $router->get('/activity/{id}/{proyek_id}/get', 'ActivityController@getByGanttId'); $router->post('/activity/search', 'ActivityController@search'); + $router->post('/activity/search-analysis', 'ActivityController@searchAnalysis'); $router->post('/activity/import', 'ActivityController@import'); $router->post('/activity/import-update', 'ActivityController@importUpdate'); $router->post('/activity/import-old', 'ActivityController@importOld'); From 5b53d9f3a0cab4629db5b018f1ec53627cfb509d Mon Sep 17 00:00:00 2001 From: wahyuun Date: Thu, 19 Oct 2023 12:35:15 +0700 Subject: [PATCH 09/12] add color select --- app/Http/Controllers/DashboardBoDController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/DashboardBoDController.php b/app/Http/Controllers/DashboardBoDController.php index 143af38..ebdf8a3 100644 --- a/app/Http/Controllers/DashboardBoDController.php +++ b/app/Http/Controllers/DashboardBoDController.php @@ -304,7 +304,7 @@ class DashboardBoDController extends Controller { $year = $this->interpolateYear($year); - $divisions = Divisi::select('id', 'name') + $divisions = Divisi::select('id', 'name', 'color') ->with('children') ->whereNull('parent') ->get(); From 6d8bfa260279bfd86efd656177adc77167001522 Mon Sep 17 00:00:00 2001 From: wahyu Date: Thu, 19 Oct 2023 13:24:58 +0700 Subject: [PATCH 10/12] Fix endline --- .../Controllers/ActivityDokumenController.php | 190 +++++++++--------- 1 file changed, 95 insertions(+), 95 deletions(-) diff --git a/app/Http/Controllers/ActivityDokumenController.php b/app/Http/Controllers/ActivityDokumenController.php index f3a1143..999e860 100644 --- a/app/Http/Controllers/ActivityDokumenController.php +++ b/app/Http/Controllers/ActivityDokumenController.php @@ -1,95 +1,95 @@ -json(['status'=>'failed','message'=>'activity id is required!','code'=>400], 400); - - $dataDokumen = ActivityDokumen::where("activity_id", $id)->get(); - return response()->json(['status'=>'success','data'=>$dataDokumen,'code'=>200], 200); - } - - public function delete($id) - { - if(empty($id) || !is_int((int)$id)) - return response()->json(['status'=>'failed','message'=>'Id is required!','code'=>400], 400); - - $document = ActivityDokumen::find($id); - - if(!$document) - return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404); - - if(file_exists($this->pathActivityDocument.$document->file)) - unlink($this->pathActivityDocument.$document->file); - - $document->delete(); - return response()->json(['status'=>'success','message'=>'Dokumen deleted successfully!','code'=>200], 200); - } - - public function uploadProjectDokumen(Request $request) - { - if(!$request->hasFile('dokumen')) - return response()->json(['status'=>'failed','message'=>'file is required!','code'=>400], 400); - - $activity_id = $request->activity_id; - $document = $request->file('dokumen'); - $name = $document->getClientOriginalName(); - - $result = $document->move($this->pathActivityDocument, $name); - - if(!$result) - return response()->json(['status'=>'failed','message'=>'Upload failed!','code'=> 500], 500); - - $data = [ - 'activity_id' => (int)$activity_id, - 'file' => $name, - 'description' => $request->description - ]; - - $result = ActivityDokumen::create($data); - - if(!$result){ - unlink($this->pathActivityDocument.$name); - return response()->json(['status'=>'failed','message'=>'Upload failed!','code'=> 500], 500); - } - - return response()->json(['status'=>'success','message'=>'Upload success!','code'=>200], 200); - } - - public function searchDocProject(Request $request){ - $payload = $request->all(); - - $dataBuilder = $this->setUpPayload($payload, 'm_document_activity'); - $builder = $dataBuilder['builder']; - $countBuilder = $dataBuilder['count']; - $dataGet = $builder->get(); - $totalRecord = $countBuilder->count(); - - return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); - } - - public function downloadDokumen($id) - { - if(empty($id) || !is_int((int)$id)) - return response()->json(['status'=>'failed','message'=>'Id is required!','code'=>400], 400); - - $document = ActivityDokumen::find($id); - - if(!$document) - return response()->json(['status'=>'failed','message'=>'Data not found!','code'=>400], 400); - - if(file_exists($this->pathActivityDocument.$document->file)){ - $pathToFile = $this->pathActivityDocument.$document->file; - return response()->download($pathToFile); - } - - return response()->json(['status'=>'failed','message'=>'Data not found!','code'=>400], 400); - } -} +json(['status'=>'failed','message'=>'activity id is required!','code'=>400], 400); + + $dataDokumen = ActivityDokumen::where("activity_id", $id)->get(); + return response()->json(['status'=>'success','data'=>$dataDokumen,'code'=>200], 200); + } + + public function delete($id) + { + if(empty($id) || !is_int((int)$id)) + return response()->json(['status'=>'failed','message'=>'Id is required!','code'=>400], 400); + + $document = ActivityDokumen::find($id); + + if(!$document) + return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404); + + if(file_exists($this->pathActivityDocument.$document->file)) + unlink($this->pathActivityDocument.$document->file); + + $document->delete(); + return response()->json(['status'=>'success','message'=>'Dokumen deleted successfully!','code'=>200], 200); + } + + public function uploadProjectDokumen(Request $request) + { + if(!$request->hasFile('dokumen')) + return response()->json(['status'=>'failed','message'=>'file is required!','code'=>400], 400); + + $activity_id = $request->activity_id; + $document = $request->file('dokumen'); + $name = $document->getClientOriginalName(); + + $result = $document->move($this->pathActivityDocument, $name); + + if(!$result) + return response()->json(['status'=>'failed','message'=>'Upload failed!','code'=> 500], 500); + + $data = [ + 'activity_id' => (int)$activity_id, + 'file' => $name, + 'description' => $request->description + ]; + + $result = ActivityDokumen::create($data); + + if(!$result){ + unlink($this->pathActivityDocument.$name); + return response()->json(['status'=>'failed','message'=>'Upload failed!','code'=> 500], 500); + } + + return response()->json(['status'=>'success','message'=>'Upload success!','code'=>200], 200); + } + + public function searchDocProject(Request $request){ + $payload = $request->all(); + + $dataBuilder = $this->setUpPayload($payload, 'm_document_activity'); + $builder = $dataBuilder['builder']; + $countBuilder = $dataBuilder['count']; + $dataGet = $builder->get(); + $totalRecord = $countBuilder->count(); + + return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); + } + + public function downloadDokumen($id) + { + if(empty($id) || !is_int((int)$id)) + return response()->json(['status'=>'failed','message'=>'Id is required!','code'=>400], 400); + + $document = ActivityDokumen::find($id); + + if(!$document) + return response()->json(['status'=>'failed','message'=>'Data not found!','code'=>400], 400); + + if(file_exists($this->pathActivityDocument.$document->file)){ + $pathToFile = $this->pathActivityDocument.$document->file; + return response()->download($pathToFile); + } + + return response()->json(['status'=>'failed','message'=>'Data not found!','code'=>400], 400); + } +} From 66e72be3a2883ead8e2ab659fac2ab54a18773af Mon Sep 17 00:00:00 2001 From: wahyu Date: Thu, 19 Oct 2023 14:11:48 +0700 Subject: [PATCH 11/12] access creator only --- app/Http/Controllers/ProjectController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 46c529d..91fbb3d 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -229,7 +229,7 @@ class ProjectController extends Controller $dataBuilder = $this->setUpPayload($payload, 'm_proyek'); $builder = $dataBuilder['builder']; $countBuilder = $dataBuilder['count']; - // $builder->where("selfTable.created_by",$this->currentName); + $builder->where("selfTable.created_by",$this->currentName); $dataGet = $builder->get(); $totalRecord = $countBuilder->count(); @@ -276,7 +276,7 @@ class ProjectController extends Controller 'updated_at', 'updated_by' )->orderBy('id', 'desc') - // ->where("created_by",$this->currentName) + ->where("created_by",$this->currentName) ->get(); $countData = $data->count(); From 736eb9c617e41c4f5c0bd08b962ceaae6551b613 Mon Sep 17 00:00:00 2001 From: wahyu Date: Fri, 20 Oct 2023 11:11:28 +0700 Subject: [PATCH 12/12] disable created by --- app/Http/Controllers/ProjectController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 301dc42..39042ec 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -229,7 +229,7 @@ class ProjectController extends Controller $dataBuilder = $this->setUpPayload($payload, 'm_proyek'); $builder = $dataBuilder['builder']; $countBuilder = $dataBuilder['count']; - $builder->where("selfTable.created_by",$this->currentName); + // $builder->where("selfTable.created_by",$this->currentName); $dataGet = $builder->get(); $totalRecord = $countBuilder->count(); @@ -276,7 +276,7 @@ class ProjectController extends Controller 'updated_at', 'updated_by' )->orderBy('id', 'desc') - ->where("created_by",$this->currentName) + // ->where("created_by",$this->currentName) ->get(); $countData = $data->count();