Browse Source

Merge pull request 'Dev-Farhan' (#34) from Dev-Farhan into staging

Reviewed-on: ibnu/generic-ospro-backend#34
pull/1/head
farhantock 11 months ago
parent
commit
49451f12b2
  1. 30
      app/Helpers/MasterFunctionsHelper.php
  2. 9
      app/Http/Controllers/ActivityController.php
  3. 32
      app/Http/Controllers/AssignMaterialController.php
  4. 1
      app/Http/Controllers/AuthController.php
  5. 3
      app/Http/Controllers/Controller.php
  6. 413
      app/Http/Controllers/DashboardBoDController.php
  7. 27
      app/Http/Controllers/DivisiController.php
  8. 108
      app/Http/Controllers/ProjectController.php
  9. 14
      app/Http/Controllers/ReportActivityMaterialController.php
  10. 33
      app/Http/Controllers/UserToActivityController.php
  11. 3
      app/Http/Controllers/UserToProyekController.php
  12. 8
      app/Http/Controllers/VersionGanttController.php
  13. 1
      app/Models/HumanResource.php
  14. 3
      app/Models/Project.php
  15. 2
      app/Models/ProjectRole.php
  16. 2
      app/Models/RoleMenu.php
  17. 2
      app/Models/Satuan.php
  18. 30
      routes/web.php

30
app/Helpers/MasterFunctionsHelper.php

@ -589,15 +589,13 @@ class MasterFunctionsHelper
// if (new \DateTime($loopDay) < $today) { // if (new \DateTime($loopDay) < $today) {
// $statusCutOfDate = true; // $statusCutOfDate = true;
// } // }
if (new \DateTime($loopDay) == new \DateTime($loopDay . ' Friday')) {
$progressPlanKomulatifWeek[] += round($tmpProgressPlanWeek, 2); $progressPlanKomulatifWeek[] += round($tmpProgressPlanWeek, 2);
if (new \DateTime($loopDay . ' Friday') <= new \DateTime($today . ' Friday')) { if (new \DateTime($loopDay . ' Friday') <= new \DateTime($today . ' Friday')) {
// $tempPercentageReal[] = round($tempTtlPercentActual, 2); // $tempPercentageReal[] = round($tempTtlPercentActual, 2);
$progressActualKomulatifWeek[] += round($tmpProgressActualWeek, 2); $progressActualKomulatifWeek[] += round($tmpProgressActualWeek, 2);
}
$dateWeek[] = [$loopDay];
} }
$dateWeek[] = [$loopDay];
// $progressPlanKomulatifWeek[] += $tmpProgressPlanWeek; // $progressPlanKomulatifWeek[] += $tmpProgressPlanWeek;
foreach ($dataPlanM as $keyPlanM) { foreach ($dataPlanM as $keyPlanM) {
# hitung untuk persentase progress planning # hitung untuk persentase progress planning
@ -1471,15 +1469,13 @@ class MasterFunctionsHelper
$dataActivityPlan = []; $dataActivityPlan = [];
$dataActivityActual = []; $dataActivityActual = [];
$today = date('Y-m-d'); $today = date('Y-m-d');
if (new \DateTime($loopDay) == new \DateTime($loopDay . ' Friday')) {
$progressPlanKomulatifWeek[] += round($tmpProgressPlanWeek, 2); $progressPlanKomulatifWeek[] += round($tmpProgressPlanWeek, 2);
if (new \DateTime($loopDay . ' Friday') <= new \DateTime($today . ' Friday')) { if (new \DateTime($loopDay . ' Friday') <= new \DateTime($today . ' Friday')) {
// $tempPercentageReal[] = round($tempTtlPercentActual, 2); // $tempPercentageReal[] = round($tempTtlPercentActual, 2);
$progressActualKomulatifWeek[] += round($tmpProgressActualWeek, 2); $progressActualKomulatifWeek[] += round($tmpProgressActualWeek, 2);
}
$dateWeek[] = [$loopDay];
} }
$dateWeek[] = [$loopDay];
// $progressPlanKomulatifWeek[] += $tmpProgressPlanWeek; // $progressPlanKomulatifWeek[] += $tmpProgressPlanWeek;
// if (count($dataPlanM) > 0 && count($dataPlanM[0]) > 0) { // if (count($dataPlanM) > 0 && count($dataPlanM[0]) > 0) {
foreach ($dataPlanM as $keyPlanM) { foreach ($dataPlanM as $keyPlanM) {
@ -1740,6 +1736,9 @@ class MasterFunctionsHelper
// if($keyPlanM->duration == 0){ // if($keyPlanM->duration == 0){
// $duration = 2; // $duration = 2;
// Tanggal awal // Tanggal awal
if (count($keyPlanM) == 0) {
continue;
}
$startDate = new DateTime($keyPlanM->planned_start); $startDate = new DateTime($keyPlanM->planned_start);
// Tanggal akhir // Tanggal akhir
$endDate = new DateTime($keyPlanM->planned_end); $endDate = new DateTime($keyPlanM->planned_end);
@ -1771,6 +1770,9 @@ class MasterFunctionsHelper
// hitung progress actual // hitung progress actual
// if (count($dataActualM) > 0 && count($dataActualM[0]) > 0) { // if (count($dataActualM) > 0 && count($dataActualM[0]) > 0) {
foreach ($dataActualM as $keyActualM) { foreach ($dataActualM as $keyActualM) {
if (count($keyPlanM) == 0) {
continue;
}
# hitung untuk persentase progress actual # hitung untuk persentase progress actual
// $progressActualWeek = ((((($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) / $keyActualM->qty_plan)*100)*$keyActualM->bobot_planning)/100; // $progressActualWeek = ((((($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) / $keyActualM->qty_plan)*100)*$keyActualM->bobot_planning)/100;
// jika total report > dari planning // jika total report > dari planning

9
app/Http/Controllers/ActivityController.php

@ -691,6 +691,7 @@ class ActivityController extends Controller
'selfTable.name', 'selfTable.name',
'persentase_progress', 'persentase_progress',
'selfTable.start_date', 'selfTable.start_date',
'selfTable.id',
'selfTable.end_date', 'selfTable.end_date',
'selfTable.planned_start', 'selfTable.planned_start',
'selfTable.planned_end', 'selfTable.planned_end',
@ -700,9 +701,10 @@ class ActivityController extends Controller
'm_version_gantt.name_version', 'm_version_gantt.name_version',
DB::raw('user_names.user_name as user_name'), DB::raw('user_names.user_name as user_name'),
DB::raw('SUM(report_activity_material.qty) as qty'), DB::raw('SUM(report_activity_material.qty) as qty'),
'assign_material_to_activity.qty_planning', // DB::raw('SUM(assign_material_to_activity.qty_planning) as qty_planning'),
'assign_material_to_activity.id as join_third_id' 'assign_material_to_activity.id as join_third_id'
) )
->addSelect(DB::raw('(SELECT SUM(assign_material_to_activity.qty_planning) FROM assign_material_to_activity WHERE assign_material_to_activity.activity_id = report_activity_material.activity_id) as qty_planning'))
->join('m_version_gantt', 'm_version_gantt.id', '=', 'selfTable.version_gantt_id') ->join('m_version_gantt', 'm_version_gantt.id', '=', 'selfTable.version_gantt_id')
->leftJoin('assign_hr_to_activity', 'assign_hr_to_activity.activity_id', '=', 'selfTable.id') ->leftJoin('assign_hr_to_activity', 'assign_hr_to_activity.activity_id', '=', 'selfTable.id')
->leftJoin('report_activity_material', 'report_activity_material.activity_id', '=', 'selfTable.id') ->leftJoin('report_activity_material', 'report_activity_material.activity_id', '=', 'selfTable.id')
@ -713,13 +715,12 @@ class ActivityController extends Controller
GROUP BY activity_id) as user_names'), function ($join) { GROUP BY activity_id) as user_names'), function ($join) {
$join->on('user_names.activity_id', '=', 'selfTable.id'); $join->on('user_names.activity_id', '=', 'selfTable.id');
}) })
->where('assign_material_to_activity.id', '=', DB::raw('report_activity_material.assign_material_id'))
->groupBy('selfTable.id') ->groupBy('selfTable.id')
->groupBy('selfTable.name')
->groupBy('selfTable.persentase_progress')
->groupBy('m_version_gantt.name_version') ->groupBy('m_version_gantt.name_version')
->groupBy('assign_material_to_activity.qty_planning')
->groupBy('assign_material_to_activity.id') ->groupBy('assign_material_to_activity.id')
->groupBy('user_names.user_name') ->groupBy('user_names.user_name')
->groupBy('report_activity_material.activity_id')
->get(); ->get();
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet], 200);
} }

