From 12edaab3021417eb54630cc50c3390a130a42e5d Mon Sep 17 00:00:00 2001 From: wahyu Date: Tue, 24 Oct 2023 09:33:35 +0700 Subject: [PATCH 1/7] select activity --- app/Http/Controllers/ActivityController.php | 13 +++++++++++++ routes/web.php | 1 + 2 files changed, 14 insertions(+) diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php index df66558..0e23cdb 100644 --- a/app/Http/Controllers/ActivityController.php +++ b/app/Http/Controllers/ActivityController.php @@ -527,6 +527,19 @@ class ActivityController extends Controller return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200); } + public function searchAnalysisPrep(Request $request) + { + $data = $request->all(); + $dataGet = DB::table('m_activity') + ->select('m_activity.name') + ->where('m_activity.proyek_id', $data['columns'][0]['value']) + ->where('m_activity.type_activity', 'task') + ->where('m_activity.persentase_progress', '>', 0) + ->groupByRaw('m_activity.name') + ->get(); + return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet ], 200); + } + public function searchAnalysis(Request $request) { $dataBuilder = $this->setUpPayload($request->all(), 'm_activity'); diff --git a/routes/web.php b/routes/web.php index 73b90db..f9e79b4 100644 --- a/routes/web.php +++ b/routes/web.php @@ -207,6 +207,7 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout $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/search-analysis-prep', 'ActivityController@searchAnalysisPrep'); $router->post('/activity/import', 'ActivityController@import'); $router->post('/activity/import-update', 'ActivityController@importUpdate'); $router->post('/activity/import-old', 'ActivityController@importOld'); From 86588d4892e1675e7504b06e9d94d4806e45c3b1 Mon Sep 17 00:00:00 2001 From: wahyu Date: Tue, 24 Oct 2023 13:12:53 +0700 Subject: [PATCH 2/7] hierarchy & gantt cascade delete --- app/Models/Activity.php | 12 +++++++++--- app/Models/HierarchyFtth.php | 16 +++++++++++----- app/Models/VersionGantt.php | 7 +++++++ 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/app/Models/Activity.php b/app/Models/Activity.php index 3a8e54c..5d9c1e7 100644 --- a/app/Models/Activity.php +++ b/app/Models/Activity.php @@ -79,8 +79,14 @@ class Activity extends Model }); static::deleted(function($data) { - if(Activity::where("parent_id", $data->parent_id)->count() == 0) - Activity::find($data->parent_id)->update(["type_activity"=>"task"]); + if (isset($data->parent_id)) { + if(Activity::where("parent_id", $data->parent_id)->count() == 0) { + $activity = Activity::find($data->parent_id); + if ($activity) { + $activity->update(["type_activity"=>"task"]); + } + } + } $data->updateBobot(true); $data->updateCostPlanning(); @@ -100,7 +106,7 @@ class Activity extends Model ->whereNull('parent_id') ->first(); - if($root->rencana_biaya > 0){ + if(isset($root) && $root->rencana_biaya > 0){ $activities = Activity::where("proyek_id", $this->proyek_id)->where("version_gantt_id", $this->version_gantt_id)->get(); foreach ($activities as $activity) { if($isDelete && $activity->id == $this->id) diff --git a/app/Models/HierarchyFtth.php b/app/Models/HierarchyFtth.php index fae503c..1a0ba8c 100644 --- a/app/Models/HierarchyFtth.php +++ b/app/Models/HierarchyFtth.php @@ -3,6 +3,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; +use App\Models\VersionGantt; class HierarchyFtth extends Model { @@ -14,15 +15,20 @@ class HierarchyFtth extends Model protected $fillable = [ 'name', 'parent_id', 'project_id', 'created_at', 'updated_at', 'progress', 'bobot_planning' ]; - + public static function boot() { parent::boot(); static::deleted(function($data) { - $ftths = HierarchyFtth::where('parent_id', $data->id)->get(); - foreach ($ftths as $ftth) { - $ftth->delete(); - } + $ftths = HierarchyFtth::where('parent_id', $data->id)->get(); + foreach ($ftths as $ftth) { + $ftth->delete(); + } + + $gantts = VersionGantt::where('hierarchy_ftth_id', $data->id)->get(); + foreach ($gantts as $gantt) { + $gantt->delete(); + } }); } } diff --git a/app/Models/VersionGantt.php b/app/Models/VersionGantt.php index 765ddf1..39b9b0f 100644 --- a/app/Models/VersionGantt.php +++ b/app/Models/VersionGantt.php @@ -38,6 +38,13 @@ class VersionGantt extends Model static::updated(function($data) { $data->updateActDuration(); + }); + + static::deleted(function ($data) { + $activities = Activity::where('version_gantt_id', $data->id)->get(); + foreach ($activities as $activity) { + $activity->delete(); + } }); } From 0c487fc05b2d731bb4400d90c717956ddd3cc168 Mon Sep 17 00:00:00 2001 From: wahyu Date: Tue, 24 Oct 2023 15:50:55 +0700 Subject: [PATCH 3/7] handling plan overflow --- app/Helpers/MasterFunctionsHelper.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/Helpers/MasterFunctionsHelper.php b/app/Helpers/MasterFunctionsHelper.php index 1bed1bb..add9de1 100644 --- a/app/Helpers/MasterFunctionsHelper.php +++ b/app/Helpers/MasterFunctionsHelper.php @@ -708,6 +708,9 @@ class MasterFunctionsHelper $tempTtlPercentPlan += $sumPercentagePlan; $tempTtlPercentActual += $sumPercentageActual; + if ($tempTtlPercentPlan >= 100) + $tempTtlPercentPlan = 100; + $currentACWP += $totalACWP; $currentBCWP += $totalBCWP; @@ -715,6 +718,9 @@ class MasterFunctionsHelper $tempPercentagePlan[] = round($tempTtlPercentPlan, 2); $tempPercentagePlanWhr[] = ["weekly period", $tempPercentagePlan]; $tempPercentageReal[] = round($tempTtlPercentActual, 2); + if ($tempTtlPercentPlan >= 100 && $tempTtlPercentActual >= 100) { + break; + } } else { $tempPercentage[] = array(round($sumPercentagePlan, 2), round($sumPercentageActual, 2)); $tempPercentagePlan[] = round($sumPercentagePlan, 2); From c603efb1a62bec78795df29a22c6d2e260379642 Mon Sep 17 00:00:00 2001 From: wahyu Date: Wed, 25 Oct 2023 10:16:37 +0700 Subject: [PATCH 4/7] fix endline --- .../Controllers/ReportActivityController.php | 540 +++++++++--------- 1 file changed, 270 insertions(+), 270 deletions(-) diff --git a/app/Http/Controllers/ReportActivityController.php b/app/Http/Controllers/ReportActivityController.php index 6a458f5..94a8d89 100644 --- a/app/Http/Controllers/ReportActivityController.php +++ b/app/Http/Controllers/ReportActivityController.php @@ -1,270 +1,270 @@ -has('gantt')){ - $this->validate($request, [ - 'activity_id' => 'required', - 'user_id' => 'required', - 'report_date' => 'required', - 'job_count_report' => 'required' - ]); - }else{ - $this->validate($request, [ - 'activity_id' => 'required', - 'user_id' => 'required', - 'report_date' => 'required', - 'job_count_report' => 'required', - 'lat' => 'required', - 'lon' => 'required', - ]); - } - - $data = $request->all(); - - $data['created_by'] = $this->currentName; - - $result = ReportActivity::create($data); - - if($result){ - $this->countForProgress($request->activity_id); - if($request->hasFile("files")){ - $this->uploadImage($request->file('files'), $result->id); - } - return response()->json(['status'=>'success','message'=>'add report activity, update progress activity successfully!','code'=>200,'last_inserted_id'=>$result->id], 200); - }else{ - return response()->json(['status'=>'failed','message'=>'add report activity failed!','code'=>400], 400); - } - } - - private function uploadImage($files, $ref_id) - { - $dokumen = $files; - $extension = $dokumen->extension(); - $name = $ref_id.date("YmdHis").".".$extension; - $resultMove = $dokumen->move($this->pathImage, $name); - if($resultMove){ - $data = [ - 'ref_id' => (int)$ref_id, - 'image' => $name, - 'category' => "report_activity" - ]; - - $result = Image::create($data); - - if($result){ - return true; - } - } - } - - public function edit($id){ - if(!$id || (int) $id < 0 || $id==""){ - return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); - die(); - } - - $result = ReportActivity::select("report_activity.*", "u.name as user_name")->where("report_activity.id", $id)->join("m_users as u", "u.id", "=", "report_activity.user_id")->first(); - - if($result){ - return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); - }else{ - return response()->json(['status'=>'failed','message'=>'failed get data report activity, please try again later!','code'=>400], 400); - } - } - - public function update(Request $request, $id) - { - if(!$id || (int) $id < 0 || $id==""){ - return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); - } - - $data = ReportActivity::find($id); - - if($data){ - $dataUpdate = $request->all(); - $result = $data->update($dataUpdate); - if($result){ - if($request->hasFile("files")){ - $this->updateImage($request->file('files'), $id); - } - $this->countForProgress($data->activity_id); - return response()->json(['status'=>'success','message'=>'data report activity successfully updated!','code'=>200], 200); - }else{ - return response()->json(['status'=>'failed','message'=>'data report activity failed updated!','code'=>400], 400); - } - }else{ - return response()->json(['status'=>'failed','message'=>'data report activity not found!','code'=>400], 400); - die(); - } - } - - public function updateImage($files, $ref_id) - { - $image = Image::where("ref_id", $ref_id)->where("category", "report_activity")->first(); - if($image){ - if(file_exists($this->pathImage.$image->image)){ - unlink($this->pathImage.$image->image); - } - $image->delete(); - } - $dokumen = $files; - $extension = $dokumen->extension(); - $name = $ref_id.date("YmdHis").".".$extension; - $resultMove = $dokumen->move($this->pathImage, $name); - if($resultMove){ - $data = [ - 'ref_id' => (int)$ref_id, - 'image' => $name, - 'category' => "report_activity" - ]; - - $result = Image::create($data); - - if($result){ - return true; - } - } - } - - public function delete($id) - { - $data = ReportActivity::find($id); - - if($data){ - $delete = $data->delete(); - }else{ - return response()->json(['status'=>'failed','message'=>'data report activity not found!','code'=>400], 400); - die(); - } - - - if($delete){ - $image = Image::where("ref_id", $id)->where("category", "report_activity")->first(); - if($image){ - if(file_exists($this->pathImage.$image->image)){ - unlink($this->pathImage.$image->image); - } - $image->delete(); - } - return response()->json(['status'=>'success','message'=>'data report activity successfully deleted!','code'=>200], 200); - }else{ - return response()->json(['status'=>'failed','message'=>'data report activity failed deleted!','code'=>400], 400); - } - } - - private function countForProgress($id) - { - - $totalJobs = ReportActivity::where('activity_id', $id)->sum("job_count_report"); - $dataActivity = Activity::find($id); - $jobsActivity = (int)$dataActivity->jumlah_pekerjaan; - - if ($jobsActivity < 1) { - return false; - } - - if ($totalJobs < 1) { - return false; - } - - $persentaseActual = ($totalJobs/$jobsActivity)*100; - $dataUpdate = array( - "persentase_progress" => $persentaseActual, - "updated_by" => $this->currentName - ); - return $dataActivity->update($dataUpdate); - } - - public function search(Request $request) - { - $payload = $request->all(); - $dataBuilder = $this->setUpPayload($payload, 'report_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 list() - { - $data = ReportActivity::all(); - $countData = $data->count(); - - if($data){ - return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); - }else{ - return response()->json(['status'=>'failed','message'=>'failed get list report activity, please try again later!','code'=>400], 400); - } - } - - public function searchPoint(Request $request) { - $dataPayload = $request->all(); - $reqActivityId = []; - foreach ($dataPayload['project_id'] as $val) { - $reqActivityId[] = $this->getActivityByProjectId($val); - } - - $activity_id = []; - $getPoints = false; - - if (count($reqActivityId) > 0) { - for ($i=0; $i < count($reqActivityId); $i++) { - if (count($reqActivityId[$i]) > 0) { - foreach($reqActivityId[$i] as $reqAct) { - array_push($activity_id, $reqAct->id); - } - } - } - } - - if (count($activity_id) > 0) { - $getPoints = ReportActivity::select('report_activity.*', 'm_activity.name as activity_name', 'm_activity.jumlah_pekerjaan', 'm_proyek.nama as proyek_name') - ->leftJoin('m_activity', 'm_activity.id', '=', 'report_activity.activity_id') - ->leftJoin('m_proyek', 'm_proyek.id', '=', 'm_activity.proyek_id') - ->whereIn('report_activity.activity_id', $activity_id)->get(); - } - - if($getPoints){ - return response()->json(['status'=>'success','code'=>200,'data'=>$getPoints, 'totalRecord'=>count($getPoints)], 200); - }else{ - return response()->json(['status'=>'failed','message'=>'failed get list points, please try again later!','code'=>400], 400); - } - } - - public function getActivityByProjectId($projectId) { - $data = Activity::select('id')->where('proyek_id', $projectId)->get(); - return $data; - } - - public function datatables(Request $request){ - $id_activity = $request->query('idact'); - $data = ReportActivity::select("report_activity.*", "u.name as user_name") - ->join("m_users as u", "u.id", "=", "report_activity.user_id") - ->where('report_activity.activity_id', $id_activity) - ->get(); - return Datatables::of($data) - ->addIndexColumn() - ->addColumn('action', function($row){ - $actionBtn = ''; - $actionBtn .= ' '; - return $actionBtn; - }) - ->editColumn('report_date', function($row) { - $date = date_create($row->report_date); - return date_format($date,"d-m-Y H:i:s"); - }) - ->rawColumns(['action'])->make(true); - } -} +has('gantt')){ + $this->validate($request, [ + 'activity_id' => 'required', + 'user_id' => 'required', + 'report_date' => 'required', + 'job_count_report' => 'required' + ]); + }else{ + $this->validate($request, [ + 'activity_id' => 'required', + 'user_id' => 'required', + 'report_date' => 'required', + 'job_count_report' => 'required', + 'lat' => 'required', + 'lon' => 'required', + ]); + } + + $data = $request->all(); + + $data['created_by'] = $this->currentName; + + $result = ReportActivity::create($data); + + if($result){ + $this->countForProgress($request->activity_id); + if($request->hasFile("files")){ + $this->uploadImage($request->file('files'), $result->id); + } + return response()->json(['status'=>'success','message'=>'add report activity, update progress activity successfully!','code'=>200,'last_inserted_id'=>$result->id], 200); + }else{ + return response()->json(['status'=>'failed','message'=>'add report activity failed!','code'=>400], 400); + } + } + + private function uploadImage($files, $ref_id) + { + $dokumen = $files; + $extension = $dokumen->extension(); + $name = $ref_id.date("YmdHis").".".$extension; + $resultMove = $dokumen->move($this->pathImage, $name); + if($resultMove){ + $data = [ + 'ref_id' => (int)$ref_id, + 'image' => $name, + 'category' => "report_activity" + ]; + + $result = Image::create($data); + + if($result){ + return true; + } + } + } + + public function edit($id){ + if(!$id || (int) $id < 0 || $id==""){ + return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); + die(); + } + + $result = ReportActivity::select("report_activity.*", "u.name as user_name")->where("report_activity.id", $id)->join("m_users as u", "u.id", "=", "report_activity.user_id")->first(); + + if($result){ + return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); + }else{ + return response()->json(['status'=>'failed','message'=>'failed get data report activity, please try again later!','code'=>400], 400); + } + } + + public function update(Request $request, $id) + { + if(!$id || (int) $id < 0 || $id==""){ + return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); + } + + $data = ReportActivity::find($id); + + if($data){ + $dataUpdate = $request->all(); + $result = $data->update($dataUpdate); + if($result){ + if($request->hasFile("files")){ + $this->updateImage($request->file('files'), $id); + } + $this->countForProgress($data->activity_id); + return response()->json(['status'=>'success','message'=>'data report activity successfully updated!','code'=>200], 200); + }else{ + return response()->json(['status'=>'failed','message'=>'data report activity failed updated!','code'=>400], 400); + } + }else{ + return response()->json(['status'=>'failed','message'=>'data report activity not found!','code'=>400], 400); + die(); + } + } + + public function updateImage($files, $ref_id) + { + $image = Image::where("ref_id", $ref_id)->where("category", "report_activity")->first(); + if($image){ + if(file_exists($this->pathImage.$image->image)){ + unlink($this->pathImage.$image->image); + } + $image->delete(); + } + $dokumen = $files; + $extension = $dokumen->extension(); + $name = $ref_id.date("YmdHis").".".$extension; + $resultMove = $dokumen->move($this->pathImage, $name); + if($resultMove){ + $data = [ + 'ref_id' => (int)$ref_id, + 'image' => $name, + 'category' => "report_activity" + ]; + + $result = Image::create($data); + + if($result){ + return true; + } + } + } + + public function delete($id) + { + $data = ReportActivity::find($id); + + if($data){ + $delete = $data->delete(); + }else{ + return response()->json(['status'=>'failed','message'=>'data report activity not found!','code'=>400], 400); + die(); + } + + + if($delete){ + $image = Image::where("ref_id", $id)->where("category", "report_activity")->first(); + if($image){ + if(file_exists($this->pathImage.$image->image)){ + unlink($this->pathImage.$image->image); + } + $image->delete(); + } + return response()->json(['status'=>'success','message'=>'data report activity successfully deleted!','code'=>200], 200); + }else{ + return response()->json(['status'=>'failed','message'=>'data report activity failed deleted!','code'=>400], 400); + } + } + + private function countForProgress($id) + { + + $totalJobs = ReportActivity::where('activity_id', $id)->sum("job_count_report"); + $dataActivity = Activity::find($id); + $jobsActivity = (int)$dataActivity->jumlah_pekerjaan; + + if ($jobsActivity < 1) { + return false; + } + + if ($totalJobs < 1) { + return false; + } + + $persentaseActual = ($totalJobs/$jobsActivity)*100; + $dataUpdate = array( + "persentase_progress" => $persentaseActual, + "updated_by" => $this->currentName + ); + return $dataActivity->update($dataUpdate); + } + + public function search(Request $request) + { + $payload = $request->all(); + $dataBuilder = $this->setUpPayload($payload, 'report_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 list() + { + $data = ReportActivity::all(); + $countData = $data->count(); + + if($data){ + return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); + }else{ + return response()->json(['status'=>'failed','message'=>'failed get list report activity, please try again later!','code'=>400], 400); + } + } + + public function searchPoint(Request $request) { + $dataPayload = $request->all(); + $reqActivityId = []; + foreach ($dataPayload['project_id'] as $val) { + $reqActivityId[] = $this->getActivityByProjectId($val); + } + + $activity_id = []; + $getPoints = false; + + if (count($reqActivityId) > 0) { + for ($i=0; $i < count($reqActivityId); $i++) { + if (count($reqActivityId[$i]) > 0) { + foreach($reqActivityId[$i] as $reqAct) { + array_push($activity_id, $reqAct->id); + } + } + } + } + + if (count($activity_id) > 0) { + $getPoints = ReportActivity::select('report_activity.*', 'm_activity.name as activity_name', 'm_activity.jumlah_pekerjaan', 'm_proyek.nama as proyek_name') + ->leftJoin('m_activity', 'm_activity.id', '=', 'report_activity.activity_id') + ->leftJoin('m_proyek', 'm_proyek.id', '=', 'm_activity.proyek_id') + ->whereIn('report_activity.activity_id', $activity_id)->get(); + } + + if($getPoints){ + return response()->json(['status'=>'success','code'=>200,'data'=>$getPoints, 'totalRecord'=>count($getPoints)], 200); + }else{ + return response()->json(['status'=>'failed','message'=>'failed get list points, please try again later!','code'=>400], 400); + } + } + + public function getActivityByProjectId($projectId) { + $data = Activity::select('id')->where('proyek_id', $projectId)->get(); + return $data; + } + + public function datatables(Request $request){ + $id_activity = $request->query('idact'); + $data = ReportActivity::select("report_activity.*", "u.name as user_name") + ->join("m_users as u", "u.id", "=", "report_activity.user_id") + ->where('report_activity.activity_id', $id_activity) + ->get(); + return Datatables::of($data) + ->addIndexColumn() + ->addColumn('action', function($row){ + $actionBtn = ''; + $actionBtn .= ' '; + return $actionBtn; + }) + ->editColumn('report_date', function($row) { + $date = date_create($row->report_date); + return date_format($date,"d-m-Y H:i:s"); + }) + ->rawColumns(['action'])->make(true); + } +} From 99185941b0bbf0106572798b91c529598280d98e Mon Sep 17 00:00:00 2001 From: wahyu Date: Wed, 25 Oct 2023 11:26:19 +0700 Subject: [PATCH 5/7] update report analysis --- app/Http/Controllers/ActivityController.php | 14 +++++++++++++- app/Http/Controllers/Controller.php | 2 ++ app/Http/Controllers/UserToActivityController.php | 7 +++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php index 0e23cdb..fddd137 100644 --- a/app/Http/Controllers/ActivityController.php +++ b/app/Http/Controllers/ActivityController.php @@ -544,10 +544,22 @@ class ActivityController extends Controller { $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') + $dataGet = $builder->select( 'selfTable.name', 'persentase_progress', + 'm_version_gantt.name_version', 'm_users.name as user_name', + DB::raw('SUM(report_activity_material.qty) as qty'), 'assign_material_to_activity.qty_planning', + 'assign_material_to_activity.id as join_third_id') ->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') + ->join('report_activity_material', 'report_activity_material.activity_id', '=', 'selfTable.id') + ->join('assign_material_to_activity', 'assign_material_to_activity.activity_id', '=', 'selfTable.id') + ->groupBy("selfTable.id") + ->groupBy("selfTable.name") + ->groupBy("selfTable.persentase_progress") + ->groupBy("m_version_gantt.name_version") + ->groupBy("m_users.name") + ->groupBy("assign_material_to_activity.qty_planning") + ->groupBy("assign_material_to_activity.id") ->get(); return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet ], 200); } diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 507129d..7e00a8a 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -54,11 +54,13 @@ class Controller extends BaseController $tableName = $join['name']; $columnJoin = $join['column_join']; // foreign key table sini $columnSelf = isset($join['column_self']) ? $join['column_self'] : "id"; // primary key table lawan + if (isset($join['column_results'])) { $columnResult = $join['column_results']; foreach($columnResult as $sColumn){ $builder = $builder->addSelect($tableName.".".$sColumn." as join_".$this->listJoinAll[$no]."_".$sColumn); } + } $builder = $builder->leftJoin($tableName, $tableJoin.".".$columnJoin, '=', $tableName.'.'.$columnSelf); $no++; } diff --git a/app/Http/Controllers/UserToActivityController.php b/app/Http/Controllers/UserToActivityController.php index a1a9583..4ca00f8 100644 --- a/app/Http/Controllers/UserToActivityController.php +++ b/app/Http/Controllers/UserToActivityController.php @@ -6,6 +6,7 @@ use Illuminate\Http\Request; use App\Models\UserToActivity; use App\Models\Activity; use App\Models\AssignMaterial; +use Illuminate\Support\Facades\DB; use Datatables; class UserToActivityController extends Controller @@ -134,6 +135,12 @@ class UserToActivityController extends Controller $dataBuilder = $this->setUpPayload($request->all(), 'assign_hr_to_activity'); $builder = $dataBuilder['builder']; $countBuilder = $dataBuilder['count']; + $builder->addSelect(DB::raw('SUM(report_activity_material.qty) as volume_actual')); + $builder->groupBy("m_activity.id"); + $builder->groupBy("selfTable.id"); + $builder->groupBy("m_users.name"); + $builder->groupBy("assign_material_to_activity.id"); + $builder->groupBy("m_version_gantt.name_version"); $dataGet = $builder->get(); $totalRecord = $countBuilder->count(); return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200); From 029ccfc6abf709e5e24416c5629bc7bbaa285b42 Mon Sep 17 00:00:00 2001 From: wahyu Date: Wed, 25 Oct 2023 13:06:26 +0700 Subject: [PATCH 6/7] update progress bar --- app/Helpers/MasterFunctionsHelper.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/Helpers/MasterFunctionsHelper.php b/app/Helpers/MasterFunctionsHelper.php index add9de1..9cbc746 100644 --- a/app/Helpers/MasterFunctionsHelper.php +++ b/app/Helpers/MasterFunctionsHelper.php @@ -402,8 +402,9 @@ class MasterFunctionsHelper // if($tempTtlPercentActual >= $keyGantt['progress']) // $tempTtlPercentActual = $keyGantt['progress']; - if ($tempTtlPercentPlan >= 100) - $tempTtlPercentPlan = 100; + // todo + // if ($tempTtlPercentPlan >= 100) + // $tempTtlPercentPlan = 100; // $sumPercentageActual > $keyGantt['progress'] ? $keyGantt['progress'] : $sumPercentageActual // } @@ -707,9 +708,9 @@ class MasterFunctionsHelper if (isset($dataPayload['period']) && $dataPayload['period'] == 'week') { $tempTtlPercentPlan += $sumPercentagePlan; $tempTtlPercentActual += $sumPercentageActual; - - if ($tempTtlPercentPlan >= 100) - $tempTtlPercentPlan = 100; + // todo + // if ($tempTtlPercentPlan >= 100) + // $tempTtlPercentPlan = 100; $currentACWP += $totalACWP; $currentBCWP += $totalBCWP; From a19d0ea5cdd4e5b9077340f9d7f015fde4b70d5c Mon Sep 17 00:00:00 2001 From: wahyu Date: Thu, 26 Oct 2023 18:56:29 +0700 Subject: [PATCH 7/7] fix dashboard bod --- .../Controllers/DashboardBoDController.php | 37 ++++++++++++++----- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/DashboardBoDController.php b/app/Http/Controllers/DashboardBoDController.php index ebdf8a3..2de808e 100644 --- a/app/Http/Controllers/DashboardBoDController.php +++ b/app/Http/Controllers/DashboardBoDController.php @@ -133,7 +133,7 @@ class DashboardBoDController extends Controller ]; $projects = Project::where('mulai_proyek', 'like', $year)->get(); - foreach ($projects as $project) { + foreach ($projects as $index => $project) { $project->scurve = MasterFunctionsHelper::getSCurve($project->id); $selisihProgress = 0; if ($project->scurve && $project->scurve[0]) { @@ -144,12 +144,18 @@ class DashboardBoDController extends Controller } $selisihProgress = $planningProgress - $actualProgress; try { - if ($selisihProgress > 0 && $selisihProgress <= 5) + if ($selisihProgress > 0 && $selisihProgress <= 5){ $return['warning'] += 1; - elseif ($selisihProgress == 0) + $projects[$index]->status = 'warning'; + } + elseif ($selisihProgress == 0){ $return['on-schedule'] += 1; - else + $projects[$index]->status = 'on-schedule'; + } + else { $return['behind-schedule'] += 1; + $projects[$index]->status = 'behind-schedule'; + } } catch (\Error $e) { return response()->json(['msg' => $e->getMessage(), 'data' => $project], 200); } @@ -163,7 +169,7 @@ class DashboardBoDController extends Controller $year = $this->interpolateYear($year); $divisions = Divisi::whereNull('parent')->get(); - foreach ($divisions as $division) { + foreach ($divisions as $index => $division) { $scheduleData = new Collection(); $behindSchedule = $warning = $onSchedule = 0; @@ -171,18 +177,29 @@ class DashboardBoDController extends Controller $projects = Project::where('mulai_proyek', 'like', $year)->where('divisi_id', $division->id)->get(); foreach ($projects as $project) { $project->scurve = MasterFunctionsHelper::getSCurve($project->id); - if (@$project->scurve['difference'] > 0 && @$project->scurve['difference'] <= 5) + $selisihProgress = 0; + if ($project->scurve && $project->scurve[0]) { + $planningArray = $project->scurve[0]['data']['percentagePlan']; + $actualArray = $project->scurve[0]['data']['percentageReal']; + $planningProgress = !empty($planningArray) ? $planningArray[count($planningArray) - 1] : 0; + $actualProgress = !empty($actualArray) ? $actualArray[count($actualArray) - 1] : 0; + } + $selisihProgress = $planningProgress - $actualProgress; + if ($selisihProgress > 0 && $selisihProgress <= 5){ $warning++; - elseif (@$project->scurve['difference'] > 5 && @$project->scurve['difference'] <= 100) - $behindSchedule++; - elseif (@$project->scurve['difference'] == 0) + } + elseif ($selisihProgress == 0){ $onSchedule++; + } + else { + $behindSchedule++; + } } $scheduleData->prepend($behindSchedule, 'behindSchedule'); $scheduleData->prepend($warning, 'warning'); $scheduleData->prepend($onSchedule, 'onSchedule'); - $division->scheduleData = $scheduleData; + $divisions[$index]->scheduleData = $scheduleData; } return response()->json([ 'data' => [