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