|
|
|
@ -59,6 +59,7 @@ class ProjectController extends Controller
|
|
|
|
|
$data = $request->all(); |
|
|
|
|
|
|
|
|
|
$data['created_by'] = $this->currentName; |
|
|
|
|
$data['created_by_id'] = $this->currentId; |
|
|
|
|
|
|
|
|
|
if (empty($data['phase_id'])) |
|
|
|
|
$data['phase_id'] = 1; |
|
|
|
@ -334,10 +335,13 @@ class ProjectController extends Controller
|
|
|
|
|
'projectsByPhase' => $projectsByPhase, |
|
|
|
|
'projectTypes' => $projectTypes, |
|
|
|
|
'projectsByType' => $projectsByType, |
|
|
|
|
], 200); |
|
|
|
|
], |
|
|
|
|
200 |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getListProjectTask($id){ |
|
|
|
|
public function getListProjectTask($id) |
|
|
|
|
{ |
|
|
|
|
$data = UserToActivity::select("assign_hr_to_activity.user_id as user_id", "m_proyek.*") |
|
|
|
|
->where("assign_hr_to_activity.user_id", $id) |
|
|
|
|
->join('m_proyek', 'assign_hr_to_activity.proyek_id', '=', 'm_proyek.id') |
|
|
|
@ -350,17 +354,27 @@ class ProjectController extends Controller
|
|
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getSCurve(Request $request){ |
|
|
|
|
public function getSCurve(Request $request) |
|
|
|
|
{ |
|
|
|
|
$data = MasterFunctionsHelper::getSCurve($request); |
|
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function calculateSCurve(Request $request){ |
|
|
|
|
// testing |
|
|
|
|
public function calculateSCurvetest(Request $request) |
|
|
|
|
{ |
|
|
|
|
$data = MasterFunctionsHelper::calculateSCurve($request->project_id); |
|
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function calculateSCurve(Request $request) |
|
|
|
|
{ |
|
|
|
|
$sCurve = Project::select('scurve')->where('id', $request->project_id)->first(); |
|
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => json_decode($sCurve->scurve)], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function sCurveCommand(Request $request){ |
|
|
|
|
public function sCurveCommand(Request $request) |
|
|
|
|
{ |
|
|
|
|
Artisan::call('calculate:scurve', [ |
|
|
|
|
'project_id' => $request->project_id |
|
|
|
|
]); |
|
|
|
@ -375,12 +389,14 @@ class ProjectController extends Controller
|
|
|
|
|
// return response()->json(['message' => 'Project not found'], 404); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getLinearSCurve(Request $request){ |
|
|
|
|
public function getLinearSCurve(Request $request) |
|
|
|
|
{ |
|
|
|
|
$data = MasterFunctionsHelper::getLinearSCurve($request); |
|
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static function setSyncDate($activity_id, $activity, $report) { |
|
|
|
|
public static function setSyncDate($activity_id, $activity, $report) |
|
|
|
|
{ |
|
|
|
|
$status = AssignMaterial::where('activity_id', $activity_id)->first(); |
|
|
|
|
if (!isset($status)) { |
|
|
|
|
$reports = array( |
|
|
|
@ -479,7 +495,8 @@ class ProjectController extends Controller
|
|
|
|
|
return response()->json(['status' => 'success', 'message' => 'Set baseline success!', 'code' => 200], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getInvoiceIntegration(Request $request) { |
|
|
|
|
public function getInvoiceIntegration(Request $request) |
|
|
|
|
{ |
|
|
|
|
$ganttCount = VersionGantt::where('proyek_id', $request->id)->count(); |
|
|
|
|
$search = urlencode($request->search); |
|
|
|
|
if (empty($search)) |
|
|
|
@ -511,7 +528,8 @@ class ProjectController extends Controller
|
|
|
|
|
|
|
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => $userProyek, 'totalRecord' => $totalRecord], 200); |
|
|
|
|
} |
|
|
|
|
public function detail(Request $request, $id, $gantt_id = null, $s_curve = null){ |
|
|
|
|
public function detail(Request $request, $id, $gantt_id = null, $s_curve = null) |
|
|
|
|
{ |
|
|
|
|
if (empty($id) || !is_int((int)$id)) |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); |
|
|
|
|
|
|
|
|
@ -530,18 +548,26 @@ class ProjectController extends Controller
|
|
|
|
|
if (isset($s_curve)) { |
|
|
|
|
$result->header = Activity::whereNull('parent_id')->where("proyek_id", $id)->first(); |
|
|
|
|
$actualStartExist = Activity::where('proyek_id', $id)->whereNotNull('actual_start')->exists(); |
|
|
|
|
if($result['type_proyek_id'] === 9) |
|
|
|
|
{ |
|
|
|
|
$actualEndExist = Activity::where('proyek_id', $id)->exists(); |
|
|
|
|
if ($result['type_proyek_id'] === 9) { |
|
|
|
|
// $actualEndExist = Activity::where('proyek_id', $id)->exists(); |
|
|
|
|
$query = Activity::where('proyek_id', $id); |
|
|
|
|
$maxEndDate = Activity::where('proyek_id', $id)->select('end_date') |
|
|
|
|
->orderBy('end_date', 'desc') |
|
|
|
|
->first(); |
|
|
|
|
} else { |
|
|
|
|
$actualEndExist = Activity::where('version_gantt_id', $ganttId)->exists(); |
|
|
|
|
// $actualEndExist = Activity::where('version_gantt_id', $ganttId)->exists(); |
|
|
|
|
$maxEndDate = Activity::where('version_gantt_id', $ganttId)->select('end_date') |
|
|
|
|
->orderBy('end_date', 'desc') |
|
|
|
|
->first(); |
|
|
|
|
$query = Activity::where('version_gantt_id', $ganttId); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
$result->header = Activity::whereNull('parent_id')->where("proyek_id", $id)->where("version_gantt_id", $ganttId)->first(); |
|
|
|
|
$actualStartExist = Activity::where('version_gantt_id', $ganttId)->whereNotNull('actual_start')->exists(); |
|
|
|
|
$actualEndExist = Activity::where('version_gantt_id', $ganttId)->exists(); |
|
|
|
|
// $actualEndExist = Activity::where('version_gantt_id', $ganttId)->exists(); |
|
|
|
|
$maxEndDate = Activity::where('version_gantt_id', $ganttId)->select('end_date') |
|
|
|
|
->orderBy('end_date', 'desc') |
|
|
|
|
->first(); |
|
|
|
|
$query = Activity::where('version_gantt_id', $ganttId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -550,11 +576,13 @@ class ProjectController extends Controller
|
|
|
|
|
} else { |
|
|
|
|
$startDate = $query->orderBy('start_date')->value('start_date'); |
|
|
|
|
} |
|
|
|
|
if($actualEndExist) |
|
|
|
|
{ |
|
|
|
|
$maxEndDate = $query->max('id'); |
|
|
|
|
$endDate = $query->where('id',$maxEndDate)->first()->end_date; |
|
|
|
|
} |
|
|
|
|
// if($actualEndExist) |
|
|
|
|
// { |
|
|
|
|
// // $maxEndDate = $query->max('id'); |
|
|
|
|
// // get last end_date |
|
|
|
|
// // $endDate = $query->where('id',$maxEndDate)->first()->end_date; |
|
|
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
$plannedStart = Activity::where('version_gantt_id', $ganttId) |
|
|
|
|
->orderBy('planned_start') |
|
|
|
@ -563,13 +591,14 @@ class ProjectController extends Controller
|
|
|
|
|
->orderByDesc('planned_end') |
|
|
|
|
->value('planned_end'); |
|
|
|
|
$result->header->start_date = $startDate; |
|
|
|
|
$result->header->end_date = $endDate; |
|
|
|
|
$result->header->end_date = $maxEndDate->end_date; |
|
|
|
|
$result->header->planned_start = $plannedStart; |
|
|
|
|
$result->header->planned_end = $plannedEnd; |
|
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result, 'gantt' => $ganttId], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getOverdueActivities(Request $request){ |
|
|
|
|
public function getOverdueActivities(Request $request) |
|
|
|
|
{ |
|
|
|
|
$payload = $request->all(); |
|
|
|
|
if (empty($payload['id']) || !is_int((int)$payload['id'])) |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); |
|
|
|
@ -584,12 +613,11 @@ class ProjectController extends Controller
|
|
|
|
|
->value('end_date'); |
|
|
|
|
if (isset($payload['till_date'])) { |
|
|
|
|
if (isset($payload['scurve'])) { |
|
|
|
|
$overdueActivities = Activity::where('proyek_id', $payload['id'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->whereDate('end_date','<=',$endDate)->orderBy('end_date', 'asc')->get(); |
|
|
|
|
$overdueActivities = Activity::join('m_version_gantt', 'm_activity.version_gantt_id', '=', 'm_version_gantt.id')->where('m_activity.proyek_id', $payload['id'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->whereDate('end_date', '<=', $endDate)->orderBy('end_date', 'asc')->get(); |
|
|
|
|
} else { |
|
|
|
|
$overdueActivities = Activity::where('version_gantt_id', $payload['gantt'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->whereDate('end_date','<=',$endDate)->orderBy('end_date', 'asc')->get(); |
|
|
|
|
} |
|
|
|
|
$overdueActivities = Activity::join('m_version_gantt', 'm_activity.version_gantt_id', '=', 'm_version_gantt.id')->where('version_gantt_id', $payload['gantt'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->whereDate('end_date', '<=', $endDate)->orderBy('end_date', 'asc')->get(); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
} else { |
|
|
|
|
if (isset($payload['scurve'])) { |
|
|
|
|
$overdueActivities = Activity::where('proyek_id', $payload['id'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->orderBy('end_date', 'asc')->get(); |
|
|
|
|
} else { |
|
|
|
@ -601,15 +629,26 @@ class ProjectController extends Controller
|
|
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getReportDistribution(Request $request){ |
|
|
|
|
public function getReportDistribution(Request $request) |
|
|
|
|
{ |
|
|
|
|
$payload = $request->all(); |
|
|
|
|
|
|
|
|
|
if (empty($payload['project_id']) || !is_int((int)$payload['project_id'])) |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); |
|
|
|
|
|
|
|
|
|
$reports = DB::table('assign_material_to_activity as ama') |
|
|
|
|
->select('u.name', 'a.name as activity_name', 'ama.qty_planning', 'ram.qty as qty_real','rm.description as material_name', 'rm.uom as material_unit', |
|
|
|
|
'ram.lat', 'ram.lon', 'ram.description as report_notes', 'ram.report_date') |
|
|
|
|
->select( |
|
|
|
|
'u.name', |
|
|
|
|
'a.name as activity_name', |
|
|
|
|
'ama.qty_planning', |
|
|
|
|
'ram.qty as qty_real', |
|
|
|
|
'rm.description as material_name', |
|
|
|
|
'rm.uom as material_unit', |
|
|
|
|
'ram.lat', |
|
|
|
|
'ram.lon', |
|
|
|
|
'ram.description as report_notes', |
|
|
|
|
'ram.report_date' |
|
|
|
|
) |
|
|
|
|
->join('report_activity_material as ram', 'ram.assign_material_id', '=', 'ama.id') |
|
|
|
|
->join('m_req_material as rm', 'rm.id', '=', 'ama.material_id') |
|
|
|
|
->join('m_activity as a', 'a.id', '=', 'ama.activity_id') |
|
|
|
@ -621,12 +660,14 @@ class ProjectController extends Controller
|
|
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => $reports], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getManpower($proyek_id){ |
|
|
|
|
public function getManpower($proyek_id) |
|
|
|
|
{ |
|
|
|
|
$manCount = UserToProyek::where('proyek_id', $proyek_id)->count(); |
|
|
|
|
return response()->json(['totalRecord' => $manCount]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getAssignedHR($gantt_id){ |
|
|
|
|
public function getAssignedHR($gantt_id) |
|
|
|
|
{ |
|
|
|
|
$results = UserToActivity::select('assign_hr_to_activity.proyek_id', 'assign_hr_to_activity.user_id', 'm_activity.id', 'm_activity.name', 'm_activity.start_date', 'm_activity.end_date') |
|
|
|
|
->join('m_activity', 'm_activity.id', '=', 'assign_hr_to_activity.activity_id') |
|
|
|
|
->where('assign_hr_to_activity.version_gantt_id', $gantt_id) |
|
|
|
@ -637,8 +678,17 @@ 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', |
|
|
|
|
'mp.rencana_biaya', 'mp.company', 'mp.currency_symbol', 'mu.name as pm', 'mp.budget_health') |
|
|
|
|
->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) |
|
|
|
|
->first(); |
|
|
|
@ -653,8 +703,13 @@ class ProjectController extends Controller
|
|
|
|
|
$progress = @$rootActivity->persentase_progress ?? 0; |
|
|
|
|
|
|
|
|
|
$commentActivity = DB::table('m_comment_activity as mca') |
|
|
|
|
->select('mca.activity_id', 'mca.comment as comment', 'mca.created_by as comment_by', 'mca.created_at as comment_created', |
|
|
|
|
'ma.name as activity') |
|
|
|
|
->select( |
|
|
|
|
'mca.activity_id', |
|
|
|
|
'mca.comment as comment', |
|
|
|
|
'mca.created_by as comment_by', |
|
|
|
|
'mca.created_at as comment_created', |
|
|
|
|
'ma.name as activity' |
|
|
|
|
) |
|
|
|
|
->join('m_activity as ma', 'ma.id', '=', 'mca.activity_id') |
|
|
|
|
->where('ma.proyek_id', $id) |
|
|
|
|
->orderBy('comment_by') |
|
|
|
@ -669,7 +724,8 @@ class ProjectController extends Controller
|
|
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private function httpReq($search){ |
|
|
|
|
private function httpReq($search) |
|
|
|
|
{ |
|
|
|
|
$ch = curl_init(); |
|
|
|
|
curl_setopt($ch, CURLOPT_URL, str_replace("ADDR", $search, API_GEOLOCATION)); |
|
|
|
|
|
|
|
|
@ -685,6 +741,4 @@ class ProjectController extends Controller
|
|
|
|
|
|
|
|
|
|
return json_decode($output); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|