|
|
|
@ -6,8 +6,7 @@ use Illuminate\Http\Request;
|
|
|
|
|
use App\Models\Project; |
|
|
|
|
use App\Models\Activity; |
|
|
|
|
use App\Models\ReportActivity; |
|
|
|
|
use App\Models\UserToActivity; |
|
|
|
|
use DB; |
|
|
|
|
use App\Models\Role; |
|
|
|
|
|
|
|
|
|
class DashboardController extends Controller |
|
|
|
|
{ |
|
|
|
@ -25,11 +24,10 @@ class DashboardController extends Controller
|
|
|
|
|
$dataFinal[] = array("proyek_id" => $val['proyek_id'], "proyek_name" => isset($data) && count($data) > 0 ? $data[0]['proyek_name'] : "-", "version_gantt_id" => $val['last_version_gantt'], "data" => $data); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if($dataPayload){ |
|
|
|
|
if(!$dataFinal) |
|
|
|
|
return response()->json(['status'=>'failed','message'=>'Data not found','code'=> 404], 404); |
|
|
|
|
|
|
|
|
|
return response()->json(['status'=>'success','code'=>200,'data'=>$dataFinal, 'totalRecord'=>1], 200); |
|
|
|
|
}else{ |
|
|
|
|
return response()->json(['status'=>'failed','message'=>'failed get list role, please try again later!','code'=>400], 400); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getMaxVersionGantt($id){ |
|
|
|
@ -48,14 +46,12 @@ class DashboardController extends Controller
|
|
|
|
|
foreach ($dataMaxVersionGantt as $val) { |
|
|
|
|
$data = Activity::select('m_activity.id', 'm_activity.proyek_id', 'm_activity.name', 'm_activity.kode_sortname', 'm_activity.persentase_progress', 'm_activity.persentase_bobot', 'm_activity.bobot_planning', 'mp.nama as proyek_name')->join("m_proyek as mp", "m_activity.proyek_id", "=", "mp.id")->where('proyek_id', $val['proyek_id'])->where('version_gantt_id', $val['last_version_gantt'])->whereNull('parent_id')->orderBy('id', 'asc')->get(); |
|
|
|
|
$dataFinal[] = array("proyek_id" => $val['proyek_id'], "proyek_name" => isset($data) && count($data) > 0 ? $data[0]['proyek_name'] : "-", "version_gantt_id" => $val['last_version_gantt'], "data" => $data); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if($dataPayload){ |
|
|
|
|
return response()->json(['status'=>'success','code'=>200,'data'=>$dataFinal, 'totalRecord'=>1], 200); |
|
|
|
|
}else{ |
|
|
|
|
if(!$dataFinal) |
|
|
|
|
return response()->json(['status'=>'failed','message'=>'failed get list role, please try again later!','code'=>400], 400); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return response()->json(['status'=>'success','code'=>200,'data'=>$dataFinal, 'totalRecord'=>1], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function list() |
|
|
|
@ -63,30 +59,22 @@ class DashboardController extends Controller
|
|
|
|
|
$data = Role::all(); |
|
|
|
|
$countData = $data->count(); |
|
|
|
|
|
|
|
|
|
if($data){ |
|
|
|
|
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
|
|
|
|
}else{ |
|
|
|
|
if(!$data) |
|
|
|
|
return response()->json(['status'=>'failed','message'=>'failed get list role, please try again later!','code'=>400], 400); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getActivityByProjectId($projectId) { |
|
|
|
|
$output = []; |
|
|
|
|
$data = Activity::select('id')->where('proyek_id', $projectId)->get(); |
|
|
|
|
if (count($data) > 0) { |
|
|
|
|
foreach ($data as $actData) { |
|
|
|
|
$output[] = $actData->id; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return $output; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* for statusProyek, I want something output like this |
|
|
|
|
/* |
|
|
|
|
const statusProyek = [ |
|
|
|
|
{ |
|
|
|
|
"id": "1", |
|
|
|
@ -109,17 +97,14 @@ class DashboardController extends Controller
|
|
|
|
|
*/ |
|
|
|
|
public function statusProyek(Request $request) { |
|
|
|
|
$dataPayload = $request->all(); |
|
|
|
|
$reqProject = []; |
|
|
|
|
$dataFinal = []; |
|
|
|
|
$reqProject = $dataFinal = []; |
|
|
|
|
|
|
|
|
|
if (!isset($dataPayload['project_id'])) { |
|
|
|
|
if (!isset($dataPayload['project_id'])) |
|
|
|
|
return response()->json(['status'=>'failed','message'=>'Undefined project_id','code'=>400], 400); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
foreach ($dataPayload['project_id'] as $val) { |
|
|
|
|
$prj["project_id"] = $val; |
|
|
|
|
$prj["activity_id"] = $this->getActivityByProjectId($val); |
|
|
|
|
|
|
|
|
|
$reqProject[] = $prj; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -133,24 +118,20 @@ class DashboardController extends Controller
|
|
|
|
|
$sum_jumlah_pekerjaan = Activity::where('proyek_id', $reqProject[$i]['project_id'])->where('version_gantt_id', $last_version_gantt)->sum("jumlah_pekerjaan"); |
|
|
|
|
$count_activity = Activity::where('proyek_id', $reqProject[$i]['project_id'])->where('version_gantt_id', $last_version_gantt)->count("id"); |
|
|
|
|
$count_activity_done = Activity::where('proyek_id', $reqProject[$i]['project_id'])->where('persentase_progress', '100')->where('version_gantt_id', $last_version_gantt)->count("id"); |
|
|
|
|
$progress_percentage = Activity::where('proyek_id', $reqProject[$i]['project_id'])->whereNull('parent_id')->where('version_gantt_id', $last_version_gantt)->sum("persentase_progress"); |
|
|
|
|
$count_progress_percentage = Activity::where('proyek_id', $reqProject[$i]['project_id'])->whereNull('parent_id')->where('version_gantt_id', $last_version_gantt)->count("persentase_progress"); |
|
|
|
|
|
|
|
|
|
$progress_actual = Activity::select('id', 'bobot_planning', 'persentase_progress')->where('proyek_id', $reqProject[$i]['project_id'])->whereNull('parent_id')->where('version_gantt_id', $last_version_gantt)->get(); |
|
|
|
|
$current_progress = 0; |
|
|
|
|
|
|
|
|
|
foreach($progress_actual as $objRow) { |
|
|
|
|
$current_progress += ($objRow->bobot_planning * $objRow->persentase_progress) / 100; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (count($reqProject[$i]['activity_id']) > 0) { |
|
|
|
|
for ($j=0; $j < count($reqProject[$i]['activity_id']); $j++) { |
|
|
|
|
$sum_job_count_report = ReportActivity::whereIn('activity_id', $reqProject[$i]['activity_id'])->sum("job_count_report"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!isset($queryProject->id)) { |
|
|
|
|
if (!isset($queryProject->id)) |
|
|
|
|
return response()->json(['status'=>'failed','message'=>'Project with id='.$reqProject[$i]['project_id'].' is not found!','code'=>400], 400); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$now = time(); |
|
|
|
|
$akhir_proyek = strtotime($queryProject->akhir_proyek); |
|
|
|
@ -176,31 +157,28 @@ class DashboardController extends Controller
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if($dataFinal){ |
|
|
|
|
return response()->json(['status'=>'success','code'=>200,'data'=>$dataFinal, 'totalRecord'=>count($dataFinal)], 200); |
|
|
|
|
}else{ |
|
|
|
|
if(empty($dataFinal)) |
|
|
|
|
return response()->json(['status'=>'failed','message'=>'failed get status proyek, please try again later!','code'=>400], 400); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return response()->json(['status'=>'success','code'=>200,'data'=>$dataFinal, 'totalRecord'=>count($dataFinal)], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function curvaS(Request $request) |
|
|
|
|
{ |
|
|
|
|
$dataPayload = $request->all(); |
|
|
|
|
$dataMaxVersionGantt = []; |
|
|
|
|
$dataFinal=[]; |
|
|
|
|
|
|
|
|
|
foreach ($dataPayload['project_id'] as $val) { |
|
|
|
|
$dataMaxVersionGantt[] = $this->getMaxVersionGantt($val); |
|
|
|
|
} |
|
|
|
|
$dataFinal=[]; |
|
|
|
|
|
|
|
|
|
foreach ($dataMaxVersionGantt as $val) { |
|
|
|
|
$data = Activity::select('m_activity.id', 'm_activity.proyek_id', 'm_activity.name', 'm_activity.kode_sortname', 'm_activity.persentase_progress', 'm_activity.persentase_bobot', 'm_activity.bobot_planning', 'm_activity.biaya_actual', 'mp.nama as proyek_name')->join("m_proyek as mp", "m_activity.proyek_id", "=", "mp.id")->where('proyek_id', $val['proyek_id'])->where('version_gantt_id', $val['last_version_gantt'])->whereNull('parent_id')->orderBy('id', 'asc')->get(); |
|
|
|
|
$totalCostPlanning = Activity::where('proyek_id', $val['proyek_id'])->where('version_gantt_id', $val['last_version_gantt'])->whereNull('parent_id')->sum('rencana_biaya'); |
|
|
|
|
$dataBobotPlan =[]; |
|
|
|
|
|
|
|
|
|
for ($i=0; $i < count($data); $i++) { |
|
|
|
|
$tmpp = 0; |
|
|
|
|
$tmpa = 0; |
|
|
|
|
$tmpbc = 0; |
|
|
|
|
$tmpac = 0; |
|
|
|
|
$tmpp = $tmpa = $tmpbc = $tmpac = 0; |
|
|
|
|
for ($x=$i; $x >= 0 ; $x--) { |
|
|
|
|
$tmpp += $data[$x]['bobot_planning']; |
|
|
|
|
$tmpa += ($data[$x]['persentase_progress'] * $data[$x]['bobot_planning'])/100; |
|
|
|
@ -209,6 +187,7 @@ class DashboardController extends Controller
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$data[$i]['cal_bobot_p'] = round($tmpp,2); |
|
|
|
|
|
|
|
|
|
if($i > 0 ){ |
|
|
|
|
if($data[$i-1]['cal_bobot_a'] != null){ |
|
|
|
|
if($data[$i-1]['cal_bobot_a'] == round($tmpa,2)){ |
|
|
|
@ -219,12 +198,6 @@ class DashboardController extends Controller
|
|
|
|
|
}else{ |
|
|
|
|
$data[$i]['cal_bobot_a'] = null; |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
$data[$i]['cal_bobot_a'] = round($tmpa,2); |
|
|
|
|
} |
|
|
|
|
$data[$i]['cal_budget_cost'] = round($tmpbc,2); |
|
|
|
|
|
|
|
|
|
if($i > 0 ){ |
|
|
|
|
if($data[$i-1]['cal_actual_cost'] != null){ |
|
|
|
|
if($data[$i-1]['cal_actual_cost'] == round($tmpac,2)){ |
|
|
|
|
$data[$i]['cal_actual_cost'] = null; |
|
|
|
@ -235,18 +208,18 @@ class DashboardController extends Controller
|
|
|
|
|
$data[$i]['cal_actual_cost'] = null; |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
$data[$i]['cal_bobot_a'] = round($tmpa,2); |
|
|
|
|
$data[$i]['cal_actual_cost'] = round($tmpac,2); |
|
|
|
|
} |
|
|
|
|
$data[$i]['cal_budget_cost'] = round($tmpbc,2); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$dataFinal[] = array("proyek_id" => $val['proyek_id'], "proyek_name" => isset($data) && count($data) > 0 ? $data[0]['proyek_name'] : "-", "version_gantt_id" => $val['last_version_gantt'], "data" => $data); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if($dataPayload){ |
|
|
|
|
return response()->json(['status'=>'success','code'=>200, 'data'=>$dataFinal, 'totalRecord'=>1], 200); |
|
|
|
|
}else{ |
|
|
|
|
if(!$dataFinal) |
|
|
|
|
return response()->json(['status'=>'failed','message'=>'failed get list role, please try again later!','code'=>400], 400); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return response()->json(['status'=>'success','code'=>200, 'data'=>$dataFinal, 'totalRecord'=>1], 200); |
|
|
|
|
} |
|
|
|
|
} |