diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php index 0e23cdb..fddd137 100644 --- a/app/Http/Controllers/ActivityController.php +++ b/app/Http/Controllers/ActivityController.php @@ -544,10 +544,22 @@ class ActivityController extends Controller { $dataBuilder = $this->setUpPayload($request->all(), 'm_activity'); $builder = $dataBuilder['builder']; - $dataGet = $builder->select('selfTable.*','m_version_gantt.name_version', 'm_users.name as user_name') + $dataGet = $builder->select( 'selfTable.name', 'persentase_progress', + 'm_version_gantt.name_version', 'm_users.name as user_name', + DB::raw('SUM(report_activity_material.qty) as qty'), 'assign_material_to_activity.qty_planning', + 'assign_material_to_activity.id as join_third_id') ->join('m_version_gantt', 'm_version_gantt.id', '=', 'selfTable.version_gantt_id') ->join('assign_hr_to_activity', 'assign_hr_to_activity.activity_id', '=', 'selfTable.id') ->join('m_users', 'assign_hr_to_activity.user_id', '=', 'm_users.id') + ->join('report_activity_material', 'report_activity_material.activity_id', '=', 'selfTable.id') + ->join('assign_material_to_activity', 'assign_material_to_activity.activity_id', '=', 'selfTable.id') + ->groupBy("selfTable.id") + ->groupBy("selfTable.name") + ->groupBy("selfTable.persentase_progress") + ->groupBy("m_version_gantt.name_version") + ->groupBy("m_users.name") + ->groupBy("assign_material_to_activity.qty_planning") + ->groupBy("assign_material_to_activity.id") ->get(); return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet ], 200); } diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 507129d..7e00a8a 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -54,11 +54,13 @@ class Controller extends BaseController $tableName = $join['name']; $columnJoin = $join['column_join']; // foreign key table sini $columnSelf = isset($join['column_self']) ? $join['column_self'] : "id"; // primary key table lawan + if (isset($join['column_results'])) { $columnResult = $join['column_results']; foreach($columnResult as $sColumn){ $builder = $builder->addSelect($tableName.".".$sColumn." as join_".$this->listJoinAll[$no]."_".$sColumn); } + } $builder = $builder->leftJoin($tableName, $tableJoin.".".$columnJoin, '=', $tableName.'.'.$columnSelf); $no++; } diff --git a/app/Http/Controllers/UserToActivityController.php b/app/Http/Controllers/UserToActivityController.php index a1a9583..4ca00f8 100644 --- a/app/Http/Controllers/UserToActivityController.php +++ b/app/Http/Controllers/UserToActivityController.php @@ -6,6 +6,7 @@ use Illuminate\Http\Request; use App\Models\UserToActivity; use App\Models\Activity; use App\Models\AssignMaterial; +use Illuminate\Support\Facades\DB; use Datatables; class UserToActivityController extends Controller @@ -134,6 +135,12 @@ class UserToActivityController extends Controller $dataBuilder = $this->setUpPayload($request->all(), 'assign_hr_to_activity'); $builder = $dataBuilder['builder']; $countBuilder = $dataBuilder['count']; + $builder->addSelect(DB::raw('SUM(report_activity_material.qty) as volume_actual')); + $builder->groupBy("m_activity.id"); + $builder->groupBy("selfTable.id"); + $builder->groupBy("m_users.name"); + $builder->groupBy("assign_material_to_activity.id"); + $builder->groupBy("m_version_gantt.name_version"); $dataGet = $builder->get(); $totalRecord = $countBuilder->count(); return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200);