|
|
|
@ -7,7 +7,7 @@ use App\Models\Project;
|
|
|
|
|
use App\Models\VersionGantt; |
|
|
|
|
use App\Models\HierarchyFtth; |
|
|
|
|
use Illuminate\Support\Facades\DB; |
|
|
|
|
use Illuminate\Support\Facades\Log; |
|
|
|
|
use DateTime; |
|
|
|
|
|
|
|
|
|
class MasterFunctionsHelper |
|
|
|
|
{ |
|
|
|
@ -223,6 +223,7 @@ class MasterFunctionsHelper
|
|
|
|
|
$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'); |
|
|
|
|
} |
|
|
|
|
$period = new \DatePeriod($begin, $interval, $end); |
|
|
|
@ -286,24 +287,32 @@ class MasterFunctionsHelper
|
|
|
|
|
$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(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(); |
|
|
|
|
$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]['bobot_planning'] = $keyPlanM->bobot_planning; |
|
|
|
|
$dataTempPlan[$x]['ttl_plan'] = $sumVolPlan; |
|
|
|
@ -312,7 +321,7 @@ class MasterFunctionsHelper
|
|
|
|
|
$dataTempPlan[$x]['persentase_progress'] = $keyPlanM->persentase_progress; |
|
|
|
|
try { |
|
|
|
|
$dataTempPlan[$x]['percentage'] = $keyPlanM->bobot_planning; |
|
|
|
|
$sumPercentagePlan += $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 |
|
|
|
@ -508,11 +517,11 @@ class MasterFunctionsHelper
|
|
|
|
|
|
|
|
|
|
$minDate = $dataProject->mulai_proyek; |
|
|
|
|
|
|
|
|
|
$begin = new \DateTime($minDate); |
|
|
|
|
$begin = new \DateTime($minDate . ' Monday'); |
|
|
|
|
$begin->modify('last Monday'); |
|
|
|
|
if (isset($dataPayload['end_date'])) { |
|
|
|
|
$maxDate = $dataPayload['end_date']; |
|
|
|
|
$end = new \DateTime($maxDate); |
|
|
|
|
$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 |
|
|
|
@ -587,21 +596,31 @@ class MasterFunctionsHelper
|
|
|
|
|
$totalBCWP = isset($totalBCWP) ? $totalBCWP : 0; |
|
|
|
|
|
|
|
|
|
foreach ($dataPlanM as $keyPlanM) { |
|
|
|
|
$sumVolPlan = DB::table(function ($query) { |
|
|
|
|
$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) |
|
|
|
|
->unionAll(function ($query) { |
|
|
|
|
$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); |
|
|
|
|
})->orderBy('id', 'asc'); |
|
|
|
|
}, 'subquery') |
|
|
|
|
->sum('bobot_planning'); |
|
|
|
|
// $sumVolPlan = DB::table(function ($query) use ($projectId) { |
|
|
|
|
// $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.proyek_id', $projectId) |
|
|
|
|
// ->unionAll(function ($query) use ($projectId) { |
|
|
|
|
// $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.proyek_id', $projectId); |
|
|
|
|
// })->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]['bobot_planning'] = $keyPlanM->bobot_planning; |
|
|
|
|
$dataTempPlan[$x]['ttl_plan'] = $sumVolPlan; |
|
|
|
@ -610,7 +629,7 @@ class MasterFunctionsHelper
|
|
|
|
|
$dataTempPlan[$x]['persentase_progress'] = $keyPlanM->persentase_progress; |
|
|
|
|
try { |
|
|
|
|
$dataTempPlan[$x]['percentage'] = $keyPlanM->bobot_planning; |
|
|
|
|
$sumPercentagePlan += $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 |
|
|
|
|