|
|
@ -213,7 +213,6 @@ class ProjectController extends Controller |
|
|
|
$data = Project::orderBy('id', 'desc')->get(); |
|
|
|
$data = Project::orderBy('id', 'desc')->get(); |
|
|
|
$countData = $data->count(); |
|
|
|
$countData = $data->count(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!$data) |
|
|
|
if(!$data) |
|
|
|
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404); |
|
|
|
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404); |
|
|
|
|
|
|
|
|
|
|
@ -224,7 +223,6 @@ class ProjectController extends Controller |
|
|
|
$lastActivity = null; |
|
|
|
$lastActivity = null; |
|
|
|
$scheduleHealth = "on-track"; |
|
|
|
$scheduleHealth = "on-track"; |
|
|
|
$rootActivity = Activity::whereNull('parent_id')->where('proyek_id', $d->id)->orderBy('version_gantt_id', 'desc')->first(); |
|
|
|
$rootActivity = Activity::whereNull('parent_id')->where('proyek_id', $d->id)->orderBy('version_gantt_id', 'desc')->first(); |
|
|
|
|
|
|
|
|
|
|
|
if($rootActivity){ |
|
|
|
if($rootActivity){ |
|
|
|
$costVariance = $d->rencana_biaya - $rootActivity->biaya_actual; |
|
|
|
$costVariance = $d->rencana_biaya - $rootActivity->biaya_actual; |
|
|
|
$actualCost = $rootActivity->biaya_actual ?? 0; |
|
|
|
$actualCost = $rootActivity->biaya_actual ?? 0; |
|
|
@ -241,28 +239,26 @@ class ProjectController extends Controller |
|
|
|
} elseif ($daysRemaining <= $scheduleWarningThreshold) { |
|
|
|
} elseif ($daysRemaining <= $scheduleWarningThreshold) { |
|
|
|
$scheduleHealth = "warning"; |
|
|
|
$scheduleHealth = "warning"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$lastActivity = date("d/m/Y", strtotime($rootActivity->end_date)); |
|
|
|
$lastActivity = date("d/m/Y", strtotime($rootActivity->end_date)); |
|
|
|
$d->lastActivity = $lastActivity ?? "-"; |
|
|
|
} |
|
|
|
$d->plannedInterval = date("d/m/Y", strtotime($d->mulai_proyek)) . " - " . date("d/m/Y", strtotime($d->akhir_proyek)); |
|
|
|
$d->plannedInterval = date("d/m/Y", strtotime($d->mulai_proyek)) . " - " . date("d/m/Y", strtotime($d->akhir_proyek)); |
|
|
|
$d->scheduleHealth = $scheduleHealth; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$d->plannedCost = $d->rencana_biaya; |
|
|
|
$d->plannedCost = $d->rencana_biaya; |
|
|
|
$d->actualCost = $actualCost; |
|
|
|
$d->actualCost = $actualCost; |
|
|
|
|
|
|
|
$d->lastActivity = $lastActivity ?? "-"; |
|
|
|
|
|
|
|
//$d->lastActivity = $daysRemaining . " -- " . $lastActivity . "\n" . $date1 . "\n" . $date2; |
|
|
|
$d->costVariance = $costVariance; |
|
|
|
$d->costVariance = $costVariance; |
|
|
|
$d->costHealth = $d->budget_health; |
|
|
|
$d->costHealth = $d->budget_health; |
|
|
|
|
|
|
|
$d->scheduleHealth = $scheduleHealth; |
|
|
|
$d->progress = $progress; |
|
|
|
$d->progress = $progress; |
|
|
|
$d->lastGanttId = VersionGantt::where("proyek_id", $d->id)->orderBy('id', 'desc')->first()->id ?? null; |
|
|
|
$d->lastGanttId = VersionGantt::where("proyek_id", $d->id)->orderBy('id', 'desc')->first()->id ?? null; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$totalPlannedCost = $data->sum('plannedCost'); |
|
|
|
$totalPlannedCost = $data->sum('plannedCost'); |
|
|
|
$totalActualCost = $data->sum('actualCost'); |
|
|
|
$totalActualCost = $data->sum('actualCost'); |
|
|
|
|
|
|
|
// $manpowers = User::where('employee_type', 'employee')->count(); |
|
|
|
$manpowers = User::count(); |
|
|
|
$manpowers = User::count(); |
|
|
|
$projectPhases = ProjectPhase::orderBy('order', 'asc')->pluck('name'); |
|
|
|
$projectPhases = ProjectPhase::orderBy('order', 'asc')->pluck('name'); |
|
|
|
$projectTypes = ProjectType::orderBy('id', 'asc')->pluck('name'); |
|
|
|
$projectTypes = ProjectType::orderBy('id', 'asc')->pluck('name'); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
$projectsByPhase = DB::table('m_proyek') |
|
|
|
$projectsByPhase = DB::table('m_proyek') |
|
|
|
->select('m_proyek_phase.name', 'm_proyek_phase.color', DB::raw('count(*) as total')) |
|
|
|
->select('m_proyek_phase.name', 'm_proyek_phase.color', DB::raw('count(*) as total')) |
|
|
|