Browse Source

Merge pull request 'upload 2023-11-02' (#249) from staging into master

Reviewed-on: ordo/adw-backend#249
pull/1/head
farhantock 1 year ago
parent
commit
e5061d3a91
  1. 4
      app/Helpers/MasterFunctionsHelper.php
  2. 52
      app/Http/Controllers/ActivityController.php
  3. 23
      app/Http/Controllers/ProjectController.php

4
app/Helpers/MasterFunctionsHelper.php

@ -852,6 +852,7 @@ class MasterFunctionsHelper
$arr_ActualM = []; $arr_ActualM = [];
$tempDate = []; $tempDate = [];
$tempPercentage = [];
$tempPercentagePlan = []; $tempPercentagePlan = [];
$tempPercentagePlanWhr = []; $tempPercentagePlanWhr = [];
$tempPercentageReal = []; $tempPercentageReal = [];
@ -860,7 +861,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");

52
app/Http/Controllers/ActivityController.php

@ -544,24 +544,40 @@ 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', 'assign_hr_to_activity.id', $dataGet = $builder->select(
'm_version_gantt.name_version', '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',
->join('m_version_gantt', 'm_version_gantt.id', '=', 'selfTable.version_gantt_id') 'selfTable.end_date',
->leftJoin('assign_hr_to_activity', 'assign_hr_to_activity.activity_id', '=', 'selfTable.id') 'selfTable.planned_start',
->leftJoin('m_users', 'assign_hr_to_activity.user_id', '=', 'm_users.id') 'selfTable.planned_end',
->leftJoin('report_activity_material', 'report_activity_material.activity_id', '=', 'selfTable.id') 'selfTable.actual_start',
->join('assign_material_to_activity', 'assign_material_to_activity.activity_id', '=', 'selfTable.id') 'selfTable.actual_end',
->groupBy("selfTable.id") 'duration',
->groupBy("selfTable.name") 'm_version_gantt.name_version',
->groupBy("selfTable.persentase_progress") DB::raw('user_names.user_name as user_name'),
->groupBy("m_version_gantt.name_version") DB::raw('SUM(report_activity_material.qty) as qty'),
->groupBy("m_users.name") 'assign_material_to_activity.qty_planning',
->groupBy("assign_material_to_activity.qty_planning") 'assign_material_to_activity.id as join_third_id'
->groupBy("assign_material_to_activity.id") )
->groupBy("assign_hr_to_activity.id") ->join('m_version_gantt', 'm_version_gantt.id', '=', 'selfTable.version_gantt_id')
->get(); ->leftJoin('assign_hr_to_activity', 'assign_hr_to_activity.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')
->leftJoin(DB::raw('(SELECT activity_id, STRING_AGG(m_users.name, \',\') as user_name
FROM assign_hr_to_activity
LEFT JOIN m_users ON assign_hr_to_activity.user_id = m_users.id
GROUP BY activity_id) as user_names'), function ($join) {
$join->on('user_names.activity_id', '=', 'selfTable.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();
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet ], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet ], 200);
} }
// before upload file // before upload file

23
app/Http/Controllers/ProjectController.php

@ -45,7 +45,7 @@ class ProjectController extends Controller
{ {
$this->validate($request, [ $this->validate($request, [
'nama' => 'required', 'nama' => 'required',
'mulai_proyek' => 'required', 'mulai_proyek' => 'required',
'akhir_proyek' => 'required', 'akhir_proyek' => 'required',
'rencana_biaya' => 'required', 'rencana_biaya' => 'required',
'type_proyek_id' => 'required' 'type_proyek_id' => 'required'
@ -519,12 +519,18 @@ class ProjectController extends Controller
if (isset($s_curve)) { if (isset($s_curve)) {
$result->header = Activity::whereNull('parent_id')->where("proyek_id", $id)->first(); $result->header = Activity::whereNull('parent_id')->where("proyek_id", $id)->first();
$actualStartExist = Activity::where('proyek_id', $id)->whereNotNull('actual_start')->exists(); $actualStartExist = Activity::where('proyek_id', $id)->whereNotNull('actual_start')->exists();
$actualEndExist = Activity::where('proyek_id', $id)->whereNotNull('actual_end')->exists(); if($result['type_proyek_id'] === 9)
$query = Activity::where('proyek_id', $id); {
$actualEndExist = Activity::where('proyek_id', $id)->exists();
$query = Activity::where('proyek_id', $id);
}else{
$actualEndExist = Activity::where('version_gantt_id', $ganttId)->exists();
$query = Activity::where('version_gantt_id', $ganttId);
}
} else { } else {
$result->header = Activity::whereNull('parent_id')->where("proyek_id", $id)->where("version_gantt_id", $ganttId)->first(); $result->header = Activity::whereNull('parent_id')->where("proyek_id", $id)->where("version_gantt_id", $ganttId)->first();
$actualStartExist = Activity::where('version_gantt_id', $ganttId)->whereNotNull('actual_start')->exists(); $actualStartExist = Activity::where('version_gantt_id', $ganttId)->whereNotNull('actual_start')->exists();
$actualEndExist = Activity::where('version_gantt_id', $ganttId)->whereNotNull('actual_end')->exists(); $actualEndExist = Activity::where('version_gantt_id', $ganttId)->exists();
$query = Activity::where('version_gantt_id', $ganttId); $query = Activity::where('version_gantt_id', $ganttId);
} }
@ -533,11 +539,10 @@ class ProjectController extends Controller
} else { } else {
$startDate = $query->orderBy('start_date')->value('start_date'); $startDate = $query->orderBy('start_date')->value('start_date');
} }
if($actualEndExist)
if ($actualEndExist) { {
$endDate = $query->orderByDesc('actual_end')->value('end_date'); $maxEndDate = $query->max('id');
} else { $endDate = $query->where('id',$maxEndDate)->first()->end_date;
$endDate = $query->orderByDesc('end_date')->value('end_date');
} }
$plannedStart = Activity::where('version_gantt_id', $ganttId) $plannedStart = Activity::where('version_gantt_id', $ganttId)

Loading…
Cancel
Save