Browse Source

Merge pull request 'Remove progress status checker' (#80) from dev-wahyu into staging

Reviewed-on: ordo/adw-backend#80
pull/3/head
ibnu 1 year ago
parent
commit
580e9a6f28
  1. 2
      app/Http/Controllers/ActivityController.php
  2. 5
      app/Models/ReportActivityMaterial.php

2
app/Http/Controllers/ActivityController.php

@ -247,7 +247,7 @@ class ActivityController extends Controller
if(empty($id) || !is_int((int)$id)) if(empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed', 'action'=>'error','message'=>'id is required!','code'=>400], 400); return response()->json(['status'=>'failed', 'action'=>'error','message'=>'id is required!','code'=>400], 400);
$updateBobot = true; $updateBobot = false;
if(!$data = Activity::find($id)) if(!$data = Activity::find($id))
return response()->json(['status'=>'failed', 'action'=>'error','message'=>'Data not found!','code'=> 404], 404); return response()->json(['status'=>'failed', 'action'=>'error','message'=>'Data not found!','code'=> 404], 404);
$dataUpdate = $request->all(); $dataUpdate = $request->all();

5
app/Models/ReportActivityMaterial.php

@ -61,15 +61,10 @@ class ReportActivityMaterial extends Model
$activity->biaya_actual -= floatval($assignedMaterial->budget) * floatval($data->qty); $activity->biaya_actual -= floatval($assignedMaterial->budget) * floatval($data->qty);
$dataPlan = AssignMaterial::where('activity_id', $activity->id)->get(); $dataPlan = AssignMaterial::where('activity_id', $activity->id)->get();
if($dataPlan[0]->status_activity == 'done'){
$activity->persentase_progress = 100;
} else {
$totalPlan = $dataPlan->sum('qty_planning'); $totalPlan = $dataPlan->sum('qty_planning');
$totalVolumeActual = ReportActivityMaterial::where('activity_id', '=', $activity->id)->sum("qty"); $totalVolumeActual = ReportActivityMaterial::where('activity_id', '=', $activity->id)->sum("qty");
$percentage = ($totalVolumeActual * 100) / $totalPlan; $percentage = ($totalVolumeActual * 100) / $totalPlan;
$activity->persentase_progress = $percentage >= config('app.max_percentage_not_done') ? config('app.max_percentage_not_done') : $percentage; $activity->persentase_progress = $percentage >= config('app.max_percentage_not_done') ? config('app.max_percentage_not_done') : $percentage;
}
$activity->save(); $activity->save();
}); });

Loading…
Cancel
Save