Compare commits

..

10 Commits

  1. 10
      app/Console/Commands/ScheduleHealth.php
  2. 21
      app/Http/Controllers/DashboardBoDController.php
  3. 17
      app/Http/Controllers/ProjectController.php

10
app/Console/Commands/ScheduleHealth.php

@ -42,13 +42,13 @@ class ScheduleHealth extends Command
public function handle() public function handle()
{ {
// echo "\n------------------------------------------\n"; echo "\n------------------------------------------\n";
// echo "Command Start. \n"; echo "Command Start. \n";
// Log::info("Command Start."); Log::info("Command Start.");
$projects = Project::get(); $projects = Project::get();
$totalProjects = $projects->count(); $totalProjects = $projects->count();
$updatedProjects = []; $updatedProjects = [];
// Log::info($totalProjects); Log::info($totalProjects);
foreach ($projects as $index => $project) { foreach ($projects as $index => $project) {
$project->scurve = MasterFunctionsHelper::getSCurve($project->id); $project->scurve = MasterFunctionsHelper::getSCurve($project->id);
@ -62,7 +62,7 @@ class ScheduleHealth extends Command
$scheduleHealth = ($selisihProgress > 0 && $selisihProgress <= 20) ? 'warning' : (($selisihProgress == 0) ? 'on-schedule' : 'behind-schedule'); $scheduleHealth = ($selisihProgress > 0 && $selisihProgress <= 20) ? 'warning' : (($selisihProgress == 0) ? 'on-schedule' : 'behind-schedule');
// Log::info("Updating project with ID: " . $project->id . " - Schedule Health: " . $scheduleHealth); Log::info("Updating project with ID: " . $project->id . " - Schedule Health: " . $scheduleHealth);
$project->update(['schedule_health' => $scheduleHealth]); $project->update(['schedule_health' => $scheduleHealth]);
$updatedProjects[] = $project->id; $updatedProjects[] = $project->id;
} }

21
app/Http/Controllers/DashboardBoDController.php

@ -43,7 +43,7 @@ class DashboardBoDController extends Controller
DB::raw('SUM(CAST(COALESCE(NULLIF(REPLACE(income_year, \'.\', \'\'), \'\'), \'0\') AS DOUBLE PRECISION)) AS total_income_year') DB::raw('SUM(CAST(COALESCE(NULLIF(REPLACE(income_year, \'.\', \'\'), \'\'), \'0\') AS DOUBLE PRECISION)) AS total_income_year')
)->first(); )->first();
$projects = Project::get(); $projects = Project::get();
// Log::info(['dataTotal' => $totalBudgets]); Log::info(['dataTotal' => $totalBudgets]);
} else { } else {
$totalBudgets = Project::where('created_by_id', $hierarchy) $totalBudgets = Project::where('created_by_id', $hierarchy)
->select( ->select(
@ -66,11 +66,11 @@ class DashboardBoDController extends Controller
return response()->json([ return response()->json([
'data' => [ 'data' => [
'total_budget' => (int) ($totalBudgets->total_rencana_biaya ?? 0), 'total_budget' => $totalBudgets->total_value_proyek ?? 0,
'total_expenditure' => $totalExpenditure, 'total_expenditure' => $totalExpenditure,
'total_invoice' => $totalInvoice, 'total_invoice' => $totalInvoice,
'total_paid_invoice' => $totalPaidInvoice, 'total_paid_invoice' => $totalPaidInvoice,
'total_value_proyek' => $totalBudgets->total_value_proyek ?? 0, 'total_value_proyek' => (int) ($totalBudgets->total_rencana_biaya ?? 0),
'total_income_year' => $totalBudgets->total_income_year ?? 0 'total_income_year' => $totalBudgets->total_income_year ?? 0
] ]
], 200); ], 200);
@ -288,10 +288,7 @@ class DashboardBoDController extends Controller
->pluck('id'); ->pluck('id');
// arr overrun // arr overrun
if ($role === 'Super Admin') { if ($all_project) {
$response['data']['overrun'] = Project::where('budget_health', 'overrun')
->count();
} elseif ($all_project == 'true') {
$response['data']['overrun'] = Project::whereIn('divisi_id', $divisi) $response['data']['overrun'] = Project::whereIn('divisi_id', $divisi)
->where([['budget_health', 'overrun']]) ->where([['budget_health', 'overrun']])
->count(); ->count();
@ -301,10 +298,7 @@ class DashboardBoDController extends Controller
->count(); ->count();
} }
// arr warning // arr warning
if ($role === 'Super Admin') { if ($all_project) {
$response['data']['warning'] = Project::where('budget_health', 'warning')
->count();
} elseif ($all_project == 'true') {
$response['data']['warning'] = Project::whereIn('divisi_id', $divisi) $response['data']['warning'] = Project::whereIn('divisi_id', $divisi)
->where([['budget_health', 'warning']]) ->where([['budget_health', 'warning']])
->count(); ->count();
@ -314,10 +308,7 @@ class DashboardBoDController extends Controller
->count(); ->count();
} }
// arr on-budget // arr on-budget
if ($role === 'Super Admin') { if ($all_project) {
$response['data']['on-budget'] = Project::where('budget_health', 'on-budget')
->count();
} elseif ($all_project == 'true') {
$response['data']['on-budget'] = Project::whereIn('divisi_id', $divisi) $response['data']['on-budget'] = Project::whereIn('divisi_id', $divisi)
->where([['budget_health', 'on-budget']]) ->where([['budget_health', 'on-budget']])
->count(); ->count();

17
app/Http/Controllers/ProjectController.php

@ -291,6 +291,23 @@ class ProjectController extends Controller
$builder = $dataBuilder['builder']; $builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count']; $countBuilder = $dataBuilder['count'];
$dataGet = $builder->get(); $dataGet = $builder->get();
foreach($dataGet as $p) {
$project = Project::find($p->id);
if (!$project) continue;
$act = Activity::select('persentase_progress as total_progress')
->where([
['proyek_id', $p->id],
['parent_id', null]
])
->first();
if ($act) {
$project->persentase_progress = $act->total_progress;
} else {
$project->persentase_progress = 0;
}
$project->save();
}
$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' => $totalRecord], 200);
} }

Loading…
Cancel
Save