Browse Source

Merge pull request 'staging' (#248) from staging into general

Reviewed-on: ordo/adw-backend#248
pull/3/head
farhantock 1 year ago
parent
commit
696dfb6222
  1. 4
      app/Helpers/MasterFunctionsHelper.php
  2. 40
      app/Http/Controllers/ActivityController.php

4
app/Helpers/MasterFunctionsHelper.php

@ -853,6 +853,7 @@ class MasterFunctionsHelper
$arr_ActualM = []; $arr_ActualM = [];
$tempDate = []; $tempDate = [];
$tempPercentage = [];
$tempPercentagePlan = []; $tempPercentagePlan = [];
$tempPercentagePlanWhr = []; $tempPercentagePlanWhr = [];
$tempPercentageReal = []; $tempPercentageReal = [];
@ -861,7 +862,8 @@ class MasterFunctionsHelper
$currentACWP = 0; $currentACWP = 0;
$currentBCWP = 0; $currentBCWP = 0;
$totalACWP = 0;
$totalBCWP = 0;
foreach ($period as $dt) { foreach ($period as $dt) {
$minSevenDays = new \Datetime($dt->format("Y-m-d")); $minSevenDays = new \Datetime($dt->format("Y-m-d"));
$minSevenDays = $minSevenDays->modify('-7 day')->format("Y-m-d"); $minSevenDays = $minSevenDays->modify('-7 day')->format("Y-m-d");

40
app/Http/Controllers/ActivityController.php

@ -544,21 +544,39 @@ class ActivityController extends Controller
{ {
$dataBuilder = $this->setUpPayload($request->all(), 'm_activity'); $dataBuilder = $this->setUpPayload($request->all(), 'm_activity');
$builder = $dataBuilder['builder']; $builder = $dataBuilder['builder'];
$dataGet = $builder->select( 'selfTable.name', 'persentase_progress', 'selfTable.start_date', 'selfTable.end_date', 'duration', $dataGet = $builder->select(
'm_version_gantt.name_version', DB::raw('STRING_AGG(m_users.name, \',\') as user_name'), 'selfTable.name',
DB::raw('SUM(report_activity_material.qty) as qty'), 'assign_material_to_activity.qty_planning', 'persentase_progress',
'assign_material_to_activity.id as join_third_id') 'selfTable.start_date',
'selfTable.end_date',
'selfTable.planned_start',
'selfTable.planned_end',
'selfTable.actual_start',
'selfTable.actual_end',
'duration',
'm_version_gantt.name_version',
DB::raw('user_names.user_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('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('assign_hr_to_activity', 'assign_hr_to_activity.activity_id', '=', 'selfTable.id')
->leftJoin('m_users', 'assign_hr_to_activity.user_id', '=', 'm_users.id')
->leftJoin('report_activity_material', 'report_activity_material.activity_id', '=', 'selfTable.id') ->leftJoin('report_activity_material', 'report_activity_material.activity_id', '=', 'selfTable.id')
->join('assign_material_to_activity', 'assign_material_to_activity.activity_id', '=', 'selfTable.id') ->join('assign_material_to_activity', 'assign_material_to_activity.activity_id', '=', 'selfTable.id')
->groupBy("selfTable.id") ->leftJoin(DB::raw('(SELECT activity_id, STRING_AGG(m_users.name, \',\') as user_name
->groupBy("selfTable.name") FROM assign_hr_to_activity
->groupBy("selfTable.persentase_progress") LEFT JOIN m_users ON assign_hr_to_activity.user_id = m_users.id
->groupBy("m_version_gantt.name_version") GROUP BY activity_id) as user_names'), function ($join) {
->groupBy("assign_material_to_activity.qty_planning") $join->on('user_names.activity_id', '=', 'selfTable.id');
->groupBy("assign_material_to_activity.id") })
->groupBy('selfTable.id')
->groupBy('selfTable.name')
->groupBy('selfTable.persentase_progress')
->groupBy('m_version_gantt.name_version')
->groupBy('assign_material_to_activity.qty_planning')
->groupBy('assign_material_to_activity.id')
->groupBy('user_names.user_name')
->get(); ->get();
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet ], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet ], 200);
} }

Loading…
Cancel
Save