From 203eaa48259709cc46f0bf851c745fedeff4dd25 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Mon, 21 Nov 2022 16:34:46 +0700 Subject: [PATCH] set default max percentage --- .../ReportActivityMaterialController.php | 41 ++----------------- app/Models/Activity.php | 2 +- 2 files changed, 5 insertions(+), 38 deletions(-) diff --git a/app/Http/Controllers/ReportActivityMaterialController.php b/app/Http/Controllers/ReportActivityMaterialController.php index 04ae220..9ed7bea 100644 --- a/app/Http/Controllers/ReportActivityMaterialController.php +++ b/app/Http/Controllers/ReportActivityMaterialController.php @@ -9,13 +9,13 @@ use App\Models\AssignMaterial; use Datatables; class ReportActivityMaterialController extends Controller -{ +{ private function sanitizeDecimal($number) { $number = str_replace(".","",$number); $number = str_replace(",",".",$number); return $number; } - + public function add(Request $request){ $this->validate($request, [ @@ -88,9 +88,9 @@ class ReportActivityMaterialController extends Controller if($status_activity == 'done'){ $tmpPercentage1[] = $percentage1 > 100 ? 100 : $percentage1; }else if($status_activity == 'on-progress'){ - $tmpPercentage1[] = $percentage1 >= 100 ? 90 : $percentage1; + $tmpPercentage1[] = $percentage1 >= config('app.max_percentage_not_done') ? config('app.max_percentage_not_done') : $percentage1; }else{ - $tmpPercentage1[] = $percentage1 >= 100 ? 90 : $percentage1; + $tmpPercentage1[] = $percentage1 >= config('max_percentage_not_done') ? config('app.max_percentage_not_done') : $percentage1; } } $totalPercentage = array_sum($tmpPercentage1) / count($tmpPercentage1); @@ -108,39 +108,6 @@ class ReportActivityMaterialController extends Controller return $dataActivity->update($dataUpdate); } - public function countForProgressTest() - { - $dataPlan = AssignMaterial::where('activity_id', 807)->get(); - $tmpPercentage1 = []; - - if(!$dataPlan->isEmpty()){ - foreach ($dataPlan as $value) { - # code... - $price = $value->material_id; - $qty_plan = $value->qty_planning; - $status_activity = $value->status_activity; - - $getDataVolActual = ReportActivityMaterial::where('assign_material_id', '=', $value->id)->sum("qty"); - $percentage1 = ($getDataVolActual * 100) / $qty_plan; - $percentage1 = ($getDataVolActual * 100) / $qty_plan; - if($status_activity == 'done'){ - $tmpPercentage1[] = $percentage1 > 100 ? 100 : $percentage1; - }else if($status_activity == 'on-progress'){ - $tmpPercentage1[] = $percentage1 >= 100 ? 90 : $percentage1; - }else{ - $tmpPercentage1[] = $percentage1 >= 100 ? 90 : $percentage1; - } - - - } - $totalPercentage = array_sum($tmpPercentage1) / count($tmpPercentage1); - }else{ - $totalPercentage = 0; - } - - return response()->json(['status'=>'success','code'=>200,'data'=>$dataPlan, 'tmpPercentage1'=> $tmpPercentage1, 'totalPercentage'=> $totalPercentage], 200); - } - public function search(Request $request) { $payload = $request->all(); diff --git a/app/Models/Activity.php b/app/Models/Activity.php index 3ec0bac..9ad288b 100644 --- a/app/Models/Activity.php +++ b/app/Models/Activity.php @@ -137,7 +137,7 @@ class Activity extends Model $totalPlan = $dataPlan->sum('qty_planning'); $totalVolumeActual = ReportActivityMaterial::where('activity_id', '=', $this->id)->sum("qty"); $percentage = ($totalVolumeActual * 100) / $totalPlan; - return $percentage > 95 ? 95 : $percentage; + return $percentage > config('app.max_percentage_not_done') ? config('app.max_percentage_not_done') : $percentage; } public function getAssignHrAttribute()