Browse Source

Merge pull request 'Dev-Farhan' (#229) from Dev-Farhan into general

Reviewed-on: ordo/adw-backend#229
pull/3/head
farhantock 1 year ago
parent
commit
85631b9866
  1. 49
      app/Helpers/MasterFunctionsHelper.php

49
app/Helpers/MasterFunctionsHelper.php

@ -36,10 +36,11 @@ class MasterFunctionsHelper
return json_decode($output); return json_decode($output);
} }
public static function countDays($ganttId, $start, $end){ public static function countDays($ganttId, $start, $end)
{
$dayOffs = VersionGantt::where('id', $ganttId)->first()->config_dayoff; $dayOffs = VersionGantt::where('id', $ganttId)->first()->config_dayoff;
$diff = date_diff($start, $end); $diff = date_diff($start, $end);
$endCount = clone $end; $endCount = clone $end;
$duration = $diff->days + 1; $duration = $diff->days + 1;
$daysRemaining = $duration; $daysRemaining = $duration;
// Loop until the remaining days become zero // Loop until the remaining days become zero
@ -206,7 +207,7 @@ class MasterFunctionsHelper
$end = new \DateTime($maxDate . ' Friday'); $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 = \DateInterval::createFromDateString('1 day'); */ // should be using this but its bugged
$interval = new \DateInterval('P7D'); $interval = new \DateInterval('P7D');
} else { } else {
$actualMaxDate = DB::table('assign_material_to_activity as ama') $actualMaxDate = DB::table('assign_material_to_activity as ama')
@ -402,7 +403,7 @@ class MasterFunctionsHelper
// if($tempTtlPercentActual >= $keyGantt['progress']) // if($tempTtlPercentActual >= $keyGantt['progress'])
// $tempTtlPercentActual = $keyGantt['progress']; // $tempTtlPercentActual = $keyGantt['progress'];
// todo // todo
// if ($tempTtlPercentPlan >= 100) // if ($tempTtlPercentPlan >= 100)
// $tempTtlPercentPlan = 100; // $tempTtlPercentPlan = 100;
// $sumPercentageActual > $keyGantt['progress'] ? $keyGantt['progress'] : $sumPercentageActual // $sumPercentageActual > $keyGantt['progress'] ? $keyGantt['progress'] : $sumPercentageActual
@ -448,8 +449,8 @@ class MasterFunctionsHelper
$potential = $costDeviation == 0 ? "ON BUDGET" : "OVERRUN"; $potential = $costDeviation == 0 ? "ON BUDGET" : "OVERRUN";
} }
$lastReal = $tempPercentageReal[count($tempPercentageReal) - 1]; $lastReal = $tempPercentageReal[count($tempPercentageReal) - 1];
$totalBCWP = $lastReal * $dataProject->rencana_biaya / 100; $totalBCWP = $lastReal * $dataProject->rencana_biaya / 100;
$dataResponse = array( $dataResponse = array(
"date" => $tempDate, "date" => $tempDate,
"percentage" => $tempPercentage, "percentage" => $tempPercentage,
@ -514,7 +515,7 @@ class MasterFunctionsHelper
$end = new \DateTime($maxDate); $end = new \DateTime($maxDate);
$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 = \DateInterval::createFromDateString('1 day'); */ // should be using this but its bugged
$interval = new \DateInterval('P7D'); $interval = new \DateInterval('P7D');
} else { } else {
// $maxDate = DB::table('assign_material_to_activity as ama') // $maxDate = DB::table('assign_material_to_activity as ama')
@ -655,17 +656,17 @@ class MasterFunctionsHelper
->where('activity_id', '=', $keyActualM->activity_id) ->where('activity_id', '=', $keyActualM->activity_id)
->orderBy('status_activity', 'ASC') ->orderBy('status_activity', 'ASC')
->first(); ->first();
if (!isset($checkStatusActivity)) { if (!isset($checkStatusActivity)) {
$checkStatusActivity = (object) [ $checkStatusActivity = (object) [
'activity_id' => $keyActualM->activity_id, 'activity_id' => $keyActualM->activity_id,
'status_activity' => 'open' 'status_activity' => 'open'
]; ];
} }
if ($sumVolActual->ttl_qty_plan == "0") { if ($sumVolActual->ttl_qty_plan == "0") {
$actual = 0; $actual = 0;
} else { } else {
$actual = $keyActualM->qty / $sumVolActual->ttl_qty_plan; $actual = $keyActualM->qty / $sumVolActual->ttl_qty_plan;
} }
$dataTempReport[$w]['percentage'] = $actual * $keyActualM->bobot_planning; $dataTempReport[$w]['percentage'] = $actual * $keyActualM->bobot_planning;
// $sumPercentageActual+=($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($keyActualM->qty/$sumVolActual->ttl_qty_plan >= 1){
@ -673,7 +674,7 @@ class MasterFunctionsHelper
$sumPercentageActual += $keyActualM->bobot_planning / $reportCount; $sumPercentageActual += $keyActualM->bobot_planning / $reportCount;
// $sumPercentageActual = $sumPercentageActual > $keyGantt['progress'] ? $keyGantt['progress'] : $sumPercentageActual; // $sumPercentageActual = $sumPercentageActual > $keyGantt['progress'] ? $keyGantt['progress'] : $sumPercentageActual;
} else { } else {
if ( $actual >= 1 || (int) $sumVolActual->ttl_qty_plan == (int) $sumReportActual) { if ($actual >= 1 || (int) $sumVolActual->ttl_qty_plan == (int) $sumReportActual) {
$sumPercentageActual += ($actual * $keyActualM->bobot_planning) * (95 / 100); $sumPercentageActual += ($actual * $keyActualM->bobot_planning) * (95 / 100);
// $sumPercentageActual = $sumPercentageActual > $keyGantt['progress'] ? $keyGantt['progress'] : $sumPercentageActual; // $sumPercentageActual = $sumPercentageActual > $keyGantt['progress'] ? $keyGantt['progress'] : $sumPercentageActual;
} else { } else {
@ -708,13 +709,10 @@ class MasterFunctionsHelper
if (isset($dataPayload['period']) && $dataPayload['period'] == 'week') { if (isset($dataPayload['period']) && $dataPayload['period'] == 'week') {
$tempTtlPercentPlan += $sumPercentagePlan; $tempTtlPercentPlan += $sumPercentagePlan;
$tempTtlPercentActual += $sumPercentageActual; $tempTtlPercentActual += $sumPercentageActual;
// todo // todo
// if ($tempTtlPercentPlan >= 100) // if ($tempTtlPercentPlan >= 100)
// $tempTtlPercentPlan = 100; // $tempTtlPercentPlan = 100;
if ($tempTtlPercentPlan >= 100)
$tempTtlPercentPlan = 100;
$currentACWP += $totalACWP; $currentACWP += $totalACWP;
$currentBCWP += $totalBCWP; $currentBCWP += $totalBCWP;
@ -755,7 +753,7 @@ class MasterFunctionsHelper
} }
$lastReal = $tempPercentageReal[count($tempPercentageReal) - 1]; $lastReal = $tempPercentageReal[count($tempPercentageReal) - 1];
$totalBCWP = $lastReal * $dataProject->rencana_biaya / 100; $totalBCWP = $lastReal * $dataProject->rencana_biaya / 100;
$dataResponse = array( $dataResponse = array(
"date" => $tempDate, "date" => $tempDate,
"percentage" => $tempPercentage, "percentage" => $tempPercentage,
@ -820,7 +818,7 @@ class MasterFunctionsHelper
if (isset($dataPayload['end_date'])) { if (isset($dataPayload['end_date'])) {
$maxDate = $dataPayload['end_date']; $maxDate = $dataPayload['end_date'];
$end = new \DateTime($maxDate); $end = new \DateTime($maxDate);
/* $interval = \DateInterval::createFromDateString('1 day'); */// should be using this but its bugged /* $interval = \DateInterval::createFromDateString('1 day'); */ // should be using this but its bugged
$interval = new \DateInterval('P7D'); $interval = new \DateInterval('P7D');
} else { } else {
// $maxDate = DB::table('assign_material_to_activity as ama') // $maxDate = DB::table('assign_material_to_activity as ama')
@ -1009,5 +1007,4 @@ class MasterFunctionsHelper
return $dataFinal; return $dataFinal;
} }
} }

Loading…
Cancel
Save