|
|
|
@ -610,23 +610,7 @@ class MasterFunctionsHelper
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if($keyActualM->status_activity == 'done'){ |
|
|
|
|
// 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; |
|
|
|
@ -1326,6 +1310,15 @@ class MasterFunctionsHelper
|
|
|
|
|
{ |
|
|
|
|
DB::enableQueryLog(); |
|
|
|
|
|
|
|
|
|
// $hierarchyGantts = []; |
|
|
|
|
// if (isset($hierarchyId)) { |
|
|
|
|
// $hierarchy = HierarchyFtth::findOrFail($hierarchyId); |
|
|
|
|
// $projectId = $hierarchy->project_id; |
|
|
|
|
// // if (isset($hierarchy)) { |
|
|
|
|
// // $hierarchyGantts = VersionGantt::where('hierarchy_ftth_id', $hierarchyId)->get()->toArray(); |
|
|
|
|
// // } |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
$dataFinal = []; |
|
|
|
|
$dataPayload = []; |
|
|
|
|
$dataPayload['period'] = 'week'; |
|
|
|
@ -1340,9 +1333,9 @@ class MasterFunctionsHelper
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($dataHeader) { |
|
|
|
|
$totalRencanaBudget = Activity::where('parent_id', $dataHeader->id)->where("proyek_id", $projectId)->sum("rencana_biaya"); |
|
|
|
|
// $totalRencanaBudget = Activity::where('parent_id', $dataHeader->id)->where("proyek_id", $projectId)->sum("rencana_biaya"); |
|
|
|
|
} else { |
|
|
|
|
$totalRencanaBudget = Activity::whereNull('parent_id')->where("proyek_id", $projectId)->sum("rencana_biaya"); |
|
|
|
|
// $totalRencanaBudget = Activity::whereNull('parent_id')->where("proyek_id", $projectId)->sum("rencana_biaya"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$minDate = $dataProject->mulai_proyek; |
|
|
|
@ -1387,6 +1380,32 @@ class MasterFunctionsHelper
|
|
|
|
|
//new \Datetime($dt->format("Y-m-d")); |
|
|
|
|
// $minSevenDays = $minSevenDays->modify('-7 day')->format("Y-m-d"); |
|
|
|
|
$tempDate[] = array($dt->format("Y-m-d")); |
|
|
|
|
$dataPlanM = []; |
|
|
|
|
$dataActualM = []; |
|
|
|
|
// if (count($hierarchyGantts) > 0) { |
|
|
|
|
// foreach ($hierarchyGantts as $key => $gantt) { |
|
|
|
|
// $dataPlanM[] = DB::table('m_activity') |
|
|
|
|
// ->where('type_activity', 'task') |
|
|
|
|
// ->where('bobot_planning', '>', 0) |
|
|
|
|
// ->where('version_gantt_id', $gantt['id']) |
|
|
|
|
// ->whereDate('planned_start', '<=', $loopDay) |
|
|
|
|
// ->whereDate('planned_end', '>=', $loopDay) |
|
|
|
|
// ->select('name', 'bobot_planning', 'biaya_actual', 'duration', 'persentase_progress', 'id', 'planned_start', 'planned_end') |
|
|
|
|
// ->get()->toArray(); |
|
|
|
|
|
|
|
|
|
// $dataActualM[] = DB::table('report_activity_material as ram') |
|
|
|
|
// ->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'), |
|
|
|
|
// 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', $gantt['id']) |
|
|
|
|
// ->get()->toArray(); |
|
|
|
|
// } |
|
|
|
|
// } else { |
|
|
|
|
|
|
|
|
|
$dataPlanM = DB::table('m_activity') |
|
|
|
|
->where('type_activity', 'task') |
|
|
|
@ -1408,6 +1427,7 @@ class MasterFunctionsHelper
|
|
|
|
|
->where('ram.report_date', $loopDay) |
|
|
|
|
->where('ma.proyek_id', $projectId) |
|
|
|
|
->get(); |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
$dataActivityPlan = []; |
|
|
|
|
$dataActivityActual = []; |
|
|
|
@ -1422,86 +1442,340 @@ class MasterFunctionsHelper
|
|
|
|
|
$dateWeek[] = [$loopDay]; |
|
|
|
|
} |
|
|
|
|
// $progressPlanKomulatifWeek[] += $tmpProgressPlanWeek; |
|
|
|
|
foreach ($dataPlanM as $keyPlanM) { |
|
|
|
|
# hitung untuk persentase progress planning |
|
|
|
|
// 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, |
|
|
|
|
'name' => $keyPlanM->name, |
|
|
|
|
'bobot_p' => $keyPlanM->bobot_planning, |
|
|
|
|
'duration' => $keyPlanM->duration |
|
|
|
|
); |
|
|
|
|
$tmpProgressPlanWeek += $progressPlanWeek; |
|
|
|
|
} |
|
|
|
|
// if (count($dataPlanM) > 0 && count($dataPlanM[0]) > 0) { |
|
|
|
|
foreach ($dataPlanM as $keyPlanM) { |
|
|
|
|
# hitung untuk persentase progress planning |
|
|
|
|
// 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, |
|
|
|
|
'name' => $keyPlanM->name, |
|
|
|
|
'bobot_p' => $keyPlanM->bobot_planning, |
|
|
|
|
'duration' => $keyPlanM->duration |
|
|
|
|
); |
|
|
|
|
$tmpProgressPlanWeek += $progressPlanWeek; |
|
|
|
|
} |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
// 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; |
|
|
|
|
// 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{ |
|
|
|
|
// 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; |
|
|
|
|
// if (count($dataActualM) > 0 && count($dataActualM[0]) > 0) { |
|
|
|
|
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->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'){ |
|
|
|
|
// 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; |
|
|
|
|
} |
|
|
|
|
$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; |
|
|
|
|
} |
|
|
|
|
if($keyActualM->status_activity == 'done'){ |
|
|
|
|
// 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 |
|
|
|
|
$dataActivityPlanDate[] = array( |
|
|
|
|
"date" => $loopDay, |
|
|
|
|
"statusWeek" => new \DateTime($loopDay) == new \DateTime($loopDay . ' Friday') ? true : false, |
|
|
|
|
"activity-plan" => $dataActivityPlan, |
|
|
|
|
"activity-actual" => $dataActivityActual, |
|
|
|
|
"tmpProgressActualWeek" => $tmpProgressActualWeek, |
|
|
|
|
"progressPlanWeek" => $tmpProgressPlanWeek |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$dataFinal[] = array( |
|
|
|
|
// "date" => $dateWeek, |
|
|
|
|
"proyek_name" => $dataProject->nama, |
|
|
|
|
"data" => ["date" => $dateWeek, |
|
|
|
|
"percentagePlan" => $progressPlanKomulatifWeek, |
|
|
|
|
"percentageReal" => $progressActualKomulatifWeek |
|
|
|
|
// "data_details" => $dataActivityPlanDate |
|
|
|
|
] |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
return $dataFinal; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function calculateSCurveForProgressTree($hierarchyId) |
|
|
|
|
{ |
|
|
|
|
DB::enableQueryLog(); |
|
|
|
|
|
|
|
|
|
// $hierarchyGantts = []; |
|
|
|
|
if (isset($hierarchyId)) { |
|
|
|
|
$hierarchy = HierarchyFtth::findOrFail($hierarchyId); |
|
|
|
|
$projectId = $hierarchy->project_id; |
|
|
|
|
// if (isset($hierarchy)) { |
|
|
|
|
// $hierarchyGantts = VersionGantt::where('hierarchy_ftth_id', $hierarchyId)->get()->toArray(); |
|
|
|
|
// } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$dataFinal = []; |
|
|
|
|
$dataPayload = []; |
|
|
|
|
$dataPayload['period'] = 'week'; |
|
|
|
|
$totalACWP = 0; |
|
|
|
|
$totalBCWP = 0; |
|
|
|
|
$tempPercentage = []; |
|
|
|
|
|
|
|
|
|
$dataProject = Project::find($projectId); |
|
|
|
|
$dataHeader = Activity::where('type_activity', 'header')->where("proyek_id", $projectId)->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", $projectId)->sum("rencana_biaya"); |
|
|
|
|
} else { |
|
|
|
|
// $totalRencanaBudget = Activity::whereNull('parent_id')->where("proyek_id", $projectId)->sum("rencana_biaya"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$minDate = $dataProject->mulai_proyek; |
|
|
|
|
|
|
|
|
|
$begin = new \DateTime($minDate); |
|
|
|
|
$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'); |
|
|
|
|
/* $interval = \DateInterval::createFromDateString('1 day'); */// should be using this but its bugged |
|
|
|
|
$interval = new \DateInterval('P1D'); |
|
|
|
|
} else { |
|
|
|
|
$maxDate = $dataProject->akhir_proyek; |
|
|
|
|
$end = new \DateTime($maxDate); |
|
|
|
|
$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 = []; |
|
|
|
|
$tempDate = []; |
|
|
|
|
// $tempPercentagePlan = []; |
|
|
|
|
// $tempPercentagePlanWhr = []; |
|
|
|
|
// $tempPercentageReal = []; |
|
|
|
|
// $tempTtlPercentPlan = 0; |
|
|
|
|
// $tempTtlPercentActual = 0; |
|
|
|
|
|
|
|
|
|
// $currentACWP = 0; |
|
|
|
|
// $currentBCWP = 0; |
|
|
|
|
$dataActivityPlanDate = []; |
|
|
|
|
$progressPlanKomulatifWeek = []; |
|
|
|
|
$progressActualKomulatifWeek = []; |
|
|
|
|
$dateWeek = []; |
|
|
|
|
$tmpProgressPlanWeek = 0; |
|
|
|
|
$tmpProgressActualWeek = 0; |
|
|
|
|
foreach ($period as $dt) { |
|
|
|
|
$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")); |
|
|
|
|
$dataPlanM = []; |
|
|
|
|
$dataActualM = []; |
|
|
|
|
// if (count($hierarchyGantts) > 0) { |
|
|
|
|
// foreach ($hierarchyGantts as $key => $gantt) { |
|
|
|
|
// $dataPlanM[] = DB::table('m_activity') |
|
|
|
|
// ->where('type_activity', 'task') |
|
|
|
|
// ->where('bobot_planning', '>', 0) |
|
|
|
|
// ->where('version_gantt_id', $gantt['id']) |
|
|
|
|
// ->whereDate('planned_start', '<=', $loopDay) |
|
|
|
|
// ->whereDate('planned_end', '>=', $loopDay) |
|
|
|
|
// ->select('name', 'bobot_planning', 'biaya_actual', 'duration', 'persentase_progress', 'id', 'planned_start', 'planned_end') |
|
|
|
|
// ->get()->toArray(); |
|
|
|
|
|
|
|
|
|
// $dataActualM[] = DB::table('report_activity_material as ram') |
|
|
|
|
// ->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'), |
|
|
|
|
// 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', $gantt['id']) |
|
|
|
|
// ->get()->toArray(); |
|
|
|
|
// } |
|
|
|
|
// } else { |
|
|
|
|
|
|
|
|
|
$dataPlanM = DB::table('m_hierarchy_ftth as mhf') |
|
|
|
|
->join('m_version_gantt as mvg', 'mvg.hierarchy_ftth_id', '=', 'mhf.id') |
|
|
|
|
->join('m_activity as ma', 'ma.version_gantt_id', '=', 'mvg.id') |
|
|
|
|
->where('ma.type_activity', 'task') |
|
|
|
|
->where('ma.bobot_planning', '>', 0) |
|
|
|
|
->where('mhf.project_id', $projectId) |
|
|
|
|
->whereDate('planned_start', '<=', $loopDay) |
|
|
|
|
->whereDate('planned_end', '>=', $loopDay) |
|
|
|
|
->select('ma.name', 'ma.bobot_planning', 'ma.biaya_actual', 'ma.duration', 'ma.persentase_progress', 'ma.id', 'ma.planned_start', 'ma.planned_end') |
|
|
|
|
->get(); |
|
|
|
|
|
|
|
|
|
$dataActualM = DB::table('m_hierarchy_ftth as mhf') |
|
|
|
|
->join('m_version_gantt as mvg', 'mvg.hierarchy_ftth_id', '=', 'mhf.id') |
|
|
|
|
->join('m_activity as ma', 'ma.version_gantt_id', '=', 'mvg.id') |
|
|
|
|
->join('report_activity_material as ram', 'ram.activity_id', '=', 'ma.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'), |
|
|
|
|
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) |
|
|
|
|
->where('mhf.project_id', $projectId) |
|
|
|
|
->get(); |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
$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); |
|
|
|
|
} |
|
|
|
|
else{ |
|
|
|
|
$progressActualWeek = $progressActualWeek > ($keyActualM->bobot_planning*95)/100 ? ($keyActualM->bobot_planning*95)/100 : $progressActualWeek; |
|
|
|
|
$dateWeek[] = [$loopDay]; |
|
|
|
|
} |
|
|
|
|
// $progressPlanKomulatifWeek[] += $tmpProgressPlanWeek; |
|
|
|
|
// if (count($dataPlanM) > 0 && count($dataPlanM[0]) > 0) { |
|
|
|
|
foreach ($dataPlanM as $keyPlanM) { |
|
|
|
|
# hitung untuk persentase progress planning |
|
|
|
|
// 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, |
|
|
|
|
'name' => $keyPlanM->name, |
|
|
|
|
'bobot_p' => $keyPlanM->bobot_planning, |
|
|
|
|
'duration' => $keyPlanM->duration |
|
|
|
|
); |
|
|
|
|
$tmpProgressPlanWeek += $progressPlanWeek; |
|
|
|
|
} |
|
|
|
|
$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; |
|
|
|
|
} |
|
|
|
|
// hitung progress actual |
|
|
|
|
// if (count($dataActualM) > 0 && count($dataActualM[0]) > 0) { |
|
|
|
|
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{ |
|
|
|
|
// 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'){ |
|
|
|
|
// 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; |
|
|
|
|
} |
|
|
|
|
$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; |
|
|
|
|
} |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
$dataActivityPlanDate[] = array( |
|
|
|
|
"date" => $loopDay, |
|
|
|
|