|
|
|
@ -50,69 +50,70 @@ class ProjectController extends Controller
|
|
|
|
|
|
|
|
|
|
$data['created_by'] = $this->currentName; |
|
|
|
|
|
|
|
|
|
if(empty($data['phase_id'])) |
|
|
|
|
if (empty($data['phase_id'])) |
|
|
|
|
$data['phase_id'] = 1; |
|
|
|
|
|
|
|
|
|
$result = Project::create($data); |
|
|
|
|
|
|
|
|
|
if(!$result) |
|
|
|
|
return response()->json(['status'=>'failed','message'=>'Failed to add data!','code'=> 500], 500); |
|
|
|
|
if (!$result) |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Failed to add data!', 'code' => 500], 500); |
|
|
|
|
|
|
|
|
|
$this->createOfficeHours($result->id); |
|
|
|
|
$dataResultInsert = Project::where('nama', $data['nama'])->where('mulai_proyek', $data['mulai_proyek'])->first(); |
|
|
|
|
|
|
|
|
|
return response()->json(['status'=>'success','message'=>'Data added!', 'data_result' =>$dataResultInsert, 'code'=> 200], 200); |
|
|
|
|
return response()->json(['status' => 'success', 'message' => 'Data added!', 'data_result' => $dataResultInsert, 'code' => 200], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function edit($id){ |
|
|
|
|
if(empty($id) || !is_int((int)$id)) |
|
|
|
|
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
|
|
|
|
public function edit($id) |
|
|
|
|
{ |
|
|
|
|
if (empty($id) || !is_int((int)$id)) |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); |
|
|
|
|
|
|
|
|
|
$result = Project::find($id); |
|
|
|
|
|
|
|
|
|
if(!$result) |
|
|
|
|
return response()->json(['status'=>'failed','message'=> 'Data not found!','code'=> 404], 404); |
|
|
|
|
if (!$result) |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404); |
|
|
|
|
|
|
|
|
|
return response()->json(['status'=>'success','code'=> 200,'data'=>$result], 200); |
|
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function update(Request $request, $id) |
|
|
|
|
{ |
|
|
|
|
if(empty($id) || !is_int((int)$id)) |
|
|
|
|
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
|
|
|
|
if (empty($id) || !is_int((int)$id)) |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); |
|
|
|
|
|
|
|
|
|
$data = Project::find($id); |
|
|
|
|
|
|
|
|
|
if(!$data) |
|
|
|
|
return response()->json(['status'=>'failed','message'=> 'Data not found!','code'=> 404], 404); |
|
|
|
|
if (!$data) |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404); |
|
|
|
|
|
|
|
|
|
$result = $data->update($request->all()); |
|
|
|
|
|
|
|
|
|
if(!$result) |
|
|
|
|
return response()->json(['status'=>'failed','message'=> 'Failed to update!','code'=> 500], 500); |
|
|
|
|
if (!$result) |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Failed to update!', 'code' => 500], 500); |
|
|
|
|
|
|
|
|
|
return response()->json(['status'=>'success','message'=>'Data updated!','code' => 200], 200); |
|
|
|
|
return response()->json(['status' => 'success', 'message' => 'Data updated!', 'code' => 200], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private function createOfficeHours($proyek_id) |
|
|
|
|
{ |
|
|
|
|
$dataCreate = array( |
|
|
|
|
"proyek_id"=>$proyek_id, |
|
|
|
|
"monday_start"=> "08:00:00", |
|
|
|
|
"monday_end"=> "16:00:00", |
|
|
|
|
"tuesday_start"=> "08:00:00", |
|
|
|
|
"tuesday_end"=> "16:00:00", |
|
|
|
|
"wednesday_start"=> "08:00:00", |
|
|
|
|
"wednesday_end"=> "16:00:00", |
|
|
|
|
"thursday_start"=> "08:00:00", |
|
|
|
|
"thursday_end"=> "16:00:00", |
|
|
|
|
"friday_start"=> "08:00:00", |
|
|
|
|
"friday_end"=> "16:00:00", |
|
|
|
|
"saturday_start"=> "08:00:00", |
|
|
|
|
"saturday_end"=> "16:00:00", |
|
|
|
|
"sunday_start"=> "08:00:00", |
|
|
|
|
"sunday_end"=> "16:00:00", |
|
|
|
|
"created_by"=> $this->currentName |
|
|
|
|
"proyek_id" => $proyek_id, |
|
|
|
|
"monday_start" => "08:00:00", |
|
|
|
|
"monday_end" => "16:00:00", |
|
|
|
|
"tuesday_start" => "08:00:00", |
|
|
|
|
"tuesday_end" => "16:00:00", |
|
|
|
|
"wednesday_start" => "08:00:00", |
|
|
|
|
"wednesday_end" => "16:00:00", |
|
|
|
|
"thursday_start" => "08:00:00", |
|
|
|
|
"thursday_end" => "16:00:00", |
|
|
|
|
"friday_start" => "08:00:00", |
|
|
|
|
"friday_end" => "16:00:00", |
|
|
|
|
"saturday_start" => "08:00:00", |
|
|
|
|
"saturday_end" => "16:00:00", |
|
|
|
|
"sunday_start" => "08:00:00", |
|
|
|
|
"sunday_end" => "16:00:00", |
|
|
|
|
"created_by" => $this->currentName |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
OfficeHours::create($dataCreate); |
|
|
|
@ -124,15 +125,15 @@ class ProjectController extends Controller
|
|
|
|
|
{ |
|
|
|
|
$data = Project::find($id); |
|
|
|
|
|
|
|
|
|
if(!$data) |
|
|
|
|
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404); |
|
|
|
|
if (!$data) |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404); |
|
|
|
|
|
|
|
|
|
$this->deleteRelative($id); |
|
|
|
|
|
|
|
|
|
if(!$data->delete()) |
|
|
|
|
return response()->json(['status'=>'failed','message'=>'Delete failed!','code'=> 500], 500); |
|
|
|
|
if (!$data->delete()) |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Delete failed!', 'code' => 500], 500); |
|
|
|
|
|
|
|
|
|
return response()->json(['status'=>'success','message'=>'Data deleted!','code'=>200], 200); |
|
|
|
|
return response()->json(['status' => 'success', 'message' => 'Data deleted!', 'code' => 200], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private function deleteRelative($project_id) |
|
|
|
@ -158,16 +159,16 @@ class ProjectController extends Controller
|
|
|
|
|
foreach ($dataRa as $ra) { |
|
|
|
|
$images = Image::where("ref_id", $ra->id)->where("category", "report_activity")->get(); |
|
|
|
|
foreach ($images as $image) { |
|
|
|
|
if(file_exists($this->pathImage.$image->image)){ |
|
|
|
|
unlink($this->pathImage.$image->image); |
|
|
|
|
if (file_exists($this->pathImage . $image->image)) { |
|
|
|
|
unlink($this->pathImage . $image->image); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Image::where("ref_id", $ra->id)->where("category", "report_activity")->delete(); |
|
|
|
|
} |
|
|
|
|
$dataAd = ActivityDokumen::whereIn("activity_id", $activityIds)->get(); |
|
|
|
|
foreach ($dataAd as $ad) { |
|
|
|
|
if(file_exists($this->pathActivityDocument.$ad->file)){ |
|
|
|
|
unlink($this->pathActivityDocument.$ad->file); |
|
|
|
|
if (file_exists($this->pathActivityDocument . $ad->file)) { |
|
|
|
|
unlink($this->pathActivityDocument . $ad->file); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
ActivityDokumen::whereIn("activity_id", $activityIds)->delete(); |
|
|
|
@ -185,8 +186,8 @@ class ProjectController extends Controller
|
|
|
|
|
$dataDokumen = DokumenProject::where("type_dokumen", "project-document-out-folder")->where('ref_id', $project_id)->get(); |
|
|
|
|
|
|
|
|
|
foreach ($dataDokumen as $dokumen) { |
|
|
|
|
if(file_exists($this->pathDocument.$dokumen->file)){ |
|
|
|
|
unlink($this->pathDocument.$dokumen->file); |
|
|
|
|
if (file_exists($this->pathDocument . $dokumen->file)) { |
|
|
|
|
unlink($this->pathDocument . $dokumen->file); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
DokumenProject::where("type_dokumen", "project-document-out-folder")->where('ref_id', $project_id)->delete(); |
|
|
|
@ -195,14 +196,28 @@ class ProjectController extends Controller
|
|
|
|
|
$ref_ids = $dataFolder->all(); |
|
|
|
|
$dataDokumen = DokumenProject::where("type_dokumen", "project-document-in-folder")->whereIn('ref_id', $ref_ids)->get(); |
|
|
|
|
foreach ($dataDokumen as $dokumen) { |
|
|
|
|
if(file_exists($this->pathDocument.$dokumen->file)){ |
|
|
|
|
unlink($this->pathDocument.$dokumen->file); |
|
|
|
|
if (file_exists($this->pathDocument . $dokumen->file)) { |
|
|
|
|
unlink($this->pathDocument . $dokumen->file); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
DokumenProject::where("type_dokumen", "project-document-in-folder")->whereIn('ref_id', $ref_ids)->delete(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getByUser($id) |
|
|
|
|
{ |
|
|
|
|
$result = UserToProyek::query() |
|
|
|
|
->where([ |
|
|
|
|
['user_id', $id], |
|
|
|
|
['is_customer', true] |
|
|
|
|
])->get(); |
|
|
|
|
if ($result) { |
|
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200); |
|
|
|
|
} else { |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Get User Project Not Found!', 'code' => 404], 404); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function search(Request $request) |
|
|
|
|
{ |
|
|
|
|
$payload = $request->all(); |
|
|
|
@ -213,7 +228,7 @@ class ProjectController extends Controller
|
|
|
|
|
$dataGet = $builder->get(); |
|
|
|
|
$totalRecord = $countBuilder->count(); |
|
|
|
|
|
|
|
|
|
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
|
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function list() |
|
|
|
@ -221,17 +236,17 @@ class ProjectController extends Controller
|
|
|
|
|
$data = Project::orderBy('id', 'desc')->get(); |
|
|
|
|
$countData = $data->count(); |
|
|
|
|
|
|
|
|
|
if(!$data) |
|
|
|
|
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404); |
|
|
|
|
if (!$data) |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404); |
|
|
|
|
|
|
|
|
|
$scheduleWarningThreshold = 10; |
|
|
|
|
$scheduleDangerThreshold = 5; |
|
|
|
|
foreach($data as $d){ |
|
|
|
|
foreach ($data as $d) { |
|
|
|
|
$progress = $costVariance = $actualCost = 0; |
|
|
|
|
$lastActivity = null; |
|
|
|
|
$scheduleHealth = "on-track"; |
|
|
|
|
$rootActivity = Activity::whereNull('parent_id')->where('proyek_id', $d->id)->orderBy('version_gantt_id', 'desc')->first(); |
|
|
|
|
if($rootActivity){ |
|
|
|
|
if ($rootActivity) { |
|
|
|
|
$costVariance = (int)$d->rencana_biaya - (int)$rootActivity->biaya_actual; |
|
|
|
|
$actualCost = $rootActivity->biaya_actual ?? 0; |
|
|
|
|
$progress = $rootActivity->persentase_progress ?? 0; |
|
|
|
@ -242,7 +257,7 @@ class ProjectController extends Controller
|
|
|
|
|
$daysRemaining = $date2->diff($date1); |
|
|
|
|
$daysRemaining = $daysRemaining->d; |
|
|
|
|
|
|
|
|
|
if($daysRemaining <= $scheduleDangerThreshold) { |
|
|
|
|
if ($daysRemaining <= $scheduleDangerThreshold) { |
|
|
|
|
$scheduleHealth = "danger"; |
|
|
|
|
} elseif ($daysRemaining <= $scheduleWarningThreshold) { |
|
|
|
|
$scheduleHealth = "warning"; |
|
|
|
@ -264,7 +279,7 @@ class ProjectController extends Controller
|
|
|
|
|
->where('m_proyek.id', $d->id) |
|
|
|
|
->pluck('m_users.name') |
|
|
|
|
->first(); |
|
|
|
|
if($d->area_kerja != ''){ |
|
|
|
|
if ($d->area_kerja != '') { |
|
|
|
|
$d->geolocation = $this->httpReq($d->area_kerja); |
|
|
|
|
$d->geolocation = []; |
|
|
|
|
} else { |
|
|
|
@ -299,54 +314,61 @@ class ProjectController extends Controller
|
|
|
|
|
|
|
|
|
|
return response()->json( |
|
|
|
|
[ |
|
|
|
|
'status'=>'success', |
|
|
|
|
'code'=>200, |
|
|
|
|
'data'=>$data, |
|
|
|
|
'totalRecord'=>$countData, |
|
|
|
|
'status' => 'success', |
|
|
|
|
'code' => 200, |
|
|
|
|
'data' => $data, |
|
|
|
|
'totalRecord' => $countData, |
|
|
|
|
'totalPlannedCost' => $totalPlannedCost, |
|
|
|
|
'totalActualCost' => $totalActualCost, |
|
|
|
|
'totalRevenue' => $totalPlannedCost - $totalActualCost, |
|
|
|
|
'manpowers' => $manpowers, |
|
|
|
|
'projectsOnDanger'=> $projectsOnDanger, |
|
|
|
|
'projectsOnDanger' => $projectsOnDanger, |
|
|
|
|
'projectPhases' => $projectPhases, |
|
|
|
|
'projectsByPhase' => $projectsByPhase, |
|
|
|
|
'projectTypes' => $projectTypes, |
|
|
|
|
'projectsByType' => $projectsByType, |
|
|
|
|
], 200); |
|
|
|
|
], |
|
|
|
|
200 |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getListProjectTask($id){ |
|
|
|
|
$data = UserToActivity::select("assign_hr_to_activity.user_id as user_id","m_proyek.*") |
|
|
|
|
public function getListProjectTask($id) |
|
|
|
|
{ |
|
|
|
|
$data = UserToActivity::select("assign_hr_to_activity.user_id as user_id", "m_proyek.*") |
|
|
|
|
->where("assign_hr_to_activity.user_id", $id) |
|
|
|
|
->join('m_proyek', 'assign_hr_to_activity.proyek_id', '=', 'm_proyek.id') |
|
|
|
|
->groupBy("m_proyek.proyek_id") |
|
|
|
|
->get(); |
|
|
|
|
|
|
|
|
|
if(!$data) |
|
|
|
|
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404); |
|
|
|
|
if (!$data) |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404); |
|
|
|
|
|
|
|
|
|
return response()->json(['status'=>'success','code'=>200,'data'=>$data], 200); |
|
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getSCurve(Request $request){ |
|
|
|
|
public function getSCurve(Request $request) |
|
|
|
|
{ |
|
|
|
|
$data = MasterFunctionsHelper::getSCurve($request); |
|
|
|
|
return response()->json(['status'=>'success','code'=>200, 'data' => $data], 200); |
|
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function calculateSCurve(Request $request){ |
|
|
|
|
public function calculateSCurve(Request $request) |
|
|
|
|
{ |
|
|
|
|
$sCurve = Project::select('scurve')->where('id', $request->project_id)->first(); |
|
|
|
|
return response()->json(['status'=>'success','code'=>200, 'data' => json_decode($sCurve->scurve)], 200); |
|
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => json_decode($sCurve->scurve)], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function sCurveCommand(Request $request){ |
|
|
|
|
public function sCurveCommand(Request $request) |
|
|
|
|
{ |
|
|
|
|
Artisan::call('calculate:scurve', [ |
|
|
|
|
'project_id' => $request->project_id |
|
|
|
|
]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getLinearSCurve(Request $request){ |
|
|
|
|
public function getLinearSCurve(Request $request) |
|
|
|
|
{ |
|
|
|
|
$data = MasterFunctionsHelper::getLinearSCurve($request); |
|
|
|
|
return response()->json(['status'=>'success','code'=>200, 'data' => $data], 200); |
|
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function synchronizeReport($gantt_id) |
|
|
|
@ -354,16 +376,16 @@ class ProjectController extends Controller
|
|
|
|
|
$activities = Activity::where("version_gantt_id", $gantt_id)->get(); |
|
|
|
|
$reports = []; |
|
|
|
|
|
|
|
|
|
foreach($activities as $activity) { |
|
|
|
|
foreach ($activities as $activity) { |
|
|
|
|
$activity_id = $activity->id; |
|
|
|
|
$countReports = ReportActivityMaterial::where('activity_id', $activity_id)->count(); |
|
|
|
|
if ($countReports === 1) { |
|
|
|
|
$dataReports = ReportActivityMaterial::where('activity_id', $activity_id)->orderBy('report_date')->get(); |
|
|
|
|
foreach($dataReports as $dr) { |
|
|
|
|
foreach ($dataReports as $dr) { |
|
|
|
|
$reports[] = array( |
|
|
|
|
'activity_id'=>$activity_id, |
|
|
|
|
'min_date'=>$dr->report_date, |
|
|
|
|
'max_date'=>date_modify(date_create($dr->report_date), "1 days") |
|
|
|
|
'activity_id' => $activity_id, |
|
|
|
|
'min_date' => $dr->report_date, |
|
|
|
|
'max_date' => date_modify(date_create($dr->report_date), "1 days") |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -371,9 +393,9 @@ class ProjectController extends Controller
|
|
|
|
|
$firstReport = ReportActivityMaterial::where('activity_id', $activity_id)->orderBy('report_date')->first(); |
|
|
|
|
$lastReport = ReportActivityMaterial::where('activity_id', $activity_id)->orderByDesc('report_date')->first(); |
|
|
|
|
$reports[] = array( |
|
|
|
|
'activity_id'=>$activity_id, |
|
|
|
|
'min_date'=>$firstReport->report_date, |
|
|
|
|
'max_date'=>date_modify(date_create($lastReport->report_date), "1 days") |
|
|
|
|
'activity_id' => $activity_id, |
|
|
|
|
'min_date' => $firstReport->report_date, |
|
|
|
|
'max_date' => date_modify(date_create($lastReport->report_date), "1 days") |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
$activity->reports = $reports; |
|
|
|
@ -381,14 +403,14 @@ class ProjectController extends Controller
|
|
|
|
|
/* return response()->json(['status'=>'success','data'=> $reports,'code'=>200], 200); */ |
|
|
|
|
/* return response()->json(['status'=>'success','data'=> $activities,'code'=>200], 200); */ |
|
|
|
|
|
|
|
|
|
for ($i=0; $i < count($reports); $i++) { |
|
|
|
|
for ($i = 0; $i < count($reports); $i++) { |
|
|
|
|
$activity = Activity::find($reports[$i]['activity_id']); |
|
|
|
|
$activity->start_date = $reports[$i]['min_date']; |
|
|
|
|
$activity->end_date = $reports[$i]['max_date']; |
|
|
|
|
$activity->save(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return response()->json(['status'=>'success','message'=>'Synchronize to report success!','code'=>200], 200); |
|
|
|
|
return response()->json(['status' => 'success', 'message' => 'Synchronize to report success!', 'code' => 200], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function setBaseline($gantt_id) |
|
|
|
@ -397,15 +419,16 @@ class ProjectController extends Controller
|
|
|
|
|
|
|
|
|
|
foreach ($activities as $activity) { |
|
|
|
|
$activity->update([ |
|
|
|
|
"planned_start"=>$activity->start_date, |
|
|
|
|
"planned_end"=>$activity->end_date, |
|
|
|
|
"planned_start" => $activity->start_date, |
|
|
|
|
"planned_end" => $activity->end_date, |
|
|
|
|
]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return response()->json(['status'=>'success','message'=>'Set baseline success!','code'=> 200], 200); |
|
|
|
|
return response()->json(['status' => 'success', 'message' => 'Set baseline success!', 'code' => 200], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getInvoiceIntegration(Request $request) { |
|
|
|
|
public function getInvoiceIntegration(Request $request) |
|
|
|
|
{ |
|
|
|
|
// $search = urlencode($request->search); |
|
|
|
|
// if(empty($search)) |
|
|
|
|
// return response()->json(['status'=>'error', 'message'=>'Empty query string!'], 400); |
|
|
|
@ -414,53 +437,66 @@ class ProjectController extends Controller
|
|
|
|
|
$response = null; |
|
|
|
|
|
|
|
|
|
// return response()->json(['status'=>'success', 'data'=> $response, 'code'=>200], 200); |
|
|
|
|
return response()->json(['status'=>'success', 'data'=> '', 'code'=>200], 200); |
|
|
|
|
return response()->json(['status' => 'success', 'data' => '', 'code' => 200], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function detail($id){ |
|
|
|
|
if(empty($id) || !is_int((int)$id)) |
|
|
|
|
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
|
|
|
|
public function detail($id) |
|
|
|
|
{ |
|
|
|
|
if (empty($id) || !is_int((int)$id)) |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); |
|
|
|
|
|
|
|
|
|
$result = Project::find($id); |
|
|
|
|
|
|
|
|
|
if(!$result) |
|
|
|
|
return response()->json(['status'=>'failed','message'=> 'Data not found!','code'=> 404], 404); |
|
|
|
|
if (!$result) |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404); |
|
|
|
|
|
|
|
|
|
$gantt = MasterFunctionsHelper::getLatestGantt($id); |
|
|
|
|
$result->projectManager = User::where('id', $result->pm_id)->value('name'); |
|
|
|
|
$result->header = Activity::whereNull('parent_id')->where("proyek_id", $id)->where("version_gantt_id", $gantt['last_gantt_id'])->first(); |
|
|
|
|
return response()->json(['status'=>'success','code'=> 200,'data'=>$result, 'gantt'=>$gantt], 200); |
|
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result, 'gantt' => $gantt], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getOverdueActivities(Request $request){ |
|
|
|
|
public function getOverdueActivities(Request $request) |
|
|
|
|
{ |
|
|
|
|
$payload = $request->all(); |
|
|
|
|
if(empty($payload['id']) || !is_int((int)$payload['id'])) |
|
|
|
|
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
|
|
|
|
if (empty($payload['id']) || !is_int((int)$payload['id'])) |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); |
|
|
|
|
|
|
|
|
|
$result = Project::find($payload['id']); |
|
|
|
|
|
|
|
|
|
if(!$result) |
|
|
|
|
return response()->json(['status'=>'failed','message'=> 'Project not found!','code'=> 404], 404); |
|
|
|
|
if (!$result) |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Project not found!', 'code' => 404], 404); |
|
|
|
|
//TODO possible overdue bug |
|
|
|
|
if(isset($payload['till_date'])) |
|
|
|
|
$overdueActivities = Activity::where('proyek_id', $payload['id'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->whereDate('end_date','<=',$payload['till_date'])->orderBy('end_date', 'asc')->get(); |
|
|
|
|
if (isset($payload['till_date'])) |
|
|
|
|
$overdueActivities = Activity::where('proyek_id', $payload['id'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->whereDate('end_date', '<=', $payload['till_date'])->orderBy('end_date', 'asc')->get(); |
|
|
|
|
else |
|
|
|
|
$overdueActivities = Activity::where('proyek_id', $payload['id'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->orderBy('end_date', 'asc')->get(); |
|
|
|
|
|
|
|
|
|
$result->overdueActivities = $overdueActivities; |
|
|
|
|
|
|
|
|
|
return response()->json(['status'=>'success','code'=> 200,'data'=>$result], 200); |
|
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getReportDistribution(Request $request){ |
|
|
|
|
public function getReportDistribution(Request $request) |
|
|
|
|
{ |
|
|
|
|
$payload = $request->all(); |
|
|
|
|
|
|
|
|
|
if(empty($payload['project_id']) || !is_int((int)$payload['project_id'])) |
|
|
|
|
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
|
|
|
|
if (empty($payload['project_id']) || !is_int((int)$payload['project_id'])) |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); |
|
|
|
|
|
|
|
|
|
$reports = DB::table('assign_material_to_activity as ama') |
|
|
|
|
->select('u.name', 'a.name as activity_name', 'ama.qty_planning', 'ram.qty as qty_real','rm.description as material_name', 'rm.uom as material_unit', |
|
|
|
|
'ram.lat', 'ram.lon', 'ram.description as report_notes', 'ram.report_date') |
|
|
|
|
->select( |
|
|
|
|
'u.name', |
|
|
|
|
'a.name as activity_name', |
|
|
|
|
'ama.qty_planning', |
|
|
|
|
'ram.qty as qty_real', |
|
|
|
|
'rm.description as material_name', |
|
|
|
|
'rm.uom as material_unit', |
|
|
|
|
'ram.lat', |
|
|
|
|
'ram.lon', |
|
|
|
|
'ram.description as report_notes', |
|
|
|
|
'ram.report_date' |
|
|
|
|
) |
|
|
|
|
->join('report_activity_material as ram', 'ram.assign_material_id', '=', 'ama.id') |
|
|
|
|
->join('m_req_material as rm', 'rm.id', '=', 'ama.material_id') |
|
|
|
|
->join('m_activity as a', 'a.id', '=', 'ama.activity_id') |
|
|
|
@ -469,33 +505,44 @@ class ProjectController extends Controller
|
|
|
|
|
->whereNotNull('ram.lat') |
|
|
|
|
->whereBetween('ram.report_date', [$payload['start_date'], $payload['end_date']]); |
|
|
|
|
|
|
|
|
|
return response()->json(['status'=>'success', 'code'=> 200, 'data'=> $reports], 200); |
|
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => $reports], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getManpower($proyek_id){ |
|
|
|
|
public function getManpower($proyek_id) |
|
|
|
|
{ |
|
|
|
|
$manCount = UserToProyek::where('proyek_id', $proyek_id)->count(); |
|
|
|
|
return response()->json(['totalRecord'=>$manCount]); |
|
|
|
|
return response()->json(['totalRecord' => $manCount]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getAssignedHR($gantt_id){ |
|
|
|
|
public function getAssignedHR($gantt_id) |
|
|
|
|
{ |
|
|
|
|
$results = UserToActivity::select('assign_hr_to_activity.proyek_id', 'assign_hr_to_activity.user_id', 'm_activity.id', 'm_activity.name', 'm_activity.start_date', 'm_activity.end_date') |
|
|
|
|
->join('m_activity', 'm_activity.id', '=', 'assign_hr_to_activity.activity_id') |
|
|
|
|
->where('assign_hr_to_activity.version_gantt_id', $gantt_id) |
|
|
|
|
->get(); |
|
|
|
|
return response()->json(['data'=>$results]); |
|
|
|
|
return response()->json(['data' => $results]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function dashboard($id) |
|
|
|
|
{ |
|
|
|
|
$data = DB::table('m_proyek as mp') |
|
|
|
|
->select('mp.kode_sortname', 'mp.nama as name_project', 'mp.mulai_proyek as start', 'mp.akhir_proyek as finish', |
|
|
|
|
'mp.rencana_biaya', 'mp.company', 'mp.currency_symbol', 'mu.name as pm', 'mp.budget_health') |
|
|
|
|
->select( |
|
|
|
|
'mp.kode_sortname', |
|
|
|
|
'mp.nama as name_project', |
|
|
|
|
'mp.mulai_proyek as start', |
|
|
|
|
'mp.akhir_proyek as finish', |
|
|
|
|
'mp.rencana_biaya', |
|
|
|
|
'mp.company', |
|
|
|
|
'mp.currency_symbol', |
|
|
|
|
'mu.name as pm', |
|
|
|
|
'mp.budget_health' |
|
|
|
|
) |
|
|
|
|
->join('m_users as mu', 'mu.id', '=', 'mp.pm_id') |
|
|
|
|
->where('mp.id', $id) |
|
|
|
|
->first(); |
|
|
|
|
|
|
|
|
|
if(!$data) |
|
|
|
|
return response()->json(['status'=>'failed','message'=>'Data tidak ditemukan!','code'=> 404], 404); |
|
|
|
|
if (!$data) |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Data tidak ditemukan!', 'code' => 404], 404); |
|
|
|
|
|
|
|
|
|
$manpowers = UserToProyek::where('proyek_id', $id)->count(); |
|
|
|
|
$rootActivity = Activity::whereNull('parent_id')->where('proyek_id', $id)->orderBy('version_gantt_id', 'desc')->first(); |
|
|
|
@ -504,8 +551,13 @@ class ProjectController extends Controller
|
|
|
|
|
$progress = @$rootActivity->persentase_progress ?? 0; |
|
|
|
|
|
|
|
|
|
$commentActivity = DB::table('m_comment_activity as mca') |
|
|
|
|
->select('mca.activity_id', 'mca.comment as comment', 'mca.created_by as comment_by', 'mca.created_at as comment_created', |
|
|
|
|
'ma.name as activity') |
|
|
|
|
->select( |
|
|
|
|
'mca.activity_id', |
|
|
|
|
'mca.comment as comment', |
|
|
|
|
'mca.created_by as comment_by', |
|
|
|
|
'mca.created_at as comment_created', |
|
|
|
|
'ma.name as activity' |
|
|
|
|
) |
|
|
|
|
->join('m_activity as ma', 'ma.id', '=', 'mca.activity_id') |
|
|
|
|
->where('ma.proyek_id', $id) |
|
|
|
|
->orderBy('comment_by') |
|
|
|
@ -517,10 +569,11 @@ class ProjectController extends Controller
|
|
|
|
|
$data->comment = $commentActivity; |
|
|
|
|
$data->man_power = $manpowers; |
|
|
|
|
|
|
|
|
|
return response()->json(['status'=>'success','code'=>200,'data'=> $data], 200); |
|
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private function httpReq($search){ |
|
|
|
|
private function httpReq($search) |
|
|
|
|
{ |
|
|
|
|
$ch = curl_init(); |
|
|
|
|
curl_setopt($ch, CURLOPT_URL, str_replace("ADDR", $search, API_GEOLOCATION)); |
|
|
|
|
|
|
|
|
@ -536,6 +589,4 @@ class ProjectController extends Controller
|
|
|
|
|
|
|
|
|
|
return json_decode($output); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|