From c8162ed09b0ac5d678fc4200a102ee61ac21074c Mon Sep 17 00:00:00 2001 From: wahyu Date: Mon, 18 Dec 2023 13:33:28 +0700 Subject: [PATCH] update report analysis --- app/Http/Controllers/ActivityController.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php index af5a636..e08ff7b 100755 --- a/app/Http/Controllers/ActivityController.php +++ b/app/Http/Controllers/ActivityController.php @@ -697,9 +697,10 @@ class ActivityController extends Controller 'm_version_gantt.name_version', DB::raw('user_names.user_name as user_name'), DB::raw('SUM(report_activity_material.qty) as qty'), - DB::raw('SUM(assign_material_to_activity.qty_planning) as qty_planning'), + // DB::raw('SUM(assign_material_to_activity.qty_planning) as qty_planning'), 'assign_material_to_activity.id as join_third_id' ) + ->addSelect(DB::raw('(SELECT SUM(assign_material_to_activity.qty_planning) FROM assign_material_to_activity WHERE assign_material_to_activity.activity_id = report_activity_material.activity_id) as qty_planning')) ->join('m_version_gantt', 'm_version_gantt.id', '=', 'selfTable.version_gantt_id') ->leftJoin('assign_hr_to_activity', 'assign_hr_to_activity.activity_id', '=', 'selfTable.id') ->leftJoin('report_activity_material', 'report_activity_material.activity_id', '=', 'selfTable.id') @@ -710,11 +711,12 @@ class ActivityController extends Controller GROUP BY activity_id) as user_names'), function ($join) { $join->on('user_names.activity_id', '=', 'selfTable.id'); }) - ->where('report_activity_material.assign_material_id', '=', DB::raw('assign_material_to_activity.id')) + ->where('assign_material_to_activity.id', '=', DB::raw('report_activity_material.assign_material_id')) ->groupBy('selfTable.id') ->groupBy('m_version_gantt.name_version') ->groupBy('assign_material_to_activity.id') ->groupBy('user_names.user_name') + ->groupBy('report_activity_material.activity_id') ->get(); return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet ], 200); }