|
|
@ -6,247 +6,220 @@ use Illuminate\Http\Request; |
|
|
|
use App\Models\Project; |
|
|
|
use App\Models\Project; |
|
|
|
use App\Models\Activity; |
|
|
|
use App\Models\Activity; |
|
|
|
use App\Models\ReportActivity; |
|
|
|
use App\Models\ReportActivity; |
|
|
|
use App\Models\UserToActivity; |
|
|
|
use App\Models\Role; |
|
|
|
use DB; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DashboardController extends Controller |
|
|
|
class DashboardController extends Controller |
|
|
|
{ |
|
|
|
{ |
|
|
|
public function costPlanningActual(Request $request) |
|
|
|
public function costPlanningActual(Request $request) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$dataPayload = $request->all(); |
|
|
|
$dataPayload = $request->all(); |
|
|
|
$dataMaxVersionGantt = []; |
|
|
|
$dataMaxVersionGantt = []; |
|
|
|
foreach ($dataPayload['project_id'] as $val) { |
|
|
|
foreach ($dataPayload['project_id'] as $val) { |
|
|
|
$dataMaxVersionGantt[] = $this->getMaxVersionGantt($val); |
|
|
|
$dataMaxVersionGantt[] = $this->getMaxVersionGantt($val); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$dataFinal=[]; |
|
|
|
$dataFinal=[]; |
|
|
|
foreach ($dataMaxVersionGantt as $val) { |
|
|
|
foreach ($dataMaxVersionGantt as $val) { |
|
|
|
$data = Activity::select('m_activity.id', 'm_activity.proyek_id', 'm_activity.name', 'm_activity.kode_sortname', 'm_activity.rencana_biaya', '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(); |
|
|
|
$data = Activity::select('m_activity.id', 'm_activity.proyek_id', 'm_activity.name', 'm_activity.kode_sortname', 'm_activity.rencana_biaya', '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(); |
|
|
|
$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); |
|
|
|
$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'=>'success','code'=>200,'data'=>$dataFinal, 'totalRecord'=>1], 200); |
|
|
|
return response()->json(['status'=>'failed','message'=>'Data not found','code'=> 404], 404); |
|
|
|
}else{ |
|
|
|
|
|
|
|
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 getMaxVersionGantt($id){ |
|
|
|
public function getMaxVersionGantt($id){ |
|
|
|
$data = Activity::select(Activity::raw('MAX(version_gantt_id) as last_version_gantt'))->where("proyek_id", $id)->first(); |
|
|
|
$data = Activity::select(Activity::raw('MAX(version_gantt_id) as last_version_gantt'))->where("proyek_id", $id)->first(); |
|
|
|
return array("last_version_gantt"=>$data->last_version_gantt, "proyek_id" => $id, "proyek_name" => $data->proyek_name); |
|
|
|
return array("last_version_gantt"=>$data->last_version_gantt, "proyek_id" => $id, "proyek_name" => $data->proyek_name); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function percentagePlanningActual(Request $request) |
|
|
|
public function percentagePlanningActual(Request $request) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$dataPayload = $request->all(); |
|
|
|
$dataPayload = $request->all(); |
|
|
|
$dataMaxVersionGantt = []; |
|
|
|
$dataMaxVersionGantt = []; |
|
|
|
foreach ($dataPayload['project_id'] as $val) { |
|
|
|
foreach ($dataPayload['project_id'] as $val) { |
|
|
|
$dataMaxVersionGantt[] = $this->getMaxVersionGantt($val); |
|
|
|
$dataMaxVersionGantt[] = $this->getMaxVersionGantt($val); |
|
|
|
} |
|
|
|
} |
|
|
|
$dataFinal=[]; |
|
|
|
$dataFinal=[]; |
|
|
|
foreach ($dataMaxVersionGantt as $val) { |
|
|
|
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(); |
|
|
|
$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); |
|
|
|
$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(!$dataFinal) |
|
|
|
|
|
|
|
return response()->json(['status'=>'failed','message'=>'failed get list role, please try again later!','code'=>400], 400); |
|
|
|
if($dataPayload){ |
|
|
|
|
|
|
|
return response()->json(['status'=>'success','code'=>200,'data'=>$dataFinal, 'totalRecord'=>1], 200); |
|
|
|
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 list() |
|
|
|
} |
|
|
|
{ |
|
|
|
|
|
|
|
$data = Role::all(); |
|
|
|
public function list() |
|
|
|
$countData = $data->count(); |
|
|
|
{ |
|
|
|
|
|
|
|
$data = Role::all(); |
|
|
|
if(!$data) |
|
|
|
$countData = $data->count(); |
|
|
|
return response()->json(['status'=>'failed','message'=>'failed get list role, please try again later!','code'=>400], 400); |
|
|
|
|
|
|
|
|
|
|
|
if($data){ |
|
|
|
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
|
|
|
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
|
|
|
} |
|
|
|
}else{ |
|
|
|
|
|
|
|
return response()->json(['status'=>'failed','message'=>'failed get list role, please try again later!','code'=>400], 400); |
|
|
|
public function getActivityByProjectId($projectId) { |
|
|
|
} |
|
|
|
$output = []; |
|
|
|
} |
|
|
|
$data = Activity::select('id')->where('proyek_id', $projectId)->get(); |
|
|
|
|
|
|
|
foreach ($data as $actData) { |
|
|
|
|
|
|
|
$output[] = $actData->id; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return $output; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getActivityByProjectId($projectId) { |
|
|
|
/* |
|
|
|
$output = []; |
|
|
|
const statusProyek = [ |
|
|
|
$data = Activity::select('id')->where('proyek_id', $projectId)->get(); |
|
|
|
{ |
|
|
|
if (count($data) > 0) { |
|
|
|
"id": "1", |
|
|
|
foreach ($data as $actData) { |
|
|
|
"proyek_name": "Pembuatan Aplikasi Survey Covid Varian Baru", // ambil dari m_proyek |
|
|
|
$output[] = $actData->id; |
|
|
|
"total_task": 80, // ambil dari m_activity -> SUM(jumlah_pekerjaan) where proyek_id berdasarkan proyek_id terpilih |
|
|
|
} |
|
|
|
"task_on_progress": 60, // ambil dari report_activity -> SUM(job_count_report) where activity_id berdasarkan activity_id terpilih |
|
|
|
} |
|
|
|
"day_left": 7, // ambil dari m_proyek, cari sisa hari (end_date - hari ini) |
|
|
|
return $output; |
|
|
|
"percentage": 75 // (task_on_progress / total_task * 100) |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
/* for statusProyek, I want something output like this |
|
|
|
"id": "2", |
|
|
|
const statusProyek = [ |
|
|
|
"proyek_name": "Pembangunan Jembatan Layang", |
|
|
|
{ |
|
|
|
"total_task": 70, // SELECT SUM(jumlah_pekerjaan) FROM public.m_activity WHERE proyek_id IN (11); |
|
|
|
"id": "1", |
|
|
|
"task_on_progress": 70, // SELECT SUM(job_count_report) FROM public.report_activity WHERE activity_id IN (349, 355); |
|
|
|
"proyek_name": "Pembuatan Aplikasi Survey Covid Varian Baru", // ambil dari m_proyek |
|
|
|
"day_left": 0, |
|
|
|
"total_task": 80, // ambil dari m_activity -> SUM(jumlah_pekerjaan) where proyek_id berdasarkan proyek_id terpilih |
|
|
|
"percentage": 100 |
|
|
|
"task_on_progress": 60, // ambil dari report_activity -> SUM(job_count_report) where activity_id berdasarkan activity_id terpilih |
|
|
|
}, |
|
|
|
"day_left": 7, // ambil dari m_proyek, cari sisa hari (end_date - hari ini) |
|
|
|
... |
|
|
|
"percentage": 75 // (task_on_progress / total_task * 100) |
|
|
|
] |
|
|
|
}, |
|
|
|
*/ |
|
|
|
{ |
|
|
|
public function statusProyek(Request $request) { |
|
|
|
"id": "2", |
|
|
|
$dataPayload = $request->all(); |
|
|
|
"proyek_name": "Pembangunan Jembatan Layang", |
|
|
|
$reqProject = $dataFinal = []; |
|
|
|
"total_task": 70, // SELECT SUM(jumlah_pekerjaan) FROM public.m_activity WHERE proyek_id IN (11); |
|
|
|
|
|
|
|
"task_on_progress": 70, // SELECT SUM(job_count_report) FROM public.report_activity WHERE activity_id IN (349, 355); |
|
|
|
if (!isset($dataPayload['project_id'])) |
|
|
|
"day_left": 0, |
|
|
|
return response()->json(['status'=>'failed','message'=>'Undefined project_id','code'=>400], 400); |
|
|
|
"percentage": 100 |
|
|
|
|
|
|
|
}, |
|
|
|
foreach ($dataPayload['project_id'] as $val) { |
|
|
|
... |
|
|
|
$prj["project_id"] = $val; |
|
|
|
] |
|
|
|
$prj["activity_id"] = $this->getActivityByProjectId($val); |
|
|
|
*/ |
|
|
|
$reqProject[] = $prj; |
|
|
|
public function statusProyek(Request $request) { |
|
|
|
} |
|
|
|
$dataPayload = $request->all(); |
|
|
|
|
|
|
|
$reqProject = []; |
|
|
|
if (count($reqProject) > 0) { |
|
|
|
$dataFinal = []; |
|
|
|
$row = []; |
|
|
|
|
|
|
|
|
|
|
|
if (!isset($dataPayload['project_id'])) { |
|
|
|
for ($i=0; $i < count($reqProject); $i++) { |
|
|
|
return response()->json(['status'=>'failed','message'=>'Undefined project_id','code'=>400], 400); |
|
|
|
$dataMaxVersionGantt = Activity::select(Activity::raw('MAX(version_gantt_id) as last_version_gantt'))->where("proyek_id", $reqProject[$i]['project_id'])->first(); |
|
|
|
} |
|
|
|
$last_version_gantt = $dataMaxVersionGantt->last_version_gantt; |
|
|
|
|
|
|
|
$queryProject = Project::select('id', 'nama', 'mulai_proyek', 'akhir_proyek')->where('id',$reqProject[$i]['project_id'])->first(); |
|
|
|
foreach ($dataPayload['project_id'] as $val) { |
|
|
|
$sum_jumlah_pekerjaan = Activity::where('proyek_id', $reqProject[$i]['project_id'])->where('version_gantt_id', $last_version_gantt)->sum("jumlah_pekerjaan"); |
|
|
|
$prj["project_id"] = $val; |
|
|
|
$count_activity = Activity::where('proyek_id', $reqProject[$i]['project_id'])->where('version_gantt_id', $last_version_gantt)->count("id"); |
|
|
|
$prj["activity_id"] = $this->getActivityByProjectId($val); |
|
|
|
$count_activity_done = Activity::where('proyek_id', $reqProject[$i]['project_id'])->where('persentase_progress', '100')->where('version_gantt_id', $last_version_gantt)->count("id"); |
|
|
|
|
|
|
|
$count_progress_percentage = Activity::where('proyek_id', $reqProject[$i]['project_id'])->whereNull('parent_id')->where('version_gantt_id', $last_version_gantt)->count("persentase_progress"); |
|
|
|
$reqProject[] = $prj; |
|
|
|
$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; |
|
|
|
|
|
|
|
|
|
|
|
if (count($reqProject) > 0) { |
|
|
|
foreach($progress_actual as $objRow) { |
|
|
|
$row = []; |
|
|
|
$current_progress += ($objRow->bobot_planning * $objRow->persentase_progress) / 100; |
|
|
|
|
|
|
|
} |
|
|
|
for ($i=0; $i < count($reqProject); $i++) { |
|
|
|
if (count($reqProject[$i]['activity_id']) > 0) { |
|
|
|
$dataMaxVersionGantt = Activity::select(Activity::raw('MAX(version_gantt_id) as last_version_gantt'))->where("proyek_id", $reqProject[$i]['project_id'])->first(); |
|
|
|
for ($j=0; $j < count($reqProject[$i]['activity_id']); $j++) { |
|
|
|
$last_version_gantt = $dataMaxVersionGantt->last_version_gantt; |
|
|
|
$sum_job_count_report = ReportActivity::whereIn('activity_id', $reqProject[$i]['activity_id'])->sum("job_count_report"); |
|
|
|
$queryProject = Project::select('id', 'nama', 'mulai_proyek', 'akhir_proyek')->where('id',$reqProject[$i]['project_id'])->first(); |
|
|
|
} |
|
|
|
$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"); |
|
|
|
if (!isset($queryProject->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"); |
|
|
|
return response()->json(['status'=>'failed','message'=>'Project with id='.$reqProject[$i]['project_id'].' is not found!','code'=>400], 400); |
|
|
|
$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"); |
|
|
|
$now = time(); |
|
|
|
|
|
|
|
$akhir_proyek = strtotime($queryProject->akhir_proyek); |
|
|
|
$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(); |
|
|
|
$datediff = $akhir_proyek - $now; |
|
|
|
$current_progress = 0; |
|
|
|
|
|
|
|
foreach($progress_actual as $objRow) { |
|
|
|
$mulai_proyek = strtotime($queryProject->mulai_proyek); |
|
|
|
$current_progress += ($objRow->bobot_planning * $objRow->persentase_progress) / 100; |
|
|
|
$total_kontrak = $akhir_proyek - $mulai_proyek; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$row["id"] = $queryProject->id; |
|
|
|
if (count($reqProject[$i]['activity_id']) > 0) { |
|
|
|
$row["proyek_name"] = $queryProject->nama; |
|
|
|
for ($j=0; $j < count($reqProject[$i]['activity_id']); $j++) { |
|
|
|
$row["mulai_proyek"] = $queryProject->mulai_proyek; |
|
|
|
$sum_job_count_report = ReportActivity::whereIn('activity_id', $reqProject[$i]['activity_id'])->sum("job_count_report"); |
|
|
|
$row["akhir_proyek"] = $queryProject->akhir_proyek; |
|
|
|
} |
|
|
|
$row["total_kontrak"] = round($total_kontrak / (60 * 60 * 24)); |
|
|
|
} |
|
|
|
$row["total_task"] = $sum_jumlah_pekerjaan; |
|
|
|
|
|
|
|
$row["task_on_progress"] = $sum_job_count_report; |
|
|
|
if (!isset($queryProject->id)) { |
|
|
|
$row["count_activity"] = $count_activity; |
|
|
|
return response()->json(['status'=>'failed','message'=>'Project with id='.$reqProject[$i]['project_id'].' is not found!','code'=>400], 400); |
|
|
|
$row["count_activity_done"] = $count_activity_done; |
|
|
|
} |
|
|
|
$row["day_left"] = round($datediff / (60 * 60 * 24)); |
|
|
|
|
|
|
|
$row["percentage"] = round($current_progress,3); |
|
|
|
$now = time(); |
|
|
|
$row["count_progress_percentage"] = $count_progress_percentage; |
|
|
|
$akhir_proyek = strtotime($queryProject->akhir_proyek); |
|
|
|
|
|
|
|
$datediff = $akhir_proyek - $now; |
|
|
|
$dataFinal[] = $row; |
|
|
|
|
|
|
|
} |
|
|
|
$mulai_proyek = strtotime($queryProject->mulai_proyek); |
|
|
|
} |
|
|
|
$total_kontrak = $akhir_proyek - $mulai_proyek; |
|
|
|
|
|
|
|
|
|
|
|
if(empty($dataFinal)) |
|
|
|
$row["id"] = $queryProject->id; |
|
|
|
return response()->json(['status'=>'failed','message'=>'failed get status proyek, please try again later!','code'=>400], 400); |
|
|
|
$row["proyek_name"] = $queryProject->nama; |
|
|
|
|
|
|
|
$row["mulai_proyek"] = $queryProject->mulai_proyek; |
|
|
|
return response()->json(['status'=>'success','code'=>200,'data'=>$dataFinal, 'totalRecord'=>count($dataFinal)], 200); |
|
|
|
$row["akhir_proyek"] = $queryProject->akhir_proyek; |
|
|
|
} |
|
|
|
$row["total_kontrak"] = round($total_kontrak / (60 * 60 * 24)); |
|
|
|
|
|
|
|
$row["total_task"] = $sum_jumlah_pekerjaan; |
|
|
|
public function curvaS(Request $request) |
|
|
|
$row["task_on_progress"] = $sum_job_count_report; |
|
|
|
{ |
|
|
|
$row["count_activity"] = $count_activity; |
|
|
|
$dataPayload = $request->all(); |
|
|
|
$row["count_activity_done"] = $count_activity_done; |
|
|
|
$dataMaxVersionGantt = []; |
|
|
|
$row["day_left"] = round($datediff / (60 * 60 * 24)); |
|
|
|
$dataFinal=[]; |
|
|
|
$row["percentage"] = round($current_progress,3); |
|
|
|
|
|
|
|
$row["count_progress_percentage"] = $count_progress_percentage; |
|
|
|
foreach ($dataPayload['project_id'] as $val) { |
|
|
|
|
|
|
|
$dataMaxVersionGantt[] = $this->getMaxVersionGantt($val); |
|
|
|
$dataFinal[] = $row; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
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(); |
|
|
|
if($dataFinal){ |
|
|
|
$totalCostPlanning = Activity::where('proyek_id', $val['proyek_id'])->where('version_gantt_id', $val['last_version_gantt'])->whereNull('parent_id')->sum('rencana_biaya'); |
|
|
|
return response()->json(['status'=>'success','code'=>200,'data'=>$dataFinal, 'totalRecord'=>count($dataFinal)], 200); |
|
|
|
|
|
|
|
}else{ |
|
|
|
for ($i=0; $i < count($data); $i++) { |
|
|
|
return response()->json(['status'=>'failed','message'=>'failed get status proyek, please try again later!','code'=>400], 400); |
|
|
|
$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; |
|
|
|
|
|
|
|
$tmpbc += ((($data[$x]['persentase_progress'] * $data[$x]['bobot_planning'])/100)*$totalCostPlanning)/100; |
|
|
|
public function curvaS(Request $request) |
|
|
|
$tmpac += $data[$x]['biaya_actual']; |
|
|
|
{ |
|
|
|
} |
|
|
|
$dataPayload = $request->all(); |
|
|
|
|
|
|
|
$dataMaxVersionGantt = []; |
|
|
|
$data[$i]['cal_bobot_p'] = round($tmpp,2); |
|
|
|
foreach ($dataPayload['project_id'] as $val) { |
|
|
|
|
|
|
|
$dataMaxVersionGantt[] = $this->getMaxVersionGantt($val); |
|
|
|
if($i > 0 ){ |
|
|
|
} |
|
|
|
if($data[$i-1]['cal_bobot_a'] != null){ |
|
|
|
$dataFinal=[]; |
|
|
|
if($data[$i-1]['cal_bobot_a'] == round($tmpa,2)){ |
|
|
|
foreach ($dataMaxVersionGantt as $val) { |
|
|
|
$data[$i]['cal_bobot_a'] = null; |
|
|
|
$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(); |
|
|
|
}else{ |
|
|
|
$totalCostPlanning = Activity::where('proyek_id', $val['proyek_id'])->where('version_gantt_id', $val['last_version_gantt'])->whereNull('parent_id')->sum('rencana_biaya'); |
|
|
|
$data[$i]['cal_bobot_a'] = round($tmpa,2); |
|
|
|
$dataBobotPlan =[]; |
|
|
|
} |
|
|
|
for ($i=0; $i < count($data); $i++) { |
|
|
|
}else{ |
|
|
|
$tmpp = 0; |
|
|
|
$data[$i]['cal_bobot_a'] = null; |
|
|
|
$tmpa = 0; |
|
|
|
} |
|
|
|
$tmpbc = 0; |
|
|
|
if($data[$i-1]['cal_actual_cost'] != null){ |
|
|
|
$tmpac = 0; |
|
|
|
if($data[$i-1]['cal_actual_cost'] == round($tmpac,2)){ |
|
|
|
for ($x=$i; $x >= 0 ; $x--) { |
|
|
|
$data[$i]['cal_actual_cost'] = null; |
|
|
|
$tmpp += $data[$x]['bobot_planning']; |
|
|
|
}else{ |
|
|
|
$tmpa += ($data[$x]['persentase_progress'] * $data[$x]['bobot_planning'])/100; |
|
|
|
$data[$i]['cal_actual_cost'] = round($tmpac,2); |
|
|
|
$tmpbc += ((($data[$x]['persentase_progress'] * $data[$x]['bobot_planning'])/100)*$totalCostPlanning)/100; |
|
|
|
} |
|
|
|
$tmpac += $data[$x]['biaya_actual']; |
|
|
|
}else{ |
|
|
|
} |
|
|
|
$data[$i]['cal_actual_cost'] = null; |
|
|
|
|
|
|
|
} |
|
|
|
$data[$i]['cal_bobot_p'] = round($tmpp,2); |
|
|
|
}else{ |
|
|
|
if($i > 0 ){ |
|
|
|
$data[$i]['cal_bobot_a'] = round($tmpa,2); |
|
|
|
if($data[$i-1]['cal_bobot_a'] != null){ |
|
|
|
$data[$i]['cal_actual_cost'] = round($tmpac,2); |
|
|
|
if($data[$i-1]['cal_bobot_a'] == round($tmpa,2)){ |
|
|
|
} |
|
|
|
$data[$i]['cal_bobot_a'] = null; |
|
|
|
$data[$i]['cal_budget_cost'] = round($tmpbc,2); |
|
|
|
}else{ |
|
|
|
} |
|
|
|
$data[$i]['cal_bobot_a'] = round($tmpa,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); |
|
|
|
}else{ |
|
|
|
} |
|
|
|
$data[$i]['cal_bobot_a'] = null; |
|
|
|
|
|
|
|
} |
|
|
|
if(!$dataFinal) |
|
|
|
}else{ |
|
|
|
return response()->json(['status'=>'failed','message'=>'failed get list role, please try again later!','code'=>400], 400); |
|
|
|
$data[$i]['cal_bobot_a'] = round($tmpa,2); |
|
|
|
|
|
|
|
} |
|
|
|
return response()->json(['status'=>'success','code'=>200, 'data'=>$dataFinal, 'totalRecord'=>1], 200); |
|
|
|
$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; |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
$data[$i]['cal_actual_cost'] = round($tmpac,2); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
$data[$i]['cal_actual_cost'] = null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
$data[$i]['cal_actual_cost'] = round($tmpac,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{ |
|
|
|
|
|
|
|
return response()->json(['status'=>'failed','message'=>'failed get list role, please try again later!','code'=>400], 400); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|