|
|
@ -14,7 +14,8 @@ use App\Models\ActivityProgressLog; |
|
|
|
|
|
|
|
|
|
|
|
class VersionGanttController extends Controller |
|
|
|
class VersionGanttController extends Controller |
|
|
|
{ |
|
|
|
{ |
|
|
|
public function add(Request $request){ |
|
|
|
public function add(Request $request) |
|
|
|
|
|
|
|
{ |
|
|
|
$this->validate($request, [ |
|
|
|
$this->validate($request, [ |
|
|
|
'name_version' => 'required', |
|
|
|
'name_version' => 'required', |
|
|
|
'proyek_id' => 'required' |
|
|
|
'proyek_id' => 'required' |
|
|
@ -23,30 +24,31 @@ class VersionGanttController extends Controller |
|
|
|
$data['created_by'] = $this->currentName; |
|
|
|
$data['created_by'] = $this->currentName; |
|
|
|
|
|
|
|
|
|
|
|
$result = VersionGantt::create($data); |
|
|
|
$result = VersionGantt::create($data); |
|
|
|
if($result){ |
|
|
|
if ($result) { |
|
|
|
return response()->json(['status'=>'success','message'=>'version gantt Project successfull created','code'=>200]); |
|
|
|
return response()->json(['status' => 'success', 'message' => 'version gantt Project successfull created', 'code' => 200, 'id' => $result->id]); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
return response()->json(['status'=>'failed','message'=>'version gantt Project failed created','code'=>400]); |
|
|
|
return response()->json(['status' => 'failed', 'message' => 'version gantt Project failed created', 'code' => 400]); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function update(Request $request, $id){ |
|
|
|
public function update(Request $request, $id) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
if(!$id || (int) $id < 0 || $id==""){ |
|
|
|
if (!$id || (int) $id < 0 || $id == "") { |
|
|
|
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
|
|
|
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); |
|
|
|
} |
|
|
|
} |
|
|
|
$data = VersionGantt::find($id); |
|
|
|
$data = VersionGantt::find($id); |
|
|
|
if($data){ |
|
|
|
if ($data) { |
|
|
|
$result = $data->update($request->all()); |
|
|
|
$result = $data->update($request->all()); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
return response()->json(['status'=>'failed','message'=>'data version gantt Project not found!','code'=>400], 400); |
|
|
|
return response()->json(['status' => 'failed', 'message' => 'data version gantt Project not found!', 'code' => 400], 400); |
|
|
|
die(); |
|
|
|
die(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if($result){ |
|
|
|
if ($result) { |
|
|
|
return response()->json(['status'=>'success','message'=>'version gantt Project successfully updated!','code'=>200], 200); |
|
|
|
return response()->json(['status' => 'success', 'message' => 'version gantt Project successfully updated!', 'code' => 200], 200); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
return response()->json(['status'=>'failed','message'=>'version gantt Project failed updated!','code'=>400], 400); |
|
|
|
return response()->json(['status' => 'failed', 'message' => 'version gantt Project failed updated!', 'code' => 400], 400); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -54,19 +56,19 @@ class VersionGanttController extends Controller |
|
|
|
{ |
|
|
|
{ |
|
|
|
$data = VersionGantt::find($id); |
|
|
|
$data = VersionGantt::find($id); |
|
|
|
|
|
|
|
|
|
|
|
if($data){ |
|
|
|
if ($data) { |
|
|
|
$delete = $data->delete(); |
|
|
|
$delete = $data->delete(); |
|
|
|
$this->deleteRelative($data['id']); |
|
|
|
$this->deleteRelative($data['id']); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
return response()->json(['status'=>'failed','message'=>'data version gantt Project not found!','code'=>400], 400); |
|
|
|
return response()->json(['status' => 'failed', 'message' => 'data version gantt Project not found!', 'code' => 400], 400); |
|
|
|
die(); |
|
|
|
die(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if($delete){ |
|
|
|
if ($delete) { |
|
|
|
return response()->json(['status'=>'success','message'=>'version gantt Project successfully deleted!','code'=>200], 200); |
|
|
|
return response()->json(['status' => 'success', 'message' => 'version gantt Project successfully deleted!', 'code' => 200], 200); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
return response()->json(['status'=>'failed','message'=>'version gantt Project failed deleted!','code'=>400], 400); |
|
|
|
return response()->json(['status' => 'failed', 'message' => 'version gantt Project failed deleted!', 'code' => 400], 400); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -81,18 +83,19 @@ class VersionGanttController extends Controller |
|
|
|
ActivityProgressLog::where('version_gantt_id', $version_gantt_id)->delete(); |
|
|
|
ActivityProgressLog::where('version_gantt_id', $version_gantt_id)->delete(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function edit($id){ |
|
|
|
public function edit($id) |
|
|
|
if(!$id || (int) $id < 0 || $id==""){ |
|
|
|
{ |
|
|
|
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
|
|
|
if (!$id || (int) $id < 0 || $id == "") { |
|
|
|
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); |
|
|
|
die(); |
|
|
|
die(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$result = VersionGantt::find($id); |
|
|
|
$result = VersionGantt::find($id); |
|
|
|
|
|
|
|
|
|
|
|
if($result){ |
|
|
|
if ($result) { |
|
|
|
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); |
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
return response()->json(['status'=>'failed','message'=>'failed get data version gantt, please try again later!','code'=>400], 400); |
|
|
|
return response()->json(['status' => 'failed', 'message' => 'failed get data version gantt, please try again later!', 'code' => 400], 400); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -106,23 +109,24 @@ class VersionGanttController extends Controller |
|
|
|
$dataGet = $builder->get(); |
|
|
|
$dataGet = $builder->get(); |
|
|
|
|
|
|
|
|
|
|
|
// $totalRecord = $countBuilder->count(); |
|
|
|
// $totalRecord = $countBuilder->count(); |
|
|
|
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet], 200); |
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet], 200); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function ganttProgress($column, $value){ |
|
|
|
public function ganttProgress($column, $value) |
|
|
|
$progress = VersionGantt::select('m_version_gantt.id','m_activity.persentase_progress', 'm_activity.bobot_planning') |
|
|
|
{ |
|
|
|
->join('m_activity', 'm_version_gantt.id', '=', 'm_activity.version_gantt_id') |
|
|
|
$progress = VersionGantt::select('m_version_gantt.id', 'm_activity.persentase_progress', 'm_activity.bobot_planning') |
|
|
|
->where("m_version_gantt.".$column, $value) |
|
|
|
->join('m_activity', 'm_version_gantt.id', '=', 'm_activity.version_gantt_id') |
|
|
|
// ->where('m_activity.type_activity', "project") |
|
|
|
->where("m_version_gantt." . $column, $value) |
|
|
|
->where('m_activity.parent_id', null) |
|
|
|
// ->where('m_activity.type_activity', "project") |
|
|
|
->get(); |
|
|
|
->where('m_activity.parent_id', null) |
|
|
|
foreach($progress as $item) { |
|
|
|
->get(); |
|
|
|
if($item->persentase_progress){ |
|
|
|
foreach ($progress as $item) { |
|
|
|
$item->progress = $item->persentase_progress; |
|
|
|
if ($item->persentase_progress) { |
|
|
|
$item->bobot = $item->bobot_planning; |
|
|
|
$item->progress = $item->persentase_progress; |
|
|
|
$item->save(); |
|
|
|
$item->bobot = $item->bobot_planning; |
|
|
|
|
|
|
|
$item->save(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function list() |
|
|
|
public function list() |
|
|
@ -130,10 +134,10 @@ class VersionGanttController extends Controller |
|
|
|
$data = VersionGantt::all(); |
|
|
|
$data = VersionGantt::all(); |
|
|
|
$countData = $data->count(); |
|
|
|
$countData = $data->count(); |
|
|
|
|
|
|
|
|
|
|
|
if($data){ |
|
|
|
if ($data) { |
|
|
|
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data, 'totalRecord' => $countData], 200); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
return response()->json(['status'=>'failed','message'=>'failed get list version gantt, please try again later!','code'=>400], 400); |
|
|
|
return response()->json(['status' => 'failed', 'message' => 'failed get list version gantt, please try again later!', 'code' => 400], 400); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|