32
app/Http/Controllers/AssignMaterialController.php

@ -7,6 +7,7 @@ use App\Models\AssignMaterial;
use App\Models\RequestMaterial; use App\Models\RequestMaterial;
use App\Models\Activity; use App\Models\Activity;
use App\Models\ReportActivityMaterial; use App\Models\ReportActivityMaterial;
use Illuminate\Support\Facades\DB;
use Datatables; use Datatables;
class AssignMaterialController extends Controller class AssignMaterialController extends Controller
@ -140,28 +141,29 @@ class AssignMaterialController extends Controller
$id_activity = $request->query('idact'); $id_activity = $request->query('idact');
$data = $data =
AssignMaterial::select( AssignMaterial::select(
AssignMaterial::raw('SUM(qty_planning) as qty_planning'), DB::raw('(SELECT SUM(assign_material_to_activity.qty_planning) FROM assign_material_to_activity WHERE assign_material_to_activity.activity_id = ram.activity_id) as qty_planning'),
DB::raw('SUM(ram.qty) as qty_sum'),
"m.description as material_name", "m.description as material_name",
"assign_material_to_activity.activity_id", "assign_material_to_activity.activity_id",
"assign_material_to_activity.type"
// "assign_material_to_activity.material_id",
) )
->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id") ->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id")
->join("report_activity_material as ram", "ram.assign_material_id", "=", "assign_material_to_activity.id")
->groupBy("m.description") ->groupBy("m.description")
->groupBy("ram.activity_id")
->groupBy("assign_material_to_activity.activity_id") ->groupBy("assign_material_to_activity.activity_id")
->groupBy("assign_material_to_activity.type")
->where("assign_material_to_activity.activity_id", $id_activity)->get(); ->where("assign_material_to_activity.activity_id", $id_activity)->get();
return Datatables::of($data) return Datatables::of($data)
->addIndexColumn() ->addIndexColumn()
->addColumn('qty_sum', function($row){ // ->addColumn('qty_planning', function($row){
$val_qty_act = AssignMaterial::select(ReportActivityMaterial::raw('SUM(ram.qty) as qty_sum'),"m.description as material_name1") // $val_qty_act = AssignMaterial::select(ReportActivityMaterial::raw('SUM(ram.qty) as qty_sum'),"m.description as material_name1","m.id")
->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id") // ->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id")
->join("report_activity_material as ram", "ram.assign_material_id", "=", "assign_material_to_activity.id") // ->join("report_activity_material as ram", "ram.assign_material_id", "=", "assign_material_to_activity.id")
->groupBy("m.description") // ->groupBy("m.description")
->where("m.description", strval($row->material_name)) // ->groupBy("m.id")
->where("ram.activity_id", $row->activity_id)->first(); // ->where("m.description", strval($row->material_name))
return $val_qty_act ? $val_qty_act->qty_sum : '-'; // ->where("ram.activity_id", $row->activity_id)->first();
}) // return $val_qty_act ? $val_qty_act->qty_sum : '-';
// })
->addColumn('status_activity', function($row){ ->addColumn('status_activity', function($row){
$val_status = AssignMaterial::select("status_activity") $val_status = AssignMaterial::select("status_activity")
->join('m_req_material as m', 'm.id', '=', 'assign_material_to_activity.material_id') ->join('m_req_material as m', 'm.id', '=', 'assign_material_to_activity.material_id')
@ -196,8 +198,8 @@ class AssignMaterialController extends Controller
->addColumn('action', function($row){ ->addColumn('action', function($row){
$dataPlan = AssignMaterial::select('assign_material_to_activity.id')->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id") $dataPlan = AssignMaterial::select('assign_material_to_activity.id')->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id")
->where('activity_id', $row->activity_id)->where('m.description', $row->material_name)->first(); ->where('activity_id', $row->activity_id)->where('m.description', $row->material_name)->first();
$actionBtn = '<a href="javascript:void(0)" data-id="'.$dataPlan->id.'" data-activity_id="'.$row->activity_id.'" data-material-name="'.$row->material_name.'" class="primary btn btn-primary btn-sm btn-lihat-plan" data-toggle="tooltip" title="Lihat Plan" data-placement="top"><i class="fa fa-align-justify"></i></a>'; $actionBtn = '<a href="javascript:void(0)" data-id="'.$dataPlan->id.'" data-activity_id="'.$row->activity_id.'" data-material-id="'.$row->material_id.'" data-material-name="'.$row->material_name.'" class="primary btn btn-primary btn-sm btn-lihat-plan" data-toggle="tooltip" title="Lihat Plan" data-placement="top"><i class="fa fa-align-justify"></i></a>';
$actionBtn .= '<a href="javascript:void(0)" data-id="'.$dataPlan->id.'" data-activity_id="'.$row->activity_id.'" data-material-name="'.$row->material_name.'" class="warning btn btn-warning btn-sm btn-lihat-actual" data-toggle="tooltip" title="Input Progress" data-placement="top"><i class="fa fa-edit" aria-hidden="true"></i></a>'; $actionBtn .= '<a href="javascript:void(0)" data-id="'.$dataPlan->id.'" data-activity_id="'.$row->activity_id.'" data-material-id="'.$row->material_id.'" data-material-name="'.$row->material_name.'" class="warning btn btn-warning btn-sm btn-lihat-actual" data-toggle="tooltip" title="Input Progress" data-placement="top"><i class="fa fa-edit" aria-hidden="true"></i></a>';
return $actionBtn; return $actionBtn;
}) })
->rawColumns(['action'])->make(true); ->rawColumns(['action'])->make(true);

1
app/Http/Controllers/AuthController.php

@ -13,6 +13,7 @@ use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Password; use Illuminate\Support\Facades\Password;
use Illuminate\Validation\ValidationException; use Illuminate\Validation\ValidationException;
class AuthController extends Controller class AuthController extends Controller
{ {
public function __construct() public function __construct()

3
app/Http/Controllers/Controller.php

@ -7,8 +7,8 @@ use Illuminate\Support\Facades\Http;
use App\Models\UserToActivity; use App\Models\UserToActivity;
use App\Models\Activity; use App\Models\Activity;
use App\Models\AssignMaterial; use App\Models\AssignMaterial;
use App\Models\User;
use App\Models\Divisi; use App\Models\Divisi;
use App\Models\User;
use Laravel\Lumen\Routing\Controller as BaseController; use Laravel\Lumen\Routing\Controller as BaseController;
use App\Models\ReportK3Detail; use App\Models\ReportK3Detail;
@ -33,7 +33,6 @@ class Controller extends BaseController
$this->currentDate = date("Y-m-d H:i:s"); $this->currentDate = date("Y-m-d H:i:s");
$this->currentName = auth()->user() ? auth()->user()->name : "system"; $this->currentName = auth()->user() ? auth()->user()->name : "system";
$this->currentId = auth()->user() ? auth()->user()->id : 0; $this->currentId = auth()->user() ? auth()->user()->id : 0;
$this->companyId = auth()->user() ? auth()->user()->company_id : 0;
$this->pathImage = config('assets.image'); $this->pathImage = config('assets.image');
$this->pathDocument = config('assets.project'); $this->pathDocument = config('assets.project');
$this->pathActivityDocument = config('assets.activity'); $this->pathActivityDocument = config('assets.activity');

413
app/Http/Controllers/DashboardBoDController.php

@ -47,41 +47,46 @@ class DashboardBoDController extends Controller
{ {
if (empty($search)) if (empty($search))
return response()->json(['status' => 'error', 'message' => 'Empty query string!'], 400); return response()->json(['status' => 'error', 'message' => 'Empty query string!'], 400);
if (empty($search))
return response()->json(['status' => 'error', 'message' => 'Empty query string!'], 400);
$url = str_replace("SEARCH", $search, config('api.adw') . '/project_cost?project_no=SEARCH');
$url = str_replace("SEARCH", $search, config('api.adw') . '/project_cost?project_no=SEARCH'); $url = str_replace("SEARCH", $search, config('api.adw') . '/project_cost?project_no=SEARCH');
$token = config('api.adw_token'); $token = config('api.adw_token');
$response = $this->curlReq($url, $token); $response = $this->curlReq($url, $token);
if (@$response->data->project_no == "") if (@$response->data->project_no == "")
return null; if (@$response->data->project_no == "")
return null;
return $response; return $response;
} }
public function getCompanyCashFlow($year = '%', $company_id, $all_project, $hierarchy) public function getCompanyCashFlow($company_id, $all_project, $hierarchy, $role_name)
{ {
$year = $this->interpolateYear($year);
$totalExpenditure = $totalInvoice = $totalPaidInvoice = 0; $totalExpenditure = $totalInvoice = $totalPaidInvoice = 0;
$totalBudgets = null; $totalBudgets = null;
if ($all_project) { $role = urldecode($role_name);
$totalBudgets = Project::where('mulai_proyek', 'like', $year) if ($role === "Super Admin") {
->where('company_id', $company_id) $totalBudgets = Project::sum(DB::raw('CAST("rencana_biaya" AS DOUBLE PRECISION)'));
} elseif (!empty($all_project)) {
$totalBudgets = Project::where('company_id', $company_id)
->sum(DB::raw('CAST("rencana_biaya" AS DOUBLE PRECISION)')); ->sum(DB::raw('CAST("rencana_biaya" AS DOUBLE PRECISION)'));
} else { } else {
$totalBudgets = Project::where('mulai_proyek', 'like', $year) $totalBudgets = Project::where('created_by_id', $hierarchy)
->where('created_by_id', $hierarchy)
->sum(DB::raw('CAST("rencana_biaya" AS DOUBLE PRECISION)')); ->sum(DB::raw('CAST("rencana_biaya" AS DOUBLE PRECISION)'));
} }
$projects = null; $projects = null;
if ($all_project) {
$projects = Project::where('mulai_proyek', 'like', $year) if ($role === "Super Admin") {
->where('company_id', $company_id) $projects = Project::get();
} elseif (!empty($all_project)) {
$projects = Project::where('company_id', $company_id)
->get(); ->get();
} else { } else {
$projects = Project::where('mulai_proyek', 'like', $year) $projects = Project::where('created_by_id', $hierarchy)
->where('created_by_id', $hierarchy)
->get(); ->get();
} }
@ -114,24 +119,32 @@ class DashboardBoDController extends Controller
], 200); ], 200);
} }
public function getDetailExpenditureColor($company_id) { public function getDetailExpenditureColor($role_name, $company_id)
$query = ProjectExpenditure::where('company_id',$company_id)->get(); {
$data = []; $role = urldecode($role_name);
foreach($query as $value) { $query = null;
if($value['name'] === 'Total Budget') { if ($role === 'Super Admin') {
$data['total_budget'] = $value['color']; $query = ProjectExpenditure::get();
} } else {
if($value['name'] === 'Expenditure') { $query = ProjectExpenditure::where('company_id', $company_id)->get();
$data['total_expenditure'] = $value['color']; }
}
if($value['name'] === 'Invoice') { $data = [];
$data['total_invoice'] = $value['color']; foreach ($query as $value) {
} if ($value['name'] === 'Total Budget') {
if($value['name'] === 'Cash In') { $data['total_budget'] = $value['color'];
$data['total_paid_invoice'] = $value['color']; }
} if ($value['name'] === 'Expenditure') {
} $data['total_expenditure'] = $value['color'];
return response()->json([ }
if ($value['name'] === 'Invoice') {
$data['total_invoice'] = $value['color'];
}
if ($value['name'] === 'Cash In') {
$data['total_paid_invoice'] = $value['color'];
}
}
return response()->json([
'data' => [ 'data' => [
'total_budget' => $data['total_budget'] ?? '', 'total_budget' => $data['total_budget'] ?? '',
'total_expenditure' => $data['total_expenditure'] ?? '', 'total_expenditure' => $data['total_expenditure'] ?? '',
@ -139,85 +152,109 @@ class DashboardBoDController extends Controller
'total_paid_invoice' => $data['total_paid_invoice'] ?? '', 'total_paid_invoice' => $data['total_paid_invoice'] ?? '',
] ]
], 200); ], 200);
} }
public function getDetailFinancialHealthColor($company_id) { public function getDetailFinancialHealthColor($role_name, $company_id)
$query = ProjectFinancialHealth::where('company_id',$company_id)->get(); {
$data = []; $role = urldecode($role_name);
foreach($query as $value) { $query = null;
if($value['name'] === 'Cost Overrun') { if ($role === 'Super Admin') {
$data['overrun'] = $value['color']; $query = ProjectFinancialHealth::get();
} } else {
if($value['name'] === 'Early Warning') { $query = ProjectFinancialHealth::where('company_id', $company_id)->get();
$data['warning'] = $value['color']; }
}
if($value['name'] === 'On Budget') {
$data['on-budget'] = $value['color']; $data = [];
} foreach ($query as $value) {
} if ($value['name'] === 'Cost Overrun') {
return response()->json([ $data['overrun'] = $value['color'];
}
if ($value['name'] === 'Early Warning') {
$data['warning'] = $value['color'];
}
if ($value['name'] === 'On Budget') {
$data['on-budget'] = $value['color'];
}
}
return response()->json([
'data' => [ 'data' => [
'overrun' => $data['overrun'] ?? '', 'overrun' => $data['overrun'] ?? '',
'warning' => $data['warning'] ?? '', 'warning' => $data['warning'] ?? '',
'on-budget' => $data['on-budget'] ?? '', 'on-budget' => $data['on-budget'] ?? '',
] ]
], 200); ], 200);
} }
public function getDetailScheduleHealthColor($company_id) { public function getDetailScheduleHealthColor($role_name, $company_id)
$query = ProjectScheduleHealth::where('company_id',$company_id)->get(); {
$data = []; $role = urldecode($role_name);
foreach($query as $value) { $query = null;
if($value['name'] === 'Behind Schedule') { if ($role === 'Super Admin') {
$data['behind-schedule'] = $value['color']; $query = ProjectScheduleHealth::get();
} } else {
if($value['name'] === 'Early Warning') { $query = ProjectScheduleHealth::where('company_id', $company_id)->get();
$data['warning'] = $value['color']; }
}
if($value['name'] === 'On Schedule') { $data = [];
$data['on-schedule'] = $value['color']; foreach ($query as $value) {
} if ($value['name'] === 'Behind Schedule') {
} $data['behind-schedule'] = $value['color'];
return response()->json([ }
if ($value['name'] === 'Early Warning') {
$data['warning'] = $value['color'];
}
if ($value['name'] === 'On Schedule') {
$data['on-schedule'] = $value['color'];
}
}
return response()->json([
'data' => [ 'data' => [
'behind-schedule' => $data['behind-schedule'] ?? '', 'behind-schedule' => $data['behind-schedule'] ?? '',
'warning' => $data['warning'] ?? '', 'warning' => $data['warning'] ?? '',
'on-schedule' => $data['on-schedule'] ?? '', 'on-schedule' => $data['on-schedule'] ?? '',
] ]
], 200); ], 200);
} }
public function getDetailInvoiceColor($company_id) { public function getDetailInvoiceColor($role_name, $company_id)
$query = ProjectInvoice::where('company_id',$company_id)->get(); {
$data = []; $role = urldecode($role_name);
foreach($query as $value) { $query = null;
if($value['name'] === 'Invoiced') { if ($role === 'Super Admin') {
$data['invoiced'] = $value['color']; $query = ProjectInvoice::get();
} } else {
if($value['name'] === 'Cash In') { $query = ProjectInvoice::where('company_id', $company_id)->get();
$data['paid'] = $value['color']; }
} $data = [];
} foreach ($query as $value) {
return response()->json([ if ($value['name'] === 'Invoiced') {
$data['invoiced'] = $value['color'];
}
if ($value['name'] === 'Cash In') {
$data['paid'] = $value['color'];
}
}
return response()->json([
'data' => [ 'data' => [
'invoiced' => $data['invoiced'] ?? '', 'invoiced' => $data['invoiced'] ?? '',
'paid' => $data['paid'] ?? '' 'paid' => $data['paid'] ?? ''
] ]
], 200); ], 200);
} }
// integrasi // integrasi
public function getInvoiceOutstanding($year = '%', $company_id, $all_project, $hierarchy) public function getInvoiceOutstanding($role_name, $company_id, $all_project, $hierarchy)
{ {
$year = $this->interpolateYear($year); $role = urldecode($role_name);
$projects = null; $projects = null;
if ($all_project) { if ($role === 'Super Admin') {
$projects = Project::where('mulai_proyek', 'like', $year) $projects = Project::get();
->where('company_id', $company_id) } elseif (!empty($all_project)) {
$projects = Project::where('company_id', $company_id)
->get(); ->get();
} else { } else {
$projects = Project::where('mulai_proyek', 'like', $year) $projects = Project::where('created_by_id', $hierarchy)
->where('created_by_id', $hierarchy)
->get(); ->get();
} }
@ -241,9 +278,9 @@ class DashboardBoDController extends Controller
], 200); ], 200);
} }
public function getTotalProjectPerScheduleHealth($year = '%', $company_id, $all_project, $hierarchy) public function getTotalProjectPerScheduleHealth($role_name, $company_id, $all_project, $hierarchy)
{ {
$year = $this->interpolateYear($year); $role = urldecode($role_name);
$return = [ $return = [
'behind-schedule' => 0, 'behind-schedule' => 0,
@ -252,13 +289,13 @@ class DashboardBoDController extends Controller
]; ];
$projects = null; $projects = null;
if ($all_project) { if ($role === 'Super Admin') {
$projects = Project::where('mulai_proyek', 'like', $year) $projects = Project::get();
->where('company_id', $company_id) } elseif ($all_project) {
$projects = Project::where('company_id', $company_id)
->get(); ->get();
} else { } else {
$projects = Project::where('mulai_proyek', 'like', $year) $projects = Project::where('created_by_id', $hierarchy)
->where('created_by_id', $hierarchy)
->get(); ->get();
} }
@ -276,7 +313,7 @@ class DashboardBoDController extends Controller
} }
$selisihProgress = $planningProgress - $actualProgress; $selisihProgress = $planningProgress - $actualProgress;
try { try {
if ($selisihProgress > 0 && $selisihProgress <= 5) { if ($selisihProgress > 0 && $selisihProgress <= 20) {
$return['warning'] += 1; $return['warning'] += 1;
$projects[$index]->status = 'warning'; $projects[$index]->status = 'warning';
} elseif ($selisihProgress == 0) { } elseif ($selisihProgress == 0) {
@ -294,20 +331,24 @@ class DashboardBoDController extends Controller
return response()->json(['data' => $return, 'q' => $projects], 200); return response()->json(['data' => $return, 'q' => $projects], 200);
} }
public function getTotalProjectScheduleHealthPerDivision($year = '%', $company_id) public function getTotalProjectScheduleHealthPerDivision($role_name, $company_id)
{ {
$year = $this->interpolateYear($year); $role = urldecode($role_name);
$divisions = Divisi::whereNull('parent') $divisions = null;
->where('company_id', $company_id) if ($role === 'Super Admin') {
->whereNull('parent') $divisions = Divisi::whereNull('parent')
->get(); ->get();
} else {
$divisions = Divisi::whereNull('parent')
->where('company_id', $company_id)
->get();
}
foreach ($divisions as $index => $division) { foreach ($divisions as $index => $division) {
$scheduleData = new Collection(); $scheduleData = new Collection();
$behindSchedule = $warning = $onSchedule = 0; $behindSchedule = $warning = $onSchedule = 0;
$projects = Project::where('mulai_proyek', 'like', $year)->where('divisi_id', $division->id)->get(); $projects = Project::where('divisi_id', $division->id)->get();
foreach ($projects as $project) { foreach ($projects as $project) {
$project->scurve = MasterFunctionsHelper::getSCurve($project->id); $project->scurve = MasterFunctionsHelper::getSCurve($project->id);
$selisihProgress = 0; $selisihProgress = 0;
@ -342,9 +383,9 @@ class DashboardBoDController extends Controller
], 200); ], 200);
} }
public function getTotalProjectPerBudgetHealth($year = '%', $company_id, $all_project, $hierarchy) public function getTotalProjectPerBudgetHealth($role_name, $company_id, $all_project, $hierarchy)
{ {
$year = $this->interpolateYear($year); $role = urldecode($role_name);
$response = [ $response = [
'data' => [ 'data' => [
'overrun' => 0, 'overrun' => 0,
@ -353,81 +394,84 @@ class DashboardBoDController extends Controller
] ]
]; ];
if ($all_project) { if ($role === 'Super Admin') {
$response['data']['overrun'] = Project::where('mulai_proyek', 'like', $year) $response['data']['overrun'] = Project::where('budget_health', 'overrun')
->where('budget_health', 'overrun')
->where('company_id', $company_id)
->count();
} else {
$response['data']['overrun'] = Project::where('mulai_proyek', 'like', $year)
->where('budget_health', 'overrun')
->where('created_by_id', $hierarchy)
->count(); ->count();
} } elseif ($all_project) {
if ($all_project) { $response['data']['overrun'] = Project::where('budget_health', 'overrun')
$response['data']['overrun'] = Project::where('mulai_proyek', 'like', $year)
->where('budget_health', 'overrun')
->where('company_id', $company_id) ->where('company_id', $company_id)
->count(); ->count();
} else { } else {
$response['data']['overrun'] = Project::where('mulai_proyek', 'like', $year) $response['data']['overrun'] = Project::where('budget_health', 'overrun')
->where('budget_health', 'overrun')
->where('created_by_id', $hierarchy) ->where('created_by_id', $hierarchy)
->count(); ->count();
} }
if ($all_project) {
$response['data']['warning'] = Project::where('mulai_proyek', 'like', $year) if ($role === 'Super Admin') {
->where('budget_health', 'warning') $response['data']['overrun'] = Project::where('budget_health', 'warning')
->count();
} elseif ($all_project) {
$response['data']['warning'] = Project::where('budget_health', 'warning')
->where('company_id', $company_id) ->where('company_id', $company_id)
->count(); ->count();
} else { } else {
$response['data']['warning'] = Project::where('mulai_proyek', 'like', $year) $response['data']['warning'] = Project::where('budget_health', 'warning')
->where('budget_health', 'warning')
->where('created_by_id', $hierarchy) ->where('created_by_id', $hierarchy)
->count(); ->count();
} }
if ($all_project) { if ($role === 'Super Admin') {
$response['data']['on-budget'] = Project::where('mulai_proyek', 'like', $year) Log::info('on-budget');
->where('budget_health', 'on-budget') $response['data']['on-budget'] = Project::where('budget_health', 'on-budget')
->count();
} elseif ($all_project) {
$response['data']['on-budget'] = Project::where('budget_health', 'on-budget')
->where('company_id', $company_id) ->where('company_id', $company_id)
->count(); ->count();
} else { } else {
$response['data']['on-budget'] = Project::where('mulai_proyek', 'like', $year) $response['data']['on-budget'] = Project::where('budget_health', 'on-budget')
->where('budget_health', 'on-budget')
->where('created_by_id', $hierarchy) ->where('created_by_id', $hierarchy)
->count(); ->count();
} }
return response()->json($response, 200); return response()->json($response, 200);
} }
private function countTotalProjectByBudgetHealthInDivision($divisi, $year, $health) private function countTotalProjectByBudgetHealthInDivision($divisi, $health)
{ {
return Project::where('divisi_id', $divisi) return Project::where('divisi_id', $divisi)
->where('mulai_proyek', 'like', $year)
/* ->orWhere('akhir_proyek', 'like', $year) */ /* ->orWhere('akhir_proyek', 'like', $year) */
->where('budget_health', $health) ->where('budget_health', $health)
->count(); ->count();
} }
public function getTotalProjectBudgetHealthPerDivision($year = '%', $company_id) public function getTotalProjectBudgetHealthPerDivision($role_name, $company_id)
{ {
$year = $this->interpolateYear($year); $role = urldecode($role_name);
$divisions = Divisi::select('id', 'name') $divisions = null;
->with('children') if ($role === 'Super Admin') {
->whereNull('parent') $divisions = Divisi::select('id', 'name')
->where('company_id', $company_id) ->with('children')
->get(); ->whereNull('parent')
->get();
} else {
$divisions = Divisi::select('id', 'name')
->with('children')
->whereNull('parent')
->where('company_id', $company_id)
->get();
}
// to do : count in more than 1 level child // to do : count in more than 1 level child
foreach ($divisions as $division) { foreach ($divisions as $division) {
$budgetData = new Collection(); $budgetData = new Collection();
$budgetData->prepend($this->countTotalProjectByBudgetHealthInDivision($division->id, $year, 'overrun'), 'overrun'); $budgetData->prepend($this->countTotalProjectByBudgetHealthInDivision($division->id, 'overrun'), 'overrun');
$budgetData->prepend($this->countTotalProjectByBudgetHealthInDivision($division->id, $year, 'warning'), 'warning'); $budgetData->prepend($this->countTotalProjectByBudgetHealthInDivision($division->id, 'warning'), 'warning');
$budgetData->prepend($this->countTotalProjectByBudgetHealthInDivision($division->id, $year, 'on-budget'), 'on-budget'); $budgetData->prepend($this->countTotalProjectByBudgetHealthInDivision($division->id, 'on-budget'), 'on-budget');
foreach ($division->children as $d) { foreach ($division->children as $d) {
$budgetData['overrun'] += $this->countTotalProjectByBudgetHealthInDivision($d->id, $year, 'overrun'); $budgetData['overrun'] += $this->countTotalProjectByBudgetHealthInDivision($d->id, 'overrun');
$budgetData['warning'] += $this->countTotalProjectByBudgetHealthInDivision($d->id, $year, 'warning'); $budgetData['warning'] += $this->countTotalProjectByBudgetHealthInDivision($d->id, 'warning');
$budgetData['on-budget'] += $this->countTotalProjectByBudgetHealthInDivision($d->id, $year, 'on-budget'); $budgetData['on-budget'] += $this->countTotalProjectByBudgetHealthInDivision($d->id, 'on-budget');
} }
unset($division->children); unset($division->children);
$division->budgetData = $budgetData; $division->budgetData = $budgetData;
@ -441,20 +485,28 @@ class DashboardBoDController extends Controller
], 200); ], 200);
} }
public function getTotalProjectPerPhase($year = '%', $company_id, $all_project, $hierarchy) public function getTotalProjectPerPhase($role_name, $company_id, $all_project, $hierarchy)
{ {
$year = $this->interpolateYear($year); $role = urldecode($role_name);
$projectPhases = ProjectPhase::where('company_id', $company_id)->orderBy('order')->get(); $projectPhases = null;
if ($role === 'Super Admin') {
$projectPhases = ProjectPhase::orderBy('order')->get();
} else {
$projectPhases = ProjectPhase::where('company_id', $company_id)->orderBy('order')->get();
}
foreach ($projectPhases as $phase) { foreach ($projectPhases as $phase) {
if ($all_project) { if ($role === 'Super Admin') {
$phase->totalProject = Project::where('phase_id', $phase->id)
->count();
} elseif ($all_project) {
$phase->totalProject = Project::where('phase_id', $phase->id) $phase->totalProject = Project::where('phase_id', $phase->id)
->where('mulai_proyek', 'like', $year)
->where('company_id', $company_id) ->where('company_id', $company_id)
->count(); ->count();
} else { } else {
$phase->totalProject = Project::where('phase_id', $phase->id) $phase->totalProject = Project::where('phase_id', $phase->id)
->where('mulai_proyek', 'like', $year)
->where('created_by_id', $hierarchy) ->where('created_by_id', $hierarchy)
->count(); ->count();
} }
@ -466,29 +518,37 @@ class DashboardBoDController extends Controller
], 200); ], 200);
} }
private function countTotalProjectInDivision($id, $year) private function countTotalProjectInDivision($id)
{ {
return Project::where('divisi_id', $id) return Project::where('divisi_id', $id)
->where('mulai_proyek', 'like', $year)
->count(); ->count();
} }
public function getTotalProjectPerDivision($year = '%', $company_id) public function getTotalProjectPerDivision($role_name, $company_id)
{ {
$year = $this->interpolateYear($year); $role = urldecode($role_name);
$divisions = null;
if ($role === 'Super Admin') {
$divisions = Divisi::select('id', 'name', 'parent', 'color')
->with('children')
->whereNull('parent')
->get();
} else {
$divisions = Divisi::select('id', 'name', 'parent', 'color')
->with('children')
->whereNull('parent')
->where('company_id', $company_id)
->get();
}
$divisions = Divisi::select('id', 'name', 'parent', 'color')
->with('children')
->whereNull('parent')
->where('company_id', $company_id)
->get();
// to do : count in more than 1 level child // to do : count in more than 1 level child
foreach ($divisions as $v) { foreach ($divisions as $v) {
$v->total = $this->countTotalProjectInDivision($v->id, $year); $v->total = $this->countTotalProjectInDivision($v->id);
foreach ($v->children as $d) { foreach ($v->children as $d) {
$v->total += $this->countTotalProjectInDivision($d->id, $year); $v->total += $this->countTotalProjectInDivision($d->id);
} }
unset($v->children); unset($v->children);
} }
@ -498,30 +558,35 @@ class DashboardBoDController extends Controller
], 200); ], 200);
} }
private function countTotalProjectValueInDivision($id, $year) private function countTotalProjectValueInDivision($id)
{ {
return Project::select(DB::raw('SUM(CAST("rencana_biaya" AS DOUBLE PRECISION))')) return Project::select(DB::raw('SUM(CAST("rencana_biaya" AS DOUBLE PRECISION))'))
->where('mulai_proyek', 'like', $year)
/* ->orWhere('akhir_proyek', 'like', $year) */
->where('divisi_id', $id) ->where('divisi_id', $id)
->pluck('sum') ->pluck('sum')
->first(); ->first();
} }
public function getTotalProjectValuePerDivision($year = '%', $company_id) public function getTotalProjectValuePerDivision($role_name, $company_id)
{ {
$year = $this->interpolateYear($year); $role = urldecode($role_name);
if ($role === 'Super Admin') {
$divisions = Divisi::select('id', 'name', 'color')
->with('children')
->whereNull('parent')
->get();
} else {
$divisions = Divisi::select('id', 'name', 'color')
->with('children')
->whereNull('parent')
->where('company_id', $company_id)
->get();
}
$divisions = Divisi::select('id', 'name', 'color')
->with('children')
->whereNull('parent')
->where('company_id', $company_id)
->get();
foreach ($divisions as $v) { foreach ($divisions as $v) {
$v->total = $this->countTotalProjectValueInDivision($v->id, $year); $v->total = $this->countTotalProjectValueInDivision($v->id);
foreach ($v->children as $d) { foreach ($v->children as $d) {
$v->total += $this->countTotalProjectValueInDivision($d->id, $year); $v->total += $this->countTotalProjectValueInDivision($d->id);
} }
unset($v->children); unset($v->children);
} }

27
app/Http/Controllers/DivisiController.php

@ -83,13 +83,26 @@ class DivisiController extends Controller
public function search(Request $request) public function search(Request $request)
{ {
$payload = $request->all(); $parentDivisi = Divisi::whereNull('parent')->with('children')->get();
$dataBuilder = $this->setUpPayload($payload, 'm_divisi'); $divisions = [];
$builder = $dataBuilder['builder']; foreach ($parentDivisi as $objRow) {
$countBuilder = $dataBuilder['count']; $objRow->children = $this->getAllChildren($objRow);
$dataGet = $builder->get(); // $objRow->key = rand(1, 1000);
$totalRecord = $countBuilder->count(); $divisions[] = $objRow;
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200); }
$countData = count($divisions);
if ($countData == 0)
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404);
return response()->json(['status' => 'success', 'code' => 200, 'data' => $divisions, 'totalRecord' => $countData], 200);
// $payload = $request->all();
// $dataBuilder = $this->setUpPayload($payload, 'm_divisi');
// $builder = $dataBuilder['builder'];
// $countBuilder = $dataBuilder['count'];
// $dataGet = $builder->get();
// $totalRecord = $countBuilder->count();
// return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200);
//return $this->list(); //return $this->list();
// cant use builder for this case // cant use builder for this case
} }

