Browse Source

Formatting

pull/3/head
Wahyu Ramadhan 1 year ago
parent
commit
fc35b7869e
  1. 49
      app/Http/Controllers/DashboardBoDController.php

49
app/Http/Controllers/DashboardBoDController.php

@ -14,13 +14,15 @@ use Illuminate\Support\Facades\Log;
class DashboardBoDController extends Controller
{
private function interpolateYear($year){
private function interpolateYear($year)
{
if ($year)
$year = '%' . $year . '%';
return $year;
}
private function curlReq($url, $token){
private function curlReq($url, $token)
{
$ch = curl_init();
$headers = [
'Authorization: ' . $token
@ -37,7 +39,8 @@ class DashboardBoDController extends Controller
return json_decode($response);
}
private function getInvoiceIntegration($search) {
private function getInvoiceIntegration($search)
{
// if(empty($search))
// return response()->json(['status'=>'error', 'message'=>'Empty query string!'], 400);
//
@ -52,7 +55,8 @@ class DashboardBoDController extends Controller
}
// to do
public function getCompanyCashFlow($year = '%') {
public function getCompanyCashFlow($year = '%')
{
$year = $this->interpolateYear($year);
$totalExpenditure = $totalInvoice = $totalPaidInvoice = 0;
@ -92,7 +96,8 @@ class DashboardBoDController extends Controller
], 200);
}
public function getInvoiceOutstanding($year = '%'){
public function getInvoiceOutstanding($year = '%')
{
$year = $this->interpolateYear($year);
$projects = Project::where('mulai_proyek', 'like', $year)
/* ->orWhere('akhir_proyek', 'like', $year) */
@ -117,7 +122,8 @@ class DashboardBoDController extends Controller
], 200);
}
public function getTotalProjectPerScheduleHealth($year = '%'){
public function getTotalProjectPerScheduleHealth($year = '%')
{
$year = $this->interpolateYear($year);
$return = [
@ -152,7 +158,8 @@ class DashboardBoDController extends Controller
return response()->json(['data' => $return, 'q' => $projects], 200);
}
public function getTotalProjectScheduleHealthPerDivision($year = '%'){
public function getTotalProjectScheduleHealthPerDivision($year = '%')
{
$year = $this->interpolateYear($year);
$divisions = Divisi::whereNull('parent')->get();
@ -184,7 +191,8 @@ class DashboardBoDController extends Controller
], 200);
}
public function getTotalProjectPerBudgetHealth($year = '%'){
public function getTotalProjectPerBudgetHealth($year = '%')
{
$year = $this->interpolateYear($year);
return response()->json([
'data' => [
@ -195,7 +203,8 @@ class DashboardBoDController extends Controller
], 200);
}
private function countTotalProjectByBudgetHealthInDivision($divisi, $year, $health){
private function countTotalProjectByBudgetHealthInDivision($divisi, $year, $health)
{
return Project::where('divisi_id', $divisi)
->where('mulai_proyek', 'like', $year)
/* ->orWhere('akhir_proyek', 'like', $year) */
@ -204,7 +213,8 @@ class DashboardBoDController extends Controller
}
public function getTotalProjectBudgetHealthPerDivision($year = '%'){
public function getTotalProjectBudgetHealthPerDivision($year = '%')
{
$year = $this->interpolateYear($year);
$divisions = Divisi::select('id', 'name')
->with('children')
@ -233,7 +243,8 @@ class DashboardBoDController extends Controller
], 200);
}
public function getTotalProjectPerPhase($year = '%'){
public function getTotalProjectPerPhase($year = '%')
{
$year = $this->interpolateYear($year);
$projectPhases = ProjectPhase::orderBy('order')->get();
foreach ($projectPhases as $phase) {
@ -249,13 +260,15 @@ class DashboardBoDController extends Controller
], 200);
}
private function countTotalProjectInDivision($id, $year){
private function countTotalProjectInDivision($id, $year)
{
return Project::where('divisi_id', $id)
->where('mulai_proyek', 'like', $year)
->count();
}
public function getTotalProjectPerDivision($year = '%') {
public function getTotalProjectPerDivision($year = '%')
{
$year = $this->interpolateYear($year);
$divisions = Divisi::select('id', 'name')
@ -277,7 +290,8 @@ class DashboardBoDController extends Controller
], 200);
}
private function countTotalProjectValueInDivision($id, $year){
private function countTotalProjectValueInDivision($id, $year)
{
return Project::select(DB::raw('SUM(CAST("rencana_biaya" AS DOUBLE PRECISION))'))
->where('mulai_proyek', 'like', $year)
/* ->orWhere('akhir_proyek', 'like', $year) */
@ -286,7 +300,8 @@ class DashboardBoDController extends Controller
->first();
}
public function getTotalProjectValuePerDivision($year = '%') {
public function getTotalProjectValuePerDivision($year = '%')
{
$year = $this->interpolateYear($year);
$divisions = Divisi::select('id', 'name')
@ -309,7 +324,8 @@ class DashboardBoDController extends Controller
}
public function getDetailExpenditure($year = '%'){
public function getDetailExpenditure($year = '%')
{
$year = $this->interpolateYear($year);
$projects = Project::where('mulai_proyek', 'like', $year)
/* ->orWhere('akhir_proyek', 'like', $year) */
@ -343,4 +359,3 @@ class DashboardBoDController extends Controller
], 200);
}
}

Loading…
Cancel
Save