|
|
|
@ -2,7 +2,6 @@
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers; |
|
|
|
|
|
|
|
|
|
<<<<<<< HEAD |
|
|
|
|
use App\Helpers\MasterFunctionsHelper; |
|
|
|
|
use App\Models\Divisi; |
|
|
|
|
use App\Models\Project; |
|
|
|
@ -11,13 +10,6 @@ use App\Models\User;
|
|
|
|
|
use App\Models\UserToVersionGantt; |
|
|
|
|
use Illuminate\Support\Collection; |
|
|
|
|
use Illuminate\Support\Facades\DB; |
|
|
|
|
======= |
|
|
|
|
use App\Models\Project; |
|
|
|
|
use App\Models\Divisi; |
|
|
|
|
use App\Models\ProjectPhase; |
|
|
|
|
use Illuminate\Support\Collection; |
|
|
|
|
use DB; |
|
|
|
|
>>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6 |
|
|
|
|
|
|
|
|
|
class DashboardBoDController extends Controller |
|
|
|
|
{ |
|
|
|
@ -27,7 +19,6 @@ class DashboardBoDController extends Controller
|
|
|
|
|
return $year; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
<<<<<<< HEAD |
|
|
|
|
private function curlReq($url, $token){ |
|
|
|
|
$ch = curl_init(); |
|
|
|
|
$headers = [ |
|
|
|
@ -63,15 +54,10 @@ class DashboardBoDController extends Controller
|
|
|
|
|
public function getCompanyCashFlow($year = '%') { |
|
|
|
|
$year = $this->interpolateYear($year); |
|
|
|
|
$totalExpenditure = $totalInvoice = $totalPaidInvoice = 0; |
|
|
|
|
======= |
|
|
|
|
public function getCompanyCashFlow($year = '%') { |
|
|
|
|
$year = $this->interpolateYear($year); |
|
|
|
|
>>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6 |
|
|
|
|
|
|
|
|
|
// we can't use eloquent's sum() method because someone decided to use varchar as datatype in rencana_biaya field |
|
|
|
|
$totalBudgets = Project::select(DB::raw('SUM(CAST("rencana_biaya" AS DOUBLE PRECISION))')) |
|
|
|
|
->where('mulai_proyek', 'like', $year) |
|
|
|
|
<<<<<<< HEAD |
|
|
|
|
/* ->orWhere('akhir_proyek', 'like', $year) */ |
|
|
|
|
->pluck('sum') |
|
|
|
|
->first(); |
|
|
|
@ -101,22 +87,10 @@ class DashboardBoDController extends Controller
|
|
|
|
|
'total_expenditure' => $totalExpenditure, |
|
|
|
|
'total_invoice' => $totalInvoice, |
|
|
|
|
'total_paid_invoice' => $totalPaidInvoice , |
|
|
|
|
======= |
|
|
|
|
->pluck('sum') |
|
|
|
|
->first(); |
|
|
|
|
|
|
|
|
|
return response()->json([ |
|
|
|
|
'data' => [ |
|
|
|
|
'total_budget' => (int) $totalBudgets ?? rand(0,10), |
|
|
|
|
'total_expenditure' => rand(0,10), // to do integrasi |
|
|
|
|
'total_invoice' => rand(0,10), |
|
|
|
|
'total_paid_invoice' => rand(0,10), |
|
|
|
|
>>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6 |
|
|
|
|
] |
|
|
|
|
], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
<<<<<<< HEAD |
|
|
|
|
public function getInvoiceOutstanding($year = '%'){ |
|
|
|
|
$year = $this->interpolateYear($year); |
|
|
|
|
$projects = Project::where('mulai_proyek', 'like', $year) |
|
|
|
@ -170,27 +144,10 @@ class DashboardBoDController extends Controller
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getTotalProjectScheduleHealthPerDivision($year = '%'){ |
|
|
|
|
======= |
|
|
|
|
public function getProjectPerScheduleHealth($year = '%'){ |
|
|
|
|
$year = $this->interpolateYear($year); |
|
|
|
|
// get data plan (vol) in % |
|
|
|
|
// get data actual in % |
|
|
|
|
return response()->json([ |
|
|
|
|
'data' => [ |
|
|
|
|
'behind-schedule' => rand(0,10), |
|
|
|
|
'warning' => rand(0,10), |
|
|
|
|
'on-schedule' => rand(0,10), |
|
|
|
|
] |
|
|
|
|
], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getProjectScheduleHealthPerDivision($year = '%'){ |
|
|
|
|
>>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6 |
|
|
|
|
$year = $this->interpolateYear($year); |
|
|
|
|
|
|
|
|
|
$divisions = Divisi::whereNull('parent')->get(); |
|
|
|
|
foreach($divisions as $division){ |
|
|
|
|
<<<<<<< HEAD |
|
|
|
|
|
|
|
|
|
$scheduleData = new Collection(); |
|
|
|
|
$behindSchedule = $warning = $onSchedule = 0; |
|
|
|
@ -209,12 +166,6 @@ class DashboardBoDController extends Controller
|
|
|
|
|
$scheduleData->prepend($behindSchedule, 'behindSchedule'); |
|
|
|
|
$scheduleData->prepend($warning, 'warning'); |
|
|
|
|
$scheduleData->prepend($onSchedule, 'onSchedule'); |
|
|
|
|
======= |
|
|
|
|
$scheduleData = new Collection(); |
|
|
|
|
$scheduleData->prepend(rand(0, 10), 'behindSchedule'); |
|
|
|
|
$scheduleData->prepend(rand(0, 10), 'warning'); |
|
|
|
|
$scheduleData->prepend(rand(0, 10), 'onSchedule'); |
|
|
|
|
>>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6 |
|
|
|
|
$division->scheduleData = $scheduleData; |
|
|
|
|
} |
|
|
|
|
return response()->json([ |
|
|
|
@ -224,7 +175,6 @@ class DashboardBoDController extends Controller
|
|
|
|
|
], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
<<<<<<< HEAD |
|
|
|
|
public function getTotalProjectPerBudgetHealth($year = '%'){ |
|
|
|
|
$year = $this->interpolateYear($year); |
|
|
|
|
return response()->json([ |
|
|
|
@ -232,20 +182,10 @@ class DashboardBoDController extends Controller
|
|
|
|
|
'overrun' => Project::where('mulai_proyek', 'like', $year)->where('budget_health', 'overrun')->count(), |
|
|
|
|
'warning' => Project::where('mulai_proyek', 'like', $year)->where('budget_health', 'warning')->count(), |
|
|
|
|
'on-budget' => Project::where('mulai_proyek', 'like', $year)->where('budget_health', 'on-budget')->count(), |
|
|
|
|
======= |
|
|
|
|
public function getProjectPerBudgetHealth($year = '%'){ |
|
|
|
|
$year = $this->interpolateYear($year); |
|
|
|
|
return response()->json([ |
|
|
|
|
'data' => [ |
|
|
|
|
'overrun' => rand(0,10), |
|
|
|
|
'warning' => rand(0,10), |
|
|
|
|
'on-budget' => rand(0,10), |
|
|
|
|
>>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6 |
|
|
|
|
] |
|
|
|
|
], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
<<<<<<< HEAD |
|
|
|
|
private function countTotalProjectByBudgetHealthInDivision($divisi, $year, $health){ |
|
|
|
|
return Project::where('divisi_id', $divisi) |
|
|
|
|
->where('mulai_proyek', 'like', $year) |
|
|
|
@ -277,19 +217,6 @@ class DashboardBoDController extends Controller
|
|
|
|
|
} |
|
|
|
|
foreach($divisions as $division){ |
|
|
|
|
} |
|
|
|
|
======= |
|
|
|
|
public function getProjectBudgetHealthPerDivision($year = '%'){ |
|
|
|
|
$year = $this->interpolateYear($year); |
|
|
|
|
|
|
|
|
|
$divisions = Divisi::whereNull('parent')->get(); |
|
|
|
|
foreach($divisions as $division){ |
|
|
|
|
$budgetData = new Collection(); |
|
|
|
|
$budgetData->prepend(rand(0, 10), 'overrun'); |
|
|
|
|
$budgetData->prepend(rand(0, 10), 'warning'); |
|
|
|
|
$budgetData->prepend(rand(0, 10), 'onBudget'); |
|
|
|
|
$division->budgetData = $budgetData; |
|
|
|
|
} |
|
|
|
|
>>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6 |
|
|
|
|
return response()->json([ |
|
|
|
|
'data' => [ |
|
|
|
|
$divisions |
|
|
|
@ -297,7 +224,6 @@ class DashboardBoDController extends Controller
|
|
|
|
|
], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
<<<<<<< HEAD |
|
|
|
|
public function getTotalProjectPerPhase($year = '%'){ |
|
|
|
|
$year = $this->interpolateYear($year); |
|
|
|
|
$projectPhases = ProjectPhase::orderBy('order')->get(); |
|
|
|
@ -306,13 +232,6 @@ class DashboardBoDController extends Controller
|
|
|
|
|
->where('mulai_proyek', 'like', $year) |
|
|
|
|
/* ->orWhere('akhir_proyek', 'like', $year) */ |
|
|
|
|
->count(); |
|
|
|
|
======= |
|
|
|
|
public function getProjectPerPhase($year = '%'){ |
|
|
|
|
$year = $this->interpolateYear($year); |
|
|
|
|
$projectPhases = ProjectPhase::orderBy('order')->get(); |
|
|
|
|
foreach($projectPhases as $phase){ |
|
|
|
|
$phase->totalProject = rand(0,10); |
|
|
|
|
>>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6 |
|
|
|
|
} |
|
|
|
|
return response()->json([ |
|
|
|
|
'data' => [ |
|
|
|
@ -324,31 +243,19 @@ class DashboardBoDController extends Controller
|
|
|
|
|
private function countTotalProjectInDivision($id, $year){ |
|
|
|
|
return Project::where('divisi_id', $id) |
|
|
|
|
->where('mulai_proyek', 'like', $year) |
|
|
|
|
<<<<<<< HEAD |
|
|
|
|
/* ->orWhere('akhir_proyek', 'like', $year) */ |
|
|
|
|
======= |
|
|
|
|
>>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6 |
|
|
|
|
->count(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getTotalProjectPerDivision($year = '%') { |
|
|
|
|
$year = $this->interpolateYear($year); |
|
|
|
|
|
|
|
|
|
<<<<<<< HEAD |
|
|
|
|
$divisions = Divisi::select('id','name') |
|
|
|
|
======= |
|
|
|
|
$totalProjectPerDivision = Divisi::select('id','name') |
|
|
|
|
>>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6 |
|
|
|
|
->with('children') |
|
|
|
|
->whereNull('parent') |
|
|
|
|
->get(); |
|
|
|
|
|
|
|
|
|
// to do : count in more than 1 level child |
|
|
|
|
<<<<<<< HEAD |
|
|
|
|
foreach($divisions as $v){ |
|
|
|
|
======= |
|
|
|
|
foreach($totalProjectPerDivision as $v){ |
|
|
|
|
>>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6 |
|
|
|
|
$v->total = $this->countTotalProjectInDivision($v->id, $year); |
|
|
|
|
foreach($v->children as $d){ |
|
|
|
|
$v->total += $this->countTotalProjectInDivision($d->id, $year); |
|
|
|
@ -357,21 +264,14 @@ class DashboardBoDController extends Controller
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return response()->json([ |
|
|
|
|
<<<<<<< HEAD |
|
|
|
|
'data' => $divisions |
|
|
|
|
======= |
|
|
|
|
'data' => $totalProjectPerDivision |
|
|
|
|
>>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6 |
|
|
|
|
], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private function countTotalProjectValueInDivision($id, $year){ |
|
|
|
|
return Project::select(DB::raw('SUM(CAST("rencana_biaya" AS DOUBLE PRECISION))')) |
|
|
|
|
->where('mulai_proyek', 'like', $year) |
|
|
|
|
<<<<<<< HEAD |
|
|
|
|
/* ->orWhere('akhir_proyek', 'like', $year) */ |
|
|
|
|
======= |
|
|
|
|
>>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6 |
|
|
|
|
->where('divisi_id', $id) |
|
|
|
|
->pluck('sum') |
|
|
|
|
->first(); |
|
|
|
@ -380,21 +280,13 @@ class DashboardBoDController extends Controller
|
|
|
|
|
public function getTotalProjectValuePerDivision($year = '%') { |
|
|
|
|
$year = $this->interpolateYear($year); |
|
|
|
|
|
|
|
|
|
<<<<<<< HEAD |
|
|
|
|
$divisions = Divisi::select('id','name') |
|
|
|
|
======= |
|
|
|
|
$totalProjectValuePerDivision = Divisi::select('id','name') |
|
|
|
|
>>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6 |
|
|
|
|
->with('children') |
|
|
|
|
->whereNull('parent') |
|
|
|
|
->get(); |
|
|
|
|
|
|
|
|
|
// to do : count in more than 1 level child |
|
|
|
|
<<<<<<< HEAD |
|
|
|
|
foreach($divisions as $v){ |
|
|
|
|
======= |
|
|
|
|
foreach($totalProjectValuePerDivision as $v){ |
|
|
|
|
>>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6 |
|
|
|
|
$v->total = $this->countTotalProjectValueInDivision($v->id, $year); |
|
|
|
|
foreach($v->children as $d){ |
|
|
|
|
$v->total += $this->countTotalProjectValueInDivision($d->id, $year); |
|
|
|
@ -403,7 +295,6 @@ class DashboardBoDController extends Controller
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return response()->json([ |
|
|
|
|
<<<<<<< HEAD |
|
|
|
|
'data' => $divisions |
|
|
|
|
], 200); |
|
|
|
|
} |
|
|
|
@ -438,11 +329,5 @@ class DashboardBoDController extends Controller
|
|
|
|
|
'total_manpowers' => User::count() |
|
|
|
|
], 200); |
|
|
|
|
} |
|
|
|
|
======= |
|
|
|
|
'data' => $totalProjectValuePerDivision |
|
|
|
|
], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
>>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|