Browse Source

Dashboard PMO & Project Phase

pull/3/head
Yusuf 2 years ago
parent
commit
67d39113eb
  1. BIN
      app/Http/Controllers/.ReportActivityMaterialController.php.swp
  2. 14
      app/Http/Controllers/ProjectController.php
  3. 89
      app/Http/Controllers/ProjectPhaseController.php
  4. 2
      app/Models/Project.php

BIN
app/Http/Controllers/.ReportActivityMaterialController.php.swp

Binary file not shown.

14
app/Http/Controllers/ProjectController.php

@ -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'))

89
app/Http/Controllers/ProjectPhaseController.php

@ -1,3 +1,4 @@
<<<<<<< HEAD
<?php <?php
namespace App\Http\Controllers; namespace App\Http\Controllers;
@ -82,3 +83,91 @@ class ProjectPhaseController extends Controller
} }
} }
=======
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\ProjectPhase;
class ProjectPhaseController extends Controller
{
public function add(Request $request)
{
$this->validate($request, [
'name' => 'required',
]);
$data = $request->all();
$data['created_by'] = $this->currentName;
if(!ProjectPhase::create($data))
return response()->json(['status'=>'failed','message'=>'Failed to add data','code'=> 500], 500);
return response()->json(['status'=>'success','message'=>'data added!','code'=>200], 200);
}
public function edit($id){
if(!$id || (int) $id < 0 || $id=="")
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
if(!$result = ProjectPhase::find($id))
return response()->json(['status'=>'failed','message'=>'Failed to get data!','code'=> 404], 404);
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200);
}
public function update(Request $request, $id)
{
if(!$id || (int) $id < 0 || $id=="")
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
if(!$data = ProjectPhase::find($id))
return response()->json(['status'=>'failed','message'=>'data role not found!','code'=>400], 400);
if(!$data->update($request->all()))
return response()->json(['status'=>'failed','message'=>'data project type failed updated!','code'=>400], 400);
return response()->json(['status'=>'success','message'=>'data project type successfully updated!','code'=>200], 200);
}
public function delete($id)
{
if(!$data = ProjectPhase::find($id))
return response()->json(['status'=>'failed','message'=>'data project type not found!','code'=>400], 400);
if(!$data->delete())
return response()->json(['status'=>'failed','message'=>'data project type failed deleted!','code'=>400], 400);
return response()->json(['status'=>'success','message'=>'data project type successfully deleted!','code'=>200], 200);
}
public function search(Request $request)
{
$payload = $request->all();
dd($payload);
$dataBuilder = $this->setUpPayload($payload, 'm_proyek_phase');
$builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count'];
$dataGet = $builder->get();
$totalRecord = $countBuilder->count();
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200);
}
public function list()
{
$data = ProjectPhase::all();
$countData = $data->count();
if(!$data)
return response()->json(['status'=>'failed','message'=>'failed get list project type, please try again later!','code'=>400], 400);
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200);
}
}
>>>>>>> 3ef5875 (Dashboard PMO & Project Phase)

2
app/Models/Project.php

@ -39,6 +39,8 @@ class Project extends Model
'currency_code', 'currency_code',
'currency_symbol', 'currency_symbol',
'currency_name', 'currency_name',
'budget_health',
'phase_id',
'created_at', 'created_at',
'created_by', 'created_by',
'updated_at', 'updated_at',

Loading…
Cancel
Save