Browse Source

Report date validation

pull/3/head
Wahyu Ramadhan 2 years ago
parent
commit
f4a3195ec5
  1. 20
      app/Http/Controllers/ReportActivityMaterialController.php

20
app/Http/Controllers/ReportActivityMaterialController.php

@ -23,18 +23,24 @@ class ReportActivityMaterialController extends Controller
'qty' => 'required'
]);
$activity = Activity::where('id', $request->activity_id)->first();
$start_date = $activity->start_date;
$start_date = substr($start_date, 0, 19); // remove the timezone offset
$startDate = new \DateTime(date("Y-m-d", strtotime($start_date)));
$reportDate = new \DateTime(date("Y-m-d", strtotime($request->report_date)));
$data = $request->all();
$data['created_by'] = $this->currentName;
/* $data['assign_material_id'] = AssignMaterial::where('activity_id', $request->activity_id)->pluck('id')->first(); */
$data['assign_material_id'] = $request->assign_material_id;
$data['qty'] = $this->sanitizeDecimal($data['qty']);
$created = ReportActivityMaterial::create($data);
if(!$created)
return response()->json(['status'=>'failed','message'=>'Input progress report activity failed created','code'=>400,'data'=>null]);
return response()->json(['status'=>'success','message'=>'Input progress report activity created','code'=>200,'data'=>array('report_id'=>$created->id)]);
if($reportDate > $startDate){
$created = ReportActivityMaterial::create($data);
return response()->json(['status'=>'success','message'=>'Input progress report activity created','code'=>200,'data'=>array('report_id'=>$created->id)]);
} else {
return response()->json(['status'=>'failed','message'=>'Input progress report activity failed created','code'=>400,'data'=>null], 400);
}
}
public function updateStatusStartFinish(Request $request){

Loading…
Cancel
Save