From 8a26f1bcb1fda04baff94b29fdc78b56a6627777 Mon Sep 17 00:00:00 2001 From: wahyuun Date: Fri, 27 Oct 2023 11:35:11 +0700 Subject: [PATCH 01/12] add parent 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 ebdf8a3..78c614f 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', 'color') + $divisions = Divisi::select('id', 'name', 'parent', 'color') ->with('children') ->whereNull('parent') ->get(); From 7cd6e4ef307e0bf8db72822b4fd65649b4eede72 Mon Sep 17 00:00:00 2001 From: wahyuun Date: Fri, 27 Oct 2023 13:19:07 +0700 Subject: [PATCH 02/12] rollback --- 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 78c614f..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', 'parent', 'color') + $divisions = Divisi::select('id', 'name', 'color') ->with('children') ->whereNull('parent') ->get(); From 4e69d7c35c8315fdeb0226d867d26260bc8fd454 Mon Sep 17 00:00:00 2001 From: wahyu Date: Tue, 31 Oct 2023 10:55:26 +0700 Subject: [PATCH 03/12] update dashboard bod --- app/Helpers/MasterFunctionsHelper.php | 2 +- app/Http/Controllers/DashboardBoDController.php | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Helpers/MasterFunctionsHelper.php b/app/Helpers/MasterFunctionsHelper.php index 52708e6..d1c2c47 100644 --- a/app/Helpers/MasterFunctionsHelper.php +++ b/app/Helpers/MasterFunctionsHelper.php @@ -310,7 +310,7 @@ class MasterFunctionsHelper ->groupBy('activity_id') ->first(); $weekCount = $keyPlanM->duration / 7; - $weeklyPlan = $sumVolPlan->ttl_qty_plan / $weekCount; + $weeklyPlan = $weekCount > 0 ? $sumVolPlan->ttl_qty_plan / $weekCount : 0; $weeklyProgress = $weeklyPlan / $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning; $dataTempPlan[$x]['activity_id'] = $keyPlanM->id; $dataTempPlan[$x]['bobot_planning'] = $keyPlanM->bobot_planning; diff --git a/app/Http/Controllers/DashboardBoDController.php b/app/Http/Controllers/DashboardBoDController.php index 2de808e..deb8065 100644 --- a/app/Http/Controllers/DashboardBoDController.php +++ b/app/Http/Controllers/DashboardBoDController.php @@ -136,6 +136,9 @@ class DashboardBoDController extends Controller foreach ($projects as $index => $project) { $project->scurve = MasterFunctionsHelper::getSCurve($project->id); $selisihProgress = 0; + $planningProgress = 0; + $actualProgress = 0; + if ($project->scurve && $project->scurve[0]) { $planningArray = $project->scurve[0]['data']['percentagePlan']; $actualArray = $project->scurve[0]['data']['percentageReal']; @@ -178,6 +181,9 @@ class DashboardBoDController extends Controller foreach ($projects as $project) { $project->scurve = MasterFunctionsHelper::getSCurve($project->id); $selisihProgress = 0; + $planningProgress = 0; + $actualProgress = 0; + if ($project->scurve && $project->scurve[0]) { $planningArray = $project->scurve[0]['data']['percentagePlan']; $actualArray = $project->scurve[0]['data']['percentageReal']; From 2923ec649f9122cc7d5f5353738f27a26d4e2004 Mon Sep 17 00:00:00 2001 From: wahyuun Date: Wed, 1 Nov 2023 16:00:55 +0700 Subject: [PATCH 04/12] update estimated finish --- app/Http/Controllers/ProjectController.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 39042ec..6540e1a 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -45,7 +45,7 @@ class ProjectController extends Controller { $this->validate($request, [ 'nama' => 'required', - 'mulai_proyek' => 'required', + 'mulai_proyek' => 'required', 'akhir_proyek' => 'required', 'rencana_biaya' => 'required', 'type_proyek_id' => 'required' @@ -519,12 +519,12 @@ class ProjectController extends Controller if (isset($s_curve)) { $result->header = Activity::whereNull('parent_id')->where("proyek_id", $id)->first(); $actualStartExist = Activity::where('proyek_id', $id)->whereNotNull('actual_start')->exists(); - $actualEndExist = Activity::where('proyek_id', $id)->whereNotNull('actual_end')->exists(); + $actualEndExist = Activity::where('proyek_id', $id)->exists(); $query = Activity::where('proyek_id', $id); } else { $result->header = Activity::whereNull('parent_id')->where("proyek_id", $id)->where("version_gantt_id", $ganttId)->first(); $actualStartExist = Activity::where('version_gantt_id', $ganttId)->whereNotNull('actual_start')->exists(); - $actualEndExist = Activity::where('version_gantt_id', $ganttId)->whereNotNull('actual_end')->exists(); + $actualEndExist = Activity::where('version_gantt_id', $ganttId)->exists(); $query = Activity::where('version_gantt_id', $ganttId); } @@ -533,11 +533,10 @@ class ProjectController extends Controller } else { $startDate = $query->orderBy('start_date')->value('start_date'); } - - if ($actualEndExist) { - $endDate = $query->orderByDesc('actual_end')->value('end_date'); - } else { - $endDate = $query->orderByDesc('end_date')->value('end_date'); + if($actualEndExist) + { + $maxEndDate = $query->max('id'); + $endDate = $query->where('id',$maxEndDate)->first()->end_date; } $plannedStart = Activity::where('version_gantt_id', $ganttId) From c6452c9cc231b106ecc748b708c55abdc0112d1d Mon Sep 17 00:00:00 2001 From: wahyu Date: Thu, 2 Nov 2023 09:11:48 +0700 Subject: [PATCH 05/12] update report analysis --- app/Http/Controllers/ActivityController.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php index ea48586..16ccb60 100644 --- a/app/Http/Controllers/ActivityController.php +++ b/app/Http/Controllers/ActivityController.php @@ -544,8 +544,8 @@ class ActivityController extends Controller { $dataBuilder = $this->setUpPayload($request->all(), 'm_activity'); $builder = $dataBuilder['builder']; - $dataGet = $builder->select( 'selfTable.name', 'persentase_progress', 'selfTable.start_date', 'selfTable.end_date', 'duration', 'assign_hr_to_activity.id', - 'm_version_gantt.name_version', 'm_users.name as user_name', + $dataGet = $builder->select( 'selfTable.name', 'persentase_progress', 'selfTable.start_date', 'selfTable.end_date', 'duration', + 'm_version_gantt.name_version', DB::raw('STRING_AGG(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') @@ -557,10 +557,8 @@ class ActivityController extends Controller ->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") - ->groupBy("assign_hr_to_activity.id") ->get(); return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet ], 200); } From 228c7db9f8c4814b64e4bf94062b0af6997b6de8 Mon Sep 17 00:00:00 2001 From: wahyu Date: Thu, 2 Nov 2023 10:54:51 +0700 Subject: [PATCH 06/12] update dashboard bod --- app/Helpers/MasterFunctionsHelper.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Helpers/MasterFunctionsHelper.php b/app/Helpers/MasterFunctionsHelper.php index d1c2c47..53f0be8 100644 --- a/app/Helpers/MasterFunctionsHelper.php +++ b/app/Helpers/MasterFunctionsHelper.php @@ -852,6 +852,7 @@ class MasterFunctionsHelper $arr_ActualM = []; $tempDate = []; + $tempPercentage = []; $tempPercentagePlan = []; $tempPercentagePlanWhr = []; $tempPercentageReal = []; @@ -860,7 +861,8 @@ class MasterFunctionsHelper $currentACWP = 0; $currentBCWP = 0; - + $totalACWP = 0; + $totalBCWP = 0; foreach ($period as $dt) { $minSevenDays = new \Datetime($dt->format("Y-m-d")); $minSevenDays = $minSevenDays->modify('-7 day')->format("Y-m-d"); From 5f73a147ea82f3cf83a77e5f8e2f6d8a05f33118 Mon Sep 17 00:00:00 2001 From: wahyuun Date: Thu, 2 Nov 2023 12:15:24 +0700 Subject: [PATCH 07/12] update condition type proyek --- app/Http/Controllers/ProjectController.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 6540e1a..42bcb6d 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -519,8 +519,14 @@ class ProjectController extends Controller if (isset($s_curve)) { $result->header = Activity::whereNull('parent_id')->where("proyek_id", $id)->first(); $actualStartExist = Activity::where('proyek_id', $id)->whereNotNull('actual_start')->exists(); - $actualEndExist = Activity::where('proyek_id', $id)->exists(); - $query = Activity::where('proyek_id', $id); + if($result['type_proyek_id'] === 9) + { + $actualEndExist = Activity::where('proyek_id', $id)->exists(); + $query = Activity::where('proyek_id', $id); + }else{ + $actualEndExist = Activity::where('version_gantt_id', $ganttId)->exists(); + $query = Activity::where('version_gantt_id', $ganttId); + } } else { $result->header = Activity::whereNull('parent_id')->where("proyek_id", $id)->where("version_gantt_id", $ganttId)->first(); $actualStartExist = Activity::where('version_gantt_id', $ganttId)->whereNotNull('actual_start')->exists(); From 60fe1064a58232296400293d554b32c5c2b402d4 Mon Sep 17 00:00:00 2001 From: wahyu Date: Thu, 2 Nov 2023 13:02:51 +0700 Subject: [PATCH 08/12] update string agg --- app/Http/Controllers/ActivityController.php | 46 ++++++++++++++------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php index 16ccb60..70e84ff 100644 --- a/app/Http/Controllers/ActivityController.php +++ b/app/Http/Controllers/ActivityController.php @@ -544,22 +544,36 @@ class ActivityController extends Controller { $dataBuilder = $this->setUpPayload($request->all(), 'm_activity'); $builder = $dataBuilder['builder']; - $dataGet = $builder->select( 'selfTable.name', 'persentase_progress', 'selfTable.start_date', 'selfTable.end_date', 'duration', - 'm_version_gantt.name_version', DB::raw('STRING_AGG(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') - ->leftJoin('assign_hr_to_activity', 'assign_hr_to_activity.activity_id', '=', 'selfTable.id') - ->leftJoin('m_users', 'assign_hr_to_activity.user_id', '=', 'm_users.id') - ->leftJoin('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("assign_material_to_activity.qty_planning") - ->groupBy("assign_material_to_activity.id") - ->get(); + $dataGet = $builder->select( + 'selfTable.name', + 'persentase_progress', + 'selfTable.start_date', + 'selfTable.end_date', + 'duration', + 'm_version_gantt.name_version', + DB::raw('user_names.user_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') + ->leftJoin('assign_hr_to_activity', 'assign_hr_to_activity.activity_id', '=', 'selfTable.id') + ->leftJoin('report_activity_material', 'report_activity_material.activity_id', '=', 'selfTable.id') + ->join('assign_material_to_activity', 'assign_material_to_activity.activity_id', '=', 'selfTable.id') + ->leftJoin(DB::raw('(SELECT activity_id, STRING_AGG(m_users.name, \',\') as user_name + FROM assign_hr_to_activity + LEFT JOIN m_users ON assign_hr_to_activity.user_id = m_users.id + GROUP BY activity_id) as user_names'), function ($join) { + $join->on('user_names.activity_id', '=', 'selfTable.id'); + }) + ->groupBy('selfTable.id') + ->groupBy('selfTable.name') + ->groupBy('selfTable.persentase_progress') + ->groupBy('m_version_gantt.name_version') + ->groupBy('assign_material_to_activity.qty_planning') + ->groupBy('assign_material_to_activity.id') + ->groupBy('user_names.user_name') + ->get(); return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet ], 200); } // before upload file From 69a48a16d802e5cfa29e6d6da1bd73616b92b92c Mon Sep 17 00:00:00 2001 From: wahyu Date: Thu, 2 Nov 2023 16:28:48 +0700 Subject: [PATCH 09/12] update report analysis activity --- app/Http/Controllers/ActivityController.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php index 70e84ff..733ee1d 100644 --- a/app/Http/Controllers/ActivityController.php +++ b/app/Http/Controllers/ActivityController.php @@ -549,6 +549,10 @@ class ActivityController extends Controller 'persentase_progress', 'selfTable.start_date', 'selfTable.end_date', + 'selfTable.planned_start', + 'selfTable.planned_end', + 'selfTable.actual_start', + 'selfTable.actual_end', 'duration', 'm_version_gantt.name_version', DB::raw('user_names.user_name as user_name'), From 60b9eb39d122d1bed4a959c529b81e7595b3c469 Mon Sep 17 00:00:00 2001 From: wahyuun Date: Mon, 13 Nov 2023 11:23:36 +0700 Subject: [PATCH 10/12] handle delete project --- app/Http/Controllers/ProjectController.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 42bcb6d..ca92810 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -9,13 +9,17 @@ use App\Models\Image; use App\Models\Holiday; use App\Models\Project; use App\Models\Activity; +use App\Models\ReportK3; use App\Jobs\ProcessSCurve; +use App\Models\AssignTools; use App\Models\OfficeHours; use App\Models\ProjectType; use App\Models\ProjectPhase; +use App\Models\ProjectRisks; use App\Models\UserToProyek; use App\Models\VersionGantt; use Illuminate\Http\Request; +use App\Models\HierarchyFtth; use App\Models\ProjectIssues; use App\Models\AssignMaterial; use App\Models\DokumenProject; @@ -26,13 +30,14 @@ use App\Models\UserToActivity; use App\Models\ActivityDokumen; use App\Models\CommentActivity; use App\Models\ProjectApproval; +use App\Models\RequestMaterial; use App\Models\ProjectMileStone; use App\Models\ProjectChecklists; use Illuminate\Support\Facades\DB; use App\Models\ProjectParticipants; use App\Models\FolderDocumentProyek; +use App\Models\ProjectToChecklistK3; use App\Helpers\MasterFunctionsHelper; -use App\Models\ProjectRisks; use App\Models\ReportActivityMaterial; use Illuminate\Support\Facades\Artisan; @@ -163,6 +168,12 @@ class ProjectController extends Controller ProjectChecklists::where('proyek_id', $project_id)->delete(); ProjectIssues::where('proyek_id', $project_id)->delete(); ProjectRisks::where('proyek_id', $project_id)->delete(); + ProjectToChecklistK3::where('proyek_id', $project_id)->delete(); + HierarchyFtth::where('project_id', $project_id)->delete(); + AssignTools::where('proyek_id', $project_id)->delete(); + OfficeHours::where('proyek_id', $project_id)->delete(); + ReportK3::where('proyek_id', $project_id)->delete(); + RequestMaterial::where('proyek_id', $project_id)->delete(); $this->deleteVersionGantt($project_id); $this->deleteDokumenProject($project_id); } From a90e077b9b58f88b68bc7573927be27c0f3fc237 Mon Sep 17 00:00:00 2001 From: wahyuun Date: Mon, 13 Nov 2023 15:50:03 +0700 Subject: [PATCH 11/12] handle delete Gantt --- .../Controllers/VersionGanttController.php | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/VersionGanttController.php b/app/Http/Controllers/VersionGanttController.php index c3fe398..c5fabab 100644 --- a/app/Http/Controllers/VersionGanttController.php +++ b/app/Http/Controllers/VersionGanttController.php @@ -2,8 +2,15 @@ namespace App\Http\Controllers; -use Illuminate\Http\Request; +use App\Models\Link; +use App\Models\Holiday; +use App\Models\Activity; use App\Models\VersionGantt; +use Illuminate\Http\Request; +use App\Models\ShowHideColumn; +use App\Models\UserToActivity; +use App\Models\UserToVersionGantt; +use App\Models\ActivityProgressLog; class VersionGanttController extends Controller { @@ -49,6 +56,7 @@ class VersionGanttController extends Controller if($data){ $delete = $data->delete(); + $this->deleteRelative($data['id']); }else{ return response()->json(['status'=>'failed','message'=>'data version gantt Project not found!','code'=>400], 400); die(); @@ -62,6 +70,17 @@ class VersionGanttController extends Controller } } + private function deleteRelative($version_gantt_id) + { + UserToActivity::where('version_gantt_id', $version_gantt_id)->delete(); + Activity::where('version_gantt_id', $version_gantt_id)->delete(); + ShowHideColumn::where('version_gantt_id', $version_gantt_id)->delete(); + Link::where('version_gantt_id', $version_gantt_id)->delete(); + UserToVersionGantt::where('version_gantt_id', $version_gantt_id)->delete(); + Holiday::where('version_gantt_id', $version_gantt_id)->delete(); + ActivityProgressLog::where('version_gantt_id', $version_gantt_id)->delete(); + } + public function edit($id){ if(!$id || (int) $id < 0 || $id==""){ return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); From 2bc036ac37492ae420b51e410ee6bdc56d319f4e Mon Sep 17 00:00:00 2001 From: wahyuun Date: Mon, 13 Nov 2023 17:21:43 +0700 Subject: [PATCH 12/12] handle delete activity --- app/Http/Controllers/ActivityController.php | 34 +++++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php index 733ee1d..21dc80c 100644 --- a/app/Http/Controllers/ActivityController.php +++ b/app/Http/Controllers/ActivityController.php @@ -1,22 +1,23 @@ json(['status' => 'failed', 'action' => 'error', 'message' => 'Data not found!', 'code' => 404], 404); - + $this->deleteRelative($id); if (!$data->delete()) return response()->json(['status' => 'failed', 'action' => 'error', 'message' => 'data activity failed deleted!', 'code' => 500], 500); return response()->json(['status' => 'success', "action" => "deleted", 'message' => 'data activity successfully deleted!', 'code' => 200], 200); } + private function deleteRelative($activity_id) + { + UserToActivity::where('activity_id', $activity_id)->delete(); + AssignMaterial::where('activity_id', $activity_id)->delete(); + $dataAd = ActivityDokumen::where("activity_id", $activity_id)->get(); + foreach ($dataAd as $ad) { + if(file_exists($this->pathActivityDocument.$ad->file)){ + unlink($this->pathActivityDocument.$ad->file); + } + } + ActivityDokumen::where("activity_id", $activity_id)->delete(); + } + public function getUpdate($id) { if (!$data = Activity::find($id))