From 937ae248cdd9412fb85244830e7c4b390da20ed7 Mon Sep 17 00:00:00 2001 From: wahyu Date: Tue, 17 Oct 2023 19:31:17 +0700 Subject: [PATCH 1/9] 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 2/9] 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 3/9] 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 4/9] 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 5/9] 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 6/9] 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 7/9] 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 a72135a55ba6396dd5d8e6f9ed1ac8657c7de60f Mon Sep 17 00:00:00 2001 From: farhan048 Date: Thu, 19 Oct 2023 12:59:08 +0700 Subject: [PATCH 8/9] resolve conflict --- app/Models/HumanResource.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Models/HumanResource.php b/app/Models/HumanResource.php index 222a835..1f28852 100644 --- a/app/Models/HumanResource.php +++ b/app/Models/HumanResource.php @@ -33,6 +33,7 @@ class HumanResource extends Model 'updated_at', 'updated_by', 'divisi_id', - 'status_boundary' + 'status_boundary', + 'company_id' ]; } From b5e3bf60fd1fdef001cd7c247eebf6b86af93e27 Mon Sep 17 00:00:00 2001 From: farhan048 Date: Thu, 19 Oct 2023 15:46:26 +0700 Subject: [PATCH 9/9] update field for ospro general --- app/Http/Controllers/CompanyController.php | 85 ++++++++ app/Http/Controllers/Controller.php | 235 +++++++++++---------- app/Models/Company.php | 37 ++++ app/Models/Divisi.php | 36 ++-- app/Models/Menu.php | 2 +- app/Models/ProjectPhase.php | 2 +- app/Models/ProjectRole.php | 2 +- app/Models/ProjectType.php | 2 +- app/Models/Role.php | 2 +- app/Models/RoleMenu.php | 2 +- app/Models/Satuan.php | 2 +- 11 files changed, 270 insertions(+), 137 deletions(-) create mode 100644 app/Http/Controllers/CompanyController.php create mode 100644 app/Models/Company.php diff --git a/app/Http/Controllers/CompanyController.php b/app/Http/Controllers/CompanyController.php new file mode 100644 index 0000000..d71519b --- /dev/null +++ b/app/Http/Controllers/CompanyController.php @@ -0,0 +1,85 @@ +currentDate = date("Y-m-d H:i:s"); $this->currentName = auth()->user() ? auth()->user()->name : "system"; $this->currentId = auth()->user() ? auth()->user()->id : 0; - + $this->companyId = auth()->user() ? auth()->user()->company_id : 0; $this->pathImage = config('assets.image'); $this->pathDocument = config('assets.project'); $this->pathActivityDocument = config('assets.activity'); @@ -36,41 +40,41 @@ class Controller extends BaseController protected function setUpPayload($condition, $tableSelf) { $alias = "selfTable"; - $builder = DB::table($tableSelf." AS ".$alias); + $builder = DB::table($tableSelf . " AS " . $alias); // $builder = $builder->select($alias.".*"); - if($condition){ - if(isset($condition['select'])){ - foreach($condition['select'] as $select){ - $builder = $builder->addSelect($alias.".".$select); + if ($condition) { + if (isset($condition['select'])) { + foreach ($condition['select'] as $select) { + $builder = $builder->addSelect($alias . "." . $select); } - }else{ - $builder = $builder->addSelect($alias.".*"); + } else { + $builder = $builder->addSelect($alias . ".*"); } - if(isset($condition['joins'])){ + if (isset($condition['joins'])) { $selectColumn = []; $no = 0; - foreach($condition['joins'] as $join){ + foreach ($condition['joins'] as $join) { $tableJoin = isset($join['name1']) ? $join['name1'] : $alias; $tableName = $join['name']; $columnJoin = $join['column_join']; // foreign key table sini $columnSelf = isset($join['column_self']) ? $join['column_self'] : "id"; // primary key table lawan $columnResult = $join['column_results']; - foreach($columnResult as $sColumn){ - $builder = $builder->addSelect($tableName.".".$sColumn." as join_".$this->listJoinAll[$no]."_".$sColumn); + foreach ($columnResult as $sColumn) { + $builder = $builder->addSelect($tableName . "." . $sColumn . " as join_" . $this->listJoinAll[$no] . "_" . $sColumn); } - $builder = $builder->leftJoin($tableName, $tableJoin.".".$columnJoin, '=', $tableName.'.'.$columnSelf); + $builder = $builder->leftJoin($tableName, $tableJoin . "." . $columnJoin, '=', $tableName . '.' . $columnSelf); $no++; } } - if(isset($condition['columns'])){ + if (isset($condition['columns'])) { $listWhere = $condition['columns']; - $builder = $builder->where(function ($query) use($listWhere, $alias){ - foreach($listWhere as $where){ + $builder = $builder->where(function ($query) use ($listWhere, $alias) { + foreach ($listWhere as $where) { $value = $where['value']; - if($value && $value!="" && $value!=" "){ + if ($value && $value != "" && $value != " ") { $column = $where['name']; $operator = strtolower($where['logic_operator']); // like, =, <>, range $value2 = isset($where['value1']) ? $where['value1'] : ""; @@ -81,22 +85,22 @@ class Controller extends BaseController }); } - if(isset($condition['group_column'])){ + if (isset($condition['group_column'])) { $builder = $this->groupWhere($builder, $condition['group_column'], $alias); } $data['count'] = clone $builder; - if(isset($condition['paging'])){ + if (isset($condition['paging'])) { $builder = $builder->offset($condition['paging']['start'])->limit($condition['paging']['length']); } - if(isset($condition['orders'])){ + if (isset($condition['orders'])) { $orders = $condition['orders']; $sortBy = $orders['ascending'] ? "ASC" : "DESC"; $columnOrder = $orders['columns']; - foreach($columnOrder as $column){ - $builder = $builder->orderBy($alias.".".$column, $sortBy); + foreach ($columnOrder as $column) { + $builder = $builder->orderBy($alias . "." . $column, $sortBy); } } } @@ -111,8 +115,8 @@ class Controller extends BaseController $operator = $listGroupWhere['operator']; $operatorGroup = $listGroupWhere['group_operator']; $listWhere = $listGroupWhere['where']; - if(strtolower($operator)=="and"){ - $builder = $builder->where(function($query) use($operatorGroup, $listWhere, $alias){ + if (strtolower($operator) == "and") { + $builder = $builder->where(function ($query) use ($operatorGroup, $listWhere, $alias) { $no = 1; foreach ($listWhere as $where) { $value = $where['value']; @@ -120,22 +124,22 @@ class Controller extends BaseController $operator = strtolower($where['logic_operator']); $value2 = isset($where['value1']) ? $where['value1'] : ""; $tableColumn = isset($where['table_name']) ? $where['table_name'] : $alias; - if($value && $value!="" && $value!=" "){ - if($operatorGroup=="and"){ + if ($value && $value != "" && $value != " ") { + if ($operatorGroup == "and") { $query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2); - }else{ - if($no==1){ + } else { + if ($no == 1) { $query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2); - }else{ + } else { $query = $this->orWhereCondition($query, $operator, $tableColumn, $column, $value, $value2); } } } - $no = $no+1; + $no = $no + 1; } }); - }else if(strtolower($operator)=="or"){ - $builder = $builder->orWhere(function($query) use($operatorGroup, $listWhere, $alias){ + } else if (strtolower($operator) == "or") { + $builder = $builder->orWhere(function ($query) use ($operatorGroup, $listWhere, $alias) { $no = 1; foreach ($listWhere as $where) { $value = $where['value']; @@ -143,13 +147,13 @@ class Controller extends BaseController $operator = strtolower($where['logic_operator']); $value2 = isset($where['value1']) ? $where['value1'] : ""; $tableColumn = isset($where['table_name']) ? $where['table_name'] : $alias; - if($value && $value!="" && $value!=" "){ - if($operatorGroup=="and"){ + if ($value && $value != "" && $value != " ") { + if ($operatorGroup == "and") { $query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2); - }else{ - if($no==1){ + } else { + if ($no == 1) { $query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2); - }else{ + } else { $query = $this->orWhereCondition($query, $operator, $tableColumn, $column, $value, $value2); } } @@ -164,39 +168,40 @@ class Controller extends BaseController private function whereCondition($oldQuery, $operator, $tableColumn, $column, $value, $value2) { $query = $oldQuery; - if($operator=="range"){ - $query = $query->whereBetween($tableColumn.".".$column, [$value, $value2]); - }else if($operator=="like"){ - $query = $query->where($tableColumn.".".$column, 'like', '%'.$value.'%'); - }else if($operator=="ilike"){ - $query = $query->where($tableColumn.".".$column, '~*', $value); - }else if($operator=="="){ - $query = $query->where($tableColumn.".".$column, $value); - }else if($operator=="in"){ - $query = $query->whereIn($tableColumn.".".$column, $value); - }else if($operator=="notin"){ - $query = $query->whereNotIn($tableColumn.".".$column, $value); - }else{ - $query = $query->where($tableColumn.".".$column, $operator, $value); + if ($operator == "range") { + $query = $query->whereBetween($tableColumn . "." . $column, [$value, $value2]); + } else if ($operator == "like") { + $query = $query->where($tableColumn . "." . $column, 'like', '%' . $value . '%'); + } else if ($operator == "ilike") { + $query = $query->where($tableColumn . "." . $column, '~*', $value); + } else if ($operator == "=") { + $query = $query->where($tableColumn . "." . $column, $value); + } else if ($operator == "in") { + $query = $query->whereIn($tableColumn . "." . $column, $value); + } else if ($operator == "notin") { + $query = $query->whereNotIn($tableColumn . "." . $column, $value); + } else { + $query = $query->where($tableColumn . "." . $column, $operator, $value); } return $query; } - private function whereConditionSingleTable($oldQuery, $operator, $column, $value, $value2){ + private function whereConditionSingleTable($oldQuery, $operator, $column, $value, $value2) + { $query = $oldQuery; - if($operator=="range"){ + if ($operator == "range") { $query = $query->whereBetween($column, [$value, $value2]); - }else if($operator=="like"){ - $query = $query->where($column, 'like', '%'.$value.'%'); - }else if($operator=="ilike"){ + } else if ($operator == "like") { + $query = $query->where($column, 'like', '%' . $value . '%'); + } else if ($operator == "ilike") { $query = $query->where($column, '~*', $value); - }else if($operator=="="){ + } else if ($operator == "=") { $query = $query->where($column, $value); - }else if($operator=="in"){ + } else if ($operator == "in") { $query = $query->whereIn($column, $value); - }else if($operator=="notin"){ + } else if ($operator == "notin") { $query = $query->whereNotIn($column, $value); - }else{ + } else { $query = $query->where($column, $operator, $value); } return $query; @@ -205,25 +210,26 @@ class Controller extends BaseController private function orWhereCondition($oldQuery, $operator, $tableColumn, $column, $value, $value2) { $query = $oldQuery; - if($operator=="range"){ - $query = $query->orWhereBetween($tableColumn.".".$column, [$value, $value2]); - }else if($operator=="like"){ - $query = $query->orWhere($tableColumn.".".$column, 'like', '%'.$value.'%'); - }else if($operator=="ilike"){ - $query = $query->where($tableColumn.".".$column, '~*', $value); - }else if($operator=="="){ - $query = $query->orWhere($tableColumn.".".$column, $value); - }else if($operator=="in"){ - $query = $query->orWhereIn($tableColumn.".".$column, $value); - }else if($operator=="notin"){ - $query = $query->orWhereNotIn($tableColumn.".".$column, $value); - }else{ - $query = $query->orWhere($tableColumn.".".$column, $operator, $value); + if ($operator == "range") { + $query = $query->orWhereBetween($tableColumn . "." . $column, [$value, $value2]); + } else if ($operator == "like") { + $query = $query->orWhere($tableColumn . "." . $column, 'like', '%' . $value . '%'); + } else if ($operator == "ilike") { + $query = $query->where($tableColumn . "." . $column, '~*', $value); + } else if ($operator == "=") { + $query = $query->orWhere($tableColumn . "." . $column, $value); + } else if ($operator == "in") { + $query = $query->orWhereIn($tableColumn . "." . $column, $value); + } else if ($operator == "notin") { + $query = $query->orWhereNotIn($tableColumn . "." . $column, $value); + } else { + $query = $query->orWhere($tableColumn . "." . $column, $operator, $value); } return $query; } - protected function calculateAllCost($activity_id, $proyek_id){ + protected function calculateAllCost($activity_id, $proyek_id) + { $humanCostPlanning = $this->calculateAllHumanCost($activity_id, $proyek_id); $materialCostPlanning = $this->calculateMaterialCost($activity_id, $proyek_id); $toolsCostPlanning = 0; @@ -234,11 +240,11 @@ class Controller extends BaseController private function calculateAllHumanCost($activity_id, $proyek_id) { - $dataHuman = UserToActivity::select("ahp.standart_rate as standart_rate","ahp.max_used as max_used", "ahp.cost_per_used as cost_per_used", "ahp.uom_standart_rate as uom_standart_rate") - ->leftJoin("assign_hr_to_proyek as ahp", "assign_hr_to_activity.user_id", "=", "ahp.user_id") - ->where("assign_hr_to_activity.activity_id", $activity_id)->where("assign_hr_to_activity.proyek_id", $proyek_id) - ->where("ahp.proyek_id", $proyek_id) - ->get(); + $dataHuman = UserToActivity::select("ahp.standart_rate as standart_rate", "ahp.max_used as max_used", "ahp.cost_per_used as cost_per_used", "ahp.uom_standart_rate as uom_standart_rate") + ->leftJoin("assign_hr_to_proyek as ahp", "assign_hr_to_activity.user_id", "=", "ahp.user_id") + ->where("assign_hr_to_activity.activity_id", $activity_id)->where("assign_hr_to_activity.proyek_id", $proyek_id) + ->where("ahp.proyek_id", $proyek_id) + ->get(); $totalCost = 0; foreach ($dataHuman as $human) { @@ -253,58 +259,61 @@ class Controller extends BaseController $activity = Activity::find($activity_id); $duration = $activity->duration; $standarRate = $human->standart_rate; - $maxUsed = $human->max_used/100; + $maxUsed = $human->max_used / 100; if ($human->uom_standart_rate == "Hour") { - $totalCost = ($standarRate*8*$duration)*$maxUsed; - return $totalCost; + $totalCost = ($standarRate * 8 * $duration) * $maxUsed; + return $totalCost; } - $totalCost = ($standarRate*$duration)*$maxUsed; + $totalCost = ($standarRate * $duration) * $maxUsed; return $totalCost; } private function calculateMaterialCost($activity_id, $proyek_id) { - $totalCost = AssignMaterial::selectRaw("COALESCE(qty_planning,0)*COALESCE(budget,0) as totalCost") - ->where("proyek_id", $proyek_id) - ->where("activity_id", $activity_id) - ->sum(AssignMaterial::raw("COALESCE(qty_planning, 0) * COALESCE(budget, 0)")); + $totalCost = AssignMaterial::selectRaw("COALESCE(qty_planning,0)*COALESCE(budget,0) as totalCost") + ->where("proyek_id", $proyek_id) + ->where("activity_id", $activity_id) + ->sum(AssignMaterial::raw("COALESCE(qty_planning, 0) * COALESCE(budget, 0)")); return $totalCost; } - protected function getLoc($lat, $lng){ + protected function getLoc($lat, $lng) + { // $response = Http::get(config('api.nominatim') . "/reverse?lat=".$lat."&lon=".$lng."&format=json"); // return $response->json; - $url = config('api.nominatim') . "/reverse?lat=".$lat."&lon=".$lng."&format=json"; - // $token = config('api.adw_token'); - $response = $this->curlRequest($url); + $url = config('api.nominatim') . "/reverse?lat=" . $lat . "&lon=" . $lng . "&format=json"; + // $token = config('api.adw_token'); + $response = $this->curlRequest($url); return $response; } - private function curlRequest($url){ - $ch = curl_init(); - // $headers = [ - // 'Authorization: '.$token - // ]; - curl_setopt($ch, CURLOPT_URL, $url); - // curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + private function curlRequest($url) + { + $ch = curl_init(); + // $headers = [ + // 'Authorization: '.$token + // ]; + curl_setopt($ch, CURLOPT_URL, $url); + // curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - $response = curl_exec($ch); - if ($response === false) - $response = curl_error($ch); - curl_close($ch); + $response = curl_exec($ch); + if ($response === false) + $response = curl_error($ch); + curl_close($ch); - return json_decode($response); - } + return json_decode($response); + } - protected function addDetailK3($dataDetail, $report_id){ + protected function addDetailK3($dataDetail, $report_id) + { foreach ($dataDetail as $value) { $dataNew = array( - "report_k3_id"=>$report_id, - "checklist_k3_id"=>$value['checklist_id'], - "name_checklist_k3"=>$value['checklist_name'], - "created_by"=>$this->currentName + "report_k3_id" => $report_id, + "checklist_k3_id" => $value['checklist_id'], + "name_checklist_k3" => $value['checklist_name'], + "created_by" => $this->currentName ); ReportK3Detail::create($dataNew); diff --git a/app/Models/Company.php b/app/Models/Company.php new file mode 100644 index 0000000..7b85e58 --- /dev/null +++ b/app/Models/Company.php @@ -0,0 +1,37 @@ +children()->delete(); }); } public function parent() { - return $this->belongsTo('App\Models\Divisi','parent')->where('parent', null)->with('parent'); + return $this->belongsTo('App\Models\Divisi', 'parent')->where('parent', null)->with('parent'); } public function children() { - return $this->hasMany('App\Models\Divisi','parent')->with('children'); + return $this->hasMany('App\Models\Divisi', 'parent')->with('children'); } } diff --git a/app/Models/Menu.php b/app/Models/Menu.php index a507545..951f6da 100644 --- a/app/Models/Menu.php +++ b/app/Models/Menu.php @@ -13,6 +13,6 @@ class Menu extends Model protected $fillable = [ 'parent_id', 'icon', 'name', 'alias_name', 'url', 'sequence', - 'created_at', 'created_by', 'updated_at', 'updated_by' + 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id' ]; } diff --git a/app/Models/ProjectPhase.php b/app/Models/ProjectPhase.php index 1a82a81..ffe1ed4 100644 --- a/app/Models/ProjectPhase.php +++ b/app/Models/ProjectPhase.php @@ -12,6 +12,6 @@ class ProjectPhase extends Model const UPDATED_AT = 'updated_at'; protected $fillable = [ - 'name', 'color', 'order', 'created_at', 'created_by', 'updated_at', 'updated_by' + 'name', 'color', 'order', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id' ]; } diff --git a/app/Models/ProjectRole.php b/app/Models/ProjectRole.php index 52a7b46..9d15c1a 100644 --- a/app/Models/ProjectRole.php +++ b/app/Models/ProjectRole.php @@ -12,6 +12,6 @@ class ProjectRole extends Model const UPDATED_AT = 'updated_at'; protected $fillable = [ - 'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by' + 'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id' ]; } diff --git a/app/Models/ProjectType.php b/app/Models/ProjectType.php index 9edca0e..f6e9604 100644 --- a/app/Models/ProjectType.php +++ b/app/Models/ProjectType.php @@ -12,6 +12,6 @@ class ProjectType extends Model const UPDATED_AT = 'updated_at'; protected $fillable = [ - 'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by' + 'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id' ]; } diff --git a/app/Models/Role.php b/app/Models/Role.php index 73de4a2..4fdc897 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', 'default_page', 'created_at', 'created_by', 'updated_at', 'updated_by' + 'name', 'description', 'default_page', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id' ]; } diff --git a/app/Models/RoleMenu.php b/app/Models/RoleMenu.php index 3540ea6..2a59ede 100644 --- a/app/Models/RoleMenu.php +++ b/app/Models/RoleMenu.php @@ -12,6 +12,6 @@ class RoleMenu extends Model const UPDATED_AT = 'updated_at'; protected $fillable = [ - 'role_id', 'menu_id', 'created_at', 'created_by', 'updated_at', 'updated_by' + 'role_id', 'menu_id', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id', "create", "read", "update", "delete" ]; } diff --git a/app/Models/Satuan.php b/app/Models/Satuan.php index 05305af..9779db6 100644 --- a/app/Models/Satuan.php +++ b/app/Models/Satuan.php @@ -12,6 +12,6 @@ class Satuan extends Model const UPDATED_AT = 'updated_at'; protected $fillable = [ - 'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by' + 'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id' ]; }