|
|
|
@ -28,6 +28,8 @@ use App\Models\ReportActivity;
|
|
|
|
|
use App\Models\OfficeHours; |
|
|
|
|
use DB; |
|
|
|
|
|
|
|
|
|
const API_GEOLOCATION = "https://nominatim.oslogdev.com/search/ADDR?format=json&addressdetails=1&limit=1"; |
|
|
|
|
|
|
|
|
|
class ProjectController extends Controller |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
@ -245,18 +247,28 @@ class ProjectController extends Controller
|
|
|
|
|
$d->plannedCost = $d->rencana_biaya; |
|
|
|
|
$d->actualCost = $actualCost; |
|
|
|
|
$d->lastActivity = $lastActivity ?? "-"; |
|
|
|
|
//$d->lastActivity = $daysRemaining . " -- " . $lastActivity . "\n" . $date1 . "\n" . $date2; |
|
|
|
|
$d->costVariance = $costVariance; |
|
|
|
|
$d->costHealth = $d->budget_health; |
|
|
|
|
$d->scheduleHealth = $scheduleHealth; |
|
|
|
|
$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); |
|
|
|
|
} else { |
|
|
|
|
$d->geolocation = ''; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$totalPlannedCost = $data->sum('plannedCost'); |
|
|
|
|
$totalActualCost = $data->sum('actualCost'); |
|
|
|
|
// $manpowers = User::where('employee_type', 'employee')->count(); |
|
|
|
|
$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 { |
|
|
|
@ -288,6 +300,7 @@ class ProjectController extends Controller
|
|
|
|
|
'totalActualCost' => $totalActualCost, |
|
|
|
|
'totalRevenue' => $totalPlannedCost - $totalActualCost, |
|
|
|
|
'manpowers' => $manpowers, |
|
|
|
|
'projectsOnDanger'=> $projectsOnDanger, |
|
|
|
|
'projectPhases' => $projectPhases, |
|
|
|
|
'projectsByPhase' => $projectsByPhase, |
|
|
|
|
'projectTypes' => $projectTypes, |
|
|
|
@ -358,4 +371,20 @@ class ProjectController extends Controller
|
|
|
|
|
|
|
|
|
|
return response()->json(['status'=>'success','code'=>200,'data'=>$dataRes, 'totalRecord'=>$countData], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private function httpReq($search){ |
|
|
|
|
$ch = curl_init(); |
|
|
|
|
curl_setopt($ch, CURLOPT_URL, str_replace("ADDR", $search, API_GEOLOCATION)); |
|
|
|
|
|
|
|
|
|
// SSL important |
|
|
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); |
|
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
|
|
|
//curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); |
|
|
|
|
|
|
|
|
|
$output = curl_exec($ch); |
|
|
|
|
curl_close($ch); |
|
|
|
|
|
|
|
|
|
return json_decode($output); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|