Browse Source

update calculate curva with day

pull/1/head
ibnu 10 months ago
parent
commit
de9b52592d
  1. 404
      app/Helpers/MasterFunctionsHelper.php
  2. 1
      app/Http/Controllers/ActivityController.php
  3. 21
      rest-client.http

404
app/Helpers/MasterFunctionsHelper.php

@ -165,41 +165,26 @@ class MasterFunctionsHelper
public function calculateProgressBasedOnReportMaterialOld($keyGantt)
{
DB::enableQueryLog();
$dataFinal = [];
$dataPayload = [];
$dataPayload['period'] = 'week';
$totalACWP = 0;
$totalBCWP = 0;
$tempPercentage = [];
$dataProject = Project::find($keyGantt['proyek_id']);
$dataHeader = Activity::where('type_activity', 'header')->where("proyek_id", $keyGantt['proyek_id'])->where("version_gantt_id", $keyGantt['id'])->first();
if (isset($dataPayload['end_date']) && $dataPayload['end_date'] > $dataProject->akhir_proyek) {
$dataPayload['end_date'] = $dataProject->akhir_proyek;
}
if ($dataHeader) {
$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");
}
if (!Activity::where("version_gantt_id", $keyGantt['id'])->first())
return $dataFinal;
$alreadyHasReport = DB::table('report_activity_material as a')
->select('a.id')
->join('m_activity as b', 'b.id', '=', 'a.activity_id')
->where('b.version_gantt_id', '=', $keyGantt['id'])
->exists();
// note : delete this
// if(!$alreadyHasReport)
// return $dataFinal;
$minDate = Activity::where('version_gantt_id', $keyGantt['id'])->whereNull('parent_id')->pluck('start_date')->first();
$begin = new \DateTime($minDate . ' Monday');
$begin = new \DateTime($minDate);
$begin->modify('last Monday');
if (isset($dataPayload['end_date'])) {
$maxDate = $dataPayload['end_date'];
@ -226,7 +211,6 @@ class MasterFunctionsHelper
$interval = new \DateInterval('P7D');
}
$period = new \DatePeriod($begin, $interval, $end);
$arr_ActualM = [];
$tempDate = [];
$tempPercentagePlan = [];
@ -234,23 +218,12 @@ class MasterFunctionsHelper
$tempPercentageReal = [];
$tempTtlPercentPlan = 0;
$tempTtlPercentActual = 0;
$currentACWP = 0;
$currentBCWP = 0;
foreach ($period as $dt) {
$minSevenDays = new \Datetime($dt->format("Y-m-d"));
$minSevenDays = $minSevenDays->modify('-7 day')->format("Y-m-d");
$tempDate[] = array($dt->format("Y-m-d"));
// $dataPlanM = DB::table('assign_material_to_activity as ama')
// ->select('ama.activity_id', 'ama.qty_planning', 'ama.plan_date', 'ama.start_activity', 'a.bobot_planning', 'a.biaya_actual', 'a.duration', 'a.persentase_progress')
// ->join('m_activity as a', 'a.id', '=', 'ama.activity_id')
// ->where('ama.proyek_id', '=', $keyGantt['proyek_id'])
// ->where('a.version_gantt_id', '=', $keyGantt['id'])
// ->whereDate('ama.plan_date', '<=',$dt->format("Y-m-d"))
// ->whereDate('ama.plan_date', '>', $minSevenDays)
// ->get();
$activities = DB::table('m_activity AS a')
->join('assign_material_to_activity AS amta', 'amta.activity_id', '=', 'a.id')
->where('a.type_activity', 'task')
@ -259,7 +232,6 @@ class MasterFunctionsHelper
->whereDate('amta.plan_date', '<=', $dt->format("Y-m-d"))
->whereDate('amta.plan_date', '>', $minSevenDays)
->select('a.bobot_planning', 'a.biaya_actual', 'a.duration', 'a.persentase_progress', 'a.id');
$dataPlanM = DB::table('m_activity AS a')
->join('assign_hr_to_activity AS ahta', 'ahta.activity_id', '=', 'a.id')
->where('a.type_activity', 'task')
@ -270,7 +242,6 @@ class MasterFunctionsHelper
->select('a.bobot_planning', 'a.biaya_actual', 'a.duration', 'a.persentase_progress', 'a.id')
->union($activities)
->get();
$dataActualM = DB::table('report_activity_material as ram')
->select('ram.activity_id', 'ram.qty', 'ram.report_date', 'a.bobot_planning', 'a.biaya_actual', 'a.duration', 'a.persentase_progress')
->join('m_activity as a', 'a.id', '=', 'ram.activity_id')
@ -284,7 +255,6 @@ class MasterFunctionsHelper
$sumPercentagePlan = 0;
$totalACWP = isset($totalACWP) ? $totalACWP : 0;
$totalBCWP = isset($totalBCWP) ? $totalBCWP : 0;
foreach ($dataPlanM as $keyPlanM) {
// $sumVolPlan = DB::table(function ($query) use ($keyGantt) {
// $query->select('a.*')
@ -309,9 +279,21 @@ class MasterFunctionsHelper
->where('activity_id', '=', $keyPlanM->id)
->groupBy('activity_id')
->first();
$weekCount = $keyPlanM->duration / $keyPlanM->duration;
$weeklyPlan = $weekCount > 0 ? $sumVolPlan->ttl_qty_plan / $weekCount : 0;
$weeklyProgress = $weeklyPlan / $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning;
if($keyPlanM->duration){
$weekCount = $keyPlanM->duration / 7;
$weeklyPlan = $weekCount >= 1 ? $sumVolPlan->ttl_qty_plan / $weekCount : $sumVolPlan->ttl_qty_plan / $weekCount / 7;
// $weeklyProgress = $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning;
$weeklyProgress = $weeklyPlan / $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning;
// $bobotHari = $keyPlanM->bobot_planning / $keyPlanM->duration;
}else{
// $weeklyProgress = 0;
$weekCount = 1 / 7;
$weeklyPlan = $weekCount >= 1 ? $sumVolPlan->ttl_qty_plan / $weekCount : $sumVolPlan->ttl_qty_plan / $weekCount / 7;
// $weeklyProgress = $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning;
$weeklyProgress = $weeklyPlan / $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning;
}
// $weeklyPlan = $weekCount > 0 ? $keyPlanM->bobot_planning / $weekCount : 0;
// $weeklyProgress = $weeklyPlan * $keyPlanM->bobot_planning;
$dataTempPlan[$x]['activity_id'] = $keyPlanM->id;
@ -333,7 +315,6 @@ class MasterFunctionsHelper
}
$x++;
}
$w = 0;
$dataTempReport = [];
$sumPercentageActual = 0;
@ -384,8 +365,6 @@ class MasterFunctionsHelper
// $sumPercentageActual+=($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning;
// }
// }
$totalACWP += $keyActualM->duration > 0 ? $keyActualM->biaya_actual / $keyActualM->duration : 0;
} catch (\DivisionByZeroError $e) {
return response()->json(['message' => $e->getMessage()]);
@ -393,7 +372,6 @@ class MasterFunctionsHelper
$dataTempReport[$w]['totalacwp'] = $totalACWP;
$w++;
}
$arr_ActualM[] = array(
'date' => $dt->format("Y-m-d"),
'percentPlan' => $sumPercentagePlan,
@ -401,42 +379,30 @@ class MasterFunctionsHelper
'plan' => $dataTempPlan,
'actual' => $dataTempReport,
);
$today = new DateTime();
$date = new DateTime($dt->format("Y-m-d"));
if (isset($dataPayload['period']) && $dataPayload['period'] == 'week') {
$tempTtlPercentPlan += $sumPercentagePlan;
$tempTtlPercentActual += $sumPercentageActual;
// if($tempTtlPercentPlan >= 100 || $tempTtlPercentActual >= $keyGantt['progress'];){
// if($tempTtlPercentActual >= 100)
// $tempTtlPercentActual = 100;
// if($tempTtlPercentPlan >= 100)
// $tempTtlPercentPlan = 100;
// if($tempTtlPercentActual >= $keyGantt['progress'])
// $tempTtlPercentActual = $keyGantt['progress'];
// todo
// if ($tempTtlPercentPlan >= 100)
// $tempTtlPercentPlan = 100;
// $sumPercentageActual > $keyGantt['progress'] ? $keyGantt['progress'] : $sumPercentageActual
// }
$currentACWP += $totalACWP;
$currentBCWP += $totalBCWP;
$tempPercentage[] = array(round($tempTtlPercentPlan, 2), round($tempTtlPercentActual, 2));
$tempPercentagePlan[] = round($tempTtlPercentPlan, 2);
$tempPercentagePlanWhr[] = ["weekly period", $tempPercentagePlan];
if ($date < $today) {
$tempPercentageReal[] = round($tempTtlPercentActual, 2);
}
if ($tempTtlPercentPlan >= 100 && $tempTtlPercentActual >= 100) {
break;
}
} else {
$tempPercentage[] = array(round($sumPercentagePlan, 2), round($sumPercentageActual, 2));
$tempPercentagePlan[] = round($sumPercentagePlan, 2);
if ($date < $today) {
$tempPercentageReal[] = round($sumPercentageActual, 2);
}
}
}
try {
if (round($totalACWP, 0) > $totalRencanaBudget) {
$estimatedCost = round($totalACWP, 0) + 0;
@ -451,14 +417,12 @@ class MasterFunctionsHelper
]);
}
$estimatedCost = $totalACWP > $totalRencanaBudget ? $totalACWP : $totalRencanaBudget;
$costDeviation = $totalRencanaBudget - $estimatedCost;
if ($costDeviation > 0) {
$potential = "SAVING";
} else {
$potential = $costDeviation == 0 ? "ON BUDGET" : "OVERRUN";
}
}
$lastReal = $tempPercentageReal[count($tempPercentageReal) - 1];
$totalBCWP = $lastReal * $dataProject->rencana_biaya / 100;
$dataResponse = array(
@ -478,13 +442,11 @@ class MasterFunctionsHelper
"potential" => $potential,
)
);
$dataFinal[] = array(
"proyek_name" => $dataProject->nama,
"data" => $dataResponse,
"gantt" => $keyGantt
);
return $dataFinal;
}
@ -517,14 +479,14 @@ class MasterFunctionsHelper
$minDate = Activity::where('version_gantt_id', $keyGantt['id'])->whereNull('parent_id')->pluck('start_date')->first();
$begin = new \DateTime($minDate);
$begin->modify('last Monday');
$begin = $begin->modify('-1 day');
if (isset($dataPayload['end_date'])) {
$maxDate = $dataPayload['end_date'];
$end = new \DateTime($maxDate . ' Friday');
$end->modify('next Friday');
$end->modify('next Friday');
// $end->modify('next Friday');
// $end->modify('next Friday');
/* $interval = \DateInterval::createFromDateString('1 day'); */// should be using this but its bugged
$interval = new \DateInterval('P7D');
$interval = new \DateInterval('P1D');
} else {
$actualMaxDate = DB::table('assign_material_to_activity as ama')
->where("ama.proyek_id", $keyGantt['proyek_id'])
@ -538,9 +500,9 @@ class MasterFunctionsHelper
->max("a.planned_end"); // plan date overlapped with assign_material_to_activity's, it should be m_activity'
$maxDate = max(new \DateTime($plannedMaxDate), new \DateTime($actualMaxDate));
$end = new \DateTime($maxDate->format('Y-m-d') . ' Friday');
$end->modify('next Friday');
$end->modify('next Friday');
$interval = new \DateInterval('P7D');
// $end->modify('next Friday');
// $end->modify('next Friday');
$interval = new \DateInterval('P1D');
}
$period = new \DatePeriod($begin, $interval, $end);
@ -554,245 +516,113 @@ class MasterFunctionsHelper
$currentACWP = 0;
$currentBCWP = 0;
$dataActivityPlanDate = [];
$progressPlanKomulatifWeek = [];
$progressActualKomulatifWeek = [];
$dateWeek = [];
$tmpProgressPlanWeek = 0;
$tmpProgressActualWeek = 0;
foreach ($period as $dt) {
$minSevenDays = new \Datetime($dt->format("Y-m-d"));
$minSevenDays = $minSevenDays->modify('-7 day')->format("Y-m-d");
$loopDay = $dt->format("Y-m-d");
//new \Datetime($dt->format("Y-m-d"));
// $minSevenDays = $minSevenDays->modify('-7 day')->format("Y-m-d");
$tempDate[] = array($dt->format("Y-m-d"));
$activities = DB::table('m_activity AS a')
->join('assign_material_to_activity AS amta', 'amta.activity_id', '=', 'a.id')
->where('a.type_activity', 'task')
->where('a.bobot_planning', '>', 0)
->where('a.version_gantt_id', $keyGantt['id'])
->whereDate('amta.plan_date', '<=', $dt->format("Y-m-d"))
->whereDate('amta.plan_date', '>', $minSevenDays)
->select('a.bobot_planning', 'a.biaya_actual', 'a.duration', 'a.persentase_progress', 'a.id');
$dataPlanM = DB::table('m_activity AS a')
->join('assign_hr_to_activity AS ahta', 'ahta.activity_id', '=', 'a.id')
->where('a.type_activity', 'task')
->where('a.bobot_planning', '>', 0)
->where('a.version_gantt_id', $keyGantt['id'])
->whereDate('a.start_date', '<=', $dt->format("Y-m-d"))
->whereDate('a.start_date', '>', $minSevenDays)
->select('a.bobot_planning', 'a.biaya_actual', 'a.duration', 'a.persentase_progress', 'a.id')
->union($activities)
->get();
$dataPlanM = DB::table('m_activity')
->where('type_activity', 'task')
->where('bobot_planning', '>', 0)
->where('version_gantt_id', $keyGantt['id'])
->whereDate('planned_start', '<=', $loopDay)
->whereDate('planned_end', '>=', $loopDay)
->select('name', 'bobot_planning', 'biaya_actual', 'duration', 'persentase_progress', 'id')
->get();
$dataActualM = DB::table('report_activity_material as ram')
->select('ram.activity_id', 'ram.qty', 'ram.report_date', 'a.bobot_planning', 'a.biaya_actual', 'a.duration', 'a.persentase_progress')
->join('m_activity as a', 'a.id', '=', 'ram.activity_id')
->where('a.version_gantt_id', '=', $keyGantt['id'])
->where('a.proyek_id', '=', $keyGantt['proyek_id'])
->whereDate('ram.report_date', '<=', $dt->format("Y-m-d"))
->whereDate('ram.report_date', '>', $minSevenDays)
->join('m_activity as ma', 'ma.id', '=', 'ram.activity_id')
->select('ram.activity_id', 'ram.qty as qty_actual', 'ma.bobot_planning', 'ma.name',
DB::raw('(SELECT SUM(amta.qty_planning) FROM assign_material_to_activity amta WHERE amta.activity_id = ram.activity_id) AS qty_plan'),
DB::raw('(SELECT SUM(ram.qty) FROM report_activity_material ram WHERE ram.activity_id = ma.id) AS sum_qty_actual'),
DB::raw('(SELECT DISTINCT status_activity FROM assign_material_to_activity amta WHERE amta.activity_id = ram.activity_id) AS status_activity')
)
->where('ram.report_date', $loopDay)
->where('ma.version_gantt_id', $keyGantt['id'])
->get();
$dataTempPlan = [];
$x = 0;
$sumPercentagePlan = 0;
$totalACWP = isset($totalACWP) ? $totalACWP : 0;
$totalBCWP = isset($totalBCWP) ? $totalBCWP : 0;
foreach ($dataPlanM as $keyPlanM) {
// $sumVolPlan = DB::table(function ($query) use ($keyGantt) {
// $query->select('a.*')
// ->from('m_activity AS a')
// ->join('assign_material_to_activity as amta', 'amta.activity_id', '=', 'a.id')
// ->where('a.type_activity', 'task')
// ->where('a.bobot_planning', '>', 0)
// ->where('a.version_gantt_id', $keyGantt['id'])
// ->unionAll(function ($query) use ($keyGantt) {
// $query->select('a.*')
// ->from('m_activity AS a')
// ->join('assign_hr_to_activity as ahta', 'ahta.activity_id', '=', 'a.id')
// ->where('a.type_activity', 'task')
// ->where('a.bobot_planning', '>', 0)
// ->where('a.version_gantt_id', $keyGantt['id']);
// })
// ->orderBy('id', 'asc');
// }, 'subquery')
// ->sum('bobot_planning');
$sumVolPlan = DB::table('assign_material_to_activity')
->select('activity_id', DB::raw('SUM(qty_planning) as ttl_qty_plan'))
->where('activity_id', '=', $keyPlanM->id)
->groupBy('activity_id')
->first();
if($keyPlanM->duration){
$weekCount = $keyPlanM->duration / 7;
$weeklyPlan = $weekCount >= 1 ? $sumVolPlan->ttl_qty_plan / $weekCount : $sumVolPlan->ttl_qty_plan / $weekCount / 7;
// $weeklyProgress = $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning;
$weeklyProgress = $weeklyPlan / $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning;
// $bobotHari = $keyPlanM->bobot_planning / $keyPlanM->duration;
}else{
// $weeklyProgress = 0;
$weekCount = 1 / 7;
$weeklyPlan = $weekCount >= 1 ? $sumVolPlan->ttl_qty_plan / $weekCount : $sumVolPlan->ttl_qty_plan / $weekCount / 7;
// $weeklyProgress = $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning;
$weeklyProgress = $weeklyPlan / $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning;
$dataActivityPlan = [];
$dataActivityActual = [];
$today = new DateTime();
if (new \DateTime($loopDay) == new \DateTime($loopDay . ' Friday')){
$progressPlanKomulatifWeek[] += round($tmpProgressPlanWeek,2);
if (new \DateTime($loopDay) < $today) {
// $tempPercentageReal[] = round($tempTtlPercentActual, 2);
$progressActualKomulatifWeek[] += round($tmpProgressActualWeek,2);
}
// $weeklyPlan = $weekCount > 0 ? $keyPlanM->bobot_planning / $weekCount : 0;
// $weeklyProgress = $weeklyPlan * $keyPlanM->bobot_planning;
$dataTempPlan[$x]['activity_id'] = $keyPlanM->id;
$dataTempPlan[$x]['bobot_planning'] = $keyPlanM->bobot_planning;
$dataTempPlan[$x]['ttl_plan'] = $sumVolPlan;
$dataTempPlan[$x]['biaya_actual'] = $keyPlanM->biaya_actual;
$dataTempPlan[$x]['duration'] = $keyPlanM->duration;
$dataTempPlan[$x]['persentase_progress'] = $keyPlanM->persentase_progress;
try {
$dataTempPlan[$x]['percentage'] = $keyPlanM->bobot_planning;
$sumPercentagePlan += $weeklyProgress;
if (isset($keyPlanM->duration) && $keyPlanM->duration > 0)
$totalBCWP += (((($keyPlanM->persentase_progress * $keyPlanM->bobot_planning) / 100) / $keyPlanM->duration) * $totalRencanaBudget) / 100;
else
$totalBCWP = 0;
$dataTempPlan[$x]['totalBCWP'] = $totalBCWP;
} catch (\DivisionByZeroError $e) {
return response()->json(['message' => $e->getMessage()]);
}
$x++;
$dateWeek[] = [$loopDay];
// $tmpProgressPlanWeek = 0;
// $tmpProgressActualWeek = 0;
}
$w = 0;
$dataTempReport = [];
$sumPercentageActual = 0;
foreach ($dataActualM as $keyActualM) {
$sumVolActual = DB::table('assign_material_to_activity')
->select('activity_id', DB::raw('SUM(qty_planning) as ttl_qty_plan'))
->where('activity_id', '=', $keyActualM->activity_id)
->groupBy('activity_id')
->first();
$sumReportActual = DB::table('report_activity_material')
->where('activity_id', $keyActualM->activity_id)
->sum('qty');
$reportCount = DB::table('report_activity_material')->where('activity_id', '=', $keyActualM->activity_id)->count();
$dataTempReport[$w]['activity_id'] = $keyActualM->activity_id;
$dataTempReport[$w]['qty'] = $keyActualM->qty;
$dataTempReport[$w]['report_date'] = $keyActualM->report_date;
$dataTempReport[$w]['bobot_planning'] = $keyActualM->bobot_planning;
$dataTempReport[$w]['ttl_plan'] = $sumVolActual->ttl_qty_plan;
$dataTempReport[$w]['biaya_actual'] = $keyActualM->biaya_actual;
$dataTempReport[$w]['duration'] = $keyActualM->duration;
$dataTempReport[$w]['persentase_progress'] = $keyActualM->persentase_progress;
try {
// assign_material_to_activity
$checkStatusActivity = DB::table('assign_material_to_activity')
->select('activity_id', 'status_activity')
->where('activity_id', '=', $keyActualM->activity_id)
->orderBy('status_activity', 'ASC')
->first();
$dataTempReport[$w]['percentage'] = ($keyActualM->qty / $sumVolActual->ttl_qty_plan) * $keyActualM->bobot_planning;
// $sumPercentageActual+=($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning;
// if($keyActualM->qty/$sumVolActual->ttl_qty_plan >= 1){
if ($checkStatusActivity->status_activity == 'done') {
$sumPercentageActual += $keyActualM->bobot_planning / $reportCount;
// $sumPercentageActual = $sumPercentageActual > $keyGantt['progress'] ? $keyGantt['progress'] : $sumPercentageActual;
} else {
if ($keyActualM->qty / $sumVolActual->ttl_qty_plan >= 1 || (int) $sumVolActual->ttl_qty_plan == (int) $sumReportActual) {
$sumPercentageActual += (($keyActualM->qty / $sumVolActual->ttl_qty_plan) * $keyActualM->bobot_planning) * (95 / 100);
// $sumPercentageActual = $sumPercentageActual > $keyGantt['progress'] ? $keyGantt['progress'] : $sumPercentageActual;
} else {
$sumPercentageActual += ($keyActualM->qty / $sumVolActual->ttl_qty_plan) * $keyActualM->bobot_planning;
// $sumPercentageActual = $sumPercentageActual > $keyGantt['progress'] ? $keyGantt['progress'] : $sumPercentageActual;
}
}
// }else {
// if($checkStatusActivity->status_activity == 'done'){
// $sumPercentageActual+=($keyActualM->qty/$keyActualM->qty)*$keyActualM->bobot_planning;
// }else{
// $sumPercentageActual+=($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning;
// }
// }
$totalACWP += $keyActualM->duration > 0 ? $keyActualM->biaya_actual / $keyActualM->duration : 0;
} catch (\DivisionByZeroError $e) {
return response()->json(['message' => $e->getMessage()]);
}
$dataTempReport[$w]['totalacwp'] = $totalACWP;
$w++;
// $progressPlanKomulatifWeek[] += $tmpProgressPlanWeek;
foreach ($dataPlanM as $keyPlanM) {
# hitung untuk persentase progress planning
$dataActivityPlan[] = array(
'progressPlanDay' => $keyPlanM->bobot_planning / $keyPlanM->duration,
'name' => $keyPlanM->name,
'bobot_p' => $keyPlanM->bobot_planning,
'duration' => $keyPlanM->duration
);
$tmpProgressPlanWeek += $keyPlanM->bobot_planning / $keyPlanM->duration;
}
$arr_ActualM[] = array(
'date' => $dt->format("Y-m-d"),
'percentPlan' => $sumPercentagePlan,
'percentActual' => $sumPercentageActual,
'plan' => $dataTempPlan,
'actual' => $dataTempReport,
);
$today = new DateTime();
$date = new DateTime($dt->format("Y-m-d"));
if (isset($dataPayload['period']) && $dataPayload['period'] == 'week') {
$tempTtlPercentPlan += $sumPercentagePlan;
$tempTtlPercentActual += $sumPercentageActual;
$currentACWP += $totalACWP;
$currentBCWP += $totalBCWP;
$tempPercentage[] = array(round($tempTtlPercentPlan, 2), round($tempTtlPercentActual, 2));
$tempPercentagePlan[] = round($tempTtlPercentPlan, 2);
$tempPercentagePlanWhr[] = ["weekly period", $tempPercentagePlan];
if ($date < $today) {
$tempPercentageReal[] = round($tempTtlPercentActual, 2);
// hitung progress actual
foreach ($dataActualM as $keyActualM) {
# hitung untuk persentase progress actual
// $progressActualWeek = ((((($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) / $keyActualM->qty_plan)*100)*$keyActualM->bobot_planning)/100;
if($keyActualM->sum_qty_actual > $keyActualM->qty_plan){
$progressActualWeek = (($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) *$keyActualM->bobot_planning/100;
}else{
$progressActualWeek = ((($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) / $keyActualM->qty_plan)*$keyActualM->bobot_planning;
}
if ($tempTtlPercentPlan >= 100 && $tempTtlPercentActual >= 100) {
break;
if($keyActualM->status_activity == 'done'){
$progressActualWeek = $progressActualWeek > $keyActualM->bobot_planning ? $keyActualM->bobot_planning : $progressActualWeek;
}
} else {
$tempPercentage[] = array(round($sumPercentagePlan, 2), round($sumPercentageActual, 2));
$tempPercentagePlan[] = round($sumPercentagePlan, 2);
if ($date < $today) {
$tempPercentageReal[] = round($sumPercentageActual, 2);
else{
$progressActualWeek = $progressActualWeek > ($keyActualM->bobot_planning*95)/100 ? ($keyActualM->bobot_planning*95)/100 : $progressActualWeek;
}
$dataActivityActual[] = array(
'progressActualDay' => $progressActualWeek,
'qty_act' => $keyActualM->qty_actual,
'bobot_p' => $keyActualM->bobot_planning,
'qty_plan' => $keyActualM->qty_plan,
'status_activity' => $keyActualM->status_activity,
'sum_qty_actual' => $keyActualM->sum_qty_actual,
'name' => $keyActualM->name
);
$tmpProgressActualWeek += $progressActualWeek;
}
}
try {
if (round($totalACWP, 0) > $totalRencanaBudget) {
$estimatedCost = round($totalACWP, 0) + 0;
} else {
$estimatedCost = ($totalRencanaBudget + 0);
}
} catch (\DivisionByZeroError $e) {
return response()->json([
'message' => $e->getMessage(),
"line" => 566,
'gantt' => $keyGantt,
]);
$dataActivityPlanDate[] = array(
"date" => $loopDay,
"statusWeek" => new \DateTime($loopDay) == new \DateTime($loopDay . ' Friday') ? true : false,
"activity-plan" => $dataActivityPlan,
"activity-actual" => $dataActivityActual,
"tmpProgressActualWeek" => $tmpProgressActualWeek,
"progressPlanWeek" => $tmpProgressPlanWeek
);
}
$estimatedCost = $totalACWP > $totalRencanaBudget ? $totalACWP : $totalRencanaBudget;
$costDeviation = $totalRencanaBudget - $estimatedCost;
if ($costDeviation > 0) {
$potential = "SAVING";
} else {
$potential = $costDeviation == 0 ? "ON BUDGET" : "OVERRUN";
}
$lastReal = $tempPercentageReal[count($tempPercentageReal) - 1];
$totalBCWP = $lastReal * $dataProject->rencana_biaya / 100;
$dataResponse = array(
"date" => $tempDate,
"percentage" => $tempPercentage,
"percentagePlan" => $tempPercentagePlan,
"percentageReal" => $tempPercentageReal,
"data_details" => $arr_ActualM,
"budget_control" => array(
"current_budget" => $totalRencanaBudget,
"acwp" => round($totalACWP, 0),
"bcwp" => round($totalBCWP, 0),
"rem_to_complete" => ($totalRencanaBudget - round($totalACWP, 0)),
"add_cost_to_complete" => 0,
"estimated_at_completion" => $estimatedCost,
"cost_deviation" => $costDeviation,
"potential" => $potential,
)
);
$dataFinal[] = array(
// "date" => $dateWeek,
"proyek_name" => $dataProject->nama,
"data" => $dataResponse,
"data" => ["date" => $dateWeek,
"percentagePlan" => $progressPlanKomulatifWeek,
"percentageActual" => $progressActualKomulatifWeek,
"data_details" => $dataActivityPlanDate
],
"gantt" => $keyGantt
);

1
app/Http/Controllers/ActivityController.php

@ -604,6 +604,7 @@ class ActivityController extends Controller
$activityToUpdate = $activity->firstWhere('id', $entity['data']['id']);
$entity['data']['name'] = $entity['data']['text'];
$entity['data']['persentase_progress'] = $entity['data']['progress'] * 100;
$entity['data']['type_activity'] = $entity['data']['type'];
if (isset($entity['data']['rencana_biaya'])) {
$entity['data']['rencana_biaya'] = str_replace(",", ".", $entity['data']['rencana_biaya']);
}

21
rest-client.http

@ -1,4 +1,4 @@
@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9iYWNrZW5kLnRlc3RcL2FwaVwvbG9naW4iLCJpYXQiOjE3MDA0NTA1ODYsImV4cCI6MTcwMTA1NTM4NiwibmJmIjoxNzAwNDUwNTg2LCJqdGkiOiJack9MMU04UGdKWGkwTUU1Iiwic3ViIjoxLCJwcnYiOiIyM2JkNWM4OTQ5ZjYwMGFkYjM5ZTcwMWM0MDA4NzJkYjdhNTk3NmY3In0.fyg6CyiCAcX3GD4iSy8urkHpZEJ4mnXSXQc4NKC8U9A
@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9iYWNrZW5kLnRlc3RcL2FwaVwvbG9naW4iLCJpYXQiOjE3MDEzNzMzNzQsImV4cCI6MTcwMTk3ODE3NCwibmJmIjoxNzAxMzczMzc0LCJqdGkiOiJhbkJWOHIwUDZndFRXZk5KIiwic3ViIjoxNzg4LCJwcnYiOiIyM2JkNWM4OTQ5ZjYwMGFkYjM5ZTcwMWM0MDA4NzJkYjdhNTk3NmY3In0.QCiXq-62da7Sdk7sEb_J0apEij_R6IQgZVYG9iL6M8g
@tokenS = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9hZHctYXBpLm9zcHJvLmlkXC9hcGlcL2xvZ2luIiwiaWF0IjoxNjkxNTcyMTIwLCJleHAiOjE2OTIxNzY5MjAsIm5iZiI6MTY5MTU3MjEyMCwianRpIjoiVUdqbnhLRVdlZzYyTTBnayIsInN1YiI6MSwicHJ2IjoiMjNiZDVjODk0OWY2MDBhZGIzOWU3MDFjNDAwODcyZGI3YTU5NzZmNyJ9.5QqK0dLW5jzbVOkSCSW0mFo0K7ycGOBW9NCG_2Zldm4
@ -18,8 +18,8 @@ POST {{hostname}}/login
content-type: application/json
{
"username": "admin",
"password": "1nt3gr4s14"
"username": "testing",
"password": "testing123"
}
###### Tools Req
@ -835,8 +835,9 @@ POST {{hostname}}/project/s-curve-command-test
Authorization: Bearer {{token}}
content-type: application/json
{"period":"week","project_id":"129","gantt_id":"862"}
### {"period":"week","project_id":"129","gantt_id":"862"}
# {"period":"week","project_id":"137","gantt_id":"916"}
# {"period":"week","project_id":"129","gantt_id":"862"}
{"period":"week","project_id":"140","gantt_id":"1103"}
###
POST {{hostname}}/project/calculate-s-curve
@ -851,8 +852,14 @@ POST {{hostname}}/project/get-s-curve
Authorization: Bearer {{token}}
content-type: application/json
{"period":"week","project_id":"129","gantt_id":"800"}
### {"period":"week","project_id":"135","gantt_id":"891"}
{"project_id":"164","gantt_id":"973","period":"week"}
### {"period":"week","project_id":"129","gantt_id":"800"}
#######
GET {{hostname}}/activity/s-curve/137/892
Authorization: Bearer {{token}}
content-type: application/json
###
GET https://adw-api.ospro.id/api/request-material/get-material-integration?name=c

Loading…
Cancel
Save