Browse Source

fix: clear comment

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

67
app/Http/Controllers/DashboardBoDController.php

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

Loading…
Cancel
Save