|
|
|
@ -212,7 +212,6 @@ class ProjectController extends Controller
|
|
|
|
|
{ |
|
|
|
|
$data = Project::orderBy('id', 'desc')->get(); |
|
|
|
|
$countData = $data->count(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!$data) |
|
|
|
|
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404); |
|
|
|
@ -224,7 +223,6 @@ class ProjectController extends Controller
|
|
|
|
|
$lastActivity = null; |
|
|
|
|
$scheduleHealth = "on-track"; |
|
|
|
|
$rootActivity = Activity::whereNull('parent_id')->where('proyek_id', $d->id)->orderBy('version_gantt_id', 'desc')->first(); |
|
|
|
|
|
|
|
|
|
if($rootActivity){ |
|
|
|
|
$costVariance = $d->rencana_biaya - $rootActivity->biaya_actual; |
|
|
|
|
$actualCost = $rootActivity->biaya_actual ?? 0; |
|
|
|
@ -241,28 +239,26 @@ class ProjectController extends Controller
|
|
|
|
|
} elseif ($daysRemaining <= $scheduleWarningThreshold) { |
|
|
|
|
$scheduleHealth = "warning"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$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->scheduleHealth = $scheduleHealth; |
|
|
|
|
|
|
|
|
|
$d->plannedCost = $d->rencana_biaya; |
|
|
|
|
$d->actualCost = $actualCost; |
|
|
|
|
$d->costVariance = $costVariance; |
|
|
|
|
$d->costHealth = $d->budget_health; |
|
|
|
|
|
|
|
|
|
$d->progress = $progress; |
|
|
|
|
$d->lastGanttId = VersionGantt::where("proyek_id", $d->id)->orderBy('id', 'desc')->first()->id ?? null; |
|
|
|
|
} |
|
|
|
|
$d->plannedInterval = date("d/m/Y", strtotime($d->mulai_proyek)) . " - " . date("d/m/Y", strtotime($d->akhir_proyek)); |
|
|
|
|
$d->plannedCost = $d->rencana_biaya; |
|
|
|
|
$d->actualCost = $actualCost; |
|
|
|
|
$d->lastActivity = $lastActivity ?? "-"; |
|
|
|
|
//$d->lastActivity = $daysRemaining . " -- " . $lastActivity . "\n" . $date1 . "\n" . $date2; |
|
|
|
|
$d->costVariance = $costVariance; |
|
|
|
|
$d->costHealth = $d->budget_health; |
|
|
|
|
$d->scheduleHealth = $scheduleHealth; |
|
|
|
|
$d->progress = $progress; |
|
|
|
|
$d->lastGanttId = VersionGantt::where("proyek_id", $d->id)->orderBy('id', 'desc')->first()->id ?? null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$totalPlannedCost = $data->sum('plannedCost'); |
|
|
|
|
$totalActualCost = $data->sum('actualCost'); |
|
|
|
|
// $manpowers = User::where('employee_type', 'employee')->count(); |
|
|
|
|
$manpowers = User::count(); |
|
|
|
|
$projectPhases = ProjectPhase::orderBy('order', 'asc')->pluck('name'); |
|
|
|
|
$projectTypes = ProjectType::orderBy('id', 'asc')->pluck('name'); |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
$projectsByPhase = DB::table('m_proyek') |
|
|
|
|
->select('m_proyek_phase.name', 'm_proyek_phase.color', DB::raw('count(*) as total')) |
|
|
|
@ -313,18 +309,18 @@ class ProjectController extends Controller
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function dashboard($id) |
|
|
|
|
{ |
|
|
|
|
{ |
|
|
|
|
$data = DB::table('m_proyek as mp') |
|
|
|
|
->select('mp.kode_sortname', 'mp.nama as name_project', 'mp.mulai_proyek as start', 'mp.akhir_proyek as finish', |
|
|
|
|
->select('mp.kode_sortname', 'mp.nama as name_project', 'mp.mulai_proyek as start', 'mp.akhir_proyek as finish', |
|
|
|
|
'mp.rencana_biaya', 'mp.company', 'mp.currency_symbol', 'mu.name as pm', 'mp.budget_health') |
|
|
|
|
->join('m_users as mu', 'mu.id', '=', 'mp.pm_id') |
|
|
|
|
->where('mp.id', $id) |
|
|
|
|
->get(); |
|
|
|
|
$countData = $data->count(); |
|
|
|
|
->get(); |
|
|
|
|
$countData = $data->count(); |
|
|
|
|
|
|
|
|
|
$manpowers = UserToProyek::where('proyek_id', $id)->count(); |
|
|
|
|
$rootActivity = Activity::whereNull('parent_id')->where('proyek_id', $id)->orderBy('version_gantt_id', 'desc')->first(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if($rootActivity){ |
|
|
|
|
$actualCost = $rootActivity->biaya_actual ?? 0; |
|
|
|
|
$progress = $rootActivity->persentase_progress ?? 0; |
|
|
|
@ -355,10 +351,10 @@ class ProjectController extends Controller
|
|
|
|
|
$dataRes['progress'] = $progress; |
|
|
|
|
$dataRes['comment'] = $commentActivity; |
|
|
|
|
$dataRes['man_power'] = $manpowers; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
|
|
return response()->json(['status'=>'success','code'=>200,'data'=>$dataRes, 'totalRecord'=>$countData], 200); |
|
|
|
|
} |
|
|
|
|