Browse Source

Merge pull request 'staging' (#275) from staging into master

Reviewed-on: ordo/adw-backend#275
pull/1/head
ibnu 11 months ago
parent
commit
ea084ac7d9
  1. 2
      app/Console/Commands/CalculateProgressGantt.php
  2. 40
      app/Helpers/MasterFunctionsHelper.php
  3. 32
      app/Http/Controllers/ProjectController.php

2
app/Console/Commands/CalculateProgressGantt.php

@ -22,7 +22,7 @@ class CalculateProgressGantt extends Command
$data = MasterFunctionsHelper::calculateSCurveForProgressTree($hierarchy_id); $data = MasterFunctionsHelper::calculateSCurveForProgressTree($hierarchy_id);
$hierarchy->bobot_planning = 100; $hierarchy->bobot_planning = 100;
$hierarchy->progress =((int) end($data[0]['data']['percentageReal']) / (int) end($data[0]['data']['percentagePlan'])) * 100; $hierarchy->progress =round(((int) end($data[0]['data']['percentageReal']) / (int) end($data[0]['data']['percentagePlan'])) * 100, 2);
$hierarchy->save(); $hierarchy->save();
} }
} }

40
app/Helpers/MasterFunctionsHelper.php

@ -468,9 +468,9 @@ class MasterFunctionsHelper
} }
if ($dataHeader) { if ($dataHeader) {
$totalRencanaBudget = Activity::where('parent_id', $dataHeader->id)->where("proyek_id", $keyGantt['proyek_id'])->where("version_gantt_id", $keyGantt['id'])->sum("rencana_biaya"); // $totalRencanaBudget = Activity::where('parent_id', $dataHeader->id)->where("proyek_id", $keyGantt['proyek_id'])->where("version_gantt_id", $keyGantt['id'])->sum("rencana_biaya");
} else { } else {
$totalRencanaBudget = Activity::whereNull('parent_id')->where("proyek_id", $keyGantt['proyek_id'])->where("version_gantt_id", $keyGantt['id'])->sum("rencana_biaya"); // $totalRencanaBudget = Activity::whereNull('parent_id')->where("proyek_id", $keyGantt['proyek_id'])->where("version_gantt_id", $keyGantt['id'])->sum("rencana_biaya");
} }
if (!Activity::where("version_gantt_id", $keyGantt['id'])->first()) if (!Activity::where("version_gantt_id", $keyGantt['id'])->first())
@ -506,16 +506,16 @@ class MasterFunctionsHelper
} }
$period = new \DatePeriod($begin, $interval, $end); $period = new \DatePeriod($begin, $interval, $end);
$arr_ActualM = []; // $arr_ActualM = [];
$tempDate = []; $tempDate = [];
$tempPercentagePlan = []; // $tempPercentagePlan = [];
$tempPercentagePlanWhr = []; // $tempPercentagePlanWhr = [];
$tempPercentageReal = []; // $tempPercentageReal = [];
$tempTtlPercentPlan = 0; // $tempTtlPercentPlan = 0;
$tempTtlPercentActual = 0; // $tempTtlPercentActual = 0;
$currentACWP = 0; // $currentACWP = 0;
$currentBCWP = 0; // $currentBCWP = 0;
$dataActivityPlanDate = []; $dataActivityPlanDate = [];
$progressPlanKomulatifWeek = []; $progressPlanKomulatifWeek = [];
$progressActualKomulatifWeek = []; $progressActualKomulatifWeek = [];
@ -551,11 +551,15 @@ class MasterFunctionsHelper
$dataActivityPlan = []; $dataActivityPlan = [];
$dataActivityActual = []; $dataActivityActual = [];
$today = new DateTime(); $today = date('Y-m-d');
$statusCutOfDate = false;
// if (new \DateTime($loopDay) < $today) {
// $statusCutOfDate = true;
// }
if (new \DateTime($loopDay) == new \DateTime($loopDay . ' Friday')){ if (new \DateTime($loopDay) == new \DateTime($loopDay . ' Friday')){
$progressPlanKomulatifWeek[] += round($tmpProgressPlanWeek,2); $progressPlanKomulatifWeek[] += round($tmpProgressPlanWeek,2);
if (new \DateTime($loopDay) < $today) { if (new \DateTime($loopDay . ' Friday') <= new \DateTime($today . ' Friday')) {
// $tempPercentageReal[] = round($tempTtlPercentActual, 2); // $tempPercentageReal[] = round($tempTtlPercentActual, 2);
$progressActualKomulatifWeek[] += round($tmpProgressActualWeek,2); $progressActualKomulatifWeek[] += round($tmpProgressActualWeek,2);
} }
@ -599,7 +603,7 @@ class MasterFunctionsHelper
// $progressActualWeek = ((((($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) / $keyActualM->qty_plan)*100)*$keyActualM->bobot_planning)/100; // $progressActualWeek = ((((($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) / $keyActualM->qty_plan)*100)*$keyActualM->bobot_planning)/100;
// jika total report > dari planning // jika total report > dari planning
if($keyActualM->sum_qty_actual > $keyActualM->qty_plan){ if($keyActualM->sum_qty_actual > $keyActualM->qty_plan){
$progressActualWeek = (($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) *$keyActualM->bobot_planning/100; $progressActualWeek = ($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * $keyActualM->bobot_planning;
}else{ }else{
// jika total report < dari planning // jika total report < dari planning
// $progressActualWeek = ((($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) / $keyActualM->qty_plan)*$keyActualM->bobot_planning; // $progressActualWeek = ((($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) / $keyActualM->qty_plan)*$keyActualM->bobot_planning;
@ -1431,11 +1435,11 @@ class MasterFunctionsHelper
$dataActivityPlan = []; $dataActivityPlan = [];
$dataActivityActual = []; $dataActivityActual = [];
$today = new DateTime(); $today = date('Y-m-d');
if (new \DateTime($loopDay) == new \DateTime($loopDay . ' Friday')){ if (new \DateTime($loopDay) == new \DateTime($loopDay . ' Friday')){
$progressPlanKomulatifWeek[] += round($tmpProgressPlanWeek,2); $progressPlanKomulatifWeek[] += round($tmpProgressPlanWeek,2);
if (new \DateTime($loopDay) < $today) { if (new \DateTime($loopDay . ' Friday') <= new \DateTime($today . ' Friday')) {
// $tempPercentageReal[] = round($tempTtlPercentActual, 2); // $tempPercentageReal[] = round($tempTtlPercentActual, 2);
$progressActualKomulatifWeek[] += round($tmpProgressActualWeek,2); $progressActualKomulatifWeek[] += round($tmpProgressActualWeek,2);
} }
@ -1681,11 +1685,11 @@ class MasterFunctionsHelper
$dataActivityPlan = []; $dataActivityPlan = [];
$dataActivityActual = []; $dataActivityActual = [];
$today = new DateTime(); $today = date('Y-m-d');
if (new \DateTime($loopDay) == new \DateTime($loopDay . ' Friday')){ if (new \DateTime($loopDay) == new \DateTime($loopDay . ' Friday')){
$progressPlanKomulatifWeek[] += round($tmpProgressPlanWeek,2); $progressPlanKomulatifWeek[] += round($tmpProgressPlanWeek,2);
if (new \DateTime($loopDay) < $today) { if (new \DateTime($loopDay . ' Friday') <= new \DateTime($today . ' Friday')) {
// $tempPercentageReal[] = round($tempTtlPercentActual, 2); // $tempPercentageReal[] = round($tempTtlPercentActual, 2);
$progressActualKomulatifWeek[] += round($tmpProgressActualWeek,2); $progressActualKomulatifWeek[] += round($tmpProgressActualWeek,2);
} }

32
app/Http/Controllers/ProjectController.php

@ -538,16 +538,26 @@ class ProjectController extends Controller
$actualStartExist = Activity::where('proyek_id', $id)->whereNotNull('actual_start')->exists(); $actualStartExist = Activity::where('proyek_id', $id)->whereNotNull('actual_start')->exists();
if($result['type_proyek_id'] === 9) if($result['type_proyek_id'] === 9)
{ {
$actualEndExist = Activity::where('proyek_id', $id)->exists(); // $actualEndExist = Activity::where('proyek_id', $id)->exists();
$query = Activity::where('proyek_id', $id); // $query = Activity::where('proyek_id', $id);
$maxEndDate = Activity::where('proyek_id', $id)->select('end_date')
->orderBy('end_date', 'desc')
->first();
}else{ }else{
$actualEndExist = Activity::where('version_gantt_id', $ganttId)->exists(); // $actualEndExist = Activity::where('version_gantt_id', $ganttId)->exists();
$maxEndDate = Activity::where('version_gantt_id', $ganttId)->select('end_date')
->orderBy('end_date', 'desc')
->first();
$query = Activity::where('version_gantt_id', $ganttId); $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)->exists(); // $actualEndExist = Activity::where('version_gantt_id', $ganttId)->exists();
$maxEndDate = Activity::where('version_gantt_id', $ganttId)->select('end_date')
->orderBy('end_date', 'desc')
->first();
$query = Activity::where('version_gantt_id', $ganttId); $query = Activity::where('version_gantt_id', $ganttId);
} }
@ -556,11 +566,13 @@ 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)
{ // {
$maxEndDate = $query->max('id'); // // $maxEndDate = $query->max('id');
$endDate = $query->where('id',$maxEndDate)->first()->end_date; // // get last end_date
} // // $endDate = $query->where('id',$maxEndDate)->first()->end_date;
// }
$plannedStart = Activity::where('version_gantt_id', $ganttId) $plannedStart = Activity::where('version_gantt_id', $ganttId)
->orderBy('planned_start') ->orderBy('planned_start')
@ -569,7 +581,7 @@ class ProjectController extends Controller
->orderByDesc('planned_end') ->orderByDesc('planned_end')
->value('planned_end'); ->value('planned_end');
$result->header->start_date = $startDate; $result->header->start_date = $startDate;
$result->header->end_date = $endDate; $result->header->end_date = $maxEndDate->end_date;
$result->header->planned_start = $plannedStart; $result->header->planned_start = $plannedStart;
$result->header->planned_end = $plannedEnd; $result->header->planned_end = $plannedEnd;
return response()->json(['status'=>'success','code'=> 200,'data'=>$result, 'gantt'=>$ganttId], 200); return response()->json(['status'=>'success','code'=> 200,'data'=>$result, 'gantt'=>$ganttId], 200);

Loading…
Cancel
Save