Browse Source

update s curve

pull/3/head
wahyu 11 months ago
parent
commit
165247b462
  1. 95
      app/Helpers/MasterFunctionsHelper.php

95
app/Helpers/MasterFunctionsHelper.php

@ -7,7 +7,7 @@ use App\Models\Project;
use App\Models\VersionGantt; use App\Models\VersionGantt;
use App\Models\HierarchyFtth; use App\Models\HierarchyFtth;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log; use DateTime;
class MasterFunctionsHelper class MasterFunctionsHelper
{ {
@ -222,6 +222,7 @@ class MasterFunctionsHelper
$maxDate = max(new \DateTime($plannedMaxDate), new \DateTime($actualMaxDate)); $maxDate = max(new \DateTime($plannedMaxDate), new \DateTime($actualMaxDate));
$end = new \DateTime($maxDate->format('Y-m-d') . ' Friday'); $end = new \DateTime($maxDate->format('Y-m-d') . ' Friday');
$end->modify('next Friday'); $end->modify('next Friday');
$end->modify('next Friday');
$interval = new \DateInterval('P7D'); $interval = new \DateInterval('P7D');
} }
$period = new \DatePeriod($begin, $interval, $end); $period = new \DatePeriod($begin, $interval, $end);
@ -285,24 +286,32 @@ class MasterFunctionsHelper
$totalBCWP = isset($totalBCWP) ? $totalBCWP : 0; $totalBCWP = isset($totalBCWP) ? $totalBCWP : 0;
foreach ($dataPlanM as $keyPlanM) { foreach ($dataPlanM as $keyPlanM) {
$sumVolPlan = DB::table(function ($query) use ($keyGantt) { // $sumVolPlan = DB::table(function ($query) use ($keyGantt) {
$query->select('a.*') // $query->select('a.*')
->from('m_activity AS a') // ->from('m_activity AS a')
->join('assign_material_to_activity as amta', 'amta.activity_id', '=', 'a.id') // ->join('assign_material_to_activity as amta', 'amta.activity_id', '=', 'a.id')
->where('a.type_activity', 'task') // ->where('a.type_activity', 'task')
->where('a.bobot_planning', '>', 0) // ->where('a.bobot_planning', '>', 0)
->where('a.version_gantt_id', $keyGantt['id']) // ->where('a.version_gantt_id', $keyGantt['id'])
->unionAll(function ($query) use ($keyGantt) { // ->unionAll(function ($query) use ($keyGantt) {
$query->select('a.*') // $query->select('a.*')
->from('m_activity AS a') // ->from('m_activity AS a')
->join('assign_hr_to_activity as ahta', 'ahta.activity_id', '=', 'a.id') // ->join('assign_hr_to_activity as ahta', 'ahta.activity_id', '=', 'a.id')
->where('a.type_activity', 'task') // ->where('a.type_activity', 'task')
->where('a.bobot_planning', '>', 0) // ->where('a.bobot_planning', '>', 0)
->where('a.version_gantt_id', $keyGantt['id']); // ->where('a.version_gantt_id', $keyGantt['id']);
}) // })
->orderBy('id', 'asc'); // ->orderBy('id', 'asc');
}, 'subquery') // }, 'subquery')
->sum('bobot_planning'); // ->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();
$weekCount = $keyPlanM->duration / 7;
$weeklyPlan = $sumVolPlan->ttl_qty_plan / $weekCount;
$weeklyProgress = $weeklyPlan / $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning;
$dataTempPlan[$x]['activity_id'] = $keyPlanM->id; $dataTempPlan[$x]['activity_id'] = $keyPlanM->id;
$dataTempPlan[$x]['bobot_planning'] = $keyPlanM->bobot_planning; $dataTempPlan[$x]['bobot_planning'] = $keyPlanM->bobot_planning;
$dataTempPlan[$x]['ttl_plan'] = $sumVolPlan; $dataTempPlan[$x]['ttl_plan'] = $sumVolPlan;
@ -311,7 +320,7 @@ class MasterFunctionsHelper
$dataTempPlan[$x]['persentase_progress'] = $keyPlanM->persentase_progress; $dataTempPlan[$x]['persentase_progress'] = $keyPlanM->persentase_progress;
try { try {
$dataTempPlan[$x]['percentage'] = $keyPlanM->bobot_planning; $dataTempPlan[$x]['percentage'] = $keyPlanM->bobot_planning;
$sumPercentagePlan += $keyPlanM->bobot_planning; $sumPercentagePlan += $weeklyProgress;
if (isset($keyPlanM->duration) && $keyPlanM->duration > 0) if (isset($keyPlanM->duration) && $keyPlanM->duration > 0)
$totalBCWP += (((($keyPlanM->persentase_progress * $keyPlanM->bobot_planning) / 100) / $keyPlanM->duration) * $totalRencanaBudget) / 100; $totalBCWP += (((($keyPlanM->persentase_progress * $keyPlanM->bobot_planning) / 100) / $keyPlanM->duration) * $totalRencanaBudget) / 100;
else else
@ -507,11 +516,11 @@ class MasterFunctionsHelper
$minDate = $dataProject->mulai_proyek; $minDate = $dataProject->mulai_proyek;
$begin = new \DateTime($minDate); $begin = new \DateTime($minDate . ' Monday');
$begin->modify('last Monday'); $begin->modify('last Monday');
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 . ' 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
@ -586,21 +595,31 @@ class MasterFunctionsHelper
$totalBCWP = isset($totalBCWP) ? $totalBCWP : 0; $totalBCWP = isset($totalBCWP) ? $totalBCWP : 0;
foreach ($dataPlanM as $keyPlanM) { foreach ($dataPlanM as $keyPlanM) {
$sumVolPlan = DB::table(function ($query) { // $sumVolPlan = DB::table(function ($query) use ($projectId) {
$query->select('a.*') // $query->select('a.*')
->from('m_activity AS a') // ->from('m_activity AS a')
->join('assign_material_to_activity as amta', 'amta.activity_id', '=', 'a.id') // ->join('assign_material_to_activity as amta', 'amta.activity_id', '=', 'a.id')
->where('a.type_activity', 'task') // ->where('a.type_activity', 'task')
->where('a.bobot_planning', '>', 0) // ->where('a.bobot_planning', '>', 0)
->unionAll(function ($query) { // ->where('a.proyek_id', $projectId)
$query->select('a.*') // ->unionAll(function ($query) use ($projectId) {
->from('m_activity AS a') // $query->select('a.*')
->join('assign_hr_to_activity as ahta', 'ahta.activity_id', '=', 'a.id') // ->from('m_activity AS a')
->where('a.type_activity', 'task') // ->join('assign_hr_to_activity as ahta', 'ahta.activity_id', '=', 'a.id')
->where('a.bobot_planning', '>', 0); // ->where('a.type_activity', 'task')
})->orderBy('id', 'asc'); // ->where('a.bobot_planning', '>', 0)
}, 'subquery') // ->where('a.proyek_id', $projectId);
->sum('bobot_planning'); // })->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();
$weekCount = $keyPlanM->duration / 7;
$weeklyPlan = $sumVolPlan->ttl_qty_plan / $weekCount;
$weeklyProgress = $weeklyPlan / $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning;
$dataTempPlan[$x]['activity_id'] = $keyPlanM->id; $dataTempPlan[$x]['activity_id'] = $keyPlanM->id;
$dataTempPlan[$x]['bobot_planning'] = $keyPlanM->bobot_planning; $dataTempPlan[$x]['bobot_planning'] = $keyPlanM->bobot_planning;
$dataTempPlan[$x]['ttl_plan'] = $sumVolPlan; $dataTempPlan[$x]['ttl_plan'] = $sumVolPlan;
@ -609,7 +628,7 @@ class MasterFunctionsHelper
$dataTempPlan[$x]['persentase_progress'] = $keyPlanM->persentase_progress; $dataTempPlan[$x]['persentase_progress'] = $keyPlanM->persentase_progress;
try { try {
$dataTempPlan[$x]['percentage'] = $keyPlanM->bobot_planning; $dataTempPlan[$x]['percentage'] = $keyPlanM->bobot_planning;
$sumPercentagePlan += $keyPlanM->bobot_planning; $sumPercentagePlan += $weeklyProgress;
if (isset($keyPlanM->duration) && $keyPlanM->duration > 0) if (isset($keyPlanM->duration) && $keyPlanM->duration > 0)
$totalBCWP += (((($keyPlanM->persentase_progress * $keyPlanM->bobot_planning) / 100) / $keyPlanM->duration) * $totalRencanaBudget) / 100; $totalBCWP += (((($keyPlanM->persentase_progress * $keyPlanM->bobot_planning) / 100) / $keyPlanM->duration) * $totalRencanaBudget) / 100;
else else

Loading…
Cancel
Save