|
|
@ -47,6 +47,9 @@ class ProjectController extends Controller |
|
|
|
|
|
|
|
|
|
|
|
$data['created_by'] = $this->currentName; |
|
|
|
$data['created_by'] = $this->currentName; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(empty($data['phase_id'])) |
|
|
|
|
|
|
|
$data['phase_id'] = 1; |
|
|
|
|
|
|
|
|
|
|
|
$result = Project::create($data); |
|
|
|
$result = Project::create($data); |
|
|
|
|
|
|
|
|
|
|
|
if(!$result) |
|
|
|
if(!$result) |
|
|
@ -260,11 +263,12 @@ class ProjectController extends Controller |
|
|
|
->first(); |
|
|
|
->first(); |
|
|
|
if($d->area_kerja != ''){ |
|
|
|
if($d->area_kerja != ''){ |
|
|
|
$d->geolocation = $this->httpReq($d->area_kerja); |
|
|
|
$d->geolocation = $this->httpReq($d->area_kerja); |
|
|
|
|
|
|
|
$d->geolocation = []; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$d->geolocation = ''; |
|
|
|
$d->geolocation = []; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$totalPlannedCost = $data->sum('plannedCost'); |
|
|
|
$totalPlannedCost = $data->sum('plannedCost'); |
|
|
|
$totalActualCost = $data->sum('actualCost'); |
|
|
|
$totalActualCost = $data->sum('actualCost'); |
|
|
|
$manpowers = User::count(); |
|
|
|
$manpowers = User::count(); |
|
|
@ -322,18 +326,18 @@ class ProjectController extends Controller |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function dashboard($id) |
|
|
|
public function dashboard($id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$data = DB::table('m_proyek as mp') |
|
|
|
$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', |
|
|
|
->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') |
|
|
|
'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') |
|
|
|
->join('m_users as mu', 'mu.id', '=', 'mp.pm_id') |
|
|
|
->where('mp.id', $id) |
|
|
|
->where('mp.id', $id) |
|
|
|
->get(); |
|
|
|
->get(); |
|
|
|
$countData = $data->count(); |
|
|
|
$countData = $data->count(); |
|
|
|
|
|
|
|
|
|
|
|
$manpowers = UserToProyek::where('proyek_id', $id)->count(); |
|
|
|
$manpowers = UserToProyek::where('proyek_id', $id)->count(); |
|
|
|
$rootActivity = Activity::whereNull('parent_id')->where('proyek_id', $id)->orderBy('version_gantt_id', 'desc')->first(); |
|
|
|
$rootActivity = Activity::whereNull('parent_id')->where('proyek_id', $id)->orderBy('version_gantt_id', 'desc')->first(); |
|
|
|
|
|
|
|
|
|
|
|
if($rootActivity){ |
|
|
|
if($rootActivity){ |
|
|
|
$actualCost = $rootActivity->biaya_actual ?? 0; |
|
|
|
$actualCost = $rootActivity->biaya_actual ?? 0; |
|
|
|
$progress = $rootActivity->persentase_progress ?? 0; |
|
|
|
$progress = $rootActivity->persentase_progress ?? 0; |
|
|
@ -364,27 +368,30 @@ class ProjectController extends Controller |
|
|
|
$dataRes['progress'] = $progress; |
|
|
|
$dataRes['progress'] = $progress; |
|
|
|
$dataRes['comment'] = $commentActivity; |
|
|
|
$dataRes['comment'] = $commentActivity; |
|
|
|
$dataRes['man_power'] = $manpowers; |
|
|
|
$dataRes['man_power'] = $manpowers; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(!$data) |
|
|
|
if(!$data) |
|
|
|
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404); |
|
|
|
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404); |
|
|
|
|
|
|
|
|
|
|
|
return response()->json(['status'=>'success','code'=>200,'data'=>$dataRes, 'totalRecord'=>$countData], 200); |
|
|
|
return response()->json(['status'=>'success','code'=>200,'data'=>$dataRes, 'totalRecord'=>$countData], 200); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private function httpReq($search){ |
|
|
|
private function httpReq($search){ |
|
|
|
$ch = curl_init(); |
|
|
|
$ch = curl_init(); |
|
|
|
curl_setopt($ch, CURLOPT_URL, str_replace("ADDR", $search, API_GEOLOCATION)); |
|
|
|
curl_setopt($ch, CURLOPT_URL, str_replace("ADDR", $search, API_GEOLOCATION)); |
|
|
|
|
|
|
|
|
|
|
|
// SSL important |
|
|
|
|
|
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); |
|
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); |
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
|
|
//curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); |
|
|
|
curl_setopt($ch, CURLOPT_VERBOSE, true); |
|
|
|
|
|
|
|
curl_setopt($ch, CURLOPT_STDERR, fopen('php://stderr', 'w')); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$info = curl_getinfo($ch); |
|
|
|
|
|
|
|
|
|
|
|
$output = curl_exec($ch); |
|
|
|
$output = curl_exec($ch); |
|
|
|
curl_close($ch); |
|
|
|
curl_close($ch); |
|
|
|
|
|
|
|
|
|
|
|
return json_decode($output); |
|
|
|
return json_decode($output); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|