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

Loading…
Cancel
Save