|
|
|
@ -256,125 +256,75 @@ class ProjectController extends Controller
|
|
|
|
|
$d->progress = $progress; |
|
|
|
|
$d->lastGanttId = VersionGantt::where("proyek_id", $d->id)->orderBy('id', 'desc')->first()->id ?? null; |
|
|
|
|
$d->manpower = UserToProyek::where("proyek_id", $d->id)->count() ?? 0; |
|
|
|
|
$d->projectManager = DB::table('m_proyek') |
|
|
|
|
->join('m_users', 'm_users.id', '=', 'm_proyek.pm_id') |
|
|
|
|
->where('m_proyek.id', $d->id) |
|
|
|
|
->pluck('m_users.name') |
|
|
|
|
->first(); |
|
|
|
|
if($d->area_kerja != ''){ |
|
|
|
|
$d->geolocation = $this->httpReq($d->area_kerja); |
|
|
|
|
$d->projectManager = DB::table('m_proyek') |
|
|
|
|
->join('m_users', 'm_users.id', '=', 'm_proyek.pm_id') |
|
|
|
|
->where('m_proyek.id', $d->id) |
|
|
|
|
->pluck('m_users.name') |
|
|
|
|
->first(); |
|
|
|
|
if($d->area_kerja != ''){ |
|
|
|
|
$d->geolocation = $this->httpReq($d->area_kerja); |
|
|
|
|
$d->geolocation = []; |
|
|
|
|
} else { |
|
|
|
|
$d->geolocation = []; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
$d->geolocation = []; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$totalPlannedCost = $data->sum('plannedCost'); |
|
|
|
|
$totalActualCost = $data->sum('actualCost'); |
|
|
|
|
$totalPlannedCost = $data->sum('plannedCost'); |
|
|
|
|
$totalActualCost = $data->sum('actualCost'); |
|
|
|
|
$manpowers = User::count(); |
|
|
|
|
$projectsOnDanger = Project::where('budget_health', 'danger')->count(); |
|
|
|
|
$projectPhases = ProjectPhase::orderBy('order', 'asc')->pluck('name'); |
|
|
|
|
$projectTypes = ProjectType::orderBy('id', 'asc')->pluck('name'); |
|
|
|
|
try { |
|
|
|
|
$projectsByPhase = DB::table('m_proyek') |
|
|
|
|
->select('m_proyek_phase.name', 'm_proyek_phase.color', DB::raw('count(*) as total')) |
|
|
|
|
->join('m_proyek_phase', 'm_proyek_phase.id', '=', 'm_proyek.phase_id') |
|
|
|
|
->groupBy('m_proyek_phase.name', 'm_proyek_phase.color') |
|
|
|
|
->get(); |
|
|
|
|
} catch (\Exception $e) { |
|
|
|
|
return response()->json(['message' => $e->getMessage()]); |
|
|
|
|
} |
|
|
|
|
try { |
|
|
|
|
$projectsByType = DB::table('m_proyek') |
|
|
|
|
->select('m_type_proyek.name', DB::raw('count(*) as total')) |
|
|
|
|
->join('m_type_proyek', 'm_type_proyek.id', '=', 'm_proyek.type_proyek_id') |
|
|
|
|
->groupBy('m_type_proyek.name') |
|
|
|
|
->get(); |
|
|
|
|
} catch (\Exception $e) { |
|
|
|
|
return response()->json(['message' => $e->getMessage()]); |
|
|
|
|
} |
|
|
|
|
$projectPhases = ProjectPhase::orderBy('order', 'asc')->pluck('name'); |
|
|
|
|
$projectTypes = ProjectType::orderBy('id', 'asc')->pluck('name'); |
|
|
|
|
try { |
|
|
|
|
$projectsByPhase = DB::table('m_proyek') |
|
|
|
|
->select('m_proyek_phase.name', 'm_proyek_phase.color', DB::raw('count(*) as total')) |
|
|
|
|
->join('m_proyek_phase', 'm_proyek_phase.id', '=', 'm_proyek.phase_id') |
|
|
|
|
->groupBy('m_proyek_phase.name', 'm_proyek_phase.color') |
|
|
|
|
->get(); |
|
|
|
|
} catch (\Exception $e) { |
|
|
|
|
return response()->json(['message' => $e->getMessage()]); |
|
|
|
|
} |
|
|
|
|
try { |
|
|
|
|
$projectsByType = DB::table('m_proyek') |
|
|
|
|
->select('m_type_proyek.name', DB::raw('count(*) as total')) |
|
|
|
|
->join('m_type_proyek', 'm_type_proyek.id', '=', 'm_proyek.type_proyek_id') |
|
|
|
|
->groupBy('m_type_proyek.name') |
|
|
|
|
->get(); |
|
|
|
|
} catch (\Exception $e) { |
|
|
|
|
return response()->json(['message' => $e->getMessage()]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return response()->json( |
|
|
|
|
[ |
|
|
|
|
'status'=>'success', |
|
|
|
|
'code'=>200, |
|
|
|
|
'data'=>$data, |
|
|
|
|
'totalRecord'=>$countData, |
|
|
|
|
'totalPlannedCost' => $totalPlannedCost, |
|
|
|
|
'totalActualCost' => $totalActualCost, |
|
|
|
|
'totalRevenue' => $totalPlannedCost - $totalActualCost, |
|
|
|
|
'manpowers' => $manpowers, |
|
|
|
|
'projectsOnDanger'=> $projectsOnDanger, |
|
|
|
|
'projectPhases' => $projectPhases, |
|
|
|
|
'projectsByPhase' => $projectsByPhase, |
|
|
|
|
'projectTypes' => $projectTypes, |
|
|
|
|
'projectsByType' => $projectsByType, |
|
|
|
|
], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
|
|
return response()->json(['status'=>'success','code'=>200,'data'=>$data], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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') |
|
|
|
|
->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); |
|
|
|
|
|
|
|
|
|
$manpowers = UserToProyek::where('proyek_id', $id)->count(); |
|
|
|
|
$rootActivity = Activity::whereNull('parent_id')->where('proyek_id', $id)->orderBy('version_gantt_id', 'desc')->first(); |
|
|
|
|
|
|
|
|
|
$actualCost = @$rootActivity->biaya_actual ?? 0; |
|
|
|
|
$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') |
|
|
|
|
->join('m_activity as ma', 'ma.id', '=', 'mca.activity_id') |
|
|
|
|
->where('ma.proyek_id', $id) |
|
|
|
|
->orderBy('comment_by') |
|
|
|
|
->take(2) |
|
|
|
|
->get(); |
|
|
|
|
|
|
|
|
|
$data->actual_cost = $actualCost; |
|
|
|
|
$data->progress = $progress; |
|
|
|
|
$data->comment = $commentActivity; |
|
|
|
|
$data->man_power = $manpowers; |
|
|
|
|
|
|
|
|
|
return response()->json(['status'=>'success','code'=>200,'data'=> $data], 200); |
|
|
|
|
[ |
|
|
|
|
'status'=>'success', |
|
|
|
|
'code'=>200, |
|
|
|
|
'data'=>$data, |
|
|
|
|
'totalRecord'=>$countData, |
|
|
|
|
'totalPlannedCost' => $totalPlannedCost, |
|
|
|
|
'totalActualCost' => $totalActualCost, |
|
|
|
|
'totalRevenue' => $totalPlannedCost - $totalActualCost, |
|
|
|
|
'manpowers' => $manpowers, |
|
|
|
|
'projectsOnDanger'=> $projectsOnDanger, |
|
|
|
|
'projectPhases' => $projectPhases, |
|
|
|
|
'projectsByPhase' => $projectsByPhase, |
|
|
|
|
'projectTypes' => $projectTypes, |
|
|
|
|
'projectsByType' => $projectsByType, |
|
|
|
|
], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private function httpReq($search){ |
|
|
|
|
$ch = curl_init(); |
|
|
|
|
curl_setopt($ch, CURLOPT_URL, str_replace("ADDR", $search, API_GEOLOCATION)); |
|
|
|
|
$ch = curl_init(); |
|
|
|
|
curl_setopt($ch, CURLOPT_URL, str_replace("ADDR", $search, API_GEOLOCATION)); |
|
|
|
|
|
|
|
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); |
|
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
|
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); |
|
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
|
|
|
curl_setopt($ch, CURLOPT_VERBOSE, true); |
|
|
|
|
curl_setopt($ch, CURLOPT_STDERR, fopen('php://stderr', 'w')); |
|
|
|
|
|
|
|
|
|
$info = curl_getinfo($ch); |
|
|
|
|
|
|
|
|
|
$output = curl_exec($ch); |
|
|
|
|
curl_close($ch); |
|
|
|
|
$output = curl_exec($ch); |
|
|
|
|
curl_close($ch); |
|
|
|
|
|
|
|
|
|
return json_decode($output); |
|
|
|
|
return json_decode($output); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|