|
|
|
@ -31,7 +31,6 @@ class ReportActivityMaterialController extends Controller
|
|
|
|
|
if(!ReportActivityMaterial::create($data)) |
|
|
|
|
return response()->json(['status'=>'failed','message'=>'Input progress report activity failed created','code'=>400]); |
|
|
|
|
|
|
|
|
|
$this->countForProgress($request->activity_id); |
|
|
|
|
return response()->json(['status'=>'success','message'=>'Input progress report activity created','code'=>200]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -68,46 +67,6 @@ class ReportActivityMaterialController extends Controller
|
|
|
|
|
return response()->json(['status'=>'success','message'=> 'Data deleted!','code'=>200], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private function countForProgress($id) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
$dataActivity = Activity::find($id); |
|
|
|
|
$dataPlan = AssignMaterial::where('activity_id', $id)->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; |
|
|
|
|
|
|
|
|
|
if($status_activity == 'done'){ |
|
|
|
|
$tmpPercentage1[] = $percentage1 > 100 ? 100 : $percentage1; |
|
|
|
|
}else if($status_activity == 'on-progress'){ |
|
|
|
|
$tmpPercentage1[] = $percentage1 >= config('app.max_percentage_not_done') ? config('app.max_percentage_not_done') : $percentage1; |
|
|
|
|
}else{ |
|
|
|
|
$tmpPercentage1[] = $percentage1 >= config('max_percentage_not_done') ? config('app.max_percentage_not_done') : $percentage1; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$totalPercentage = array_sum($tmpPercentage1) / count($tmpPercentage1); |
|
|
|
|
}else{ |
|
|
|
|
$totalPercentage = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$dataUpdate = array( |
|
|
|
|
"persentase_progress" => $totalPercentage, |
|
|
|
|
"updated_by" => $this->currentName |
|
|
|
|
); |
|
|
|
|
return $dataActivity->update($dataUpdate); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function search(Request $request) |
|
|
|
|
{ |
|
|
|
|
$payload = $request->all(); |
|
|
|
|