Compare commits

...

8 Commits

  1. 90
      app/Http/Controllers/DashboardBoDController.php
  2. 31
      app/Http/Controllers/ProjectController.php
  3. 1
      routes/web.php

90
app/Http/Controllers/DashboardBoDController.php

@ -32,51 +32,48 @@ class DashboardBoDController extends Controller
{ {
$totalExpenditure = $totalInvoice = $totalPaidInvoice = 0; $totalExpenditure = $totalInvoice = $totalPaidInvoice = 0;
$totalBudgets = null; $totalBudgets = [];
$role = urldecode($role_name); $projects = [];
if (!empty($all_project) || $role === "Super Admin") { $role = urldecode($role_name);
$totalBudgets = Project::sum(DB::raw('CAST("rencana_biaya" AS DOUBLE PRECISION)'));
} else { if ($all_project) {
$totalBudgets = Project::where('created_by_id', $hierarchy) $totalBudgets = Project::select(
->sum(DB::raw('CAST("rencana_biaya" AS DOUBLE PRECISION)')); DB::raw('SUM(CAST(COALESCE(NULLIF(REPLACE(rencana_biaya, \'.\', \'\'), \'\'), \'0\') AS DOUBLE PRECISION)) AS total_rencana_biaya'),
} DB::raw('SUM(CAST(COALESCE(NULLIF(REPLACE(value_proyek, \'.\', \'\'), \'\'), \'0\') AS DOUBLE PRECISION)) AS total_value_proyek'),
$totalBudgets = Project::sum(DB::raw('CAST("rencana_biaya" AS DOUBLE PRECISION)')); DB::raw('SUM(CAST(COALESCE(NULLIF(REPLACE(income_year, \'.\', \'\'), \'\'), \'0\') AS DOUBLE PRECISION)) AS total_income_year')
$projects = null; )->first();
$projects = Project::get();
if (!empty($all_project) || $role === "Super Admin") { Log::info(['dataTotal' => $totalBudgets]);
$projects = Project::get(); } else {
} else { $totalBudgets = Project::where('created_by_id', $hierarchy)
$projects = Project::where('created_by_id', $hierarchy) ->select(
->get(); DB::raw('SUM(CAST(COALESCE(NULLIF(REPLACE(rencana_biaya, \'.\', \'\'), \'\'), \'0\') AS DOUBLE PRECISION)) AS total_rencana_biaya'),
} DB::raw('SUM(CAST(COALESCE(NULLIF(REPLACE(value_proyek, \'.\', \'\'), \'\'), \'0\') AS DOUBLE PRECISION)) AS total_value_proyek'),
DB::raw('SUM(CAST(COALESCE(NULLIF(REPLACE(income_year, \'.\', \'\'), \'\'), \'0\') AS DOUBLE PRECISION)) AS total_income_year')
foreach ($projects as $project) { )->first();
$project->expenses = 0; $projects = Project::where('created_by_id', $hierarchy)->get();
$resp = null; }
if ($project->kode_sortname != "") {
foreach ($projects as $project) {
// $resp = $this->getInvoiceIntegration($project->kode_sortname); $project->expenses = 0;
// $cost = $resp->data->total_cost ?? 0; if ($project->kode_sortname != "") {
// $cost = substr($cost, 0, strpos($cost, ".")); $cost = 0;
$cost = 0; $totalExpenditure = 0;
$totalExpenditure = 0; $totalInvoice = 0;
$totalInvoice = 0; $totalPaidInvoice = 0;
$totalPaidInvoice = 0; }
}
// $totalExpenditure += (int) $cost;
// $totalInvoice += $resp->data->total_invoice_amount ?? 0; return response()->json([
// $totalPaidInvoice += $resp->data->total_invoice_paid_amount ?? 0; 'data' => [
} 'total_budget' => (int) ($totalBudgets->total_rencana_biaya ?? 0),
} 'total_expenditure' => $totalExpenditure,
'total_invoice' => $totalInvoice,
return response()->json([ 'total_paid_invoice' => $totalPaidInvoice,
'data' => [ 'total_value_proyek' => $totalBudgets->total_value_proyek ?? 0,
'total_budget' => (int) $totalBudgets ?? 0, 'total_income_year' => $totalBudgets->total_income_year ?? 0
'total_expenditure' => $totalExpenditure, ]
'total_invoice' => $totalInvoice, ], 200);
'total_paid_invoice' => $totalPaidInvoice,
]
], 200);
} }
public function getDetailExpenditureColor($role_name) public function getDetailExpenditureColor($role_name)
@ -460,8 +457,7 @@ class DashboardBoDController extends Controller
public function getDetailExpenditure($all_project, $hierarchy, $role_name) public function getDetailExpenditure($all_project, $hierarchy, $role_name)
{ {
// $year = $this->interpolateYear($year); $projects = [];
$projects = null;
if ($all_project) { if ($all_project) {
$projects = Project::orderBy('id', 'desc') $projects = Project::orderBy('id', 'desc')
->get(); ->get();

31
app/Http/Controllers/ProjectController.php

@ -292,7 +292,6 @@ class ProjectController extends Controller
$countBuilder = $dataBuilder['count']; $countBuilder = $dataBuilder['count'];
$dataGet = $builder->get(); $dataGet = $builder->get();
$totalRecord = $countBuilder->count(); $totalRecord = $countBuilder->count();
Artisan::call('calculate:ActualProgressProject');
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200);
} }
@ -415,7 +414,22 @@ class ProjectController extends Controller
public function calculateSCurve(Request $request) public function calculateSCurve(Request $request)
{ {
$sCurve = Project::select('scurve')->where('id', $request->project_id)->first(); $sCurve = Project::select('scurve')->where('id', $request->project_id)->first();
return response()->json(['status' => 'success', 'code' => 200, 'data' => json_decode($sCurve->scurve)], 200); $dcdScurve = json_decode($sCurve['scurve'],true);
$dataScurve = $dcdScurve[0]['data'];
$today = date('Y-m-d');
$progressPlanBar = 0;
foreach($dataScurve['date'] as $index => $dateArray) {
if (isset($dateArray[0])) {
$date = $dateArray[0];
if($date <= $today) {
if (isset($dataScurve['percentagePlan'][$index])) {
$progressPlanBar = round($dataScurve['percentagePlan'][$index], 2);
}
}
}
}
$dcdScurve[0]['data']['progressPlanToDay'] = round($progressPlanBar,2);
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dcdScurve], 200);
} }
public function sCurveCommand(Request $request) public function sCurveCommand(Request $request)
@ -423,17 +437,12 @@ class ProjectController extends Controller
Artisan::call('calculate:scurve', [ Artisan::call('calculate:scurve', [
'project_id' => $request->project_id 'project_id' => $request->project_id
]); ]);
// $project = Project::find($request->project_id);
// if ($project) {
// dispatch(new ProcessSCurve($project));
// return response()->json(['message' => 'S Curve calculation queued']);
// }
// return response()->json(['message' => 'Project not found'], 404);
} }
public function ActualProgressProjectCommand() {
Artisan::call('calculate:ActualProgressProject');
}
public function getLinearSCurve(Request $request) public function getLinearSCurve(Request $request)
{ {
$data = MasterFunctionsHelper::getLinearSCurve($request); $data = MasterFunctionsHelper::getLinearSCurve($request);

1
routes/web.php

@ -93,6 +93,7 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->post('/project/get-s-curve', 'ProjectController@getSCurve'); $router->post('/project/get-s-curve', 'ProjectController@getSCurve');
$router->post('/project/calculate-s-curve', 'ProjectController@calculateSCurve'); $router->post('/project/calculate-s-curve', 'ProjectController@calculateSCurve');
$router->post('/project/s-curve-command', 'ProjectController@sCurveCommand'); $router->post('/project/s-curve-command', 'ProjectController@sCurveCommand');
$router->get('/project/actual-progress-project-command', 'ProjectController@ActualProgressProjectCommand');
$router->post('/project/s-curve-command-test', 'ProjectController@calculateSCurvetest'); $router->post('/project/s-curve-command-test', 'ProjectController@calculateSCurvetest');
$router->post('/project/get-linear-s-curve', 'ProjectController@getLinearSCurve'); $router->post('/project/get-linear-s-curve', 'ProjectController@getLinearSCurve');
$router->post('/project/get-overdue-activities', 'ProjectController@getOverdueActivities'); $router->post('/project/get-overdue-activities', 'ProjectController@getOverdueActivities');

Loading…
Cancel
Save