Browse Source

set default max percentage

pull/3/head
Muhammad Sulaiman Yusuf 2 years ago
parent
commit
203eaa4825
  1. 41
      app/Http/Controllers/ReportActivityMaterialController.php
  2. 2
      app/Models/Activity.php

41
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();

2
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()

Loading…
Cancel
Save