|
|
|
@ -542,7 +542,8 @@ class MasterFunctionsHelper
|
|
|
|
|
->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') |
|
|
|
|
DB::raw('(SELECT DISTINCT status_activity FROM assign_material_to_activity amta WHERE amta.activity_id = ram.activity_id) AS status_activity'), |
|
|
|
|
DB::raw('(SELECT COUNT(id) FROM report_activity_material ram WHERE ram.activity_id = ma.id) AS count_report') |
|
|
|
|
) |
|
|
|
|
->where('ram.report_date', $loopDay) |
|
|
|
|
->where('ma.version_gantt_id', $keyGantt['id']) |
|
|
|
@ -563,18 +564,25 @@ class MasterFunctionsHelper
|
|
|
|
|
// $progressPlanKomulatifWeek[] += $tmpProgressPlanWeek; |
|
|
|
|
foreach ($dataPlanM as $keyPlanM) { |
|
|
|
|
# hitung untuk persentase progress planning |
|
|
|
|
if($keyPlanM->duration == 0){ |
|
|
|
|
$duration = 2; |
|
|
|
|
}else{ |
|
|
|
|
$duration = $keyPlanM->duration + 1; |
|
|
|
|
} |
|
|
|
|
// if($keyPlanM->duration == 0){ |
|
|
|
|
// $duration = 2; |
|
|
|
|
// Tanggal awal |
|
|
|
|
$startDate = new DateTime($keyPlanM->planned_start); |
|
|
|
|
// Tanggal akhir |
|
|
|
|
$endDate = new DateTime($keyPlanM->planned_end); |
|
|
|
|
// Menghitung selisih hari |
|
|
|
|
$interval = $startDate->diff($endDate); |
|
|
|
|
// Mengambil hasil selisih hari |
|
|
|
|
$duration = (int) $interval->days+1; |
|
|
|
|
// }else{ |
|
|
|
|
// $duration = $keyPlanM->duration + 2; |
|
|
|
|
// } |
|
|
|
|
// $startPlan = new DateTime($keyPlanM->planned_start); |
|
|
|
|
// $endPlan = new DateTime($keyPlanM->planned_end); |
|
|
|
|
// $interval = $startPlan->diff($endPlan); |
|
|
|
|
|
|
|
|
|
// // Mengambil hasil selisih hari |
|
|
|
|
// $duration = $interval->days; |
|
|
|
|
|
|
|
|
|
$progressPlanWeek = $keyPlanM->bobot_planning / $duration; |
|
|
|
|
$dataActivityPlan[] = array( |
|
|
|
|
'progressPlanDay' => $progressPlanWeek, |
|
|
|
@ -589,13 +597,36 @@ class MasterFunctionsHelper
|
|
|
|
|
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; |
|
|
|
|
// 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; |
|
|
|
|
}else{ |
|
|
|
|
$progressActualWeek = ((($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) / $keyActualM->qty_plan)*$keyActualM->bobot_planning; |
|
|
|
|
// jika total report < dari planning |
|
|
|
|
// $progressActualWeek = ((($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) / $keyActualM->qty_plan)*$keyActualM->bobot_planning; |
|
|
|
|
if($keyActualM->qty_actual == 0){ |
|
|
|
|
$progressActualWeek = 0; |
|
|
|
|
}else{ |
|
|
|
|
$progressActualWeek = ($keyActualM->qty_actual / $keyActualM->qty_plan) * $keyActualM->bobot_planning; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if($keyActualM->status_activity == 'done'){ |
|
|
|
|
$progressActualWeek = $progressActualWeek > $keyActualM->bobot_planning ? $keyActualM->bobot_planning : $progressActualWeek; |
|
|
|
|
// if($keyActualM->count_report > 1){ |
|
|
|
|
// $progressActualWeek = $keyActualM->bobot_planning/$keyActualM->count_report; |
|
|
|
|
// }else{ |
|
|
|
|
$progressActualWeek = $keyActualM->bobot_planning / $keyActualM->count_report; |
|
|
|
|
// } |
|
|
|
|
// if($progressActualWeek > $keyActualM->bobot_planning){ |
|
|
|
|
// $progressActualWeek = $keyActualM->bobot_planning; |
|
|
|
|
// }else if($keyActualM->qty_actual == 0){ |
|
|
|
|
// $progressActualWeek = $keyActualM->bobot_planning; |
|
|
|
|
// }else if($keyActualM->qty_plan == $keyActualM->sum_qty_actual){ |
|
|
|
|
// $progressActualWeek = $keyActualM->bobot_planning; |
|
|
|
|
// }else { |
|
|
|
|
// $progressActualWeek = $progressActualWeek; |
|
|
|
|
// } |
|
|
|
|
// $progressActualWeek = $progressActualWeek > $keyActualM->bobot_planning ? $keyActualM->bobot_planning : $progressActualWeek; |
|
|
|
|
// jika report lebih dari 1 x, maka harusnya di bagi sabanyak jumlah report, |
|
|
|
|
// contoh ada 3 report, report ke 1 adalah 5 maka 100/3 dan di looping |
|
|
|
|
} |
|
|
|
|
else{ |
|
|
|
|
$progressActualWeek = $progressActualWeek > ($keyActualM->bobot_planning*95)/100 ? ($keyActualM->bobot_planning*95)/100 : $progressActualWeek; |
|
|
|
@ -1328,23 +1359,23 @@ class MasterFunctionsHelper
|
|
|
|
|
} else { |
|
|
|
|
$maxDate = $dataProject->akhir_proyek; |
|
|
|
|
$end = new \DateTime($maxDate); |
|
|
|
|
$end = new \DateTime($maxDate->format('Y-m-d') . ' Friday'); |
|
|
|
|
$end = new \DateTime($end->format('Y-m-d') . ' Friday'); |
|
|
|
|
// $end->modify('next Friday'); |
|
|
|
|
// $end->modify('next Friday'); |
|
|
|
|
$interval = new \DateInterval('P1D'); |
|
|
|
|
} |
|
|
|
|
$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 = []; |
|
|
|
@ -1371,7 +1402,8 @@ class MasterFunctionsHelper
|
|
|
|
|
->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') |
|
|
|
|
DB::raw('(SELECT DISTINCT status_activity FROM assign_material_to_activity amta WHERE amta.activity_id = ram.activity_id) AS status_activity'), |
|
|
|
|
DB::raw('(SELECT COUNT(id) FROM report_activity_material ram WHERE ram.activity_id = ma.id) AS count_report') |
|
|
|
|
) |
|
|
|
|
->where('ram.report_date', $loopDay) |
|
|
|
|
->where('ma.proyek_id', $projectId) |
|
|
|
@ -1392,16 +1424,26 @@ class MasterFunctionsHelper
|
|
|
|
|
// $progressPlanKomulatifWeek[] += $tmpProgressPlanWeek; |
|
|
|
|
foreach ($dataPlanM as $keyPlanM) { |
|
|
|
|
# hitung untuk persentase progress planning |
|
|
|
|
if($keyPlanM->duration == 0){ |
|
|
|
|
$duration = 2; |
|
|
|
|
} |
|
|
|
|
// if($keyPlanM->duration == 0){ |
|
|
|
|
// $duration = 2; |
|
|
|
|
// Tanggal awal |
|
|
|
|
$startDate = new DateTime($keyPlanM->planned_start); |
|
|
|
|
// Tanggal akhir |
|
|
|
|
$endDate = new DateTime($keyPlanM->planned_end); |
|
|
|
|
// Menghitung selisih hari |
|
|
|
|
$interval = $startDate->diff($endDate); |
|
|
|
|
// Mengambil hasil selisih hari |
|
|
|
|
$duration = (int) $interval->days+1; |
|
|
|
|
// }else{ |
|
|
|
|
// $duration = $keyPlanM->duration + 2; |
|
|
|
|
// } |
|
|
|
|
// $startPlan = new DateTime($keyPlanM->planned_start); |
|
|
|
|
// $endPlan = new DateTime($keyPlanM->planned_end); |
|
|
|
|
// $interval = $startPlan->diff($endPlan); |
|
|
|
|
|
|
|
|
|
// // Mengambil hasil selisih hari |
|
|
|
|
// $duration = $interval->days; |
|
|
|
|
|
|
|
|
|
// 2023-07-26 |
|
|
|
|
$progressPlanWeek = $keyPlanM->bobot_planning / $duration; |
|
|
|
|
$dataActivityPlan[] = array( |
|
|
|
|
'progressPlanDay' => $progressPlanWeek, |
|
|
|
@ -1416,13 +1458,34 @@ class MasterFunctionsHelper
|
|
|
|
|
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; |
|
|
|
|
// 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; |
|
|
|
|
}else{ |
|
|
|
|
$progressActualWeek = ((($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) / $keyActualM->qty_plan)*$keyActualM->bobot_planning; |
|
|
|
|
// jika total report < dari planning |
|
|
|
|
// $progressActualWeek = ((($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) / $keyActualM->qty_plan)*$keyActualM->bobot_planning; |
|
|
|
|
if($keyActualM->qty_actual == 0){ |
|
|
|
|
$progressActualWeek = 0; |
|
|
|
|
}else{ |
|
|
|
|
$progressActualWeek = ($keyActualM->qty_actual / $keyActualM->qty_plan) * $keyActualM->bobot_planning; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if($keyActualM->status_activity == 'done'){ |
|
|
|
|
$progressActualWeek = $progressActualWeek > $keyActualM->bobot_planning ? $keyActualM->bobot_planning : $progressActualWeek; |
|
|
|
|
// if($keyActualM->sum_qty_actual > $keyActualM->qty_plan){ |
|
|
|
|
|
|
|
|
|
// } |
|
|
|
|
// if($progressActualWeek > $keyActualM->bobot_planning){ |
|
|
|
|
// $progressActualWeek = $keyActualM->bobot_planning; |
|
|
|
|
// }else if($keyActualM->qty_actual == 0){ |
|
|
|
|
// $progressActualWeek = $keyActualM->bobot_planning; |
|
|
|
|
// }else if($keyActualM->qty_plan == $keyActualM->sum_qty_actual){ |
|
|
|
|
$progressActualWeek = $keyActualM->bobot_planning / $keyActualM->count_report; |
|
|
|
|
// }else { |
|
|
|
|
// $progressActualWeek = $progressActualWeek; |
|
|
|
|
// } |
|
|
|
|
// $progressActualWeek = $progressActualWeek > $keyActualM->bobot_planning ? $keyActualM->bobot_planning : $progressActualWeek; |
|
|
|
|
// jika report lebih dari 1 x, maka harusnya di bagi sabanyak jumlah report, |
|
|
|
|
// contoh ada 3 report, report ke 1 adalah 5 maka 100/3 dan di looping |
|
|
|
|
} |
|
|
|
|
else{ |
|
|
|
|
$progressActualWeek = $progressActualWeek > ($keyActualM->bobot_planning*95)/100 ? ($keyActualM->bobot_planning*95)/100 : $progressActualWeek; |
|
|
|
@ -1456,8 +1519,8 @@ class MasterFunctionsHelper
|
|
|
|
|
"proyek_name" => $dataProject->nama, |
|
|
|
|
"data" => ["date" => $dateWeek, |
|
|
|
|
"percentagePlan" => $progressPlanKomulatifWeek, |
|
|
|
|
"percentageReal" => $progressActualKomulatifWeek, |
|
|
|
|
"data_details" => $dataActivityPlanDate |
|
|
|
|
"percentageReal" => $progressActualKomulatifWeek |
|
|
|
|
// "data_details" => $dataActivityPlanDate |
|
|
|
|
] |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|