Browse Source

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

Reviewed-on: ordo/adw-backend#275
pull/1/head
ibnu 10 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);
$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();
}
}

40
app/Helpers/MasterFunctionsHelper.php

@ -468,9 +468,9 @@ class MasterFunctionsHelper
}
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 {
$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())
@ -506,16 +506,16 @@ class MasterFunctionsHelper
}
$period = new \DatePeriod($begin, $interval, $end);
$arr_ActualM = [];
// $arr_ActualM = [];
$tempDate = [];
$tempPercentagePlan = [];
$tempPercentagePlanWhr = [];
$tempPercentageReal = [];
$tempTtlPercentPlan = 0;
$tempTtlPercentActual = 0;
// $tempPercentagePlan = [];
// $tempPercentagePlanWhr = [];
// $tempPercentageReal = [];
// $tempTtlPercentPlan = 0;
// $tempTtlPercentActual = 0;
$currentACWP = 0;
$currentBCWP = 0;
// $currentACWP = 0;
// $currentBCWP = 0;
$dataActivityPlanDate = [];
$progressPlanKomulatifWeek = [];
$progressActualKomulatifWeek = [];
@ -551,11 +551,15 @@ class MasterFunctionsHelper
$dataActivityPlan = [];
$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')){
$progressPlanKomulatifWeek[] += round($tmpProgressPlanWeek,2);
if (new \DateTime($loopDay) < $today) {
if (new \DateTime($loopDay . ' Friday') <= new \DateTime($today . ' Friday')) {
// $tempPercentageReal[] = round($tempTtlPercentActual, 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;
// jika total report > dari planning
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{
// jika total report < dari planning
// $progressActualWeek = ((($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) / $keyActualM->qty_plan)*$keyActualM->bobot_planning;
@ -1431,11 +1435,11 @@ class MasterFunctionsHelper
$dataActivityPlan = [];
$dataActivityActual = [];
$today = new DateTime();
$today = date('Y-m-d');
if (new \DateTime($loopDay) == new \DateTime($loopDay . ' Friday')){
$progressPlanKomulatifWeek[] += round($tmpProgressPlanWeek,2);
if (new \DateTime($loopDay) < $today) {
if (new \DateTime($loopDay . ' Friday') <= new \DateTime($today . ' Friday')) {
// $tempPercentageReal[] = round($tempTtlPercentActual, 2);
$progressActualKomulatifWeek[] += round($tmpProgressActualWeek,2);
}
@ -1681,11 +1685,11 @@ class MasterFunctionsHelper
$dataActivityPlan = [];
$dataActivityActual = [];
$today = new DateTime();
$today = date('Y-m-d');
if (new \DateTime($loopDay) == new \DateTime($loopDay . ' Friday')){
$progressPlanKomulatifWeek[] += round($tmpProgressPlanWeek,2);
if (new \DateTime($loopDay) < $today) {
$progressPlanKomulatifWeek[] += round($tmpProgressPlanWeek,2);
if (new \DateTime($loopDay . ' Friday') <= new \DateTime($today . ' Friday')) {
// $tempPercentageReal[] = round($tempTtlPercentActual, 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();
if($result['type_proyek_id'] === 9)
{
$actualEndExist = Activity::where('proyek_id', $id)->exists();
$query = Activity::where('proyek_id', $id);
// $actualEndExist = Activity::where('proyek_id', $id)->exists();
// $query = Activity::where('proyek_id', $id);
$maxEndDate = Activity::where('proyek_id', $id)->select('end_date')
->orderBy('end_date', 'desc')
->first();
}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);
}
} else {
$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();
$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);
}
@ -556,11 +566,13 @@ class ProjectController extends Controller
} else {
$startDate = $query->orderBy('start_date')->value('start_date');
}
if($actualEndExist)
{
$maxEndDate = $query->max('id');
$endDate = $query->where('id',$maxEndDate)->first()->end_date;
}
// if($actualEndExist)
// {
// // $maxEndDate = $query->max('id');
// // get last end_date
// // $endDate = $query->where('id',$maxEndDate)->first()->end_date;
// }
$plannedStart = Activity::where('version_gantt_id', $ganttId)
->orderBy('planned_start')
@ -569,7 +581,7 @@ class ProjectController extends Controller
->orderByDesc('planned_end')
->value('planned_end');
$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_end = $plannedEnd;
return response()->json(['status'=>'success','code'=> 200,'data'=>$result, 'gantt'=>$ganttId], 200);

Loading…
Cancel
Save