From 1fbb8ea2b014fef2565f2755246f9466c9e9290c Mon Sep 17 00:00:00 2001 From: wahyu Date: Tue, 10 Oct 2023 15:41:39 +0700 Subject: [PATCH 1/4] fix update schedule --- app/Http/Controllers/ActivityController.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php index 50ba368..e36ec6c 100644 --- a/app/Http/Controllers/ActivityController.php +++ b/app/Http/Controllers/ActivityController.php @@ -431,11 +431,12 @@ class ActivityController extends Controller $duration = MasterFunctionsHelper::countDays($ganttId, $plannedStart, $plannedEnd); if ($today >= $endDate) { $endDate = $today; - $rerataBobot = $duration > 0 ? $activity->bobot_planning / $duration : 0; - $bobotActual = $activity->progress * $activity->bobot_planning; - $sisaBobot = $activity->bobot_planning - $bobotActual; + $bobotPlanning = (int) $activity->bobot_planning; + $rerataBobot = $duration > 0 ? $bobotPlanning / $duration : 0; + $bobotActual = (int) $activity->persentase_progress/100 * $bobotPlanning; + $sisaBobot = $bobotPlanning - $bobotActual; $sisaHari = $rerataBobot > 0 ? $sisaBobot / $rerataBobot : 0; - $endDate->modify("+".$sisaHari." Days"); + $endDate->modify("+".ceil($sisaHari)." Days"); $actualDuration = MasterFunctionsHelper::countDays($ganttId, $startDate, $endDate); $activity->duration = $actualDuration; $activity->end_date = $endDate; From d98dec9c49171f0b2332386552b9d5f09292a5c4 Mon Sep 17 00:00:00 2001 From: wahyu Date: Wed, 11 Oct 2023 13:43:39 +0700 Subject: [PATCH 2/4] fix actual date, check status update schedule --- app/Http/Controllers/ActivityController.php | 10 +++++++++- .../Controllers/ReportActivityMaterialController.php | 2 ++ app/Models/ReportActivityMaterial.php | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php index e36ec6c..dce8f9e 100644 --- a/app/Http/Controllers/ActivityController.php +++ b/app/Http/Controllers/ActivityController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers; use App\Helpers\MasterFunctionsHelper; use App\Models\Activity; +use App\Models\AssignMaterial; use App\Models\CommentActivity; use App\Models\Link; use App\Models\Project; @@ -422,7 +423,14 @@ class ActivityController extends Controller return response()->json(['status' => 'failed', 'message' => 'Activities not found!', 'code' => 404], 404); $duration = 0; foreach ($activities as $key => $activity) { - if (isset($activity->planned_start) && isset($activity->planned_end)) { + $assignMaterial = AssignMaterial::where('activity_id', $activity->id)->first(); + if (isset($assignMaterial)) { + $statusActivity = $assignMaterial->status_activity; + } else { + $statusActivity = ''; + } + if (isset($activity->planned_start) && isset($activity->planned_end) && $statusActivity != "done") { + // todo check report for no report / progress == 0 $today = new DateTime(); $endDate = new DateTime($activity->end_date); $startDate = new DateTime($activity->start_date); diff --git a/app/Http/Controllers/ReportActivityMaterialController.php b/app/Http/Controllers/ReportActivityMaterialController.php index eae0d86..0ec323c 100644 --- a/app/Http/Controllers/ReportActivityMaterialController.php +++ b/app/Http/Controllers/ReportActivityMaterialController.php @@ -63,6 +63,8 @@ class ReportActivityMaterialController extends Controller $sumAssignMaterial = AssignMaterial::where('activity_id', $request->activity_id)->sum('qty_planning'); $sumReportActivityMaterial = ReportActivityMaterial::where('activity_id', $request->activity_id)->sum('qty'); $dataUpdate = array( + "actual_start" => null, + "actual_end" => null, "persentase_progress" => $sumReportActivityMaterial/$sumAssignMaterial*100, "updated_by" => $this->currentName ); diff --git a/app/Models/ReportActivityMaterial.php b/app/Models/ReportActivityMaterial.php index 39849d5..df0bb0b 100644 --- a/app/Models/ReportActivityMaterial.php +++ b/app/Models/ReportActivityMaterial.php @@ -59,6 +59,8 @@ class ReportActivityMaterial extends Model $assignedMaterial = AssignMaterial::find($data->assign_material_id); $activity->biaya_actual -= floatval($assignedMaterial->budget) * floatval($data->qty); + $activity->actual_start = null; + $activity->actual_end = null; $dataPlan = AssignMaterial::where('activity_id', $activity->id)->get(); $totalPlan = $dataPlan->sum('qty_planning'); From 02200c0ada57eda3d0d96fbfaa35669a9c8728c6 Mon Sep 17 00:00:00 2001 From: wahyu Date: Thu, 12 Oct 2023 08:05:08 +0700 Subject: [PATCH 3/4] fix endline --- .../Controllers/VersionGanttController.php | 240 +++++++++--------- 1 file changed, 120 insertions(+), 120 deletions(-) diff --git a/app/Http/Controllers/VersionGanttController.php b/app/Http/Controllers/VersionGanttController.php index 97b5857..c3fe398 100644 --- a/app/Http/Controllers/VersionGanttController.php +++ b/app/Http/Controllers/VersionGanttController.php @@ -1,120 +1,120 @@ -validate($request, [ - 'name_version' => 'required', - 'proyek_id' => 'required' - ]); - $data = $request->all(); - $data['created_by'] = $this->currentName; - - $result = VersionGantt::create($data); - if($result){ - return response()->json(['status'=>'success','message'=>'version gantt Project successfull created','code'=>200]); - }else{ - return response()->json(['status'=>'failed','message'=>'version gantt Project failed created','code'=>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 = VersionGantt::find($id); - if($data){ - $result = $data->update($request->all()); - }else{ - return response()->json(['status'=>'failed','message'=>'data version gantt Project not found!','code'=>400], 400); - die(); - } - - if($result){ - return response()->json(['status'=>'success','message'=>'version gantt Project successfully updated!','code'=>200], 200); - }else{ - return response()->json(['status'=>'failed','message'=>'version gantt Project failed updated!','code'=>400], 400); - } - } - - public function delete($id) - { - $data = VersionGantt::find($id); - - if($data){ - $delete = $data->delete(); - }else{ - return response()->json(['status'=>'failed','message'=>'data version gantt Project not found!','code'=>400], 400); - die(); - } - - - if($delete){ - return response()->json(['status'=>'success','message'=>'version gantt Project successfully deleted!','code'=>200], 200); - }else{ - return response()->json(['status'=>'failed','message'=>'version gantt Project failed deleted!','code'=>400], 400); - } - } - - public function edit($id){ - if(!$id || (int) $id < 0 || $id==""){ - return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); - die(); - } - - $result = VersionGantt::find($id); - - if($result){ - return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); - }else{ - return response()->json(['status'=>'failed','message'=>'failed get data version gantt, please try again later!','code'=>400], 400); - } - } - - public function search(Request $request) - { - $payload = $request->all(); - $dataBuilder = $this->setUpPayload($payload, 'm_version_gantt'); - $builder = $dataBuilder['builder']; - // $countBuilder = $dataBuilder['count']; - $this->ganttProgress($request->columns[0]["name"], $request->columns[0]["value"]); - $dataGet = $builder->get(); - - // $totalRecord = $countBuilder->count(); - return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet], 200); - } - - public function ganttProgress($column, $value){ - $progress = VersionGantt::select('m_version_gantt.id','m_activity.persentase_progress', 'm_activity.bobot_planning') - ->join('m_activity', 'm_version_gantt.id', '=', 'm_activity.version_gantt_id') - ->where("m_version_gantt.".$column, $value) - // ->where('m_activity.type_activity', "project") - ->where('m_activity.parent_id', null) - ->get(); - foreach($progress as $item) { - if($item->persentase_progress){ - $item->progress = $item->persentase_progress; - $item->bobot = $item->bobot_planning; - $item->save(); - } - } - } - - public function list() - { - $data = VersionGantt::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 version gantt, please try again later!','code'=>400], 400); - } - } -} +validate($request, [ + 'name_version' => 'required', + 'proyek_id' => 'required' + ]); + $data = $request->all(); + $data['created_by'] = $this->currentName; + + $result = VersionGantt::create($data); + if($result){ + return response()->json(['status'=>'success','message'=>'version gantt Project successfull created','code'=>200]); + }else{ + return response()->json(['status'=>'failed','message'=>'version gantt Project failed created','code'=>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 = VersionGantt::find($id); + if($data){ + $result = $data->update($request->all()); + }else{ + return response()->json(['status'=>'failed','message'=>'data version gantt Project not found!','code'=>400], 400); + die(); + } + + if($result){ + return response()->json(['status'=>'success','message'=>'version gantt Project successfully updated!','code'=>200], 200); + }else{ + return response()->json(['status'=>'failed','message'=>'version gantt Project failed updated!','code'=>400], 400); + } + } + + public function delete($id) + { + $data = VersionGantt::find($id); + + if($data){ + $delete = $data->delete(); + }else{ + return response()->json(['status'=>'failed','message'=>'data version gantt Project not found!','code'=>400], 400); + die(); + } + + + if($delete){ + return response()->json(['status'=>'success','message'=>'version gantt Project successfully deleted!','code'=>200], 200); + }else{ + return response()->json(['status'=>'failed','message'=>'version gantt Project failed deleted!','code'=>400], 400); + } + } + + public function edit($id){ + if(!$id || (int) $id < 0 || $id==""){ + return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); + die(); + } + + $result = VersionGantt::find($id); + + if($result){ + return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); + }else{ + return response()->json(['status'=>'failed','message'=>'failed get data version gantt, please try again later!','code'=>400], 400); + } + } + + public function search(Request $request) + { + $payload = $request->all(); + $dataBuilder = $this->setUpPayload($payload, 'm_version_gantt'); + $builder = $dataBuilder['builder']; + // $countBuilder = $dataBuilder['count']; + $this->ganttProgress($request->columns[0]["name"], $request->columns[0]["value"]); + $dataGet = $builder->get(); + + // $totalRecord = $countBuilder->count(); + return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet], 200); + } + + public function ganttProgress($column, $value){ + $progress = VersionGantt::select('m_version_gantt.id','m_activity.persentase_progress', 'm_activity.bobot_planning') + ->join('m_activity', 'm_version_gantt.id', '=', 'm_activity.version_gantt_id') + ->where("m_version_gantt.".$column, $value) + // ->where('m_activity.type_activity', "project") + ->where('m_activity.parent_id', null) + ->get(); + foreach($progress as $item) { + if($item->persentase_progress){ + $item->progress = $item->persentase_progress; + $item->bobot = $item->bobot_planning; + $item->save(); + } + } + } + + public function list() + { + $data = VersionGantt::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 version gantt, please try again later!','code'=>400], 400); + } + } +} From 88151c2f49f8be05c37825d4399f75579de9aa37 Mon Sep 17 00:00:00 2001 From: wahyu Date: Thu, 12 Oct 2023 09:27:10 +0700 Subject: [PATCH 4/4] prorate total cost for gantt --- app/Http/Controllers/ProjectController.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 75ecec4..f5b921b 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -466,12 +466,16 @@ class ProjectController extends Controller } public function getInvoiceIntegration(Request $request) { + $ganttCount = VersionGantt::where('proyek_id', $request->id)->count(); $search = urlencode($request->search); if(empty($search)) return response()->json(['status'=>'error', 'message'=>'Empty query string!'], 400); $url = str_replace("SEARCH", $search, config('api.adw').'/project_cost?project_no=SEARCH'); $response = MasterFunctionsHelper::curlReq($url); + if (isset($request->gantt_id)) { + $response->data->total_cost = $response->data->total_cost / $ganttCount; + } return response()->json(['status'=>'success', 'data'=> $response, 'code'=>200], 200); }