Browse Source

Merge pull request 'staging' (#197) from staging into master

Reviewed-on: ordo/adw-backend#197
pull/3/head
ibnu 1 year ago
parent
commit
cbd3362364
  1. 4
      app/Http/Controllers/ActivityController.php
  2. 4
      app/Http/Controllers/ReportActivityMaterialController.php

4
app/Http/Controllers/ActivityController.php

@ -431,10 +431,10 @@ class ActivityController extends Controller
$duration = MasterFunctionsHelper::countDays($ganttId, $plannedStart, $plannedEnd); $duration = MasterFunctionsHelper::countDays($ganttId, $plannedStart, $plannedEnd);
if ($today >= $endDate) { if ($today >= $endDate) {
$endDate = $today; $endDate = $today;
$rerataBobot = $activity->bobot_planning / $duration; $rerataBobot = $duration > 0 ? $activity->bobot_planning / $duration : 0;
$bobotActual = $activity->progress * $activity->bobot_planning; $bobotActual = $activity->progress * $activity->bobot_planning;
$sisaBobot = $activity->bobot_planning - $bobotActual; $sisaBobot = $activity->bobot_planning - $bobotActual;
$sisaHari = $sisaBobot / $rerataBobot; $sisaHari = $rerataBobot > 0 ? $sisaBobot / $rerataBobot : 0;
$endDate->modify("+".$sisaHari." Days"); $endDate->modify("+".$sisaHari." Days");
$actualDuration = MasterFunctionsHelper::countDays($ganttId, $startDate, $endDate); $actualDuration = MasterFunctionsHelper::countDays($ganttId, $startDate, $endDate);
$activity->duration = $actualDuration; $activity->duration = $actualDuration;

4
app/Http/Controllers/ReportActivityMaterialController.php

@ -35,11 +35,11 @@ class ReportActivityMaterialController extends Controller
/* $data['assign_material_id'] = AssignMaterial::where('activity_id', $request->activity_id)->pluck('id')->first(); */ /* $data['assign_material_id'] = AssignMaterial::where('activity_id', $request->activity_id)->pluck('id')->first(); */
$data['assign_material_id'] = $request->assign_material_id; $data['assign_material_id'] = $request->assign_material_id;
$data['qty'] = $this->sanitizeDecimal($data['qty']); $data['qty'] = $this->sanitizeDecimal($data['qty']);
if($reportDate >= $startDate){ if($reportDate >= $startDate || isset($data['force']) && $data['force'] == "true"){
$created = ReportActivityMaterial::create($data); $created = ReportActivityMaterial::create($data);
return response()->json(['status'=>'success','message'=>'Input progress report activity created','code'=>200,'data'=>array('report_id'=>$created->id)]); return response()->json(['status'=>'success','message'=>'Input progress report activity created','code'=>200,'data'=>array('report_id'=>$created->id)]);
} else { } else {
return response()->json(['status'=>'failed','message'=>'Input progress report activity failed created','code'=>400,'data'=>null], 400); return response()->json(['status'=>'failed','message'=>'Report date is before early start, still wanna add data ?','code'=>400,'data'=>$data], 400);
} }
} }

Loading…
Cancel
Save