Browse Source

fix: clear comment

pull/1/head
Watiah11 8 months ago
parent
commit
1c74aaf302
  1. 63
      app/Http/Controllers/DashboardBoDController.php

63
app/Http/Controllers/DashboardBoDController.php

@ -262,7 +262,6 @@ class DashboardBoDController extends Controller
foreach ($projects as $project) { foreach ($projects as $project) {
$resp = null; $resp = null;
if ($project->kode_sortname != "") { if ($project->kode_sortname != "") {
// $resp = $this->getInvoiceIntegration($project->kode_sortname);
array_push($return, [ array_push($return, [
'project' => $project->nama, 'project' => $project->nama,
'project_code' => $project->kode_sortname, 'project_code' => $project->kode_sortname,
@ -281,21 +280,27 @@ class DashboardBoDController extends Controller
public function getTotalProjectPerScheduleHealth($role_name, $company_id, $all_project, $hierarchy) public function getTotalProjectPerScheduleHealth($role_name, $company_id, $all_project, $hierarchy)
{ {
$role = urldecode($role_name); $role = urldecode($role_name);
$replaceHierarchy = preg_replace('/[\[\]]/', '', $hierarchy);
$return = [ $return = [
'behind-schedule' => 0, 'behind-schedule' => 0,
'warning' => 0, 'warning' => 0,
'on-schedule' => 0, 'on-schedule' => 0,
]; ];
$divisi = Divisi::query()
->where('company_id',$company_id)
->pluck('id');
$projects = null; $projects = null;
if ($role === 'Super Admin') { if ($role === 'Super Admin') {
$projects = Project::get(); $projects = Project::get();
} elseif ($all_project) { } elseif ($all_project == 'true') {
$projects = Project::where('company_id', $company_id) $projects = Project::whereIn('divisi_id',$divisi)
->where('company_id', $company_id)
->get(); ->get();
} else { } else {
$projects = Project::where('created_by_id', $hierarchy) $projects = Project::whereIn('divisi_id',$divisi)
->where('created_by_id', $replaceHierarchy)
->get(); ->get();
} }
@ -386,6 +391,8 @@ class DashboardBoDController extends Controller
public function getTotalProjectPerBudgetHealth($role_name, $company_id, $all_project, $hierarchy) public function getTotalProjectPerBudgetHealth($role_name, $company_id, $all_project, $hierarchy)
{ {
$role = urldecode($role_name); $role = urldecode($role_name);
$replaceHierarchy = preg_replace('/[\[\]]/', '', $hierarchy);
$response = [ $response = [
'data' => [ 'data' => [
'overrun' => 0, 'overrun' => 0,
@ -393,43 +400,47 @@ class DashboardBoDController extends Controller
'on-budget' => 0, 'on-budget' => 0,
] ]
]; ];
$divisi = Divisi::query()
->where('company_id',$company_id)
->pluck('id');
// arr overrun
if ($role === 'Super Admin') { if ($role === 'Super Admin') {
$response['data']['overrun'] = Project::where('budget_health', 'overrun') $response['data']['overrun'] = Project::where('budget_health', 'overrun')
->count(); ->count();
} elseif ($all_project) { } elseif ($all_project == 'true') {
$response['data']['overrun'] = Project::where('budget_health', 'overrun') $response['data']['overrun'] = Project::whereIn('divisi_id',$divisi)
->where('company_id', $company_id) ->where([['budget_health', 'overrun'],['company_id', $company_id]])
->count(); ->count();
} else { } else {
$response['data']['overrun'] = Project::where('budget_health', 'overrun') $response['data']['overrun'] = Project::whereIn('divisi_id',$divisi)
->where('created_by_id', $hierarchy) ->where([['budget_health', 'overrun'],['created_by_id', $replaceHierarchy]])
->count(); ->count();
} }
// arr warning
if ($role === 'Super Admin') { if ($role === 'Super Admin') {
$response['data']['overrun'] = Project::where('budget_health', 'warning')
->count();
} elseif ($all_project) {
$response['data']['warning'] = Project::where('budget_health', 'warning') $response['data']['warning'] = Project::where('budget_health', 'warning')
->where('company_id', $company_id) ->count();
} elseif ($all_project == 'true') {
$response['data']['warning'] = Project::whereIn('divisi_id',$divisi)
->where([['budget_health', 'warning'],['company_id', $company_id]])
->count(); ->count();
} else { } else {
$response['data']['warning'] = Project::where('budget_health', 'warning') $response['data']['warning'] = Project::whereIn('divisi_id',$divisi)
->where('created_by_id', $hierarchy) ->where([['budget_health', 'warning'],['created_by_id', $replaceHierarchy]])
->count(); ->count();
} }
// arr on-budget
if ($role === 'Super Admin') { if ($role === 'Super Admin') {
Log::info('on-budget');
$response['data']['on-budget'] = Project::where('budget_health', 'on-budget') $response['data']['on-budget'] = Project::where('budget_health', 'on-budget')
->count(); ->count();
} elseif ($all_project) { } elseif ($all_project == 'true') {
$response['data']['on-budget'] = Project::where('budget_health', 'on-budget') $response['data']['on-budget'] = Project::whereIn('divisi_id',$divisi)
->where('company_id', $company_id) ->where([['company_id', $company_id],['budget_health', 'on-budget']])
->count(); ->count();
} else { } else {
$response['data']['on-budget'] = Project::where('budget_health', 'on-budget') $response['data']['on-budget'] = Project::whereIn('divisi_id',$divisi)
->where('created_by_id', $hierarchy) ->where([['budget_health', 'on-budget'],['created_by_id', $replaceHierarchy]])
->count(); ->count();
} }
return response()->json($response, 200); return response()->json($response, 200);
@ -437,10 +448,8 @@ class DashboardBoDController extends Controller
private function countTotalProjectByBudgetHealthInDivision($divisi, $health) private function countTotalProjectByBudgetHealthInDivision($divisi, $health)
{ {
return Project::where('divisi_id', $divisi) $project = Project::where([['divisi_id', $divisi],['budget_health', $health]])->count();
/* ->orWhere('akhir_proyek', 'like', $year) */ return $project;
->where('budget_health', $health)
->count();
} }
@ -476,8 +485,6 @@ class DashboardBoDController extends Controller
unset($division->children); unset($division->children);
$division->budgetData = $budgetData; $division->budgetData = $budgetData;
} }
foreach ($divisions as $division) {
}
return response()->json([ return response()->json([
'data' => [ 'data' => [
$divisions $divisions

Loading…
Cancel
Save