diff --git a/Dockerfile b/Dockerfile index d2c749c..4edd5c1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,25 +1,37 @@ FROM php:7.4-fpm-alpine RUN apk add --update libzip-dev curl-dev &&\ - apk del gcc g++ + apk del gcc g++ RUN apk add --no-cache \ - zlib-dev \ - icu-dev \ - libpng-dev \ - oniguruma-dev \ - libpq-dev + zlib-dev \ + icu-dev \ + libpng-dev \ + oniguruma-dev \ + libpq-dev \ + libpng-dev \ + libzip-dev \ + zip \ + vim \ + unzip \ + git \ + curl + RUN rm -rf /var/cache/apk/* RUN docker-php-ext-install \ - curl \ - mbstring \ - intl \ - pdo \ - pdo_pgsql \ - pgsql \ - tokenizer + curl \ + mbstring \ + intl \ + pdo \ + pdo_pgsql \ + pgsql \ + tokenizer + +#Install Extensions +RUN docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql + RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 578ce35..1855eca 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -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); + } + } diff --git a/docker-compose.yml b/docker-compose.yml index e5c8cd4..919ce07 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,8 +5,8 @@ services: restart: unless-stopped tty: true ports: - - '8099:80' - - '449:443' + - '8444:80' + - '8555:443' volumes: - .:/var/www/html - ./docker/nginx/conf.d/:/etc/nginx/conf.d/