|
|
@ -122,9 +122,9 @@ class DashboardBoDController extends Controller |
|
|
|
], 200); |
|
|
|
], 200); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getTotalProjectPerScheduleHealth($year = '%') |
|
|
|
public function getTotalProjectPerScheduleHealth() |
|
|
|
{ |
|
|
|
{ |
|
|
|
$year = $this->interpolateYear($year); |
|
|
|
// $year = $this->interpolateYear($year); |
|
|
|
|
|
|
|
|
|
|
|
$return = [ |
|
|
|
$return = [ |
|
|
|
'behind-schedule' => 0, |
|
|
|
'behind-schedule' => 0, |
|
|
@ -132,7 +132,7 @@ class DashboardBoDController extends Controller |
|
|
|
'on-schedule' => 0, |
|
|
|
'on-schedule' => 0, |
|
|
|
]; |
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
$projects = Project::where('mulai_proyek', 'like', $year)->get(); |
|
|
|
$projects = Project::get(); |
|
|
|
foreach ($projects as $index => $project) { |
|
|
|
foreach ($projects as $index => $project) { |
|
|
|
$project->scurve = MasterFunctionsHelper::getSCurve($project->id); |
|
|
|
$project->scurve = MasterFunctionsHelper::getSCurve($project->id); |
|
|
|
$selisihProgress = 0; |
|
|
|
$selisihProgress = 0; |
|
|
@ -165,9 +165,9 @@ class DashboardBoDController extends Controller |
|
|
|
return response()->json(['data' => $return, 'q' => $projects], 200); |
|
|
|
return response()->json(['data' => $return, 'q' => $projects], 200); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getTotalProjectScheduleHealthPerDivision($year = '%') |
|
|
|
public function getTotalProjectScheduleHealthPerDivision() |
|
|
|
{ |
|
|
|
{ |
|
|
|
$year = $this->interpolateYear($year); |
|
|
|
// $year = $this->interpolateYear($year); |
|
|
|
|
|
|
|
|
|
|
|
$divisions = Divisi::whereNull('parent')->get(); |
|
|
|
$divisions = Divisi::whereNull('parent')->get(); |
|
|
|
foreach ($divisions as $index => $division) { |
|
|
|
foreach ($divisions as $index => $division) { |
|
|
@ -175,7 +175,7 @@ class DashboardBoDController extends Controller |
|
|
|
$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; |
|
|
@ -210,31 +210,30 @@ class DashboardBoDController extends Controller |
|
|
|
], 200); |
|
|
|
], 200); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getTotalProjectPerBudgetHealth($year = '%') |
|
|
|
public function getTotalProjectPerBudgetHealth() |
|
|
|
{ |
|
|
|
{ |
|
|
|
$year = $this->interpolateYear($year); |
|
|
|
|
|
|
|
return response()->json([ |
|
|
|
return response()->json([ |
|
|
|
'data' => [ |
|
|
|
'data' => [ |
|
|
|
'overrun' => Project::where('mulai_proyek', 'like', $year)->where('budget_health', 'overrun')->count(), |
|
|
|
'overrun' => Project::where('budget_health', 'overrun')->count(), |
|
|
|
'warning' => Project::where('mulai_proyek', 'like', $year)->where('budget_health', 'warning')->count(), |
|
|
|
'warning' => Project::where('budget_health', 'warning')->count(), |
|
|
|
'on-budget' => Project::where('mulai_proyek', 'like', $year)->where('budget_health', 'on-budget')->count(), |
|
|
|
'on-budget' => Project::where('budget_health', 'on-budget')->count(), |
|
|
|
] |
|
|
|
] |
|
|
|
], 200); |
|
|
|
], 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) |
|
|
|
// ->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 = '%') |
|
|
|
public function getTotalProjectBudgetHealthPerDivision() |
|
|
|
{ |
|
|
|
{ |
|
|
|
$year = $this->interpolateYear($year); |
|
|
|
// $year = $this->interpolateYear($year); |
|
|
|
$divisions = Divisi::select('id', 'name') |
|
|
|
$divisions = Divisi::select('id', 'name') |
|
|
|
->with('children') |
|
|
|
->with('children') |
|
|
|
->whereNull('parent') |
|
|
|
->whereNull('parent') |
|
|
@ -242,13 +241,13 @@ class DashboardBoDController extends Controller |
|
|
|
// 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; |
|
|
@ -262,13 +261,13 @@ class DashboardBoDController extends Controller |
|
|
|
], 200); |
|
|
|
], 200); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getTotalProjectPerPhase($year = '%') |
|
|
|
public function getTotalProjectPerPhase() |
|
|
|
{ |
|
|
|
{ |
|
|
|
$year = $this->interpolateYear($year); |
|
|
|
// $year = $this->interpolateYear($year); |
|
|
|
$projectPhases = ProjectPhase::orderBy('order')->get(); |
|
|
|
$projectPhases = ProjectPhase::orderBy('order')->get(); |
|
|
|
foreach ($projectPhases as $phase) { |
|
|
|
foreach ($projectPhases as $phase) { |
|
|
|
$phase->totalProject = Project::where('phase_id', $phase->id) |
|
|
|
$phase->totalProject = Project::where('phase_id', $phase->id) |
|
|
|
->where('mulai_proyek', 'like', $year) |
|
|
|
// ->where('mulai_proyek', 'like', $year) |
|
|
|
/* ->orWhere('akhir_proyek', 'like', $year) */ |
|
|
|
/* ->orWhere('akhir_proyek', 'like', $year) */ |
|
|
|
->count(); |
|
|
|
->count(); |
|
|
|
} |
|
|
|
} |
|
|
@ -279,16 +278,16 @@ 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) |
|
|
|
// ->where('mulai_proyek', 'like', $year) |
|
|
|
->count(); |
|
|
|
->count(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getTotalProjectPerDivision($year = '%') |
|
|
|
public function getTotalProjectPerDivision() |
|
|
|
{ |
|
|
|
{ |
|
|
|
$year = $this->interpolateYear($year); |
|
|
|
// $year = $this->interpolateYear($year); |
|
|
|
|
|
|
|
|
|
|
|
$divisions = Divisi::select('id', 'name', 'parent', 'color') |
|
|
|
$divisions = Divisi::select('id', 'name', 'parent', 'color') |
|
|
|
->with('children') |
|
|
|
->with('children') |
|
|
@ -297,9 +296,9 @@ class DashboardBoDController extends Controller |
|
|
|
|
|
|
|
|
|
|
|
// 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); |
|
|
|
} |
|
|
|
} |
|
|
@ -309,20 +308,18 @@ class DashboardBoDController extends Controller |
|
|
|
], 200); |
|
|
|
], 200); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private function countTotalProjectValueInDivision($id, $year) |
|
|
|
private function countTotalProjectValueInDivision($id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return Project::select(DB::raw("SUM(CAST(REPLACE(rencana_biaya, ',', '.') AS DOUBLE PRECISION))")) |
|
|
|
return Project::select(DB::raw("SUM(CAST(REPLACE(rencana_biaya, ',', '.') AS DOUBLE PRECISION))")) |
|
|
|
->where('mulai_proyek', 'like', $year) |
|
|
|
// ->where('mulai_proyek', 'like', $year) |
|
|
|
/* ->orWhere('akhir_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 = '%') |
|
|
|
public function getTotalProjectValuePerDivision() |
|
|
|
{ |
|
|
|
{ |
|
|
|
$year = $this->interpolateYear($year); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$divisions = Divisi::select('id', 'name', 'color') |
|
|
|
$divisions = Divisi::select('id', 'name', 'color') |
|
|
|
->with('children') |
|
|
|
->with('children') |
|
|
|
->whereNull('parent') |
|
|
|
->whereNull('parent') |
|
|
@ -330,9 +327,9 @@ class DashboardBoDController extends Controller |
|
|
|
|
|
|
|
|
|
|
|
// 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->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); |
|
|
|
} |
|
|
|
} |
|
|
@ -343,12 +340,13 @@ class DashboardBoDController extends Controller |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getDetailExpenditure($year = '%') |
|
|
|
public function getDetailExpenditure() |
|
|
|
{ |
|
|
|
{ |
|
|
|
$year = $this->interpolateYear($year); |
|
|
|
// $year = $this->interpolateYear($year); |
|
|
|
$projects = Project::select('m_proyek.*', 'md.name as divisi_name') |
|
|
|
$projects = Project::select('m_proyek.*', 'md.name as divisi_name', 'tpy.name as project_type_name') |
|
|
|
->where('mulai_proyek', 'like', $year) |
|
|
|
// ->where('mulai_proyek', 'like', $year) |
|
|
|
->join('m_divisi as md', 'md.id', '=', 'm_proyek.divisi_id') |
|
|
|
->join('m_divisi as md', 'md.id', '=', 'm_proyek.divisi_id') |
|
|
|
|
|
|
|
->join('m_type_proyek as tpy', 'tpy.id', '=', 'm_proyek.type_proyek_id') |
|
|
|
->orderBy('id', 'desc') |
|
|
|
->orderBy('id', 'desc') |
|
|
|
->get(); |
|
|
|
->get(); |
|
|
|
foreach ($projects as $project) { |
|
|
|
foreach ($projects as $project) { |
|
|
|