108
app/Http/Controllers/ProjectController.php

@ -51,10 +51,11 @@ class ProjectController extends Controller
$this->validate($request, [ $this->validate($request, [
'nama' => 'required', 'nama' => 'required',
'mulai_proyek' => 'required', 'mulai_proyek' => 'required',
'mulai_proyek' => 'required',
'akhir_proyek' => 'required', 'akhir_proyek' => 'required',
'rencana_biaya' => 'required', 'rencana_biaya' => 'required',
'type_proyek_id' => 'required', 'type_proyek_id' => 'required',
'company_id' => 'required' 'company_id' => 'required'
]); ]);
$data = $request->all(); $data = $request->all();
@ -81,18 +82,54 @@ class ProjectController extends Controller
if (empty($id) || !is_int((int)$id)) if (empty($id) || !is_int((int)$id))
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
$result = Project::query() // $result = Project::query()
->from('m_proyek AS mp') // ->from('m_proyek AS mp')
->where('mp.id', $id) // ->where('mp.id', $id)
->selectRaw('value_proyek,mp.company_id,scoupe_of_work,kode_sortname,jumlah_stakeholder,nama,mulai_proyek,akhir_proyek,area_kerja,rencana_biaya,biaya_actual,company,pm_id,type_proyek_id,divisi_id,persentase_progress,keterangan,durasi_proyek,progress_by_worklog,currency_symbol,late_consequence,assumtion,currency_code,currency_name,project_objectives,considered_success_when,potential_risk,testing_environment,budget_health,phase_id,calculation_status'); // ->selectRaw('value_proyek,scoupe_of_work,kode_sortname,jumlah_stakeholder,nama,mulai_proyek,akhir_proyek,
// area_kerja,rencana_biaya,biaya_actual,company,pm_id,type_proyek_id,divisi_id,persentase_progress,keterangan,durasi_proyek,progress_by_worklog,currency_symbol,late_consequence,assumtion,currency_code,currency_name,project_objectives,considered_success_when,potential_risk,testing_environment,budget_health,phase_id,calculation_status');
if (!is_null($result->first()['divisi_id'])) {
$result->leftJoin('m_divisi', 'mp.divisi_id', '=', 'm_divisi.id')
->addSelect(DB::raw('m_divisi.name AS nama_divisi'));
}
$result = $result->first();
// if (!is_null($result->first()['divisi_id'])) {
// $result->leftJoin('m_divisi', 'mp.divisi_id', '=', 'm_divisi.id')
// ->addSelect(DB::raw('m_divisi.name AS nama_divisi'));
// }
$result = Project::select(
'value_proyek',
'scoupe_of_work',
'kode_sortname',
'jumlah_stakeholder',
'nama',
'mulai_proyek',
'akhir_proyek',
'area_kerja',
'rencana_biaya',
'biaya_actual',
'company',
'pm_id',
'type_proyek_id',
'divisi_id',
'persentase_progress',
'keterangan',
'durasi_proyek',
'progress_by_worklog',
'currency_symbol',
'late_consequence',
'assumtion',
'currency_code',
'currency_name',
'project_objectives',
'considered_success_when',
'potential_risk',
'testing_environment',
'budget_health',
'phase_id',
'calculation_status',
'md.name as divisi_name',
'nickname',
'sponsor'
)
->join('m_divisi as md', 'md.id', '=', 'm_proyek.divisi_id')
->where('m_proyek.id', $id)
->first();
if (!$result) if (!$result)
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404); return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404);
@ -511,29 +548,20 @@ class ProjectController extends Controller
return response()->json(['status' => 'success', 'data' => $response, 'code' => 200], 200); return response()->json(['status' => 'success', 'data' => $response, 'code' => 200], 200);
} }
public function getByUser($id) { public function getByUser($id)
{
$alias = "utp";
$userProyek = UserToProyek::query() $userProyek = UserToProyek::query()
->from('assign_hr_to_proyek AS ahtp') ->from('assign_hr_to_proyek AS ' . $alias)
->where([ ->where([
['is_customer', true], ['is_customer', true],
['user_id', $id] ['user_id', $id]
]) ])
->leftJoin('m_users', 'ahtp.user_id', '=', 'm_users.id') ->leftJoin('m_users', $alias . '.user_id', '=', 'm_users.id')
->leftJoin('m_proyek AS mp', 'ahtp.proyek_id', '=', 'mp.id') ->leftJoin('m_proyek', $alias . '.proyek_id', '=', 'm_proyek.id')
->leftJoin('m_type_proyek', 'mp.type_proyek_id', '=', 'm_type_proyek.id') ->leftJoin('m_type_proyek', 'm_proyek.type_proyek_id', '=', 'm_type_proyek.id')
->select( ->select('m_proyek.*', 'm_type_proyek.name AS join_second_name', 'm_users.name AS join_first_name')
'mp.id', ->get();
'mp.nama',
'mp.rencana_biaya',
'mp.type_proyek_id',
'mp.currency_symbol',
'mp.mulai_proyek',
'mp.akhir_proyek',
'm_users.name AS join_first_name',
'm_users.username AS join_first_username',
'm_type_proyek.name AS join_second_name',
'm_type_proyek.name AS join_second_description'
)->get();
$totalRecord = $userProyek->count(); $totalRecord = $userProyek->count();
return response()->json(['status' => 'success', 'code' => 200, 'data' => $userProyek, 'totalRecord' => $totalRecord], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $userProyek, 'totalRecord' => $totalRecord], 200);
@ -560,7 +588,7 @@ class ProjectController extends Controller
$actualStartExist = Activity::where('proyek_id', $id)->whereNotNull('actual_start')->exists(); $actualStartExist = Activity::where('proyek_id', $id)->whereNotNull('actual_start')->exists();
if ($result['type_proyek_id'] === 9) { if ($result['type_proyek_id'] === 9) {
// $actualEndExist = Activity::where('proyek_id', $id)->exists(); // $actualEndExist = Activity::where('proyek_id', $id)->exists();
// $query = Activity::where('proyek_id', $id); $query = Activity::where('proyek_id', $id);
$maxEndDate = Activity::where('proyek_id', $id)->select('end_date') $maxEndDate = Activity::where('proyek_id', $id)->select('end_date')
->orderBy('end_date', 'desc') ->orderBy('end_date', 'desc')
->first(); ->first();
@ -600,10 +628,12 @@ class ProjectController extends Controller
$plannedEnd = Activity::where('version_gantt_id', $ganttId) $plannedEnd = Activity::where('version_gantt_id', $ganttId)
->orderByDesc('planned_end') ->orderByDesc('planned_end')
->value('planned_end'); ->value('planned_end');
$result->header->start_date = $startDate; if (isset($result->header)) {
$result->header->end_date = $maxEndDate->end_date; $result->header->start_date = $startDate;
$result->header->planned_start = $plannedStart; $result->header->end_date = $maxEndDate->end_date;
$result->header->planned_end = $plannedEnd; $result->header->planned_start = $plannedStart;
$result->header->planned_end = $plannedEnd;
}
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result, 'gantt' => $ganttId], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $result, 'gantt' => $ganttId], 200);
} }
@ -623,15 +653,15 @@ class ProjectController extends Controller
->value('end_date'); ->value('end_date');
if (isset($payload['till_date'])) { if (isset($payload['till_date'])) {
if (isset($payload['scurve'])) { if (isset($payload['scurve'])) {
$overdueActivities = Activity::where('proyek_id', $payload['id'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->whereDate('end_date', '<=', $endDate)->orderBy('end_date', 'asc')->get(); $overdueActivities = Activity::join('m_version_gantt', 'm_activity.version_gantt_id', '=', 'm_version_gantt.id')->where('m_activity.proyek_id', $payload['id'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->whereDate('end_date', '<=', $endDate)->orderBy('end_date', 'asc')->get();
} else { } else {
$overdueActivities = Activity::where('version_gantt_id', $payload['gantt'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->whereDate('end_date', '<=', $endDate)->orderBy('end_date', 'asc')->get(); $overdueActivities = Activity::join('m_version_gantt', 'm_activity.version_gantt_id', '=', 'm_version_gantt.id')->where('version_gantt_id', $payload['gantt'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->whereDate('end_date', '<=', $endDate)->orderBy('end_date', 'asc')->get();
} }
} else { } else {
if (isset($payload['scurve'])) { if (isset($payload['scurve'])) {
$overdueActivities = Activity::where('proyek_id', $payload['id'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->orderBy('end_date', 'asc')->get(); $overdueActivities = Activity::join('m_version_gantt', 'm_activity.version_gantt_id', '=', 'm_version_gantt.id')->where('m_activity.proyek_id', $payload['id'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->orderBy('end_date', 'asc')->get();
} else { } else {
$overdueActivities = Activity::where('version_gantt_id', $payload['gantt'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->orderBy('end_date', 'asc')->get(); $overdueActivities = Activity::join('m_version_gantt', 'm_activity.version_gantt_id', '=', 'm_version_gantt.id')->where('version_gantt_id', $payload['gantt'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->orderBy('end_date', 'asc')->get();
} }
} }
$result->overdueActivities = $overdueActivities; $result->overdueActivities = $overdueActivities;

14
app/Http/Controllers/ReportActivityMaterialController.php

@ -4,6 +4,7 @@ namespace App\Http\Controllers;
use App\Helpers\MasterFunctionsHelper; use App\Helpers\MasterFunctionsHelper;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Models\ReportActivityMaterial; use App\Models\ReportActivityMaterial;
use App\Models\Activity; use App\Models\Activity;
use App\Models\AssignMaterial; use App\Models\AssignMaterial;
@ -64,10 +65,18 @@ class ReportActivityMaterialController extends Controller
} else { } else {
$sumAssignMaterial = AssignMaterial::where('activity_id', $request->activity_id)->sum('qty_planning'); $sumAssignMaterial = AssignMaterial::where('activity_id', $request->activity_id)->sum('qty_planning');
$sumReportActivityMaterial = ReportActivityMaterial::where('activity_id', $request->activity_id)->sum('qty'); $sumReportActivityMaterial = ReportActivityMaterial::where('activity_id', $request->activity_id)->sum('qty');
// if actual >= plan
if ($sumReportActivityMaterial >= $sumAssignMaterial){
$persentaseProgress = 95;
}else{
// actual < plan
$persentaseProgress = $sumReportActivityMaterial/$sumAssignMaterial*100;
}
$dataUpdate = array( $dataUpdate = array(
"actual_start" => null, "actual_start" => null,
"actual_end" => null, "actual_end" => null,
"persentase_progress" => $sumReportActivityMaterial/$sumAssignMaterial*100, "persentase_progress" => $persentaseProgress,
"updated_by" => $this->currentName "updated_by" => $this->currentName
); );
if ($sumReportActivityMaterial > 0) { if ($sumReportActivityMaterial > 0) {
@ -124,8 +133,10 @@ class ReportActivityMaterialController extends Controller
public function datatables(Request $request){ public function datatables(Request $request){
$id_activity = $request->query('idAct'); $id_activity = $request->query('idAct');
$id_am = $request->query('idAmi');
$type = $request->query('type'); $type = $request->query('type');
$materialName = $request->query('materialName'); $materialName = $request->query('materialName');
$materialId = $request->query('materialId');
if($type == 'plan'){ if($type == 'plan'){
$activity = Activity::findOrFail($id_activity); $activity = Activity::findOrFail($id_activity);
$baselineDuration = 0; $baselineDuration = 0;
@ -135,6 +146,7 @@ class ReportActivityMaterialController extends Controller
$data = AssignMaterial::select("assign_material_to_activity.*","m.description as material_name", "m.uom as uom") $data = AssignMaterial::select("assign_material_to_activity.*","m.description as material_name", "m.uom as uom")
->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id") ->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id")
->where('assign_material_to_activity.activity_id', $id_activity) ->where('assign_material_to_activity.activity_id', $id_activity)
->where('assign_material_to_activity.id', $id_am)
->where('m.description', $materialName) ->where('m.description', $materialName)
->orderBy('assign_material_to_activity.id', 'asc') ->orderBy('assign_material_to_activity.id', 'asc')
->get(); ->get();

33
app/Http/Controllers/UserToActivityController.php

@ -158,7 +158,7 @@ class UserToActivityController extends Controller
$dataBuilder = $this->setUpPayload($payload, 'assign_hr_to_activity'); $dataBuilder = $this->setUpPayload($payload, 'assign_hr_to_activity');
$builder = $dataBuilder['builder']; $builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count']; // $countBuilder = $dataBuilder['count'];
if (isset($join_column)) { if (isset($join_column)) {
$startDate = $join_column['start_date']; $startDate = $join_column['start_date'];
$endDate = $join_column['end_date']; $endDate = $join_column['end_date'];
@ -187,8 +187,35 @@ class UserToActivityController extends Controller
} }
$dataGet = $filteredData; $dataGet = $filteredData;
} }
$totalRecord = $countBuilder->count(); // $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'=>count($dataGet)], 200);
}
public function activityUser(Request $request){
$payload = $request->all();
$activity = DB::table('m_activity as ma')
->select('ahta.id', 'ma.id as activity_id', 'ma.proyek_id', 'ma.name as join_second_name', 'ma.start_date as join_second_start_date',
'ma.end_date as join_second_end_date', 'ma.persentase_progress', 'mvg.name_version', 'mp.nama as nama_proyek', 'mp.type_proyek_id')
->join('assign_hr_to_activity as ahta', 'ahta.activity_id', '=', 'ma.id')
->join('m_version_gantt as mvg', 'mvg.id', '=', 'ma.version_gantt_id')
->join('m_proyek as mp', 'mp.id', '=', 'ma.proyek_id')
->where('ahta.user_id', $payload['user_id'])
->where('ma.start_date', '<=', $payload['end_date'])
->where('ma.end_date', '>=', $payload['start_date'])
->where('ma.proyek_id', $payload['proyek_id'])
->get();
if ($payload['status'] != "") {
$filteredData = [];
foreach ($activity as $value) {
$assignMaterial = AssignMaterial::where('activity_id', $value->activity_id)->first();
if ($assignMaterial->status_activity == $payload['status']) {
$filteredData[] = $value;
}
}
$activity = $filteredData;
}
return response()->json(['status'=>'success','code'=>200,'data'=>$activity, 'totalRecord'=>count($activity)], 200);
} }
public function list() public function list()

3
app/Http/Controllers/UserToProyekController.php

@ -50,7 +50,8 @@ class UserToProyekController extends Controller
"user_id" => $item, "user_id" => $item,
"proyek_id" => $request->proyek_id, "proyek_id" => $request->proyek_id,
"created_by" => $this->currentName, "created_by" => $this->currentName,
'is_customer'=>true 'is_customer'=>true,
'project_role'=> $request->project_role
); );
$result = UserToProyek::create($dataInsert); $result = UserToProyek::create($dataInsert);

8
app/Http/Controllers/VersionGanttController.php

@ -121,11 +121,9 @@ class VersionGanttController extends Controller
->where('m_activity.parent_id', null) ->where('m_activity.parent_id', null)
->get(); ->get();
foreach ($progress as $item) { foreach ($progress as $item) {
if ($item->persentase_progress) { $item->progress = $item->persentase_progress;
$item->progress = $item->persentase_progress; $item->bobot = $item->bobot_planning;
$item->bobot = $item->bobot_planning; $item->save();
$item->save();
}
} }
} }

1
app/Models/HumanResource.php

@ -34,6 +34,5 @@ class HumanResource extends Model
'updated_by', 'updated_by',
'divisi_id', 'divisi_id',
'status_boundary', 'status_boundary',
'company_id'
]; ];
} }

3
app/Models/Project.php

@ -15,6 +15,7 @@ class Project extends Model
'kode_sortname', 'kode_sortname',
'jumlah_stakeholder', 'jumlah_stakeholder',
'nama', 'nama',
'nickname',
'mulai_proyek', 'mulai_proyek',
'akhir_proyek', 'akhir_proyek',
'area_kerja', 'area_kerja',
@ -23,8 +24,10 @@ class Project extends Model
'biaya_actual', 'biaya_actual',
'company', 'company',
'pm_id', 'pm_id',
'scoupe_of_work',
'type_proyek_id', 'type_proyek_id',
'divisi_id', 'divisi_id',
'value_proyek',
'persentase_progress', 'persentase_progress',
'keterangan', 'keterangan',
'durasi_proyek', 'durasi_proyek',

2
app/Models/ProjectRole.php

@ -12,6 +12,6 @@ class ProjectRole extends Model
const UPDATED_AT = 'updated_at'; const UPDATED_AT = 'updated_at';
protected $fillable = [ protected $fillable = [
'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id' 'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by'
]; ];
} }

2
app/Models/RoleMenu.php

@ -12,6 +12,6 @@ class RoleMenu extends Model
const UPDATED_AT = 'updated_at'; const UPDATED_AT = 'updated_at';
protected $fillable = [ protected $fillable = [
'role_id', 'menu_id', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id', "create", "read", "update", "delete" 'role_id', 'menu_id', 'created_at', 'created_by', 'updated_at', 'updated_by'
]; ];
} }

2
app/Models/Satuan.php

@ -12,6 +12,6 @@ class Satuan extends Model
const UPDATED_AT = 'updated_at'; const UPDATED_AT = 'updated_at';
protected $fillable = [ protected $fillable = [
'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id' 'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by'
]; ];
} }

30
routes/web.php

@ -23,20 +23,20 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->group(['middleware' => ['auth', 'cors']], function () use ($router) { $router->group(['middleware' => ['auth', 'cors']], function () use ($router) {
$router->get('/dashboard/get-company-cashflow/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getCompanyCashFlow'); // project expenditure $router->get('/dashboard/get-company-cashflow/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getCompanyCashFlow'); // project expenditure
$router->get('/dashboard/get-invoice-outstanding/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getInvoiceOutstanding'); // project invoice vs cash in $router->get('/dashboard/get-invoice-outstanding/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getInvoiceOutstanding'); // project invoice vs cash in
$router->get('/dashboard/get-total-project-per-schedule-health/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getTotalProjectPerScheduleHealth'); $router->get('/dashboard/get-total-project-per-schedule-health/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getTotalProjectPerScheduleHealth');
$router->get('/dashboard/get-total-project-per-budget-health/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getTotalProjectPerBudgetHealth'); $router->get('/dashboard/get-total-project-per-budget-health/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getTotalProjectPerBudgetHealth');
$router->get('/dashboard/get-total-project-schedule-health-per-division/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getTotalProjectScheduleHealthPerDivision'); $router->get('/dashboard/get-total-project-schedule-health-per-division/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getTotalProjectScheduleHealthPerDivision');
$router->get('/dashboard/get-total-project-budget-health-per-division/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getTotalProjectBudgetHealthPerDivision'); $router->get('/dashboard/get-total-project-budget-health-per-division/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getTotalProjectBudgetHealthPerDivision');
$router->get('/dashboard/get-total-project-per-phase/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getTotalProjectPerPhase'); $router->get('/dashboard/get-total-project-per-phase/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getTotalProjectPerPhase');
$router->get('/dashboard/get-total-project-per-division/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getTotalProjectPerDivision'); $router->get('/dashboard/get-total-project-per-division/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getTotalProjectPerDivision');
$router->get('/dashboard/get-total-project-value-per-division/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getTotalProjectValuePerDivision'); $router->get('/dashboard/get-total-project-value-per-division/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getTotalProjectValuePerDivision');
$router->get('/dashboard/get-detail-expenditure/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getDetailExpenditure'); $router->get('/dashboard/get-detail-expenditure/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getDetailExpenditure');
$router->get('/dashboard/get-detail-expenditure-color/{company_id}', 'DashboardBoDController@getDetailExpenditureColor'); $router->get('/dashboard/get-detail-expenditure-color/{company_id}/{role_name}', 'DashboardBoDController@getDetailExpenditureColor');
$router->get('/dashboard/get-detail-financial-health-color/{company_id}', 'DashboardBoDController@getDetailFinancialHealthColor'); $router->get('/dashboard/get-detail-financial-health-color/{company_id}/{role_name}', 'DashboardBoDController@getDetailFinancialHealthColor');
$router->get('/dashboard/get-detail-schedule-health-color/{company_id}', 'DashboardBoDController@getDetailScheduleHealthColor'); $router->get('/dashboard/get-detail-schedule-health-color/{company_id}/{role_name}', 'DashboardBoDController@getDetailScheduleHealthColor');
$router->get('/dashboard/get-detail-invoice-color/{company_id}', 'DashboardBoDController@getDetailInvoiceColor'); $router->get('/dashboard/get-detail-invoice-color/{company_id}/{role_name}', 'DashboardBoDController@getDetailInvoiceColor');
$router->post('/role/search', 'RoleController@search'); $router->post('/role/search', 'RoleController@search');
$router->post('/role/add', 'RoleController@add'); $router->post('/role/add', 'RoleController@add');
@ -78,6 +78,7 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->post('/project/get-overdue-activities', 'ProjectController@getOverdueActivities'); $router->post('/project/get-overdue-activities', 'ProjectController@getOverdueActivities');
$router->post('/project/get-integration-invoice', 'ProjectController@getInvoiceIntegration'); $router->post('/project/get-integration-invoice', 'ProjectController@getInvoiceIntegration');
$router->post('/project/get-report-distribution', 'ProjectController@getReportDistribution'); $router->post('/project/get-report-distribution', 'ProjectController@getReportDistribution');
$router->get('/project/get-integration-project-cost={name}', 'ProjectController@getProjectCostIntegration');
/* $router->get('/project/get-expenditure/{id}/{date?}', 'ProjectController@getExpenditure'); */ /* $router->get('/project/get-expenditure/{id}/{date?}', 'ProjectController@getExpenditure'); */
@ -228,6 +229,7 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->get('/user-to-activity/edit/{id}', 'UserToActivityController@edit'); $router->get('/user-to-activity/edit/{id}', 'UserToActivityController@edit');
$router->put('/user-to-activity/update/{id}', 'UserToActivityController@update'); $router->put('/user-to-activity/update/{id}', 'UserToActivityController@update');
$router->post('/user-to-activity/search', 'UserToActivityController@search'); $router->post('/user-to-activity/search', 'UserToActivityController@search');
$router->post('/user-to-activity/by-date-status', 'UserToActivityController@activityUser');
$router->post('/user-to-activity/search-analysis', 'UserToActivityController@searchAnalysis'); $router->post('/user-to-activity/search-analysis', 'UserToActivityController@searchAnalysis');
$router->post('/user-to-activity/list-filtered', 'UserToActivityController@listFiltered'); $router->post('/user-to-activity/list-filtered', 'UserToActivityController@listFiltered');
$router->delete('/user-to-activity/delete/{id}', 'UserToActivityController@delete'); $router->delete('/user-to-activity/delete/{id}', 'UserToActivityController@delete');

Loading…
Cancel
Save